Skip to content

Commit a02eb01

Browse files
shwstpprLocharla, Sandeep
authored andcommitted
ui: reset configuration allowed only when value not default (apache#11728)
1 parent bb89ace commit a02eb01

File tree

6 files changed

+41
-11
lines changed

6 files changed

+41
-11
lines changed

ui/src/components/view/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@
977977
@onClick="$resetConfigurationValueConfirm(item, resetConfig)"
978978
v-if="editableValueKey !== record.key"
979979
icon="reload-outlined"
980-
:disabled="!('updateConfiguration' in $store.getters.apis)"
980+
:disabled="!('resetConfiguration' in $store.getters.apis) || record.value === record.defaultvalue"
981981
/>
982982
</template>
983983
<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')
@@ -318,10 +320,11 @@ export default {
318320
})
319321
}).finally(() => {
320322
this.valueLoading = false
321-
this.$emit('refresh')
323+
this.$emit('refresh', configrecord.name, configRecordEntry)
322324
})
323325
},
324326
resetConfigurationValue (configrecord) {
327+
let configRecordEntry = this.configrecord
325328
this.valueLoading = true
326329
this.editableValueKey = null
327330
const params = {
@@ -332,7 +335,8 @@ export default {
332335
params[this.scopeKey] = this.resource?.id
333336
}
334337
postAPI('resetConfiguration', params).then(json => {
335-
this.editableValue = this.getEditableValue(json.resetconfigurationresponse.configuration)
338+
configRecordEntry = json.resetconfigurationresponse.configuration
339+
this.editableValue = this.getEditableValue(configRecordEntry)
336340
this.actualValue = this.editableValue
337341
var newValue = this.editableValue
338342
if (configrecord.type === 'Range') {
@@ -360,7 +364,7 @@ export default {
360364
})
361365
}).finally(() => {
362366
this.valueLoading = false
363-
this.$emit('refresh')
367+
this.$emit('refresh', configrecord.name, configRecordEntry)
364368
})
365369
},
366370
getEditableValue (configrecord) {

0 commit comments

Comments
 (0)