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
0d138cfe
Commit
0d138cfe
authored
Feb 25, 2021
by
Kev
Committed by
Miguel Rincon
Feb 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add loading indicator to "Update username" button in account settings
parent
e9048ecc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
4 deletions
+45
-4
app/assets/javascripts/profile/account/components/update_username.vue
...avascripts/profile/account/components/update_username.vue
+6
-2
changelogs/unreleased/21759-add-loading-indicator-to-update-username-button.yml
...21759-add-loading-indicator-to-update-username-button.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/profile/account/components/update_username_spec.js
...ontend/profile/account/components/update_username_spec.js
+31
-2
No files found.
app/assets/javascripts/profile/account/components/update_username.vue
View file @
0d138cfe
...
...
@@ -90,7 +90,10 @@ Please update your Git repository remotes as soon as possible.`),
this
.
isRequestPending
=
false
;
})
.
catch
((
error
)
=>
{
Flash
(
error
.
response
.
data
.
message
);
Flash
(
error
?.
response
?.
data
?.
message
||
s__
(
'
Profiles|An error occurred while updating your username, please try again.
'
),
);
this
.
isRequestPending
=
false
;
throw
error
;
});
...
...
@@ -121,7 +124,8 @@ Please update your Git repository remotes as soon as possible.`),
</div>
<gl-button
v-gl-modal-directive=
"$options.modalId"
:disabled=
"isRequestPending || newUsername === username"
:disabled=
"newUsername === username"
:loading=
"isRequestPending"
category=
"primary"
variant=
"warning"
data-testid=
"username-change-confirmation-modal"
...
...
changelogs/unreleased/21759-add-loading-indicator-to-update-username-button.yml
0 → 100644
View file @
0d138cfe
---
title
:
Add loading indicator to "Update username" button in account settings
merge_request
:
53142
author
:
Kev @KevSlashNull
type
:
changed
locale/gitlab.pot
View file @
0d138cfe
...
...
@@ -22810,6 +22810,9 @@ msgstr ""
msgid "Profiles|Add status emoji"
msgstr ""
msgid "Profiles|An error occurred while updating your username, please try again."
msgstr ""
msgid "Profiles|Avatar cropper"
msgstr ""
...
...
spec/frontend/profile/account/components/update_username_spec.js
View file @
0d138cfe
...
...
@@ -2,10 +2,13 @@ import { GlModal } from '@gitlab/ui';
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
deprecatedCreateFlash
as
createFlash
}
from
'
~/flash
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
UpdateUsername
from
'
~/profile/account/components/update_username.vue
'
;
jest
.
mock
(
'
~/flash
'
);
describe
(
'
UpdateUsername component
'
,
()
=>
{
const
rootUrl
=
TEST_HOST
;
const
actionUrl
=
`
${
TEST_HOST
}
/update/username`
;
...
...
@@ -105,7 +108,8 @@ describe('UpdateUsername component', () => {
axiosMock
.
onPut
(
actionUrl
).
replyOnce
(()
=>
{
expect
(
input
.
attributes
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
expect
(
openModalBtn
.
props
(
'
disabled
'
)).
toBe
(
true
);
expect
(
openModalBtn
.
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
openModalBtn
.
props
(
'
loading
'
)).
toBe
(
true
);
return
[
200
,
{
message
:
'
Username changed
'
}];
});
...
...
@@ -115,6 +119,7 @@ describe('UpdateUsername component', () => {
expect
(
input
.
attributes
(
'
disabled
'
)).
toBe
(
undefined
);
expect
(
openModalBtn
.
props
(
'
disabled
'
)).
toBe
(
true
);
expect
(
openModalBtn
.
props
(
'
loading
'
)).
toBe
(
false
);
});
it
(
'
does not set the username after a erroneous update
'
,
async
()
=>
{
...
...
@@ -122,7 +127,8 @@ describe('UpdateUsername component', () => {
axiosMock
.
onPut
(
actionUrl
).
replyOnce
(()
=>
{
expect
(
input
.
attributes
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
expect
(
openModalBtn
.
props
(
'
disabled
'
)).
toBe
(
true
);
expect
(
openModalBtn
.
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
openModalBtn
.
props
(
'
loading
'
)).
toBe
(
true
);
return
[
400
,
{
message
:
'
Invalid username
'
}];
});
...
...
@@ -130,6 +136,29 @@ describe('UpdateUsername component', () => {
await
expect
(
wrapper
.
vm
.
onConfirm
()).
rejects
.
toThrow
();
expect
(
input
.
attributes
(
'
disabled
'
)).
toBe
(
undefined
);
expect
(
openModalBtn
.
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
openModalBtn
.
props
(
'
loading
'
)).
toBe
(
false
);
});
it
(
'
shows an error message if the error response has a `message` property
'
,
async
()
=>
{
axiosMock
.
onPut
(
actionUrl
).
replyOnce
(()
=>
{
return
[
400
,
{
message
:
'
Invalid username
'
}];
});
await
expect
(
wrapper
.
vm
.
onConfirm
()).
rejects
.
toThrow
();
expect
(
createFlash
).
toBeCalledWith
(
'
Invalid username
'
);
});
it
(
"
shows a fallback error message if the error response doesn't have a `message` property
"
,
async
()
=>
{
axiosMock
.
onPut
(
actionUrl
).
replyOnce
(()
=>
{
return
[
400
];
});
await
expect
(
wrapper
.
vm
.
onConfirm
()).
rejects
.
toThrow
();
expect
(
createFlash
).
toBeCalledWith
(
'
An error occurred while updating your username, please try again.
'
,
);
});
});
});
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