Skip to content

Commit 66ace64

Browse files
shwstpprdhslove
authored andcommitted
ui: refactor config update/reset notification (apache#9639)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 151519a commit 66ace64

4 files changed

Lines changed: 21 additions & 32 deletions

File tree

ui/src/components/view/ListView.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,7 @@ export default {
768768
}).then(json => {
769769
this.editableValueKey = null
770770
this.$store.dispatch('RefreshFeatures')
771-
var message = `${this.$t('message.setting.updated')} ${record.name}`
772-
if (record.isdynamic) {
773-
message += `. ${this.$t('message.setting.update.delay')}`
774-
}
775-
this.$message.success(message)
771+
this.$messageConfigSuccess(`${this.$t('message.setting.updated')} ${record.name}`, record)
776772
if (json.updateconfigurationresponse &&
777773
json.updateconfigurationresponse.configuration &&
778774
!json.updateconfigurationresponse.configuration.isdynamic &&
@@ -793,11 +789,7 @@ export default {
793789
api('resetConfiguration', {
794790
name: item.name
795791
}).then(() => {
796-
var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}`
797-
if (item.isdynamic) {
798-
message += `. ${this.$t('message.setting.update.delay')}`
799-
}
800-
this.$message.success(message)
792+
this.$messageConfigSuccess(`${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}`, item)
801793
}).catch(error => {
802794
console.error(error)
803795
this.$message.error(this.$t('message.error.reset.config'))

ui/src/components/view/SettingsTab.vue

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ export default {
191191
value: this.editableValue
192192
}).then(() => {
193193
var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.update.to')} ${this.editableValue}`
194-
if (item.isdynamic) {
195-
message += `. ${this.$t('message.setting.update.delay')}`
196-
}
197-
this.handleSuccessMessage(item.name, this.$route.meta.name, message)
194+
this.handleSuccessMessage(item, this.$route.meta.name, message)
198195
}).catch(error => {
199196
console.error(error)
200197
this.$message.error(this.$t('message.error.save.setting'))
@@ -224,10 +221,7 @@ export default {
224221
name: item.name
225222
}).then(() => {
226223
var message = `${this.$t('label.setting')} ${item.name} ${this.$t('label.reset.config.value')}`
227-
if (item.isdynamic) {
228-
message += `. ${this.$t('message.setting.update.delay')}`
229-
}
230-
this.handleSuccessMessage(item.name, this.$route.meta.name, message)
224+
this.handleSuccessMessage(item, this.$route.meta.name, message)
231225
}).catch(error => {
232226
console.error(error)
233227
this.$message.error(this.$t('message.error.reset.config'))
@@ -242,12 +236,16 @@ export default {
242236
})
243237
})
244238
},
245-
handleSuccessMessage (name, scope, message) {
246-
var obj = this.warningMessages[name]
239+
handleSuccessMessage (config, scope, message) {
240+
var obj = this.warningMessages[config.name]
247241
if (obj && obj.scope === scope) {
248-
this.$warning({ title: message, content: obj.warning })
242+
var content = obj.warning
243+
if (config.isdynamic) {
244+
content = `this.$t('message.setting.update.delay').\n ${content}`
245+
}
246+
this.$warning({ title: message, content: content })
249247
} else {
250-
this.$message.success(message)
248+
this.$messageConfigSuccess(message, config)
251249
}
252250
}
253251
}

ui/src/utils/plugins.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ export const notifierPlugin = {
289289
close: (key) => notification.close(key),
290290
destroy: () => notification.destroy()
291291
}
292+
293+
app.config.globalProperties.$messageConfigSuccess = function (msg, configrecord) {
294+
if (configrecord.isdynamic) {
295+
msg += `. ${this.$t('message.setting.update.delay')}`
296+
}
297+
message.success(msg)
298+
}
292299
}
293300
}
294301

ui/src/views/setting/ConfigurationValue.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,7 @@ export default {
258258
this.actualValue = this.editableValue
259259
this.$emit('change-config', { value: newValue })
260260
this.$store.dispatch('RefreshFeatures')
261-
var message = `${this.$t('message.setting.updated')} ${configrecord.name}`
262-
if (configrecord.isdynamic) {
263-
message += `. ${this.$t('message.setting.update.delay')}`
264-
}
265-
this.$message.success(message)
261+
this.$messageConfigSuccess(`${this.$t('message.setting.updated')} ${configrecord.name}`, configrecord)
266262
if (json.updateconfigurationresponse &&
267263
json.updateconfigurationresponse.configuration &&
268264
!json.updateconfigurationresponse.configuration.isdynamic &&
@@ -299,11 +295,7 @@ export default {
299295
}
300296
this.$emit('change-config', { value: newValue })
301297
this.$store.dispatch('RefreshFeatures')
302-
var message = `${this.$t('label.setting')} ${configrecord.name} ${this.$t('label.reset.config.value')}`
303-
if (configrecord.isdynamic) {
304-
message += `. ${this.$t('message.setting.update.delay')}`
305-
}
306-
this.$message.success(message)
298+
this.$messageConfigSuccess(`${this.$t('label.setting')} ${configrecord.name} ${this.$t('label.reset.config.value')}`, configrecord)
307299
if (json.resetconfigurationresponse &&
308300
json.resetconfigurationresponse.configuration &&
309301
!json.resetconfigurationresponse.configuration.isdynamic &&

0 commit comments

Comments
 (0)