Skip to content

Commit 7266888

Browse files
committed
fix(certificate): editable certificate paths on the import form
1 parent 1a31da3 commit 7266888

1 file changed

Lines changed: 59 additions & 2 deletions

File tree

‎app/src/views/certificate/components/CertificateFilesCard.vue‎

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ watch(() => props.managed, managed => {
1919
})
2020
2121
const hasPaths = computed(() => !!(data.value.ssl_certificate_path || data.value.ssl_certificate_key_path))
22+
23+
// Paths are typed in for other certificates, so a pasted certificate can be
24+
// saved and a file already on disk can be referenced in place.
25+
const editsPaths = computed(() => !props.managed)
26+
27+
function pathHelp(error: string | undefined, kind: string, wrongFile: string) {
28+
if (!error)
29+
return ''
30+
if (error.includes('required'))
31+
return $gettext('This field is required')
32+
return error.includes(kind) ? wrongFile : ''
33+
}
34+
35+
const certPathHelp = computed(() => pathHelp(props.errors?.ssl_certificate_path, 'certificate_path', $gettext('The path exists, but the file is not a certificate')))
36+
const keyPathHelp = computed(() => pathHelp(props.errors?.ssl_certificate_key_path, 'privatekey_path', $gettext('The path exists, but the file is not a private key')))
2237
</script>
2338

2439
<template>
@@ -36,7 +51,28 @@ const hasPaths = computed(() => !!(data.value.ssl_certificate_path || data.value
3651
</template>
3752

3853
<template v-if="!collapsed">
39-
<dl v-if="hasPaths" class="files-paths">
54+
<div v-if="editsPaths" class="files-inputs">
55+
<label class="files-field">
56+
<span class="files-label">{{ $gettext('SSL Certificate Path') }}</span>
57+
<AInput
58+
v-model:value="data.ssl_certificate_path"
59+
class="font-mono"
60+
:status="errors?.ssl_certificate_path ? 'error' : undefined"
61+
/>
62+
<span v-if="certPathHelp" class="files-help">{{ certPathHelp }}</span>
63+
</label>
64+
<label class="files-field">
65+
<span class="files-label">{{ $gettext('SSL Certificate Key Path') }}</span>
66+
<AInput
67+
v-model:value="data.ssl_certificate_key_path"
68+
class="font-mono"
69+
:status="errors?.ssl_certificate_key_path ? 'error' : undefined"
70+
/>
71+
<span v-if="keyPathHelp" class="files-help">{{ keyPathHelp }}</span>
72+
</label>
73+
</div>
74+
75+
<dl v-else-if="hasPaths" class="files-paths">
4076
<dt>{{ $gettext('Certificate') }}</dt>
4177
<dd>
4278
<ATypographyText :copyable="!!data.ssl_certificate_path" class="font-mono">
@@ -54,7 +90,7 @@ const hasPaths = computed(() => !!(data.value.ssl_certificate_path || data.value
5490
<CertificateContentEditor
5591
v-if="showContents"
5692
v-model:data="data"
57-
:class="{ 'mt-3': hasPaths }"
93+
:class="{ 'mt-3': editsPaths || hasPaths }"
5894
:errors="errors"
5995
:readonly="managed"
6096
/>
@@ -84,6 +120,27 @@ const hasPaths = computed(() => !!(data.value.ssl_certificate_path || data.value
84120
}
85121
}
86122
123+
.files-inputs {
124+
display: grid;
125+
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
126+
gap: 12px 16px;
127+
}
128+
129+
.files-field {
130+
display: flex;
131+
flex-direction: column;
132+
gap: 4px;
133+
min-width: 0;
134+
}
135+
136+
.files-label {
137+
color: var(--ant-color-text-secondary);
138+
}
139+
140+
.files-help {
141+
color: var(--ant-color-error);
142+
}
143+
87144
.files-paths {
88145
display: grid;
89146
grid-template-columns: max-content minmax(0, 1fr);

0 commit comments

Comments
 (0)