1
0
Fork 0

Add typing to KeyValueView.ts.

This commit is contained in:
Kitteh 2021-05-08 03:00:28 +01:00
parent c50252a77d
commit aba3321e90
2 changed files with 13 additions and 10 deletions

View file

@ -4,7 +4,7 @@ import { KeyValueNewPage } from "./pages/KeyValue/KeyValueNew.js";
import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit.js"; import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit.js";
import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret.js"; import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret.js";
import { KeyValueVersionsPage } from "./pages/KeyValue/KeyValueVersions"; import { KeyValueVersionsPage } from "./pages/KeyValue/KeyValueVersions";
import { KeyValueViewPage } from "./pages/KeyValue/KeyValueView.js"; import { KeyValueViewPage } from "./pages/KeyValue/KeyValueView";
import { LoginPage } from "./pages/Login"; import { LoginPage } from "./pages/Login";
import { MePage } from "./pages/Me"; import { MePage } from "./pages/Me";
import { NewTOTPPage } from "./pages/TOTP/NewTOTP"; import { NewTOTPPage } from "./pages/TOTP/NewTOTP";

View file

@ -1,9 +1,9 @@
import { DoesNotExistError } from "../../types/internalErrors"; import { DoesNotExistError } from "../../types/internalErrors";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { getSecrets } from "../../api/getSecrets"; import { getSecrets } from "../../api/getSecrets";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";
import { pageState } from "../../globalPageState.ts"; import { pageState } from "../../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';
@ -11,7 +11,7 @@ export class KeyValueViewPage extends Page {
constructor() { constructor() {
super(); super();
} }
goBack() { goBack(): void {
if (pageState.currentSecretPath.length != 0) { if (pageState.currentSecretPath.length != 0) {
pageState.popCurrentSecretPath(); pageState.popCurrentSecretPath();
changePage("KEY_VALUE_VIEW"); changePage("KEY_VALUE_VIEW");
@ -19,13 +19,16 @@ export class KeyValueViewPage extends Page {
changePage("HOME"); changePage("HOME");
} }
} }
async render() { async render(): Promise<void> {
pageState.currentSecret = ""; pageState.currentSecret = "";
setTitleElement(pageState); setTitleElement(pageState);
let kvViewPageContent = makeElement({ tag: "div" });
setPageContent(kvViewPageContent);
if (pageState.currentMountType == "cubbyhole") { if (pageState.currentMountType == "cubbyhole") {
pageContent.appendChild(makeElement({ kvViewPageContent.appendChild(makeElement({
tag: "p", tag: "p",
text: i18next.t("kv_view_cubbyhole_text"), text: i18next.t("kv_view_cubbyhole_text"),
})); }));
@ -39,7 +42,7 @@ export class KeyValueViewPage extends Page {
changePage("KEY_VALUE_NEW_SECRET"); changePage("KEY_VALUE_NEW_SECRET");
} }
}); });
pageContent.appendChild(newButton); kvViewPageContent.appendChild(newButton);
try { try {
let res = await getSecrets( let res = await getSecrets(
@ -48,7 +51,7 @@ export class KeyValueViewPage extends Page {
pageState.currentSecretPath, pageState.currentSecretPath,
); );
pageContent.appendChild(makeElement({ kvViewPageContent.appendChild(makeElement({
tag: "ul", tag: "ul",
class: ["uk-nav", "uk-nav-default"], class: ["uk-nav", "uk-nav-default"],
children: [ children: [
@ -78,7 +81,7 @@ export class KeyValueViewPage extends Page {
if (pageState.currentSecretPath.length != 0) { if (pageState.currentSecretPath.length != 0) {
return this.goBack(); return this.goBack();
} else { } else {
pageContent.appendChild(makeElement({ kvViewPageContent.appendChild(makeElement({
tag: "p", tag: "p",
text: i18next.t("kv_view_none_here_text") text: i18next.t("kv_view_none_here_text")
})); }));
@ -89,7 +92,7 @@ export class KeyValueViewPage extends Page {
} }
} }
get name() { get name(): string {
return i18next.t("kv_view_title"); return i18next.t("kv_view_title");
} }
} }