Skip to content

Commit e7c6632

Browse files
luizhf42otavio
authored andcommitted
fix(ui): disable PublicKeyEdit data field
1 parent 484b255 commit e7c6632

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

ui/src/components/PublicKeys/PublicKeyEdit.vue

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,11 @@
112112

113113
<FileTextComponent
114114
v-model="publicKeyData"
115-
v-model:error-message="publicKeyDataError"
116115
class="mt-4 mb-2"
117-
enable-paste
118-
start-in-text
116+
text-only
119117
textarea-label="Public key data"
120-
description-text="Supports RSA, DSA, ECDSA (NIST P-*) and ED25519 key types, in PEM (PKCS#1, PKCS#8) and OpenSSH formats."
121-
:validator="(t) => isKeyValid('public', t)"
122-
invalid-message="This is not a valid public key."
118+
description-text="Public key data cannot be modified after creation."
119+
:disabled="true"
123120
data-test="data-field"
124121
/>
125122
</div>
@@ -140,7 +137,6 @@ import { HostnameFilter, TagsFilter } from "@/interfaces/IFilter";
140137
import usePublicKeysStore from "@/store/modules/public_keys";
141138
import useTagsStore from "@/store/modules/tags";
142139
import FileTextComponent from "@/components/Fields/FileTextComponent.vue";
143-
import { isKeyValid } from "@/utils/sshKeys";
144140
145141
type TagsFilterNames = { tags: string[] };
146142
type LocalFilter = HostnameFilter | TagsFilterNames;
@@ -201,7 +197,6 @@ const {
201197
});
202198
203199
const publicKeyData = ref("");
204-
const publicKeyDataError = ref("");
205200
206201
const hasAuthorization = computed(() => props.hasAuthorization ?? true);
207202
@@ -377,14 +372,12 @@ const handleUpdate = () => {
377372
378373
const setLocalVariable = () => {
379374
keyLocal.value = { ...(props.publicKey as LocalPublicKey) };
380-
keyLocal.value.data = Buffer.from(props.publicKey.data, "base64").toString("utf-8");
381375
};
382376
383377
const open = () => {
384378
showDialog.value = true;
385379
name.value = props.publicKey.name;
386380
publicKeyData.value = Buffer.from(props.publicKey.data, "base64").toString("utf-8");
387-
publicKeyDataError.value = "";
388381
handleUpdate();
389382
};
390383
@@ -430,13 +423,12 @@ const isHostnameMissing = computed(() => choiceFilter.value === "hostname" && ho
430423
const areTagsMissing = computed(() => choiceFilter.value === "tags" && toTagNames(tagChoices.value).length === 0);
431424
432425
const confirmDisabled = computed(() => {
433-
if (!name.value || !publicKeyData.value) return true;
426+
if (!name.value) return true;
434427
435428
const tagRuleBlocking = choiceFilter.value === "tags" && !validateLength.value;
436429
437430
return Boolean(
438431
nameError.value
439-
|| publicKeyDataError.value
440432
|| isUsernameMissing.value
441433
|| isHostnameMissing.value
442434
|| areTagsMissing.value
@@ -462,7 +454,6 @@ const edit = async () => {
462454
...(keyLocal.value as LocalPublicKey),
463455
username: usernameToSend,
464456
filter: filterToSend,
465-
data: Buffer.from(publicKeyData.value, "utf-8").toString("base64"),
466457
};
467458
468459
try {

0 commit comments

Comments
 (0)