Skip to content

Commit 1f64887

Browse files
shwstpprowsferraro
authored andcommitted
ui: reset configuration allowed only when value not default (apache#11728)
1 parent be784db commit 1f64887

6 files changed

Lines changed: 41 additions & 11 deletions

File tree

ui/src/components/view/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@
988988
@onClick="$resetConfigurationValueConfirm(item, resetConfig)"
989989
v-if="editableValueKey !== record.key"
990990
icon="reload-outlined"
991-
:disabled="!('updateConfiguration' in $store.getters.apis)"
991+
:disabled="!('resetConfiguration' in $store.getters.apis) || record.value === record.defaultvalue"
992992
/>
993993
</template>
994994
<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
@@ -26,7 +26,8 @@
2626
<ConfigurationTable
2727
:columns="columns"
2828
:config="items"
29-
:resource="resource" />
29+
:resource="resource"
30+
@refresh-config="handleConfigRefresh" />
3031
</a-col>
3132
</div>
3233
</template>
@@ -140,6 +141,13 @@ export default {
140141
handleSearch (value) {
141142
this.filter = value
142143
this.fetchData()
144+
},
145+
handleConfigRefresh (name, updatedRecord) {
146+
if (!name || !updatedRecord) return
147+
const index = this.items.findIndex(item => item.name === name)
148+
if (index !== -1) {
149+
this.items.splice(index, 1, updatedRecord)
150+
}
143151
}
144152
}
145153
}

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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
<b> {{record.displaytext }} </b> {{ ' (' + record.name + ')' }} <br/> {{ record.description }}
3333
</template>
3434
<template v-if="column.key === 'value'">
35-
<ConfigurationValue :configrecord="record" :resource="resource" />
35+
<ConfigurationValue
36+
:configrecord="record"
37+
:resource="resource"
38+
@refresh="handleConfigRefresh" />
3639
</template>
3740
</template>
3841
</a-table>
@@ -113,6 +116,9 @@ export default {
113116
return 'config-light-row'
114117
}
115118
return 'config-dark-row'
119+
},
120+
handleConfigRefresh (name, updatedRecord) {
121+
this.$emit('refresh-config', name, updatedRecord)
116122
}
117123
}
118124
}

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>
@@ -273,6 +273,7 @@ export default {
273273
this.editableValueKey = null
274274
},
275275
updateConfigurationValue (configrecord) {
276+
let configRecordEntry = this.configrecord
276277
this.valueLoading = true
277278
this.editableValueKey = null
278279
var newValue = this.editableValue
@@ -294,7 +295,8 @@ export default {
294295
params[this.scopeKey] = this.resource?.id
295296
}
296297
postAPI('updateConfiguration', params).then(json => {
297-
this.editableValue = this.getEditableValue(json.updateconfigurationresponse.configuration)
298+
configRecordEntry = json.updateconfigurationresponse.configuration
299+
this.editableValue = this.getEditableValue(configRecordEntry)
298300
this.actualValue = this.editableValue
299301
this.$emit('change-config', { value: newValue })
300302
this.$store.dispatch('RefreshFeatures')
@@ -310,10 +312,11 @@ export default {
310312
})
311313
}).finally(() => {
312314
this.valueLoading = false
313-
this.$emit('refresh')
315+
this.$emit('refresh', configrecord.name, configRecordEntry)
314316
})
315317
},
316318
resetConfigurationValue (configrecord) {
319+
let configRecordEntry = this.configrecord
317320
this.valueLoading = true
318321
this.editableValueKey = null
319322
const params = {
@@ -324,7 +327,8 @@ export default {
324327
params[this.scopeKey] = this.resource?.id
325328
}
326329
postAPI('resetConfiguration', params).then(json => {
327-
this.editableValue = this.getEditableValue(json.resetconfigurationresponse.configuration)
330+
configRecordEntry = json.resetconfigurationresponse.configuration
331+
this.editableValue = this.getEditableValue(configRecordEntry)
328332
this.actualValue = this.editableValue
329333
var newValue = this.editableValue
330334
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)