fix: support-bundle-expiration can be invalid value 000003333 (#248)

* fix: normalize number input

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

* fix: leverage to other inputs

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

---------

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>
This commit is contained in:
Yiya Chen 2025-04-28 11:45:50 +08:00 committed by GitHub
parent 485db3066f
commit b941902088
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 6 deletions

View File

@ -61,9 +61,9 @@ export const HCI_ALLOWED_SETTINGS = {
kind: 'multiline', canReset: true, from: 'import'
},
[HCI_SETTING.OVERCOMMIT_CONFIG]: { kind: 'json', from: 'import' },
[HCI_SETTING.SUPPORT_BUNDLE_TIMEOUT]: {},
[HCI_SETTING.SUPPORT_BUNDLE_EXPIRATION]: {},
[HCI_SETTING.SUPPORT_BUNDLE_NODE_COLLECTION_TIMEOUT]: { featureFlag: 'supportBundleNodeCollectionTimeoutSetting' },
[HCI_SETTING.SUPPORT_BUNDLE_TIMEOUT]: { kind: 'number' },
[HCI_SETTING.SUPPORT_BUNDLE_EXPIRATION]: { kind: 'number' },
[HCI_SETTING.SUPPORT_BUNDLE_NODE_COLLECTION_TIMEOUT]: { kind: 'number', featureFlag: 'supportBundleNodeCollectionTimeoutSetting' },
[HCI_SETTING.SUPPORT_BUNDLE_IMAGE]: { kind: 'json', from: 'import' },
[HCI_SETTING.STORAGE_NETWORK]: {
kind: 'custom', from: 'import', canReset: true
@ -89,7 +89,7 @@ export const HCI_ALLOWED_SETTINGS = {
[HCI_SETTING.NTP_SERVERS]: {
kind: 'json', from: 'import', canReset: true
},
[HCI_SETTING.KUBECONFIG_DEFAULT_TOKEN_TTL_MINUTES]: { featureFlag: 'kubeconfigDefaultTokenTTLMinutesSetting' },
[HCI_SETTING.KUBECONFIG_DEFAULT_TOKEN_TTL_MINUTES]: { kind: 'number', featureFlag: 'kubeconfigDefaultTokenTTLMinutesSetting' },
[HCI_SETTING.LONGHORN_V2_DATA_ENGINE_ENABLED]: {
kind: 'boolean',
experimental: true,

View File

@ -4,7 +4,7 @@ import { RadioGroup } from '@components/Form/Radio';
import { LabeledInput } from '@components/Form/LabeledInput';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { TextAreaAutoGrow } from '@components/Form/TextArea';
import UnitInput from '@shell/components/form/UnitInput';
import CreateEditView from '@shell/mixins/create-edit-view';
import { HCI_ALLOWED_SETTINGS, HCI_SINGLE_CLUSTER_ALLOWED_SETTING, HCI_SETTING } from '../config/settings';
@ -15,7 +15,8 @@ export default {
LabeledInput,
LabeledSelect,
RadioGroup,
TextAreaAutoGrow
TextAreaAutoGrow,
UnitInput
},
mixins: [CreateEditView],
@ -128,6 +129,13 @@ export default {
await this.clusterRegistrationUrlTip();
}
// remove any leading zeros (e.g. '0123' becomes 123)
if (this.setting.kind === 'number' && this.value.value) {
const num = Number(this.value.value);
this.value.value = isNaN(num) ? 0 : `${ num }`;
}
this.save(done);
},
@ -238,6 +246,13 @@ export default {
:min-height="254"
/>
</div>
<div v-else-if="setting.kind === 'number'">
<LabeledInput
v-model:value="value.value"
:label="t('advancedSettings.edit.value')"
type="number"
/>
</div>
<div v-else>
<LabeledInput
v-model:value="value.value"