Skip to content

Commit 36cd40e

Browse files
committed
chore: remove some configurations come at certification.js file
Signed-off-by: Crisciany Souza <criscianysilva1997@gmail.com>
1 parent 32e2dd5 commit 36cd40e

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/views/ReadCertificate/CertificateContent.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363

6464
<script>
6565
66-
// import CertificateContent from './CertificateContent.vue'
67-
import { selectCustonOption } from '../../helpers/certification.js'
66+
import { loadState } from '@nextcloud/initial-state'
6867
6968
export default {
7069
name: 'CertificateContent',
@@ -79,6 +78,11 @@ export default {
7978
default: '0',
8079
},
8180
},
81+
data() {
82+
return {
83+
rulesService: loadState('libresign', 'rules_service') || [],
84+
}
85+
},
8286
methods: {
8387
orderList(data) {
8488
const sorted = {};
@@ -94,13 +98,12 @@ export default {
9498
})
9599
return sorted
96100
},
101+
getRuleById(id) {
102+
return this.rulesService.find(rule => rule.id === id) || {}
103+
},
97104
getLabelFromId(id) {
98-
try {
99-
const item = selectCustonOption(id).unwrap()
100-
return item.label
101-
} catch (error) {
102-
return id
103-
}
105+
const rule = this.getRuleById(id)
106+
return rule.label || id
104107
},
105108
},
106109
}

src/views/Settings/RootCertificateOpenSsl.vue

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@
5757
<NcTextField id="commonName"
5858
ref="commonName"
5959
v-model="certificate.rootCert.commonName"
60-
:helper-text="t('libresign', 'Full name of the main company or main user of this instance')"
61-
:minlength="1"
62-
:success="certificate.rootCert.commonName !== ''"
63-
:error="certificate.rootCert.commonName === ''"
60+
:helper-text="getRuleById('CN').helperText"
61+
:minlength="getRuleById('CN').min"
62+
:maxlength="getRuleById('CN').max"
63+
:success="!getRuleById('CN').required || certificate.rootCert.commonName !== ''"
64+
:error="getRuleById('CN').required && certificate.rootCert.commonName === ''"
6465
:disabled="formDisabled" />
6566
</div>
6667
<CertificateCustonOptions :names.sync="certificate.rootCert.names" />
@@ -115,7 +116,6 @@ import NcTextField from '@nextcloud/vue/components/NcTextField'
115116
import CertificateCustonOptions from './CertificateCustonOptions.vue'
116117
import CertificatePolicy from './CertificatePolicy.vue'
117118
118-
import { selectCustonOption } from '../../helpers/certification.js'
119119
import logger from '../../logger.js'
120120
import { useConfigureCheckStore } from '../../store/configureCheck.js'
121121
@@ -139,6 +139,7 @@ export default {
139139
const CPS = loadState('libresign', 'certificate_policies_cps')
140140
const rulesService = loadState('libresign', 'rules_service')
141141
return {
142+
rulesService,
142143
isThisEngine: loadState('libresign', 'certificate_engine') === 'openssl',
143144
modal: false,
144145
certificate: {
@@ -200,9 +201,16 @@ export default {
200201
this.certificate.rootCert.names = names
201202
},
202203
getLabelFromId(id) {
203-
const item = selectCustonOption(id).unwrap()
204-
return item.label
204+
const item = this.rulesService.find(rule => rule.id === id)
205+
return item ? item.label : id
205206
},
207+
getRuleById(id) {
208+
return this.rulesService.find(rule => rule.id === id) || {}
209+
},
210+
getLabelFromId(id) {
211+
const rule = this.getRuleById(id)
212+
return rule.label || id
213+
},
206214
changeEngine(engine) {
207215
this.isThisEngine = engine === 'openssl'
208216
this.loadRootCertificate()

0 commit comments

Comments
 (0)