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
984ef174
Commit
984ef174
authored
Dec 13, 2021
by
Paul Gascou-Vaillancourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert action function to a method
parent
0012a6cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
24 deletions
+23
-24
ee/app/assets/javascripts/on_demand_scans/components/actions.vue
...assets/javascripts/on_demand_scans/components/actions.vue
+23
-24
No files found.
ee/app/assets/javascripts/on_demand_scans/components/actions.vue
View file @
984ef174
...
...
@@ -13,28 +13,6 @@ import ActionButton from './action_button.vue';
const
CANCELLING_PROPERTY
=
'
isCancelling
'
;
const
RETRYING_PROPERTY
=
'
isRetrying
'
;
function
action
({
loadingProperty
,
mutation
,
mutationType
,
defaultErrorMessage
})
{
this
.
$emit
(
'
action
'
);
this
[
loadingProperty
]
=
true
;
this
.
$apollo
.
mutate
({
mutation
,
variables
:
{
id
:
this
.
scan
.
id
,
},
update
:
(
_store
,
{
data
=
{}
})
=>
{
const
[
errorMessage
]
=
data
[
mutationType
]?.
errors
??
[];
if
(
errorMessage
)
{
this
.
triggerError
(
loadingProperty
,
errorMessage
);
}
},
})
.
catch
((
exception
)
=>
{
this
.
triggerError
(
loadingProperty
,
defaultErrorMessage
,
exception
);
});
}
export
const
cancelError
=
s__
(
'
OnDemandScans|The scan could not be canceled.
'
);
export
const
retryError
=
s__
(
'
OnDemandScans|The scan could not be retried.
'
);
...
...
@@ -73,8 +51,29 @@ export default {
},
},
methods
:
{
action
({
loadingProperty
,
mutation
,
mutationType
,
defaultErrorMessage
})
{
this
.
$emit
(
'
action
'
);
this
[
loadingProperty
]
=
true
;
this
.
$apollo
.
mutate
({
mutation
,
variables
:
{
id
:
this
.
scan
.
id
,
},
update
:
(
_store
,
{
data
=
{}
})
=>
{
const
[
errorMessage
]
=
data
[
mutationType
]?.
errors
??
[];
if
(
errorMessage
)
{
this
.
triggerError
(
loadingProperty
,
errorMessage
);
}
},
})
.
catch
((
exception
)
=>
{
this
.
triggerError
(
loadingProperty
,
defaultErrorMessage
,
exception
);
});
},
cancelPipeline
()
{
action
.
call
(
this
,
{
this
.
action
(
{
loadingProperty
:
CANCELLING_PROPERTY
,
mutation
:
pipelineCancelMutation
,
mutationType
:
'
pipelineCancel
'
,
...
...
@@ -82,7 +81,7 @@ export default {
});
},
retryPipeline
()
{
action
.
call
(
this
,
{
this
.
action
(
{
loadingProperty
:
RETRYING_PROPERTY
,
mutation
:
pipelineRetryMutation
,
mutationType
:
'
pipelineRetry
'
,
...
...
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