Skip to content

Commit

Permalink
ui: refactor config update/reset notification (#9639)
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
  • Loading branch information
shwstppr authored Sep 6, 2024
1 parent 8c8d115 commit 82f113b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 32 deletions.
12 changes: 2 additions & 10 deletions ui/src/components/view/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,7 @@ export default {
}).then(json => {
this.editableValueKey = null
this.$store.dispatch('RefreshFeatures')
var message = `${this.$t('message.setting.updated')} ${record.name}`
if (record.isdynamic) {
message += `. ${this.$t('message.setting.update.delay')}`
}
this.$message.success(message)
this.$messageConfigSuccess(`${this.$t('message.setting.updated')} ${record.name}`, record)
if (json.updateconfigurationresponse &&
json.updateconfigurationresponse.configuration &&
!json.updateconfigurationresponse.configuration.isdynamic &&
Expand All @@ -786,11 +782,7 @@ export default {
api('resetConfiguration', {
name: item.name
}).then(() => {
var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}`
if (item.isdynamic) {
message += `. ${this.$t('message.setting.update.delay')}`
}
this.$message.success(message)
this.$messageConfigSuccess(`${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}`, item)
}).catch(error => {
console.error(error)
this.$message.error(this.$t('message.error.reset.config'))
Expand Down
22 changes: 10 additions & 12 deletions ui/src/components/view/SettingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ export default {
value: this.editableValue
}).then(() => {
var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.update.to')} ${this.editableValue}`
if (item.isdynamic) {
message += `. ${this.$t('message.setting.update.delay')}`
}
this.handleSuccessMessage(item.name, this.$route.meta.name, message)
this.handleSuccessMessage(item, this.$route.meta.name, message)
}).catch(error => {
console.error(error)
this.$message.error(this.$t('message.error.save.setting'))
Expand Down Expand Up @@ -208,10 +205,7 @@ export default {
name: item.name
}).then(() => {
var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}`
if (item.isdynamic) {
message += `. ${this.$t('message.setting.update.delay')}`
}
this.handleSuccessMessage(item.name, this.$route.meta.name, message)
this.handleSuccessMessage(item, this.$route.meta.name, message)
}).catch(error => {
console.error(error)
this.$message.error(this.$t('message.error.reset.config'))
Expand All @@ -226,12 +220,16 @@ export default {
})
})
},
handleSuccessMessage (name, scope, message) {
var obj = this.warningMessages[name]
handleSuccessMessage (config, scope, message) {
var obj = this.warningMessages[config.name]
if (obj && obj.scope === scope) {
this.$warning({ title: message, content: obj.warning })
var content = obj.warning
if (config.isdynamic) {
content = `this.$t('message.setting.update.delay').\n ${content}`
}
this.$warning({ title: message, content: content })
} else {
this.$message.success(message)
this.$messageConfigSuccess(message, config)
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions ui/src/utils/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ export const notifierPlugin = {
close: (key) => notification.close(key),
destroy: () => notification.destroy()
}

app.config.globalProperties.$messageConfigSuccess = function (msg, configrecord) {
if (configrecord.isdynamic) {
msg += `. ${this.$t('message.setting.update.delay')}`
}
message.success(msg)
}
}
}

Expand Down
12 changes: 2 additions & 10 deletions ui/src/views/setting/ConfigurationValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,7 @@ export default {
this.actualValue = this.editableValue
this.$emit('change-config', { value: newValue })
this.$store.dispatch('RefreshFeatures')
var message = `${this.$t('message.setting.updated')} ${configrecord.name}`
if (configrecord.isdynamic) {
message += `. ${this.$t('message.setting.update.delay')}`
}
this.$message.success(message)
this.$messageConfigSuccess(`${this.$t('message.setting.updated')} ${configrecord.name}`, configrecord)
if (json.updateconfigurationresponse &&
json.updateconfigurationresponse.configuration &&
!json.updateconfigurationresponse.configuration.isdynamic &&
Expand Down Expand Up @@ -299,11 +295,7 @@ export default {
}
this.$emit('change-config', { value: newValue })
this.$store.dispatch('RefreshFeatures')
var message = `${this.$t('label.setting')} ${configrecord.name} ${this.$t('label.reset.config.value')}`
if (configrecord.isdynamic) {
message += `. ${this.$t('message.setting.update.delay')}`
}
this.$message.success(message)
this.$messageConfigSuccess(`${this.$t('label.setting')} ${configrecord.name} ${this.$t('label.reset.config.value')}`, configrecord)
if (json.resetconfigurationresponse &&
json.resetconfigurationresponse.configuration &&
!json.resetconfigurationresponse.configuration.isdynamic &&
Expand Down

0 comments on commit 82f113b

Please sign in to comment.