Skip to content

ui: confirm on reset configurations #10745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 4.19
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,7 @@
"message.confirm.remove.vmware.datacenter": "Please confirm you want to remove VMware datacenter.",
"message.confirm.remove.vpc.offering": "Are you sure you want to remove this VPC offering?",
"message.confirm.replace.acl.new.one": "Do you want to replace the ACL with a new one?",
"message.confirm.reset.configuration.value": "Are you sure you want reset configuration - %x?",
"message.confirm.reset.network.permissions": "Are you sure you want to reset this Network permissions?",
"message.confirm.scale.up.router.vm": "Do you really want to scale up the router Instance?",
"message.confirm.scale.up.system.vm": "Do you really want to scale up the system VM?",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/view/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
iconTwoToneColor="#52c41a" />
<tooltip-button
:tooltip="$t('label.reset.config.value')"
@onClick="resetConfig(record)"
@onClick="$resetConfigurationValueConfirm(item, resetConfig)"
v-if="editableValueKey !== record.key"
icon="reload-outlined"
:disabled="!('updateConfiguration' in $store.getters.apis)" />
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/view/SettingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
iconTwoToneColor="#52c41a" />
<tooltip-button
:tooltip="$t('label.reset.config.value')"
@onClick="resetConfig(item)"
@onClick="$resetConfigurationValueConfirm(item, resetConfig)"
v-if="editableValueKey !== index"
icon="reload-outlined"
:disabled="!('updateConfiguration' in $store.getters.apis)" />
Expand Down
4 changes: 3 additions & 1 deletion ui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {
resourceTypePlugin,
fileSizeUtilPlugin,
genericUtilPlugin,
localesPlugin
localesPlugin,
dialogUtilPlugin
} from './utils/plugins'
import { VueAxios } from './utils/request'
import directives from './utils/directives'
Expand All @@ -51,6 +52,7 @@ vueApp.use(resourceTypePlugin)
vueApp.use(fileSizeUtilPlugin)
vueApp.use(localesPlugin)
vueApp.use(genericUtilPlugin)
vueApp.use(dialogUtilPlugin)
vueApp.use(extensions)
vueApp.use(directives)

Expand Down
17 changes: 16 additions & 1 deletion ui/src/utils/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import _ from 'lodash'
import { i18n } from '@/locales'
import { api } from '@/api'
import { message, notification } from 'ant-design-vue'
import { message, notification, Modal } from 'ant-design-vue'
import eventBus from '@/config/eventBus'
import store from '@/store'
import { sourceToken } from '@/utils/request'
Expand Down Expand Up @@ -527,3 +527,18 @@ export function createPathBasedOnVmType (vmtype, virtualmachineid) {

return path + virtualmachineid
}

export const dialogUtilPlugin = {
install (app) {
app.config.globalProperties.$resetConfigurationValueConfirm = function (configRecord, callback) {
Modal.confirm({
title: i18n.global.t('label.reset.config.value'),
content: `${i18n.global.t('message.confirm.reset.configuration.value').replace('%x', configRecord.name)}`,
okText: i18n.global.t('label.yes'),
cancelText: i18n.global.t('label.no'),
okType: 'primary',
onOk: () => callback(configRecord)
})
}
}
}
2 changes: 1 addition & 1 deletion ui/src/views/setting/ConfigurationValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
:disabled="valueLoading" />
<tooltip-button
:tooltip="$t('label.reset.config.value')"
@onClick="resetConfigurationValue(configrecord)"
@onClick="$resetConfigurationValueConfirm(configrecord, resetConfigurationValue)"
v-if="editableValueKey === null"
icon="reload-outlined"
:disabled="(!('resetConfiguration' in $store.getters.apis) || configDisabled || valueLoading)" />
Expand Down
4 changes: 3 additions & 1 deletion ui/tests/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
showIconPlugin,
resourceTypePlugin,
fileSizeUtilPlugin,
genericUtilPlugin
genericUtilPlugin,
dialogUtilPlugin
} from '@/utils/plugins'

function createMockRouter (newRoutes = []) {
Expand Down Expand Up @@ -88,6 +89,7 @@ function createFactory (component, options) {
resourceTypePlugin,
fileSizeUtilPlugin,
genericUtilPlugin,
dialogUtilPlugin,
StoragePlugin
],
mocks
Expand Down