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