diff --git a/apps/client/src/translations/cn/translation.json b/apps/client/src/translations/cn/translation.json index 5eb6608a5..8b98473a6 100644 --- a/apps/client/src/translations/cn/translation.json +++ b/apps/client/src/translations/cn/translation.json @@ -253,7 +253,7 @@ "help_title": "关于保护笔记的帮助", "close_label": "关闭", "form_label": "输入密码进入保护会话以继续:", - "start_button": "开始保护会话 回车" + "start_button": "开始保护会话" }, "recent_changes": { "title": "最近修改", diff --git a/apps/client/src/translations/de/translation.json b/apps/client/src/translations/de/translation.json index 81277edb3..fa7a8f3b8 100644 --- a/apps/client/src/translations/de/translation.json +++ b/apps/client/src/translations/de/translation.json @@ -253,7 +253,7 @@ "help_title": "Hilfe zu geschützten Notizen", "close_label": "Schließen", "form_label": "Um mit der angeforderten Aktion fortzufahren, musst du eine geschützte Sitzung starten, indem du ein Passwort eingibst:", - "start_button": "Geschützte Sitzung starten enter" + "start_button": "Geschützte Sitzung starten" }, "recent_changes": { "title": "Aktuelle Änderungen", diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index e76012cf3..efa0b5d3c 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -257,7 +257,7 @@ "help_title": "Help on Protected notes", "close_label": "Close", "form_label": "To proceed with requested action you need to start protected session by entering password:", - "start_button": "Start protected session enter" + "start_button": "Start protected session" }, "recent_changes": { "title": "Recent changes", diff --git a/apps/client/src/translations/es/translation.json b/apps/client/src/translations/es/translation.json index fd0326ce4..bb5a0f958 100644 --- a/apps/client/src/translations/es/translation.json +++ b/apps/client/src/translations/es/translation.json @@ -256,7 +256,7 @@ "help_title": "Ayuda sobre notas protegidas", "close_label": "Cerrar", "form_label": "Para continuar con la acción solicitada, debe iniciar en la sesión protegida ingresando la contraseña:", - "start_button": "Iniciar sesión protegida entrar" + "start_button": "Iniciar sesión protegida" }, "recent_changes": { "title": "Cambios recientes", diff --git a/apps/client/src/translations/fr/translation.json b/apps/client/src/translations/fr/translation.json index fe6869abc..3a9e4348c 100644 --- a/apps/client/src/translations/fr/translation.json +++ b/apps/client/src/translations/fr/translation.json @@ -253,7 +253,7 @@ "help_title": "Aide sur les notes protégées", "close_label": "Fermer", "form_label": "Pour procéder à l'action demandée, vous devez démarrer une session protégée en saisissant le mot de passe :", - "start_button": "Démarrer une session protégée entrer" + "start_button": "Démarrer une session protégée" }, "recent_changes": { "title": "Modifications récentes", diff --git a/apps/client/src/translations/ro/translation.json b/apps/client/src/translations/ro/translation.json index 7c1c326a2..4e47861b4 100644 --- a/apps/client/src/translations/ro/translation.json +++ b/apps/client/src/translations/ro/translation.json @@ -992,7 +992,7 @@ "form_label": "Pentru a putea continua cu acțiunea cerută este nevoie să fie pornită sesiunea protejată prin introducerea parolei:", "help_title": "Informații despre notițe protejate", "modal_title": "Sesiune protejată", - "start_button": "Pornește sesiunea protejată enter" + "start_button": "Pornește sesiunea protejată" }, "protected_session_status": { "active": "Sesiunea protejată este activă. Clic pentru a închide sesiunea protejată.", diff --git a/apps/client/src/translations/sr/translation.json b/apps/client/src/translations/sr/translation.json index 816c2f89d..b37bbd140 100644 --- a/apps/client/src/translations/sr/translation.json +++ b/apps/client/src/translations/sr/translation.json @@ -257,7 +257,7 @@ "help_title": "Pomoć za Zaštićene beleške", "close_label": "Zatvori", "form_label": "Da biste nastavili sa traženom akcijom moraćete započeti zaštićenu sesiju tako što ćete uneti lozinku:", - "start_button": "Započni zaštićenu sesiju enter" + "start_button": "Započni zaštićenu sesiju" }, "recent_changes": { "title": "Nedavne promene", diff --git a/apps/client/src/translations/tw/translation.json b/apps/client/src/translations/tw/translation.json index 59eec1d0b..21d2e5c3c 100644 --- a/apps/client/src/translations/tw/translation.json +++ b/apps/client/src/translations/tw/translation.json @@ -231,7 +231,7 @@ "help_title": "關於保護筆記的幫助", "close_label": "關閉", "form_label": "輸入密碼進入保護會話以繼續:", - "start_button": "開始保護會話 Enter" + "start_button": "開始保護會話" }, "recent_changes": { "title": "最近修改", diff --git a/apps/client/src/widgets/dialogs/protected_session_password.ts b/apps/client/src/widgets/dialogs/protected_session_password.ts deleted file mode 100644 index 75f15684f..000000000 --- a/apps/client/src/widgets/dialogs/protected_session_password.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { openDialog } from "../../services/dialog.js"; -import { t } from "../../services/i18n.js"; -import protectedSessionService from "../../services/protected_session.js"; -import BasicWidget from "../basic_widget.js"; -import { Modal } from "bootstrap"; - -const TPL = /*html*/` -`; - -export default class ProtectedSessionPasswordDialog extends BasicWidget { - - private modal!: bootstrap.Modal; - private $passwordForm!: JQuery; - private $passwordInput!: JQuery; - - doRender() { - this.$widget = $(TPL); - this.modal = Modal.getOrCreateInstance(this.$widget[0]); - - this.$passwordForm = this.$widget.find(".protected-session-password-form"); - this.$passwordInput = this.$widget.find(".protected-session-password"); - this.$passwordForm.on("submit", () => { - const password = String(this.$passwordInput.val()); - this.$passwordInput.val(""); - - protectedSessionService.setupProtectedSession(password); - - return false; - }); - } - - showProtectedSessionPasswordDialogEvent() { - openDialog(this.$widget); - - this.$passwordInput.trigger("focus"); - } - - closeProtectedSessionPasswordDialogEvent() { - this.modal.hide(); - } -} diff --git a/apps/client/src/widgets/dialogs/protected_session_password.tsx b/apps/client/src/widgets/dialogs/protected_session_password.tsx new file mode 100644 index 000000000..37023c8d5 --- /dev/null +++ b/apps/client/src/widgets/dialogs/protected_session_password.tsx @@ -0,0 +1,50 @@ +import { useRef, useState } from "preact/hooks"; +import { closeActiveDialog, openDialog } from "../../services/dialog"; +import { t } from "../../services/i18n"; +import Button from "../react/Button"; +import FormTextBox from "../react/FormTextBox"; +import Modal from "../react/Modal"; +import ReactBasicWidget from "../react/ReactBasicWidget"; +import protected_session from "../../services/protected_session"; + +function ProtectedSessionPasswordDialogComponent() { + const [ password, setPassword ] = useState(""); + const inputRef = useRef(null); + + return ( + } + onSubmit={() => protected_session.setupProtectedSession(password)} + onShown={() => inputRef.current?.focus()} + > + + + + ) +} + +export default class ProtectedSessionPasswordDialog extends ReactBasicWidget { + + get component() { + return ; + } + + showProtectedSessionPasswordDialogEvent() { + openDialog(this.$widget); + } + + closeProtectedSessionPasswordDialogEvent() { + closeActiveDialog(); + } + +} \ No newline at end of file diff --git a/apps/client/src/widgets/react/FormTextBox.tsx b/apps/client/src/widgets/react/FormTextBox.tsx index 0a5610eb4..0a91cb935 100644 --- a/apps/client/src/widgets/react/FormTextBox.tsx +++ b/apps/client/src/widgets/react/FormTextBox.tsx @@ -1,17 +1,24 @@ +import { HTMLInputTypeAttribute } from "preact/compat"; + interface FormTextBoxProps { + id?: string; name: string; + type?: HTMLInputTypeAttribute; currentValue?: string; className?: string; + autoComplete?: string; onChange?(newValue: string): void; } -export default function FormTextBox({ name, className, currentValue, onChange }: FormTextBoxProps) { +export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete }: FormTextBoxProps) { return ( onChange?.(e.currentTarget.value)} /> ); } \ No newline at end of file diff --git a/apps/client/src/widgets/react/Modal.tsx b/apps/client/src/widgets/react/Modal.tsx index 0ae9541f9..677b8ef0b 100644 --- a/apps/client/src/widgets/react/Modal.tsx +++ b/apps/client/src/widgets/react/Modal.tsx @@ -6,7 +6,7 @@ import type { CSSProperties } from "preact/compat"; interface ModalProps { className: string; title: string | ComponentChildren; - size: "lg" | "sm"; + size: "lg" | "md" | "sm"; children: ComponentChildren; footer?: ComponentChildren; maxWidth?: number;