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
681e8cff
Commit
681e8cff
authored
Feb 11, 2021
by
Paul Gascou-Vaillancourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve loading UX
Put clicked button in the loading state and disable other buttons
parent
755b86a1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
12 deletions
+55
-12
ee/app/assets/javascripts/security_configuration/dast_profiles/components/dast_saved_scans_list.vue
...ration/dast_profiles/components/dast_saved_scans_list.vue
+16
-4
ee/spec/frontend/security_configuration/dast_profiles/components/dast_saved_scans_list_spec.js
...on/dast_profiles/components/dast_saved_scans_list_spec.js
+31
-7
ee/spec/frontend/security_configuration/dast_profiles/mocks/mock_data.js
...d/security_configuration/dast_profiles/mocks/mock_data.js
+8
-1
No files found.
ee/app/assets/javascripts/security_configuration/dast_profiles/components/dast_saved_scans_list.vue
View file @
681e8cff
...
...
@@ -19,11 +19,17 @@ export default {
required
:
true
,
},
},
data
:
()
=>
({
isRunningScan
:
null
,
}),
methods
:
{
async
runScan
({
id
})
{
this
.
isRunningScan
=
id
;
try
{
const
{
data
:
{
dastProfileRun
:
{
pipelineUrl
,
errors
},
},
}
=
await
this
.
$apollo
.
mutate
({
mutation
:
dastProfileRunMutation
,
variables
:
{
...
...
@@ -44,6 +50,7 @@ export default {
}
},
handleError
(
error
)
{
this
.
isRunningScan
=
null
;
createFlash
({
message
:
ERROR_MESSAGES
[
ERROR_RUN_SCAN
],
error
,
captureError
:
true
});
},
},
...
...
@@ -58,9 +65,14 @@ export default {
</
template
>
<
template
#actions=
"{ profile }"
>
<gl-button
size=
"small"
data-testid=
"dast-scan-run-button"
@
click=
"runScan(profile)"
>
{{
s__
(
'
DastProfiles|Run scan
'
)
}}
</gl-button>
<gl-button
size=
"small"
data-testid=
"dast-scan-run-button"
:loading=
"isRunningScan === profile.id"
:disabled=
"Boolean(isRunningScan)"
@
click=
"runScan(profile)"
>
{{
s__
(
'
DastProfiles|Run scan
'
)
}}
</gl-button
>
</
template
>
</profiles-list>
</template>
ee/spec/frontend/security_configuration/dast_profiles/components/dast_saved_scans_list_spec.js
View file @
681e8cff
...
...
@@ -78,18 +78,42 @@ describe('EE - DastSavedScansList', () => {
});
describe
(
'
run scan
'
,
()
=>
{
it
(
'
redirects to the running pipeline page on success
'
,
async
()
=>
{
const
pipelineUrl
=
'
/pipeline/url
'
;
const
successHandler
=
jest
.
fn
().
mockResolvedValue
({
data
:
{
dastProfileRun
:
{
pipelineUrl
,
errors
:
[],
},
},
});
it
(
'
puts the clicked button in the loading state and disabled other buttons
'
,
async
()
=>
{
createFullComponent
({
propsData
:
{
profiles
:
savedScans
},
mocks
:
{
$apollo
:
{
mutate
:
jest
.
fn
().
mockResolvedValue
({
dastProfileRun
:
{
pipelineUrl
,
errors
:
[],
mutate
:
successHandler
,
},
}),
},
});
const
buttons
=
wrapper
.
findAll
(
'
[data-testid="dast-scan-run-button"]
'
);
expect
(
buttons
.
at
(
0
).
props
(
'
loading
'
)).
toBe
(
false
);
expect
(
buttons
.
at
(
1
).
props
(
'
disabled
'
)).
toBe
(
false
);
await
buttons
.
at
(
0
).
trigger
(
'
click
'
);
expect
(
buttons
.
at
(
0
).
props
(
'
loading
'
)).
toBe
(
true
);
expect
(
buttons
.
at
(
1
).
props
(
'
disabled
'
)).
toBe
(
true
);
});
it
(
'
redirects to the running pipeline page on success
'
,
async
()
=>
{
createFullComponent
({
propsData
:
{
profiles
:
savedScans
},
mocks
:
{
$apollo
:
{
mutate
:
successHandler
,
},
},
});
...
...
ee/spec/frontend/security_configuration/dast_profiles/mocks/mock_data.js
View file @
681e8cff
...
...
@@ -64,10 +64,17 @@ export const scannerProfiles = [
export
const
savedScans
=
[
{
id
:
'
gid://gitlab/Dast
Scan
/1
'
,
id
:
'
gid://gitlab/Dast
Profile
/1
'
,
name
:
'
Scan 1
'
,
dastSiteProfile
:
siteProfiles
[
0
],
dastScannerProfile
:
scannerProfiles
[
0
],
editPath
:
'
/1/edit
'
,
},
{
id
:
'
gid://gitlab/DastProfile/2
'
,
name
:
'
Scan 2
'
,
dastSiteProfile
:
siteProfiles
[
1
],
dastScannerProfile
:
scannerProfiles
[
1
],
editPath
:
'
/2/edit
'
,
},
];
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