1
0
Fork 0

Add typing to KeyValueNew.ts.

This commit is contained in:
Kitteh 2021-05-08 03:10:21 +01:00
parent e180c44e50
commit bb6e5a7310
2 changed files with 14 additions and 10 deletions

View file

@ -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";

View file

@ -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");
}
}