Skip to content

Commit

Permalink
fix: display custom options when loaded from backend
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Jan 4, 2025
1 parent 218afc4 commit 9f444d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
27 changes: 18 additions & 9 deletions src/views/Settings/CertificateCustonOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@
<div v-for="certificate in certificateList"
:key="certificate.id"
class="customNames">
<label :for="certificate.id" class="form-heading--required">
{{ certificate.label }}
</label>
<div class="item">
<NcTextField v-if="certificate"
:id="certificate.id"
v-model="certificate.value"
:success="typeof certificate.error === 'boolean' && !certificate.error"
:error="certificate.error"
:maxlength="certificate.max ? certificate.max : undefined"
:label="certificate.label"
:helper-text="certificate.helperText"
:maxlength="getOptionProperty(certificate.id, 'max')"
:label="getOptionProperty(certificate.id, 'label')"
:helper-text="getOptionProperty(certificate.id, 'helperText')"
@update:value="validate(certificate.id)" />
<NcButton :aria-label="t('settings', 'Remove custom name entry from root certificate')"
@click="removeOptionalAttribute(certificate.id)">
Expand Down Expand Up @@ -78,12 +75,26 @@ export default {
},
data() {
return {
customNamesOptions: options,
certificateList: [],
options,
}
},
computed: {
customNamesOptions() {
return this.options.filter(itemA =>
!this.certificateList.some(itemB => itemB.id === itemA.id),
)
},
},
watch: {
names(values) {
this.certificateList = values
},
},
methods: {
getOptionProperty(id, property) {
return this.options.find(option => option.id === id)[property]
},
validateMin(item) {
return item.value.length >= item.min
},
Expand Down Expand Up @@ -118,14 +129,12 @@ export default {
}
const list = this.certificateList.filter(item => item.id !== itemSelected.id)
this.certificateList = list
this.customNamesOptions = [...this.customNamesOptions, itemSelected]
}
},
async onOptionalAttributeSelect(selected) {
const custonOption = selectCustonOption(selected.id)
if (custonOption.isSome()) {
this.certificateList = [custonOption.unwrap(), ...this.certificateList]
this.customNamesOptions = this.customNamesOptions.filter(item => item.id !== selected.id)
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/views/Settings/RootCertificateCfssl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ export default {
this.modal = false
},
clearAndShowForm() {
this.certificate = {
this.$set(this, 'certificate', {
rootCert: {
commonName: '',
names: [],
},
cfsslUri: '',
configPath: '',
}
})
this.customData = false
this.formDisabled = false
this.modal = false
Expand All @@ -228,7 +228,7 @@ export default {
if (!data.ocs.data || data.ocs.data.message) {
throw new Error(data.ocs.data)
}
this.certificate = data.ocs.data.data
this.$set(this, 'certificate', data.ocs.data.data)
this.afterCertificateGenerated()
this.configureCheckStore.checkSetup()
})
Expand Down
6 changes: 3 additions & 3 deletions src/views/Settings/RootCertificateOpenSsl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ export default {
this.modal = false
},
clearAndShowForm() {
this.certificate = {
this.$set(this, 'certificate', {
rootCert: {
commonName: '',
names: [],
},
configPath: '',
}
})
this.customData = false
this.formDisabled = false
this.modal = false
Expand All @@ -213,7 +213,7 @@ export default {
if (!data.ocs.data || data.ocs.data.message) {
throw new Error(data.ocs.data)
}
this.certificate = data.ocs.data.data
this.$set(this, 'certificate', data.ocs.data.data)
this.afterCertificateGenerated()
this.configureCheckStore.checkSetup()
})
Expand Down

0 comments on commit 9f444d1

Please sign in to comment.