Skip to content

Commit 13be966

Browse files
authored
Reenable Pipeline operation buttons if pipeline trigger fails (#5153) (#5278)
* On successfully accepting the pipeline-trigger request (status:202), we disable the trigger buttons to disallow users from trigger pipeline multiple times. * Though, if the pipeline scheduling fails for MDU issue, the pipeline operation buttons are not enabled. * The dashboard API says {"schedulable": true}, but as we've manually disabled the buttons on the trigger call, there is inconsistency between the view and the data. * Force a redraw on the next dashboard api response to make buttons either enabled or disabled based on the Dashboard API response. * Also, as the operation buttons' state is refreshed on the next dashboard api response, those can be enabled within a span of 0-10 sec
1 parent b35fbaa commit 13be966

File tree

7 files changed

+16
-4
lines changed

7 files changed

+16
-4
lines changed

server/webapp/WEB-INF/rails/spec/webpack/views/dashboard/pipeline_widget_spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ describe("Dashboard Pipeline Widget", () => {
949949
view() {
950950
return m(PipelineWidget, {
951951
pipeline,
952+
invalidateEtag: () => {},
952953
isQuickEditPageEnabled,
953954
pluginsSupportingAnalytics,
954955
shouldShowAnalyticsIcon,

server/webapp/WEB-INF/rails/webpack/views/dashboard/dashboard_groups_widget.js.msx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Group = {
2929
return <div class="dashboard-group" key={vm.name}>
3030
<GroupHeading {...vnode.attrs} />
3131
<ul class="dashboard-group_items">
32-
{_.map(pipelines, (pipeline) => <PipelineWidget pipeline={pipeline} key={pipeline.name} {...sharedArgs} />)}
32+
{_.map(pipelines, (pipeline) => <PipelineWidget invalidateEtag={vnode.attrs.invalidateEtag} pipeline={pipeline} key={pipeline.name} {...sharedArgs} />)}
3333
</ul>
3434
</div>;
3535
}
@@ -40,7 +40,9 @@ const DashboardGroupsWidget = {
4040
const sharedArgs = _.assign({}, vnode.attrs);
4141
delete sharedArgs.groups;
4242

43-
return _.map(vnode.attrs.groups, (group) => <Group vm={group} {...sharedArgs} />);
43+
return _.map(vnode.attrs.groups, (group) => <Group vm={group}
44+
invalidateEtag={vnode.attrs.invalidateEtag}
45+
{...sharedArgs} />);
4446
}
4547
};
4648

server/webapp/WEB-INF/rails/webpack/views/dashboard/dashboard_widget.js.msx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ const DashboardWidget = {
7979
</section>
8080

8181
{messageView}
82-
<DashboardGroupsWidget groups={vm.filteredGroups(personalizeVM.currentFilter())} scheme={vm.scheme()}
83-
resolver={dashboard} {...sharedGroupArgs} />
82+
<DashboardGroupsWidget scheme={vm.scheme()}
83+
invalidateEtag={vm.invalidateEtag}
84+
resolver={dashboard} {...sharedGroupArgs}
85+
groups={vm.filteredGroups(personalizeVM.currentFilter())}/>
8486
</div>
8587
</div>
8688
);

server/webapp/WEB-INF/rails/webpack/views/dashboard/models/dashboard_view_model.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,15 @@ function DashboardViewModel(dashboard) {
114114

115115
let dropdownPipelineName, dropdownPipelineCounter;
116116

117+
const self = this;
118+
117119
_.assign(this, {
118120
dashboard,
119121

120122
etag: Stream(null),
121123

124+
invalidateEtag: () => self.etag(null),
125+
122126
dropdown: {
123127
isOpen: (name, instanceCounter) => ((name === dropdownPipelineName) && (instanceCounter === dropdownPipelineCounter)),
124128

server/webapp/WEB-INF/rails/webpack/views/dashboard/pipeline_header_widget.js.msx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const PipelineHeaderWidget = {
7676
</div>
7777
</div>
7878
<PipelineOperationsWidget pipeline={vnode.attrs.pipeline}
79+
invalidateEtag={vnode.attrs.invalidateEtag}
7980
doCancelPolling={vnode.attrs.doCancelPolling}
8081
doRefreshImmediately={vnode.attrs.doRefreshImmediately}
8182
operationMessages={vnode.attrs.operationMessages}/>

server/webapp/WEB-INF/rails/webpack/views/dashboard/pipeline_operations_widget.js.msx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const PipelineOperationsWidget = {
3535
pipeline.trigger(options).then((res) => {
3636
pipeline.triggerDisabled(true);
3737
operationMessages.success(pipeline.name, res.message);
38+
vnode.attrs.invalidateEtag();
3839
}, (res) => {
3940
operationMessages.failure(pipeline.name, res.responseJSON.message);
4041
});

server/webapp/WEB-INF/rails/webpack/views/dashboard/pipeline_widget.js.msx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const PipelineWidget = {
4646
<li class="dashboard-group_pipeline">
4747
<div class="pipeline">
4848
<PipelineHeaderWidget pipeline={vnode.attrs.pipeline}
49+
invalidateEtag={vnode.attrs.invalidateEtag}
4950
doCancelPolling={vnode.attrs.doCancelPolling}
5051
doRefreshImmediately={vnode.attrs.doRefreshImmediately}
5152
pluginsSupportingAnalytics={vnode.attrs.pluginsSupportingAnalytics}

0 commit comments

Comments
 (0)