From bb6e5a731073be9d9d63c43bf96ca476673d7578 Mon Sep 17 00:00:00 2001 From: Kitteh Date: Sat, 8 May 2021 03:10:21 +0100 Subject: [PATCH] Add typing to KeyValueNew.ts. --- src/allPages.ts | 2 +- .../{KeyValueNew.js => KeyValueNew.ts} | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) rename src/pages/KeyValue/{KeyValueNew.js => KeyValueNew.ts} (85%) diff --git a/src/allPages.ts b/src/allPages.ts index 92c7185..9986a23 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -1,6 +1,6 @@ import { HomePage } from "./pages/Home"; import { KeyValueDeletePage } from "./pages/KeyValue/KeyValueDelete.js"; -import { KeyValueNewPage } from "./pages/KeyValue/KeyValueNew.js"; +import { KeyValueNewPage } from "./pages/KeyValue/KeyValueNew"; import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit"; import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret"; import { KeyValueVersionsPage } from "./pages/KeyValue/KeyValueVersions"; diff --git a/src/pages/KeyValue/KeyValueNew.js b/src/pages/KeyValue/KeyValueNew.ts similarity index 85% rename from src/pages/KeyValue/KeyValueNew.js rename to src/pages/KeyValue/KeyValueNew.ts index dc5ca10..7a084a3 100644 --- a/src/pages/KeyValue/KeyValueNew.js +++ b/src/pages/KeyValue/KeyValueNew.ts @@ -2,17 +2,21 @@ import { Page } from "../../types/Page"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { createOrUpdateSecret } from "../../api/createOrUpdateSecret"; import { makeElement } from "../../htmlUtils"; -import { pageState } from "../../globalPageState.ts"; +import { pageState } from "../../globalPageState"; import i18next from 'i18next'; export class KeyValueNewPage extends Page { constructor() { super(); } - goBack() { + + goBack(): void { changePage("KEY_VALUE_VIEW"); } - render() { + + addKVNewForm: HTMLFormElement; + + render(): void { setTitleElement(pageState); this.addKVNewForm = makeElement({ tag: "form", @@ -46,7 +50,7 @@ export class KeyValueNewPage extends Page { } }) ] - }); + }) as HTMLFormElement; setPageContent(this.addKVNewForm); this.addKVNewForm.addEventListener("submit", function (e) { @@ -55,9 +59,9 @@ export class KeyValueNewPage extends Page { }.bind(this)); } - newKVSecretHandleForm() { - let formData = new FormData(this.addKVNewForm); - let path = formData.get("path"); + newKVSecretHandleForm(): void { + const formData = new FormData(this.addKVNewForm); + const path = formData.get("path") as string; let keyData = {}; if (["kv-v1", "cubbyhole"].includes(pageState.currentMountType)) { @@ -78,11 +82,11 @@ export class KeyValueNewPage extends Page { }); } - get titleSuffix() { + get titleSuffix(): string { return i18next.t("kv_new_suffix"); } - get name() { + get name(): string { return i18next.t("kv_new_title"); } } \ No newline at end of file