From d00826fa67aa0cc9302cecc50a0016265ced007f Mon Sep 17 00:00:00 2001 From: Kitteh Date: Sat, 8 May 2021 03:13:50 +0100 Subject: [PATCH] Add typing to TransitView.ts. --- src/allPages.ts | 2 +- .../{TransitView.js => TransitView.ts} | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) rename src/pages/Transit/{TransitView.js => TransitView.ts} (70%) diff --git a/src/allPages.ts b/src/allPages.ts index 736fe0e..821a4ea 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -15,7 +15,7 @@ import { SetVaultURLPage } from "./pages/SetVaultURL"; import { TOTPViewPage } from "./pages/TOTP/TOTPView"; import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js"; import { TransitEncryptPage } from "./pages/Transit/TransitEncrypt.js"; -import { TransitViewPage } from "./pages/Transit/TransitView.js"; +import { TransitViewPage } from "./pages/Transit/TransitView"; import { TransitViewSecretPage } from "./pages/Transit/TransitViewSecret.js"; import { UnsealPage } from "./pages/Unseal"; diff --git a/src/pages/Transit/TransitView.js b/src/pages/Transit/TransitView.ts similarity index 70% rename from src/pages/Transit/TransitView.js rename to src/pages/Transit/TransitView.ts index a3214d9..72deefb 100644 --- a/src/pages/Transit/TransitView.js +++ b/src/pages/Transit/TransitView.ts @@ -1,24 +1,29 @@ import { DoesNotExistError } from "../../types/internalErrors"; import { Page } from "../../types/Page"; -import { changePage, setErrorText, setTitleElement } from "../../pageUtils"; +import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { getTransitKeys } from "../../api/getTransitKeys"; import { makeElement } from "../../htmlUtils"; -import { pageState } from "../../globalPageState.ts"; +import { pageState } from "../../globalPageState"; import i18next from 'i18next'; export class TransitViewPage extends Page { constructor() { super(); } - goBack() { + + goBack(): void { changePage("HOME"); } - async render() { + + async render(): Promise { pageState.currentSecret = ""; setTitleElement(pageState); - let newButton = makeElement({ + const transitViewContent = makeElement({ tag: "div" }); + setPageContent(transitViewContent); + + const newButton = makeElement({ tag: "button", text: "New", class: ["uk-button", "uk-button-primary", "uk-margin-bottom"], @@ -26,12 +31,12 @@ export class TransitViewPage extends Page { changePage("TRANSIT_NEW_KEY"); } }); - pageContent.appendChild(newButton); + transitViewContent.appendChild(newButton); try { - let res = await getTransitKeys(pageState.currentBaseMount); + const res = await getTransitKeys(pageState.currentBaseMount); - pageContent.appendChild(makeElement({ + transitViewContent.appendChild(makeElement({ tag: "ul", class: ["uk-nav", "uk-nav-default"], children: [ @@ -52,7 +57,7 @@ export class TransitViewPage extends Page { })); } catch (e) { if (e == DoesNotExistError) { - pageContent.appendChild(makeElement({ + transitViewContent.appendChild(makeElement({ tag: "p", text: i18next.t("transit_view_none_here_text") })); @@ -62,7 +67,7 @@ export class TransitViewPage extends Page { } } - get name() { + get name(): string { return i18next.t("transit_view_title"); } }