Show error message on jira import fail

stable
Jesús Espino 2017-03-21 12:08:41 +01:00 committed by David Barragán Merino
parent ff7ac8498a
commit 48d4c53810
3 changed files with 16 additions and 3 deletions

View File

@ -28,9 +28,10 @@ class ImportProjectController
'$routeParams', '$routeParams',
'$tgNavUrls', '$tgNavUrls',
'$tgConfig', '$tgConfig',
'$tgConfirm',
] ]
constructor: (@trelloService, @jiraService, @githubService, @asanaService, @location, @window, @routeParams, @tgNavUrls, @config) -> constructor: (@trelloService, @jiraService, @githubService, @asanaService, @location, @window, @routeParams, @tgNavUrls, @config, @confirm) ->
start: -> start: ->
@.token = null @.token = null
@ -88,7 +89,9 @@ class ImportProjectController
@window.open(url, "_self") @window.open(url, "_self")
else if from == "jira" else if from == "jira"
@jiraService.getAuthUrl(@.jiraUrl).then (url) => @jiraService.getAuthUrl(@.jiraUrl).then (url) =>
@window.open(url, "_self") @window.open url, "_self"
, (err) =>
@confirm.notify('error', err)
else if from == "github" else if from == "github"
callbackUri = @location.absUrl() + "/github" callbackUri = @location.absUrl() + "/github"
@githubService.getAuthUrl(callbackUri).then (url) => @githubService.getAuthUrl(callbackUri).then (url) =>

View File

@ -68,6 +68,13 @@ describe "ImportProjectCtrl", ->
$provide.value("$window", mocks.window) $provide.value("$window", mocks.window)
_mockConfirm = ->
mocks.confirm = {
notify: sinon.stub()
}
$provide.value("$tgConfirm", mocks.confirm)
_mockLocation = -> _mockLocation = ->
mocks.location = { mocks.location = {
search: sinon.stub() search: sinon.stub()
@ -98,6 +105,7 @@ describe "ImportProjectCtrl", ->
_mockJiraImportService() _mockJiraImportService()
_mockAsanaImportService() _mockAsanaImportService()
_mockWindow() _mockWindow()
_mockConfirm()
_mockLocation() _mockLocation()
_mockTgNavUrls() _mockTgNavUrls()
_mockRouteParams() _mockRouteParams()

View File

@ -41,10 +41,12 @@ class JiraImportService extends taiga.Service
@resources.jiraImporter.importProject(@.url, @.token, name, description, projectId, userBindings, keepExternalReference, isPrivate, projectType, importerType) @resources.jiraImporter.importProject(@.url, @.token, name, description, projectId, userBindings, keepExternalReference, isPrivate, projectType, importerType)
getAuthUrl: (url) -> getAuthUrl: (url) ->
return new Promise (resolve) => return new Promise (resolve, reject) =>
@resources.jiraImporter.getAuthUrl(url).then (response) => @resources.jiraImporter.getAuthUrl(url).then (response) =>
@.authUrl = response.data.url @.authUrl = response.data.url
resolve(@.authUrl) resolve(@.authUrl)
, (err) =>
reject(err.data._error_message)
authorize: () -> authorize: () ->
return new Promise (resolve, reject) => return new Promise (resolve, reject) =>