diff --git a/Gemfile b/Gemfile index fd6364427..3cddb2774 100644 --- a/Gemfile +++ b/Gemfile @@ -123,7 +123,6 @@ gem 'acts_as_list' # integrations gem 'clearbit' -gem 'graphql-client' gem 'net-ldap' gem 'slack-notifier' gem 'zendesk_api' diff --git a/Gemfile.lock b/Gemfile.lock index 03bdd0727..cb397af57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -218,10 +218,6 @@ GEM activesupport (>= 4.2.0) gmail_xoauth (0.4.2) oauth (>= 0.3.6) - graphql (1.11.6) - graphql-client (0.16.0) - activesupport (>= 3.0) - graphql (~> 1.8) guard (2.15.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -617,7 +613,6 @@ DEPENDENCIES faker github_changelog_generator gmail_xoauth - graphql-client guard guard-livereload guard-symlink diff --git a/app/assets/javascripts/app/controllers/_integration/github.coffee b/app/assets/javascripts/app/controllers/_integration/github.coffee index e3ace7e5a..284f01945 100644 --- a/app/assets/javascripts/app/controllers/_integration/github.coffee +++ b/app/assets/javascripts/app/controllers/_integration/github.coffee @@ -51,8 +51,7 @@ class Form extends App.Controller ) return - config.schema = data.response - App.Setting.set('github_config', config) + App.Setting.set('github_config', config, notify: true) error: (data, status) -> diff --git a/app/assets/javascripts/app/controllers/_integration/gitlab.coffee b/app/assets/javascripts/app/controllers/_integration/gitlab.coffee index 223905ca0..a0220d37c 100644 --- a/app/assets/javascripts/app/controllers/_integration/gitlab.coffee +++ b/app/assets/javascripts/app/controllers/_integration/gitlab.coffee @@ -51,8 +51,7 @@ class Form extends App.Controller ) return - config.schema = data.response - App.Setting.set('gitlab_config', config) + App.Setting.set('gitlab_config', config, notify: true) error: (data, status) -> diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee index 9590e4461..19d28e93d 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee @@ -4,7 +4,8 @@ class App.SidebarGitIssue extends App.Controller constructor: -> super - @issueLinks = [] + @issueLinks = [] + @issueLinkData = [] @providerIdentifier = @provider.toLowerCase() sidebarItem: => @@ -13,7 +14,7 @@ class App.SidebarGitIssue extends App.Controller name: @providerIdentifier badgeCallback: @badgeRender sidebarHead: @provider - sidebarCallback: @showObjects + sidebarCallback: @reloadIssues sidebarActions: [ { title: 'Link issue' @@ -26,8 +27,8 @@ class App.SidebarGitIssue extends App.Controller shown: -> return if !@ticket - return if !@ticket.id - @showIssues() + + @listIssues() metaBadge: => counter = '' @@ -45,6 +46,7 @@ class App.SidebarGitIssue extends App.Controller @badgeRenderLocal() badgeRenderLocal: => + return if !@badgeEl @badgeEl.html(App.view('generic/sidebar_tabs_item')(@metaBadge())) linkIssue: => @@ -54,86 +56,141 @@ class App.SidebarGitIssue extends App.Controller taskKey: @taskKey container: @el.closest('.content') callback: (link, ui) => - if @ticket && @ticket.id - @saveTicketIssues = true - ui.close() - @showIssues([link]) + @getIssues( + links: [link] + success: (result) => + if !_.contains(@issueLinks, link) + @issueLinks.push(result[0].url) + @issueLinkData = @issueLinkData.concat(result) + + if @ticket && @ticket.id + @saveIssues( + ticket_id: @ticket.id + links: @issueLinks + success: => + ui.close() + @renderIssues() + error: (message = 'Unable to save issue') => + ui.showAlert(App.i18n.translatePlain(message)) + form = ui.el.find('.js-result') + @formEnable(form) + ) + else + ui.close() + @renderIssues() + error: (message = 'Unable to load issues') => + ui.showAlert(App.i18n.translatePlain(message)) + form = ui.el.find('.js-result') + @formEnable(form) + ) ) - showObjects: (el) => - @el = el + reloadIssues: (el) => + if el + @el = el - # show placeholder - if @ticket && @ticket.preferences && @ticket.preferences[@providerIdentifier] && @ticket.preferences[@providerIdentifier].issue_links - @issueLinks = @ticket.preferences[@providerIdentifier].issue_links - queryParams = @queryParam() + return @renderIssues() if !@ticket - # TODO: what is 'gitlab_issue_links' - if queryParams && queryParams.gitlab_issue_links - @issueLinks.push queryParams.gitlab_issue_links - @showIssues() + ticketLinks = @ticket?.preferences?[@providerIdentifier]?.issue_links || [] + return @renderIssues() if _.isEqual(@issueLinks, ticketLinks) - showIssues: (issueLinks) => - if issueLinks - @issueLinks = _.uniq(@issueLinks.concat(issueLinks)) + @issueLinks = ticketLinks + @listIssues(true) - # show placeholder - if _.isEmpty(@issueLinks) - @html("