Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
834fdcc7
Commit
834fdcc7
authored
Jul 16, 2020
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show server-generated errors for importers when applicable
Makes reasoning about failed import easier for end user
parent
fb15ee16
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
4 deletions
+46
-4
app/assets/javascripts/import_projects/store/actions.js
app/assets/javascripts/import_projects/store/actions.js
+13
-2
changelogs/unreleased/xanf-expose-bitbucket-error.yml
changelogs/unreleased/xanf-expose-bitbucket-error.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/import_projects/store/actions_spec.js
spec/frontend/import_projects/store/actions_spec.js
+25
-2
No files found.
app/assets/javascripts/import_projects/store/actions.js
View file @
834fdcc7
...
@@ -70,8 +70,19 @@ export const fetchImport = ({ state, commit }, { newName, targetNamespace, repo
...
@@ -70,8 +70,19 @@ export const fetchImport = ({ state, commit }, { newName, targetNamespace, repo
repoId
:
repo
.
id
,
repoId
:
repo
.
id
,
}),
}),
)
)
.
catch
(()
=>
{
.
catch
(
e
=>
{
createFlash
(
s__
(
'
ImportProjects|Importing the project failed
'
));
const
serverErrorMessage
=
e
?.
response
?.
data
?.
errors
;
const
flashMessage
=
serverErrorMessage
?
sprintf
(
s__
(
'
ImportProjects|Importing the project failed: %{reason}
'
),
{
reason
:
serverErrorMessage
,
},
false
,
)
:
s__
(
'
ImportProjects|Importing the project failed
'
);
createFlash
(
flashMessage
);
commit
(
types
.
RECEIVE_IMPORT_ERROR
,
repo
.
id
);
commit
(
types
.
RECEIVE_IMPORT_ERROR
,
repo
.
id
);
});
});
...
...
changelogs/unreleased/xanf-expose-bitbucket-error.yml
0 → 100644
View file @
834fdcc7
---
title
:
Fix displaying import errors from server
merge_request
:
37073
author
:
type
:
fixed
locale/gitlab.pot
View file @
834fdcc7
...
@@ -12521,6 +12521,9 @@ msgstr ""
...
@@ -12521,6 +12521,9 @@ msgstr ""
msgid "ImportProjects|Importing the project failed"
msgid "ImportProjects|Importing the project failed"
msgstr ""
msgstr ""
msgid "ImportProjects|Importing the project failed: %{reason}"
msgstr ""
msgid "ImportProjects|Requesting your %{provider} repositories failed"
msgid "ImportProjects|Requesting your %{provider} repositories failed"
msgstr ""
msgstr ""
...
...
spec/frontend/import_projects/store/actions_spec.js
View file @
834fdcc7
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
createFlash
from
'
~/flash
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
@@ -22,6 +23,8 @@ import {
...
@@ -22,6 +23,8 @@ import {
}
from
'
~/import_projects/store/actions
'
;
}
from
'
~/import_projects/store/actions
'
;
import
state
from
'
~/import_projects/store/state
'
;
import
state
from
'
~/import_projects/store/state
'
;
jest
.
mock
(
'
~/flash
'
);
describe
(
'
import_projects store actions
'
,
()
=>
{
describe
(
'
import_projects store actions
'
,
()
=>
{
let
localState
;
let
localState
;
const
repos
=
[{
id
:
1
},
{
id
:
2
}];
const
repos
=
[{
id
:
1
},
{
id
:
2
}];
...
@@ -130,10 +133,28 @@ describe('import_projects store actions', () => {
...
@@ -130,10 +133,28 @@ describe('import_projects store actions', () => {
);
);
});
});
it
(
'
commits REQUEST_IMPORT and RECEIVE_IMPORT_ERROR
on an unsuccessful request
'
,
()
=>
{
it
(
'
commits REQUEST_IMPORT and RECEIVE_IMPORT_ERROR
and shows generic error message on an unsuccessful request
'
,
async
()
=>
{
mock
.
onPost
(
`
${
TEST_HOST
}
/endpoint.json`
).
reply
(
500
);
mock
.
onPost
(
`
${
TEST_HOST
}
/endpoint.json`
).
reply
(
500
);
return
testAction
(
await
testAction
(
fetchImport
,
importPayload
,
localState
,
[
{
type
:
REQUEST_IMPORT
,
payload
:
importPayload
.
repo
.
id
},
{
type
:
RECEIVE_IMPORT_ERROR
,
payload
:
importPayload
.
repo
.
id
},
],
[],
);
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
Importing the project failed
'
);
});
it
(
'
commits REQUEST_IMPORT and RECEIVE_IMPORT_ERROR and shows detailed error message on an unsuccessful request with errors fields in response
'
,
async
()
=>
{
const
ERROR_MESSAGE
=
'
dummy
'
;
mock
.
onPost
(
`
${
TEST_HOST
}
/endpoint.json`
).
reply
(
500
,
{
errors
:
ERROR_MESSAGE
});
await
testAction
(
fetchImport
,
fetchImport
,
importPayload
,
importPayload
,
localState
,
localState
,
...
@@ -143,6 +164,8 @@ describe('import_projects store actions', () => {
...
@@ -143,6 +164,8 @@ describe('import_projects store actions', () => {
],
],
[],
[],
);
);
expect
(
createFlash
).
toHaveBeenCalledWith
(
`Importing the project failed:
${
ERROR_MESSAGE
}
`
);
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment