Commit ac393ade authored by Filipa Lacerda's avatar Filipa Lacerda

Ensures disabled status while request is being made

parent 12bf940c
...@@ -31,28 +31,39 @@ export default { ...@@ -31,28 +31,39 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
buttonDisabled: {
type: String,
required: false,
default: null,
}, },
data() {
return {
isDisabled: false,
linkRequested: '',
};
}, },
computed: { computed: {
cssClass() { cssClass() {
const actionIconDash = dasherize(this.actionIcon); const actionIconDash = dasherize(this.actionIcon);
return `${actionIconDash} js-icon-${actionIconDash}`; return `${actionIconDash} js-icon-${actionIconDash}`;
}, },
isDisabled() {
return this.buttonDisabled === this.link;
},
}, },
methods: { methods: {
onClickAction() { onClickAction() {
$(this.$el).tooltip('hide'); $(this.$el).tooltip('hide');
eventHub.$emit('graphAction', this.link); eventHub.$emit('graphAction', this.link);
this.linkRequested = this.link;
this.isDisabled = true;
},
updateDisabled(actionUrl) {
if (actionUrl === this.linkRequested) {
this.isDisabled = false;
}
}
},
created() {
eventHub.$on('graphActionFinished', this.updateDisabled);
}, },
beforeDestroy() {
eventHub.$off('graphActionFinished', this.updateDisabled);
}, },
}; };
</script> </script>
......
...@@ -17,11 +17,6 @@ export default { ...@@ -17,11 +17,6 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
actionDisabled: {
type: String,
required: false,
default: null,
},
}, },
computed: { computed: {
...@@ -75,7 +70,6 @@ export default { ...@@ -75,7 +70,6 @@ export default {
:key="stage.name" :key="stage.name"
:stage-connector-class="stageConnectorClass(index, stage)" :stage-connector-class="stageConnectorClass(index, stage)"
:is-first-column="isFirstColumn(index)" :is-first-column="isFirstColumn(index)"
:action-disabled="actionDisabled"
/> />
</ul> </ul>
</div> </div>
......
...@@ -54,12 +54,6 @@ export default { ...@@ -54,12 +54,6 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
actionDisabled: {
type: String,
required: false,
default: null,
},
}, },
computed: { computed: {
...@@ -136,7 +130,6 @@ export default { ...@@ -136,7 +130,6 @@ export default {
:tooltip-text="status.action.title" :tooltip-text="status.action.title"
:link="status.action.path" :link="status.action.path"
:action-icon="status.action.icon" :action-icon="status.action.icon"
:button-disabled="actionDisabled"
/> />
</div> </div>
......
...@@ -29,11 +29,6 @@ export default { ...@@ -29,11 +29,6 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
actionDisabled: {
type: String,
required: false,
default: null,
},
}, },
methods: { methods: {
...@@ -74,7 +69,6 @@ export default { ...@@ -74,7 +69,6 @@ export default {
v-if="job.size === 1" v-if="job.size === 1"
:job="job" :job="job"
css-class-job-name="build-content" css-class-job-name="build-content"
:action-disabled="actionDisabled"
/> />
<dropdown-job-component <dropdown-job-component
......
...@@ -25,7 +25,6 @@ export default () => { ...@@ -25,7 +25,6 @@ export default () => {
data() { data() {
return { return {
mediator, mediator,
actionDisabled: null,
}; };
}, },
created() { created() {
...@@ -36,16 +35,14 @@ export default () => { ...@@ -36,16 +35,14 @@ export default () => {
}, },
methods: { methods: {
postAction(action) { postAction(action) {
this.actionDisabled = action;
this.mediator.service.postAction(action) this.mediator.service.postAction(action)
.then(() => { .then(() => {
this.mediator.refreshPipeline(); this.mediator.refreshPipeline();
this.actionDisabled = null; eventHub.$emit('graphActionFinished', action);
}) })
.catch(() => { .catch(() => {
this.actionDisabled = null;
Flash(__('An error occurred while making the request.')); Flash(__('An error occurred while making the request.'));
eventHub.$emit('graphActionFinished', action);
}); });
}, },
}, },
...@@ -54,7 +51,6 @@ export default () => { ...@@ -54,7 +51,6 @@ export default () => {
props: { props: {
isLoading: this.mediator.state.isLoading, isLoading: this.mediator.state.isLoading,
pipeline: this.mediator.store.state.pipeline, pipeline: this.mediator.store.state.pipeline,
actionDisabled: this.actionDisabled,
}, },
}); });
}, },
......
...@@ -468,6 +468,14 @@ ...@@ -468,6 +468,14 @@
margin-bottom: 10px; margin-bottom: 10px;
white-space: normal; white-space: normal;
.ci-job-dropdown-container {
// override dropdown.scss
.dropdown-menu li button {
padding: 0;
text-align: center;
}
}
// ensure .build-content has hover style when action-icon is hovered // ensure .build-content has hover style when action-icon is hovered
.ci-job-dropdown-container:hover .build-content { .ci-job-dropdown-container:hover .build-content {
@extend .build-content:hover; @extend .build-content:hover;
......
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