Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(providerForm): compatible with older versions for config ui #383

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/views/components/providerForm/AlibabaClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ const form = reactive({
config: {},
options: {}
})
const dashboardUI = ref(false)
// decode options
watch(
() => props.initValue,
Expand All @@ -352,14 +353,24 @@ watch(
form.options[k] = Base64.decode(v)
}
})
dashboardUI.value = props.initValue?.config?.enable?.includes('explorer') ?? false
// Compatible with older versions start
if (props.initValue?.config?.ui === true) {
dashboardUI.value = true
delete form.config.ui
} else if (props.initValue?.config?.ui === false) {
dashboardUI.value = false
delete form.config.ui
}
// Compatible with older versions end
},
{ immediate: true }
)
const tabPosition = inject('tab-position', 'left')
const { getForm: getSubform, validate: validateSubForm } = useFormManage()
const advanceConfigVisible = ref(false)
const acitiveTab = ref('instance')
const dashboardUI = ref(false)

const readonlyOption = computed(() => {
return { readOnly: props.readonly }
})
Expand Down Expand Up @@ -660,20 +671,15 @@ const vpcChange = (v) => {
}

watch(
[acitiveTab, () => props.readonly, () => props.initValue],
([tab, readonly, initValue], [oldTab]) => {
[acitiveTab, () => props.readonly],
([tab, readonly], [oldTab]) => {
if (
readonly === false &&
(!oldTab || tab !== 'credential') &&
(keyInfo.accessKey !== form.options['access-key'] || keyInfo.accessSecret !== form.options['access-secret'])
) {
validateCredentials()
}
if (initValue?.config?.enable) {
dashboardUI.value = initValue?.config?.enable?.findIndex((item) => item === 'explorer') !== -1
} else if (initValue.config?.ui) {
dashboardUI.value = true
}
},
{ immediate: true }
)
Expand Down
25 changes: 17 additions & 8 deletions src/views/components/providerForm/AwsClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,38 @@ const form = reactive({
config: {},
options: {}
})
const dashboardUI = ref(false)
// decode options
watch(
() => props.initValue,
() => {
;({ config: form.config, options: form.options, provider: form.provider } = cloneDeep(props.initValue))

needDecodeOptionKeys.forEach((k) => {
const v = form.options[k]
if (v) {
form.options[k] = Base64.decode(v)
}
})

dashboardUI.value = props.initValue?.config?.enable?.includes('explorer') ?? false
// Compatible with older versions start
if (props.initValue?.config?.ui === true) {
dashboardUI.value = true
delete form.config.ui
} else if (props.initValue?.config?.ui === false) {
dashboardUI.value = false
delete form.config.ui
}
// Compatible with older versions end
},
{ immediate: true }
)
const tabPosition = inject('tab-position', 'left')
const { getForm: getSubform, validate: validateSubForm } = useFormManage()
const advanceConfigVisible = ref(false)
const acitiveTab = ref('instance')
const dashboardUI = ref(false)

const readonlyOption = computed(() => {
return { readOnly: props.readonly }
})
Expand Down Expand Up @@ -511,6 +524,7 @@ const credentialValue = computed({
form.options['session-token'] = v['session-token']
}
})

updateActiveTab()

const tags = ref(null)
Expand Down Expand Up @@ -737,9 +751,9 @@ const zoneChange = (zone) => {
}

watch(
[acitiveTab, () => props.readonly, () => props.initValue],
[acitiveTab, () => props.readonly],
// eslint-disable-next-line no-unused-vars
([tab, readonly, initValue], [oldTab]) => {
([tab, readonly], [oldTab]) => {
if (
readonly === false &&
(!oldTab || tab !== 'credential') &&
Expand All @@ -750,11 +764,6 @@ watch(
) {
validateCredentials()
}
if (initValue?.config?.enable) {
dashboardUI.value = initValue?.config?.enable?.findIndex((item) => item === 'explorer') !== -1
} else if (initValue.config?.ui) {
dashboardUI.value = true
}
},
{ immediate: true }
)
Expand Down
22 changes: 14 additions & 8 deletions src/views/components/providerForm/GoogleClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ const form = reactive({
config: {},
options: {}
})
const dashboardUI = ref(false)
// decode options
watch(
() => props.initValue,
Expand All @@ -388,14 +389,24 @@ watch(
form.options[k] = Base64.decode(v)
}
})
dashboardUI.value = props.initValue?.config?.enable?.includes('explorer') ?? false
// Compatible with older versions start
if (props.initValue?.config?.ui === true) {
dashboardUI.value = true
delete form.config.ui
} else if (props.initValue?.config?.ui === false) {
dashboardUI.value = false
delete form.config.ui
}
// Compatible with older versions end
},
{ immediate: true }
)
const tabPosition = inject('tab-position', 'left')
const { getForm: getSubform, validate: validateSubForm } = useFormManage()
const advanceConfigVisible = ref(false)
const acitiveTab = ref('instance')
const dashboardUI = ref(false)

const readonlyOption = computed(() => {
return { readOnly: props.readonly }
})
Expand Down Expand Up @@ -491,20 +502,15 @@ const validateCredentials = () => {
}

watch(
[credentialId, acitiveTab, () => props.readonly, () => props.initValue],
([cId, tab, readonly, initValue], [oldTab]) => {
[credentialId, acitiveTab, () => props.readonly],
([cId, tab, readonly], [oldTab]) => {
if (
readonly === false &&
(!oldTab || tab !== 'credential') &&
(keyInfo.credentialId !== cId || keyInfo.project !== form.options['project'])
) {
validateCredentials()
}
if (initValue?.config?.enable) {
dashboardUI.value = initValue?.config?.enable?.findIndex((item) => item === 'explorer') !== -1
} else if (initValue.config?.ui) {
dashboardUI.value = true
}
},
{ immediate: true }
)
Expand Down
13 changes: 9 additions & 4 deletions src/views/components/providerForm/HarvesterClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -352,19 +352,24 @@ const dashboardUI = ref(false)
// decode options
watch(
() => props.initValue,
(initValue) => {
() => {
;({ config: form.config, options: form.options, provider: form.provider } = cloneDeep(props.initValue))
needDecodeOptionKeys.forEach((k) => {
const v = form.options[k]
if (v) {
form.options[k] = Base64.decode(v)
}
})
if (initValue?.config?.enable) {
dashboardUI.value = initValue?.config?.enable?.findIndex((item) => item === 'explorer') !== -1
} else if (initValue.config?.ui) {
dashboardUI.value = props.initValue?.config?.enable?.includes('explorer') ?? false
// Compatible with older versions start
if (props.initValue?.config?.ui === true) {
dashboardUI.value = true
delete form.config.ui
} else if (props.initValue?.config?.ui === false) {
dashboardUI.value = false
delete form.config.ui
}
// Compatible with older versions end
},
{ immediate: true }
)
Expand Down
16 changes: 11 additions & 5 deletions src/views/components/providerForm/NativeClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,26 @@ const form = reactive({
config: {},
options: {}
})
const dashboardUI = ref(false)
const tabPosition = inject('tab-position', 'left')
watch(
() => props.initValue,
(initValue) => {
() => {
;({ config: form.config, options: form.options, provider: form.provider } = cloneDeep(props.initValue))
if (initValue?.config?.enable) {
dashboardUI.value = initValue?.config?.enable?.findIndex((item) => item === 'explorer') !== -1
} else if (initValue.config?.ui) {
dashboardUI.value = props.initValue?.config?.enable?.includes('explorer') ?? false
// Compatible with older versions start
if (props.initValue?.config?.ui === true) {
dashboardUI.value = true
delete form.config.ui
} else if (props.initValue?.config?.ui === false) {
dashboardUI.value = false
delete form.config.ui
}
// Compatible with older versions end
},
{ immediate: true }
)
const dashboardUI = ref(false)

const { getForm: getSubform, validate: validateSubForm } = useFormManage()
const addons = ref(null)
const getForm = () => {
Expand Down
22 changes: 14 additions & 8 deletions src/views/components/providerForm/TencentClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ const form = reactive({
config: {},
options: {}
})
const dashboardUI = ref(false)
const tabPosition = inject('tab-position', 'left')
// decode options
watch(
Expand All @@ -347,6 +348,16 @@ watch(
form.options[k] = Base64.decode(v)
}
})
dashboardUI.value = props.initValue?.config?.enable?.includes('explorer') ?? false
// Compatible with older versions start
if (props.initValue?.config?.ui === true) {
dashboardUI.value = true
delete form.config.ui
} else if (props.initValue?.config?.ui === false) {
dashboardUI.value = false
delete form.config.ui
}
// Compatible with older versions end
},
{ immediate: true }
)
Expand All @@ -360,7 +371,7 @@ const updateActiveTab = () => {
}
acitiveTab.value = 'instance'
}
const dashboardUI = ref(false)

const readonlyOption = computed(() => {
return { readOnly: props.readonly }
})
Expand Down Expand Up @@ -542,20 +553,15 @@ const vpcChange = (v) => {
}

watch(
[acitiveTab, () => props.readonly, () => props.initValue],
([tab, readonly, initValue], [oldTab]) => {
[acitiveTab, () => props.readonly],
([tab, readonly], [oldTab]) => {
if (
readonly === false &&
(!oldTab || tab !== 'credential') &&
(keyInfo.secretId !== form.options['secret-id'] || keyInfo.secretKey !== form.options['secret-key'])
) {
validateCredentials()
}
if (initValue?.config?.enable) {
dashboardUI.value = initValue?.config?.enable?.findIndex((item) => item === 'explorer') !== -1
} else if (initValue.config?.ui) {
dashboardUI.value = true
}
},
{ immediate: true }
)
Expand Down