Add typing to KeyValueSecret.ts.
This commit is contained in:
parent
cf6af8efe7
commit
e180c44e50
|
@ -2,7 +2,7 @@ import { HomePage } from "./pages/Home";
|
|||
import { KeyValueDeletePage } from "./pages/KeyValue/KeyValueDelete.js";
|
||||
import { KeyValueNewPage } from "./pages/KeyValue/KeyValueNew.js";
|
||||
import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit";
|
||||
import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret.js";
|
||||
import { KeyValueSecretPage } from "./pages/KeyValue/KeyValueSecret";
|
||||
import { KeyValueVersionsPage } from "./pages/KeyValue/KeyValueVersions";
|
||||
import { KeyValueViewPage } from "./pages/KeyValue/KeyValueView";
|
||||
import { LoginPage } from "./pages/Login";
|
||||
|
|
|
@ -4,7 +4,7 @@ import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
|
|||
import { getCapabilities } from "../../api/getCapabilities";
|
||||
import { getSecret } from "../../api/getSecret";
|
||||
import { makeElement } from "../../htmlUtils";
|
||||
import { pageState } from "../../globalPageState.ts";
|
||||
import { pageState } from "../../globalPageState";
|
||||
import { sortedObjectMap } from "../../utils";
|
||||
import { undeleteSecret } from "../../api/undeleteSecret";
|
||||
import Prism from "prismjs";
|
||||
|
@ -15,7 +15,7 @@ export class KeyValueSecretPage extends Page {
|
|||
constructor() {
|
||||
super();
|
||||
}
|
||||
goBack() {
|
||||
goBack(): void {
|
||||
if (pageState.currentSecretVersion != null) {
|
||||
pageState.currentSecretVersion = null;
|
||||
changePage("KEY_VALUE_VERSIONS");
|
||||
|
@ -25,7 +25,7 @@ export class KeyValueSecretPage extends Page {
|
|||
}
|
||||
|
||||
}
|
||||
async render() {
|
||||
async render(): Promise<void> {
|
||||
setTitleElement(pageState);
|
||||
setPageContent(makeElement({
|
||||
tag: "div",
|
||||
|
@ -46,10 +46,10 @@ export class KeyValueSecretPage extends Page {
|
|||
]
|
||||
}));
|
||||
|
||||
let buttonsBlock = document.querySelector("#buttonsBlock");
|
||||
let kvList = document.querySelector("#kvList");
|
||||
const buttonsBlock = document.querySelector("#buttonsBlock");
|
||||
const kvList = document.querySelector("#kvList");
|
||||
let isSecretNestedJson = false;
|
||||
let caps = await getCapabilities(pageState.currentBaseMount, pageState.currentSecretPath, pageState.currentSecret);
|
||||
const caps = await getCapabilities(pageState.currentBaseMount, pageState.currentSecretPath, pageState.currentSecret);
|
||||
if (caps.includes("delete")) {
|
||||
let deleteButtonText = i18next.t("kv_secret_delete_btn");
|
||||
if (pageState.currentMountType == "kv-v2" && pageState.currentSecretVersion == null) {
|
||||
|
@ -119,7 +119,7 @@ export class KeyValueSecretPage extends Page {
|
|||
pageState.currentSecret,
|
||||
pageState.currentSecretVersion
|
||||
).then(_ => {
|
||||
changePage(pageState.currentPage);
|
||||
changePage(pageState.currentPageString);
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
@ -128,12 +128,12 @@ export class KeyValueSecretPage extends Page {
|
|||
|
||||
const secretsMap = sortedObjectMap(secretInfo);
|
||||
|
||||
for (let value of secretsMap.values()) {
|
||||
for (const value of secretsMap.values()) {
|
||||
if (typeof value == 'object') isSecretNestedJson = true;
|
||||
}
|
||||
|
||||
if (isSecretNestedJson) {
|
||||
let jsonText = JSON.stringify(Object.fromEntries(secretsMap), null, 4);
|
||||
const jsonText = JSON.stringify(sortedObjectMap(secretsMap as Record<any, any>), null, 4);
|
||||
kvList.appendChild(makeElement({
|
||||
tag: "pre",
|
||||
class: ["code-block", "language-json", "line-numbers"],
|
||||
|
@ -141,14 +141,14 @@ export class KeyValueSecretPage extends Page {
|
|||
}));
|
||||
} else {
|
||||
secretsMap.forEach((value, key) => {
|
||||
let kvListElement = this.makeKVListElement(key, value);
|
||||
const kvListElement = this.makeKVListElement(key, value);
|
||||
kvList.appendChild(kvListElement);
|
||||
}, this);
|
||||
}
|
||||
document.getElementById("loadingText").remove();
|
||||
});
|
||||
}
|
||||
makeKVListElement(key, value) {
|
||||
makeKVListElement(key: string, value: string): HTMLElement {
|
||||
return makeElement({
|
||||
tag: "div",
|
||||
class: ["uk-grid", "uk-grid-small", "uk-text-left"],
|
||||
|
@ -156,7 +156,7 @@ export class KeyValueSecretPage extends Page {
|
|||
});
|
||||
}
|
||||
|
||||
get name() {
|
||||
get name(): string {
|
||||
return i18next.t("kv_secret_title");
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ export function removeDoubleSlash(str: string): string {
|
|||
export const getObjectKeys =
|
||||
(obj: Record<string, unknown>): string[] => Object.getOwnPropertyNames(obj);
|
||||
export const objectToMap =
|
||||
(obj: Record<string, unknown>): Map<any, any> => new Map(Object.entries(obj));
|
||||
(obj: Record<any, any>): Map<any, any> => new Map(Object.entries(obj));
|
||||
export const sortedObjectMap =
|
||||
(obj: Record<string, unknown>): Map<any, any> => new Map(Object.entries(obj).sort());
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"noImplicitAny": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"module": "es6",
|
||||
"target": "es5",
|
||||
"target": "es2015",
|
||||
"jsx": "react",
|
||||
"allowJs": true,
|
||||
"moduleResolution": "node",
|
||||
|
|
Loading…
Reference in a new issue