Skip to content

Commit bbba7d7

Browse files
committed
ui: reset configuration allowed only when value not default
Fixes #11643 Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 8089d32 commit bbba7d7

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

ui/src/components/view/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@
921921
@onClick="$resetConfigurationValueConfirm(item, resetConfig)"
922922
v-if="editableValueKey !== record.key"
923923
icon="reload-outlined"
924-
:disabled="!('updateConfiguration' in $store.getters.apis)"
924+
:disabled="!('resetConfiguration' in $store.getters.apis) || record.value === record.defaultvalue"
925925
/>
926926
</template>
927927
<template v-if="column.key === 'gpuDeviceActions'">

ui/src/components/view/SettingsTab.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
@search="handleSearch" />
2626
<ConfigurationTable
2727
:columns="columns"
28-
:config="items" />
28+
:config="items"
29+
@refresh-config="handleConfigRefresh" />
2930
</a-col>
3031
</div>
3132
</template>
@@ -139,6 +140,13 @@ export default {
139140
handleSearch (value) {
140141
this.filter = value
141142
this.fetchData()
143+
},
144+
handleConfigRefresh (name, updatedRecord) {
145+
if (!name || !updatedRecord) return
146+
const index = this.items.findIndex(item => item.name === name)
147+
if (index !== -1) {
148+
this.items.splice(index, 1, updatedRecord)
149+
}
142150
}
143151
}
144152
}

ui/src/views/setting/ConfigurationHierarchy.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<span :style="record.parent ? 'padding-left: 50px; display:block' : 'padding-left: 25px; display:block'">{{ record.description }}</span>
3535
</template>
3636
<template v-if="column.key === 'value'">
37-
<ConfigurationValue :configrecord="record" />
37+
<ConfigurationValue :configrecord="record" @refresh="handleConfigRefresh" />
3838
</template>
3939
</template>
4040
</a-table>
@@ -83,6 +83,9 @@ export default {
8383
return 'light-row'
8484
}
8585
return 'dark-row'
86+
},
87+
handleConfigRefresh (name, updatedRecord) {
88+
this.$emit('refresh-config', name, updatedRecord)
8689
}
8790
}
8891
}

ui/src/views/setting/ConfigurationTab.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
:count="count"
5959
:page="page"
6060
:pagesize="pagesize"
61-
@change-page="changePage" />
61+
@change-page="changePage"
62+
@refresh-config="handleConfigRefresh" />
6263
</a-tab-pane>
6364
<a-tab-pane
6465
v-for="(group) in groups"
@@ -74,7 +75,8 @@
7475
:tab="subgroup.name" >
7576
<ConfigurationHierarchy
7677
:columns="columns"
77-
:config="config" />
78+
:config="config"
79+
@refresh-config="handleConfigRefresh" />
7880
</a-tab-pane>
7981
</a-tabs>
8082
</a-tab-pane>
@@ -322,6 +324,13 @@ export default {
322324
'#' + this.$route.path
323325
)
324326
}
327+
},
328+
handleConfigRefresh (name, updatedRecord) {
329+
if (!name || !updatedRecord) return
330+
const index = this.config.findIndex(item => item.name === name)
331+
if (index !== -1) {
332+
this.config.splice(index, 1, updatedRecord)
333+
}
325334
}
326335
}
327336
}

ui/src/views/setting/ConfigurationTable.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<b> {{record.displaytext }} </b> {{ ' (' + record.name + ')' }} <br/> {{ record.description }}
3333
</template>
3434
<template v-if="column.key === 'value'">
35-
<ConfigurationValue :configrecord="record" />
35+
<ConfigurationValue :configrecord="record" @refresh="handleConfigRefresh" />
3636
</template>
3737
</template>
3838
</a-table>
@@ -109,6 +109,9 @@ export default {
109109
return 'config-light-row'
110110
}
111111
return 'config-dark-row'
112+
},
113+
handleConfigRefresh (name, updatedRecord) {
114+
this.$emit('refresh-config', name, updatedRecord)
112115
}
113116
}
114117
}

ui/src/views/setting/ConfigurationValue.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
@onClick="$resetConfigurationValueConfirm(configrecord, resetConfigurationValue)"
188188
v-if="editableValueKey === null"
189189
icon="reload-outlined"
190-
:disabled="(!('resetConfiguration' in $store.getters.apis) || configDisabled || valueLoading)" />
190+
:disabled="(!('resetConfiguration' in $store.getters.apis) || configDisabled || valueLoading || configrecord.value === configrecord.defaultvalue)" />
191191
</span>
192192
</a-list-item>
193193
</a-list>
@@ -263,6 +263,7 @@ export default {
263263
this.editableValueKey = null
264264
},
265265
updateConfigurationValue (configrecord) {
266+
let configRecordEntry = this.configrecord
266267
this.valueLoading = true
267268
this.editableValueKey = null
268269
var newValue = this.editableValue
@@ -281,7 +282,8 @@ export default {
281282
value: newValue
282283
}
283284
postAPI('updateConfiguration', params).then(json => {
284-
this.editableValue = this.getEditableValue(json.updateconfigurationresponse.configuration)
285+
configRecordEntry = json.updateconfigurationresponse.configuration
286+
this.editableValue = this.getEditableValue(configRecordEntry)
285287
this.actualValue = this.editableValue
286288
this.$emit('change-config', { value: newValue })
287289
this.$store.dispatch('RefreshFeatures')
@@ -305,18 +307,20 @@ export default {
305307
})
306308
}).finally(() => {
307309
this.valueLoading = false
308-
this.$emit('refresh')
310+
this.$emit('refresh', configrecord.name, configRecordEntry)
309311
})
310312
},
311313
resetConfigurationValue (configrecord) {
314+
let configRecordEntry = this.configrecord
312315
this.valueLoading = true
313316
this.editableValueKey = null
314317
const params = {
315318
[this.scopeKey]: this.$route.params?.id,
316319
name: configrecord.name
317320
}
318321
postAPI('resetConfiguration', params).then(json => {
319-
this.editableValue = this.getEditableValue(json.resetconfigurationresponse.configuration)
322+
configRecordEntry = json.resetconfigurationresponse.configuration
323+
this.editableValue = this.getEditableValue(configRecordEntry)
320324
this.actualValue = this.editableValue
321325
var newValue = this.editableValue
322326
if (configrecord.type === 'Range') {
@@ -344,7 +348,7 @@ export default {
344348
})
345349
}).finally(() => {
346350
this.valueLoading = false
347-
this.$emit('refresh')
351+
this.$emit('refresh', configrecord.name, configRecordEntry)
348352
})
349353
},
350354
getEditableValue (configrecord) {

0 commit comments

Comments
 (0)