Commit 0b45caac authored by pburdette's avatar pburdette

Apply reviewer feedback

Use reusable method to follow
DRY principles.
parent 156d5fe9
...@@ -14,6 +14,8 @@ const POLL_INTERVAL = 10000; ...@@ -14,6 +14,8 @@ const POLL_INTERVAL = 10000;
export default { export default {
name: 'PipelineHeaderSection', name: 'PipelineHeaderSection',
pipelineCancel: 'pipelineCancel',
pipelineRetry: 'pipelineRetry',
components: { components: {
ciHeader, ciHeader,
GlAlert, GlAlert,
...@@ -125,16 +127,14 @@ export default { ...@@ -125,16 +127,14 @@ export default {
reportFailure(errorType) { reportFailure(errorType) {
this.failureType = errorType; this.failureType = errorType;
}, },
async cancelPipeline() { async postPipelineAction(name, mutation) {
this.isCanceling = true;
try { try {
const { const {
data: { data: {
pipelineCancel: { errors }, [name]: { errors },
}, },
} = await this.$apollo.mutate({ } = await this.$apollo.mutate({
mutation: cancelPipelineMutation, mutation,
variables: { id: this.pipeline.id }, variables: { id: this.pipeline.id },
}); });
...@@ -147,27 +147,13 @@ export default { ...@@ -147,27 +147,13 @@ export default {
this.reportFailure(POST_FAILURE); this.reportFailure(POST_FAILURE);
} }
}, },
async retryPipeline() { cancelPipeline() {
this.isRetrying = true; this.isCanceling = true;
this.postPipelineAction(this.$options.pipelineCancel, cancelPipelineMutation);
try {
const {
data: {
pipelineRetry: { errors },
}, },
} = await this.$apollo.mutate({ retryPipeline() {
mutation: retryPipelineMutation, this.isRetrying = true;
variables: { id: this.pipeline.id }, this.postPipelineAction(this.$options.pipelineRetry, retryPipelineMutation);
});
if (errors.length > 0) {
this.reportFailure(POST_FAILURE);
} else {
this.$apollo.queries.pipeline.refetch();
}
} catch {
this.reportFailure(POST_FAILURE);
}
}, },
async deletePipeline() { async deletePipeline() {
this.isDeleting = true; this.isDeleting = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment