Skip to content

Commit 7f88a28

Browse files
shwstpprdhslove
authored andcommitted
ui: reset configuration allowed only when value not default (apache#11728)
1 parent 6912c5e commit 7f88a28

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
@@ -1020,7 +1020,7 @@
10201020
@onClick="$resetConfigurationValueConfirm(item, resetConfig)"
10211021
v-if="editableValueKey !== record.key"
10221022
icon="reload-outlined"
1023-
:disabled="!('updateConfiguration' in $store.getters.apis)"
1023+
:disabled="!('resetConfiguration' in $store.getters.apis) || record.value === record.defaultvalue"
10241024
/>
10251025
</template>
10261026
<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>
@@ -183,6 +184,13 @@ export default {
183184
handleSearch (value) {
184185
this.filter = value
185186
this.fetchData()
187+
},
188+
handleConfigRefresh (name, updatedRecord) {
189+
if (!name || !updatedRecord) return
190+
const index = this.items.findIndex(item => item.name === name)
191+
if (index !== -1) {
192+
this.items.splice(index, 1, updatedRecord)
193+
}
186194
}
187195
}
188196
}

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>
@@ -360,6 +362,13 @@ export default {
360362
}).catch(error => {
361363
this.$notifyError(error)
362364
})
365+
},
366+
handleConfigRefresh (name, updatedRecord) {
367+
if (!name || !updatedRecord) return
368+
const index = this.config.findIndex(item => item.name === name)
369+
if (index !== -1) {
370+
this.config.splice(index, 1, updatedRecord)
371+
}
363372
}
364373
}
365374
}

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>
@@ -115,6 +118,9 @@ export default {
115118
return 'config-light-row'
116119
}
117120
return 'config-dark-row'
121+
},
122+
handleConfigRefresh (name, updatedRecord) {
123+
this.$emit('refresh-config', name, updatedRecord)
118124
}
119125
}
120126
}

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)