Skip to content

Commit 2c59171

Browse files
committed
ui: enable/disable as separate actions
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent d8bd9de commit 2c59171

File tree

4 files changed

+66
-9
lines changed

4 files changed

+66
-9
lines changed

ui/public/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@
825825
"label.directdownload": "Direct download",
826826
"label.direction": "Direction",
827827
"label.disable.autoscale.vmgroup": "Disable AutoScaling Group",
828+
"label.disable.custom.action": "Disable Custom Action",
828829
"label.disable.extension": "Disable Extension",
829830
"label.disable.host": "Disable host",
830831
"label.disable.network.offering": "Disable Network offering",
@@ -938,6 +939,7 @@
938939
"label.elastic": "Elastic",
939940
"label.email": "Email",
940941
"label.enable.autoscale.vmgroup": "Enable AutoScaling Group",
942+
"label.enable.custom.action": "Enable Custom Action",
941943
"label.enable.extension": "Enable Extension",
942944
"label.enable.host": "Enable Host",
943945
"label.enable.network.offering": "Enable Network offering",
@@ -2985,6 +2987,7 @@
29852987
"message.confirm.delete.traffic.type": "Please confirm that you would like to delete traffic type.",
29862988
"message.confirm.destroy.router": "All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router. Please confirm that you would like to destroy this router.",
29872989
"message.confirm.disable.autoscale.vmgroup": "Please confirm that you want to disable this autoscaling group.",
2990+
"message.confirm.disable.custom.action": "Please confirm that you want to disable this custom action.",
29882991
"message.confirm.disable.extension": "Please confirm that you want to disable this extension.",
29892992
"message.confirm.disable.host": "Please confirm that you want to disable the host.",
29902993
"message.confirm.disable.network.offering": "Are you sure you want to disable this Network offering?",
@@ -2993,6 +2996,7 @@
29932996
"message.confirm.disable.vpc.offering": "Are you sure you want to disable this VPC offering?",
29942997
"message.confirm.disable.webhook": "Please confirm that you want to disable this webhook.",
29952998
"message.confirm.enable.autoscale.vmgroup": "Please confirm that you want to enable this autoscaling group.",
2999+
"message.confirm.enable.custom.action": "Please confirm that you want to enable this custom action.",
29963000
"message.confirm.enable.extension": "Please confirm that you want to enable this extension.",
29973001
"message.confirm.enable.host": "Please confirm that you want to enable the host.",
29983002
"message.confirm.enable.network.offering": "Are you sure you want to enable this Network offering?",
@@ -3702,6 +3706,7 @@
37023706
"message.success.update.bgp.peer": "Successfully updated BGP peer",
37033707
"message.success.update.bucket": "Successfully updated bucket",
37043708
"message.success.update.condition": "Successfully updated condition",
3709+
"message.success.update.custom.action": "Successfully updated Custom Action",
37053710
"message.success.update.extension": "Successfully updated Extension",
37063711
"message.success.update.sharedfs": "Successfully updated Shared FileSystem",
37073712
"message.success.update.ipaddress": "Successfully updated IP address",

ui/src/config/section/extension/customaction.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ export default {
5757
popup: true,
5858
component: shallowRef(defineAsyncComponent(() => import('@/views/extension/UpdateCustomAction.vue')))
5959
},
60+
{
61+
api: 'updateCustomAction',
62+
icon: 'play-circle-outlined',
63+
label: 'label.enable.custom.action',
64+
message: 'message.confirm.enable.custom.action',
65+
dataView: true,
66+
groupAction: true,
67+
popup: true,
68+
defaultArgs: { enabled: true },
69+
groupMap: (selection) => { return selection.map(x => { return { id: x } }) },
70+
show: (record) => { return !record.enabled }
71+
},
72+
{
73+
api: 'updateCustomAction',
74+
icon: 'pause-circle-outlined',
75+
label: 'label.disable.custom.action',
76+
message: 'message.confirm.disable.custom.action',
77+
dataView: true,
78+
groupAction: true,
79+
popup: true,
80+
defaultArgs: { enabled: false },
81+
groupMap: (selection) => { return selection.map(x => { return { id: x } }) },
82+
show: (record) => { return record.enabled }
83+
},
6084
{
6185
api: 'deleteCustomAction',
6286
icon: 'delete-outlined',

ui/src/views/extension/ExtensionCustomActionsTab.vue

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
icon="edit-outlined"
5353
@click="openUpdateCustomActionModal(record)" />
5454
</span>
55+
<span style="margin-right: 5px">
56+
<a-popconfirm
57+
v-if="'updateCustomAction' in $store.getters.apis"
58+
placement="topRight"
59+
:title="record.enabled ? $t('message.confirm.disable.custom.action') : $t('message.confirm.enable.custom.action')"
60+
:ok-text="$t('label.yes')"
61+
:cancel-text="$t('label.no')"
62+
:loading="updateLoading"
63+
@confirm="updateCustomAction(record)"
64+
>
65+
<tooltip-button
66+
:tooltip="record.enabled ? $t('label.disable.custom.action') : $t('label.enable.custom.action')"
67+
:icon="record.enabled ? 'pause-circle-outlined' : 'play-circle-outlined'" />
68+
</a-popconfirm>
69+
</span>
5570
<span style="margin-right: 5px">
5671
<a-popconfirm
5772
v-if="'deleteCustomAction' in $store.getters.apis"
@@ -158,6 +173,7 @@ export default {
158173
pageSize: 20,
159174
totalCount: 0,
160175
showAddCustomAction: false,
176+
updateLoading: false,
161177
deleteLoading: false,
162178
showUpdateCustomAction: false,
163179
customActionForUpdate: {}
@@ -215,10 +231,29 @@ export default {
215231
this.showUpdateCustomAction = false
216232
this.customActionForUpdate = {}
217233
},
234+
updateCustomAction (record) {
235+
const params = {
236+
id: record.id,
237+
enabled: !record.enabled
238+
}
239+
this.updateLoading = true
240+
api('updateCustomAction', params).then(json => {
241+
this.fetchCustomActions()
242+
this.$notification.success({
243+
message: record.enabled ? this.$t('label.disable.custom.action') : this.$t('label.enable.custom.action'),
244+
description: this.$t('message.success.update.custom.action')
245+
})
246+
}).catch(error => {
247+
this.$notifyError(error)
248+
}).finally(() => {
249+
this.updateLoading = false
250+
})
251+
},
218252
deleteCustomAction (record) {
219253
const params = {
220254
id: record.id
221255
}
256+
this.deleteLoading = true
222257
api('deleteCustomAction', params).then(json => {
223258
this.fetchCustomActions()
224259
this.$notification.success({

ui/src/views/extension/UpdateCustomAction.vue

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,6 @@
9292
:placeholder="apiParams.timeout.description"
9393
:min="1" />
9494
</a-form-item>
95-
<a-form-item name="enabled" ref="enabled">
96-
<template #label>
97-
<tooltip-label :title="$t('label.enabled')" :tooltip="apiParams.enabled.description"/>
98-
</template>
99-
<a-switch v-model:checked="form.enabled" />
100-
</a-form-item>
10195
<div :span="24" class="action-button">
10296
<a-button @click="closeAction">{{ $t('label.cancel') }}</a-button>
10397
<a-button :loading="loading" ref="submit" type="primary" @click="handleSubmit">{{ $t('label.ok') }}</a-button>
@@ -161,7 +155,7 @@ export default {
161155
const formData = {
162156
parameters: this.fixParamatersOptions(this.resource.parameters)
163157
}
164-
const keys = ['description', 'allowedroletypes', 'successmessage', 'errormessage', 'details', 'timeout', 'enabled']
158+
const keys = ['description', 'allowedroletypes', 'successmessage', 'errormessage', 'details', 'timeout']
165159
for (const key of keys) {
166160
formData[key] = this.resource[key]
167161
}
@@ -185,8 +179,7 @@ export default {
185179
const values = toRaw(this.form)
186180
this.loading = true
187181
const params = {
188-
id: this.resource.id,
189-
enabled: values.enabled
182+
id: this.resource.id
190183
}
191184
const keys = ['description', 'allowedroletypes', 'successmessage', 'errormessage', 'timeout']
192185
for (const key of keys) {

0 commit comments

Comments
 (0)