diff --git a/package.json b/package.json index 7646662..19586cb 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,12 @@ "@types/js-yaml": "^4.0.5", "@types/prismjs": "^1.16.6", "@types/uikit": "^3.3.2", - "@typescript-eslint/eslint-plugin": "^5.9.1", - "@typescript-eslint/parser": "^5.9.1", + "@typescript-eslint/eslint-plugin": "^5.10.0", + "@typescript-eslint/parser": "^5.10.0", "babel-loader": "^8.2.3", "css-loader": "^6.5.1", - "css-minimizer-webpack-plugin": "^3.3.1", - "eslint": "^8.6.0", + "css-minimizer-webpack-plugin": "^3.4.1", + "eslint": "^8.7.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.4", "eslint-plugin-prettier": "^4.0.0", @@ -38,7 +38,7 @@ "dependencies": { "clipboard": "^2.0.8", "codejar": "^3.5.0", - "core-js": "^3.20.2", + "core-js": "^3.20.3", "date-fns": "^2.28.0", "file-saver": "^2.0.5", "hjson": "^3.2.2", diff --git a/src/scss/uikit/uikit-base.scss b/src/scss/uikit/uikit-base.scss index d7d1ddc..22de97b 100644 --- a/src/scss/uikit/uikit-base.scss +++ b/src/scss/uikit/uikit-base.scss @@ -26,7 +26,6 @@ @import "uikit/src/scss/components/label.scss"; // JavaScript -@import "uikit/src/scss/components/modal.scss"; @import "uikit/src/scss/components/slider.scss"; @import "uikit/src/scss/components/switcher.scss"; @import "uikit/src/scss/components/notification.scss"; diff --git a/src/translations/de.js b/src/translations/de.js index 4015859..a261b54 100644 --- a/src/translations/de.js +++ b/src/translations/de.js @@ -16,9 +16,9 @@ module.exports = { not_implemented: "Noch nicht implementiert", // Copyable Modal - copy_modal_download_btn: "Download", - copy_modal_copy_btn: "Kopieren", - copy_modal_close_btn: "Schließen", + copy_box_download_btn: "Download", + copy_box_copy_btn: "Kopieren", + copy_box_close_btn: "Schließen", // Generic Loading Text content_loading: "Laden..", @@ -206,7 +206,7 @@ module.exports = { transit_encrypt_input_placeholder: "Normaler-Text oder base64", transit_encrypt_already_encoded_checkbox: "Ist der text schon in base64 verschlüsselt?", transit_encrypt_encrypt_btn: "Verschlüsseln", - transit_encrypt_encryption_result_modal_title: "Verachlüsselungs ergebnis", + transit_encrypt_encryption_result_title: "Verachlüsselungs ergebnis", // Transit Decrypt Page transit_decrypt_title: "Transit Decrypt", @@ -214,7 +214,7 @@ module.exports = { transit_decrypt_input_placeholder: "Cyphertext", transit_decrypt_decode_checkbox: "Soll der Text base64 codiert werden?", transit_decrypt_decrypt_btn: "Entschlüsseln", - transit_decrypt_decryption_result_modal_title: "Entschlüsselungs ergebnis", + transit_decrypt_decryption_result_title: "Entschlüsselungs ergebnis", // Transit Rewrap Page transit_rewrap_title: "Transit Rewrap", @@ -223,7 +223,7 @@ module.exports = { transit_rewrap_latest_version_option_text: "{{version_num}} (neuste)", transit_rewrap_input_placeholder: "Cyphertext", transit_rewrap_rewrap_btn: "Rewrap", - transit_rewrap_result_modal_title: "Rewrap Result", + transit_rewrap_result_title: "Rewrap Result", // Delete Secret Engine Page delete_secrets_engine_title: "Delete Secret Engine ({{mount}})", diff --git a/src/translations/en.js b/src/translations/en.js index 89a275b..e4aafbc 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -35,9 +35,9 @@ module.exports = { not_implemented: "Not Yet Implemented", // Copyable Modal - copy_modal_download_btn: "Download", - copy_modal_copy_btn: "Copy", - copy_modal_close_btn: "Close", + copy_box_download_btn: "Download", + copy_box_copy_btn: "Copy", + copy_box_close_btn: "Close", // Generic Loading Text content_loading: "Loading..", @@ -227,14 +227,14 @@ module.exports = { transit_encrypt_suffix: " (encrypt)", transit_encrypt_input_placeholder: "Plaintext or base64", transit_encrypt_already_encoded_checkbox: "Is the data already encoded in base64?", - transit_encrypt_encryption_result_modal_title: "Encryption Result", + transit_encrypt_encryption_result_title: "Encryption Result", // Transit Decrypt Page transit_decrypt_title: "Transit Decrypt", transit_decrypt_suffix: " (decrypt)", transit_decrypt_input_placeholder: "Cyphertext", transit_decrypt_decode_checkbox: "Should the plaintext be base64 decoded?", - transit_decrypt_decryption_result_modal_title: "Decryption Result", + transit_decrypt_decryption_result_title: "Decryption Result", // Transit Rewrap Page transit_rewrap_title: "Transit Rewrap", @@ -242,7 +242,7 @@ module.exports = { transit_rewrap_version_option_text: "{{version_num}}", transit_rewrap_latest_version_option_text: "{{version_num}} (latest)", transit_rewrap_input_placeholder: "Cyphertext", - transit_rewrap_result_modal_title: "Rewrap Result", + transit_rewrap_result_title: "Rewrap Result", // Delete Secret Engine Page delete_secrets_engine_title: "Delete Secret Engine ({{mount}})", diff --git a/src/translations/fr.js b/src/translations/fr.js index 53c318b..ab40520 100644 --- a/src/translations/fr.js +++ b/src/translations/fr.js @@ -14,9 +14,9 @@ module.exports = { notification_copy_success: "Copié dans le presse-papiers.", // Copyable Modal - copy_modal_download_btn: "Télécharger", - copy_modal_copy_btn: "Copier", - copy_modal_close_btn: "Fermer", + copy_box_download_btn: "Télécharger", + copy_box_copy_btn: "Copier", + copy_box_close_btn: "Fermer", // Copyable Input Box copy_input_box_copy_icon_text: "Bouton Copier", @@ -140,7 +140,7 @@ module.exports = { transit_encrypt_input_placeholder: "Texte brut ou base64", transit_encrypt_already_encoded_checkbox: "Les données sont-elles déjà encodées en base64 ?", transit_encrypt_encrypt_btn: "Chiffrer", - transit_encrypt_encryption_result_modal_title: "Résultat chiffré", + transit_encrypt_encryption_result_title: "Résultat chiffré", // Transit decrypt Page transit_decrypt_title: "Déchiffrement Transit", @@ -148,5 +148,5 @@ module.exports = { transit_decrypt_input_placeholder: "Message chiffré", transit_decrypt_decode_checkbox: "Est-ce que le texte brut doit être encodé en base64 ?", transit_decrypt_decrypt_btn: "Déchiffrer", - transit_decrypt_decryption_result_modal_title: "Résultat déchiffré", + transit_decrypt_decryption_result_title: "Résultat déchiffré", }; diff --git a/src/translations/ru.js b/src/translations/ru.js index c960c02..62c09e4 100644 --- a/src/translations/ru.js +++ b/src/translations/ru.js @@ -35,9 +35,9 @@ module.exports = { not_implemented: "Функция ещё не реализована", // Copyable Modal - copy_modal_download_btn: "Загрузить", - copy_modal_copy_btn: "Копировать", - copy_modal_close_btn: "Закрыть", + copy_box_download_btn: "Загрузить", + copy_box_copy_btn: "Копировать", + copy_box_close_btn: "Закрыть", // Generic Loading Text content_loading: "Загрузка..", @@ -222,14 +222,14 @@ module.exports = { transit_encrypt_suffix: " (шифр.)", transit_encrypt_input_placeholder: "Текст или base64", transit_encrypt_already_encoded_checkbox: "Данные уже закодированы в base64?", - transit_encrypt_encryption_result_modal_title: "Результат шифрования", + transit_encrypt_encryption_result_title: "Результат шифрования", // Transit Decrypt Page transit_decrypt_title: "Расшифрование Transit", transit_decrypt_suffix: " (расшифр.)", transit_decrypt_input_placeholder: "Шифр-текст", transit_decrypt_decode_checkbox: "Нужно ли раскодировать текст из base64?", - transit_decrypt_decryption_result_modal_title: "Результат расшифрования", + transit_decrypt_decryption_result_title: "Результат расшифрования", // Transit Rewrap Page transit_rewrap_title: "Перешифрование Transit", @@ -237,7 +237,7 @@ module.exports = { transit_rewrap_version_option_text: "{{version_num}}", transit_rewrap_latest_version_option_text: "{{version_num}} (последняя версия)", transit_rewrap_input_placeholder: "Шифр-текст", - transit_rewrap_result_modal_title: "Результат перешифрования", + transit_rewrap_result_title: "Результат перешифрования", // Delete Secret Engine Page delete_secrets_engine_title: "Удалить обработчик тайн ({{mount}})", diff --git a/src/ui/elements/Button.tsx b/src/ui/elements/Button.tsx index 023f937..d066cda 100644 --- a/src/ui/elements/Button.tsx +++ b/src/ui/elements/Button.tsx @@ -1,4 +1,4 @@ -import { JSX } from "preact"; +import { JSX, RefObject } from "preact"; import { route } from "preact-router"; export type ButtonProps = { @@ -8,6 +8,7 @@ export type ButtonProps = { route?: string; onClick?: () => unknown; type?: "submit" | null; + buttonRef?: RefObject; }; export function Button(props: ButtonProps): JSX.Element { @@ -15,6 +16,8 @@ export function Button(props: ButtonProps): JSX.Element { if (props.route) { return ( ); diff --git a/src/ui/elements/CodeBlock.tsx b/src/ui/elements/CodeBlock.tsx index 0c78bc6..d908b37 100644 --- a/src/ui/elements/CodeBlock.tsx +++ b/src/ui/elements/CodeBlock.tsx @@ -2,22 +2,26 @@ import { JSX } from "preact"; import Prism from "prismjs"; export type CodeBlockProps = { - language: string; code: string; + language?: string; }; export function CodeBlock(props: CodeBlockProps): JSX.Element { - const highlightedCode = Prism.highlight( - props.code, - Prism.languages[props.language], - props.language, - ); + if (props.language) { + const highlightedCode = Prism.highlight( + props.code, + Prism.languages[props.language], + props.language, + ); - return ( -
-  );
+    return (
+      
+    );
+  } else {
+    return 
;
+  }
 }
diff --git a/src/ui/elements/CopyableBox.tsx b/src/ui/elements/CopyableBox.tsx
new file mode 100644
index 0000000..56cf724
--- /dev/null
+++ b/src/ui/elements/CopyableBox.tsx
@@ -0,0 +1,57 @@
+import { Button } from "./Button";
+import { CodeBlock } from "./CodeBlock";
+import { Component, JSX, createRef } from "preact";
+import { addClipboardNotifications } from "../../pageUtils";
+import ClipboardJS from "clipboard";
+import FileSaver from "file-saver";
+import i18next from "i18next";
+
+export type CopyableBoxProps = {
+  title: string;
+  contentString: string;
+  goBack?: () => void;
+};
+
+export class CopyableBox extends Component {
+  copyButtonRef = createRef();
+
+  saveAsFile(): void {
+    const blob = new Blob([this.props.contentString], {
+      type: "text/plain;charset=utf-8",
+    });
+    FileSaver.saveAs(blob, "result.txt");
+  }
+
+  componentDidMount(): void {
+    console.log(this.copyButtonRef.current);
+    const clipboard = new ClipboardJS(this.copyButtonRef.current);
+    addClipboardNotifications(clipboard, 600);
+  }
+
+  render(): JSX.Element {
+    return (
+      
+
+

{this.props.title}

+
+ +

+

+ ); + } +} diff --git a/src/ui/elements/CopyableModal.tsx b/src/ui/elements/CopyableModal.tsx deleted file mode 100644 index 0a9a90f..0000000 --- a/src/ui/elements/CopyableModal.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { Component, JSX, createRef } from "preact"; -import { addClipboardNotifications } from "../../pageUtils"; -import ClipboardJS from "clipboard"; -import FileSaver from "file-saver"; -import i18next from "i18next"; - -export type CopyableModalProps = { - id: string; - name: string; - contentString: string; -}; - -export class CopyableModal extends Component { - ref = createRef(); - copyButtonRef = createRef(); - - saveAsFile(): void { - const blob = new Blob([this.props.contentString], { - type: "text/plain;charset=utf-8", - }); - FileSaver.saveAs(blob, "result.txt"); - } - - componentDidMount(): void { - const clipboard = new ClipboardJS(this.copyButtonRef.current); - addClipboardNotifications(clipboard, 600); - } - - render(): JSX.Element { - return ( - - - ); - } -} diff --git a/src/ui/pages/Secrets/Transit/TransitDecrypt.tsx b/src/ui/pages/Secrets/Transit/TransitDecrypt.tsx index 1dbef0f..38548c7 100644 --- a/src/ui/pages/Secrets/Transit/TransitDecrypt.tsx +++ b/src/ui/pages/Secrets/Transit/TransitDecrypt.tsx @@ -1,6 +1,6 @@ import { Button } from "../../../elements/Button"; -import { Component, render } from "preact"; -import { CopyableModal } from "../../../elements/CopyableModal"; +import { Component } from "preact"; +import { CopyableBox } from "../../../elements/CopyableBox"; import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { FileUploadInput } from "../../../elements/FileUploadInput"; import { Form } from "../../../elements/Form"; @@ -9,41 +9,59 @@ import { Margin } from "../../../elements/Margin"; import { SecretTitleElement } from "../SecretTitleElement"; import { fileToBase64 } from "../../../../htmlUtils"; import { setErrorText } from "../../../../pageUtils"; -import UIkit from "uikit"; import i18next from "i18next"; -export class TransitDecrypt extends Component { +export class TransitDecrypt extends Component { render() { const baseMount = this.props.matches["baseMount"]; const secretItem = this.props.matches["secretItem"]; - return ( - <> - -
await this.onSubmit(data)}> - -