fix(connection): copy raw password from the edit dialog field
This commit is contained in:
5 files changed
+139
-4
No files matched your search
@@ -103,7 +103,7 @@ import { consulAgentAddressesMatch } from "@/lib/consul/agentTarget";
|
||||
import { appendConnectionErrorHints, isJdbcMissingRuntimeDependencyError } from "@/lib/connection/connectionErrorHints";
|
||||
import { buildCassandraExternalConfig, cassandraTlsConfigFromExternalConfig, type CassandraTlsConfig } from "@/lib/connection/cassandraTlsOptions";
|
||||
import { savedMysqlTlsFormFields, supportsMysqlTlsOptions as mysqlTlsOptionsSupported, supportsMysqlTlsTab } from "@/lib/connection/mysqlTlsCapabilities";
|
||||
import { preventDialogDocumentSelectAll } from "@/lib/connection/dialogTextSelection";
|
||||
import { copyDialogPasswordFieldValue, preventDialogDocumentSelectAll } from "@/lib/connection/dialogTextSelection";
|
||||
import { postgresLegacyTlsEnabled, postgresTlsModeForForm, setPostgresLegacyTlsEnabled } from "@/lib/connection/postgresTlsMode";
|
||||
import { buildMqKafkaConnectionExtra, mqKafkaConnectionTarget, resolveMqKafkaConnectionSource, type MqKafkaConnectionSource } from "@/lib/connection/mqKafkaConnection";
|
||||
import { assertCompleteDatabaseCategories, databaseSelectionForCategory } from "@/lib/connection/databaseCategoryOptions";
|
||||
@@ -6832,7 +6832,16 @@ function openExternalUrl(url: string) {
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent :style="dialogContentStyle" class="connection-dialog-content" :class="connectionDialogContentClass" :data-wide="shouldUseWideConnectionDialog ? 'true' : undefined" @interact-outside.prevent @escape-key-down="handleDialogEscape" @keydown="preventDialogDocumentSelectAll">
|
||||
<DialogContent
|
||||
:style="dialogContentStyle"
|
||||
class="connection-dialog-content"
|
||||
:class="connectionDialogContentClass"
|
||||
:data-wide="shouldUseWideConnectionDialog ? 'true' : undefined"
|
||||
@interact-outside.prevent
|
||||
@escape-key-down="handleDialogEscape"
|
||||
@keydown="preventDialogDocumentSelectAll"
|
||||
@copy="copyDialogPasswordFieldValue"
|
||||
>
|
||||
<DialogHeader class="cursor-move select-none" @pointerdown="onDialogHeaderPointerDown" @pointermove="onDialogHeaderPointerMove" @pointerup="onDialogHeaderPointerEnd" @pointercancel="onDialogHeaderPointerEnd">
|
||||
<DialogTitle>{{ editingId ? t("connection.editTitle") : t("connection.title") }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
@@ -31,7 +31,7 @@ const toggleLabel = computed(() => (visible.value ? props.hideLabel || t("common
|
||||
|
||||
<template>
|
||||
<div :class="props.class" class="relative">
|
||||
<Input v-model="model" :type="visible ? 'text' : 'password'" :placeholder="placeholder" :disabled="disabled" :class="[props.inputClass, props.showToggle ? 'pr-8' : undefined]" v-bind="$attrs" />
|
||||
<Input v-model="model" data-password-input :type="visible ? 'text' : 'password'" :placeholder="placeholder" :disabled="disabled" :class="[props.inputClass, props.showToggle ? 'pr-8' : undefined]" v-bind="$attrs" />
|
||||
<button
|
||||
v-if="props.showToggle"
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { createApp, nextTick } from "vue";
|
||||
import { createI18n } from "vue-i18n";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import PasswordInput from "@/components/ui/PasswordInput.vue";
|
||||
|
||||
const mountedContainers: HTMLDivElement[] = [];
|
||||
|
||||
async function mountPasswordInput(value: string) {
|
||||
const container = document.createElement("div");
|
||||
mountedContainers.push(container);
|
||||
document.body.append(container);
|
||||
|
||||
const app = createApp(PasswordInput, { modelValue: value });
|
||||
app.use(createI18n({ legacy: false, locale: "en", messages: { en: { common: { showPassword: "Show password", hidePassword: "Hide password" } } } }));
|
||||
app.mount(container);
|
||||
await nextTick();
|
||||
return container;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
while (mountedContainers.length > 0) mountedContainers.pop()?.remove();
|
||||
});
|
||||
|
||||
describe("PasswordInput", () => {
|
||||
it("marks the field so dialogs can copy the raw value when revealed", async () => {
|
||||
const container = await mountPasswordInput("p^ss%40@x#y");
|
||||
const input = container.querySelector<HTMLInputElement>("input[data-password-input]");
|
||||
|
||||
expect(input).not.toBeNull();
|
||||
expect(input?.value).toBe("p^ss%40@x#y");
|
||||
expect(input?.getAttribute("type")).toBe("password");
|
||||
|
||||
container.querySelector<HTMLButtonElement>("button")?.click();
|
||||
await nextTick();
|
||||
expect(container.querySelector<HTMLInputElement>("input[data-password-input]")?.getAttribute("type")).toBe("text");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user