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 { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret.js";
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 { MePage } from "./pages/Me";
import { NewTOTPPage } from "./pages/TOTP/NewTOTP";

View file

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