Add typing to KeyValueSecretsEdit.ts.
This commit is contained in:
parent
aba3321e90
commit
cf6af8efe7
|
@ -1,7 +1,7 @@
|
||||||
import { HomePage } from "./pages/Home";
|
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.js";
|
import { KeyValueSecretEditPage } from "./pages/KeyValue/KeyValueSecretsEdit";
|
||||||
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";
|
import { KeyValueViewPage } from "./pages/KeyValue/KeyValueView";
|
||||||
|
|
|
@ -4,28 +4,28 @@ import { changePage, setErrorText, setPageContent, setTitleElement } from "../..
|
||||||
import { createOrUpdateSecret } from "../../api/createOrUpdateSecret";
|
import { createOrUpdateSecret } from "../../api/createOrUpdateSecret";
|
||||||
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 { verifyJSONString } from "../../utils";
|
import { sortedObjectMap, verifyJSONString } from "../../utils";
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
|
|
||||||
export class KeyValueSecretEditPage extends Page {
|
export class KeyValueSecretEditPage extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
goBack() {
|
goBack(): void {
|
||||||
changePage("KEY_VALUE_SECRET");
|
changePage("KEY_VALUE_SECRET");
|
||||||
}
|
}
|
||||||
render() {
|
render(): void {
|
||||||
setTitleElement(pageState);
|
setTitleElement(pageState);
|
||||||
let loadingText = makeElement({
|
const loadingText = makeElement({
|
||||||
tag: "p",
|
tag: "p",
|
||||||
text: i18next.t("kv_sec_edit_loading")
|
text: i18next.t("kv_sec_edit_loading")
|
||||||
});
|
});
|
||||||
let editor = makeElement({
|
const editor = makeElement({
|
||||||
tag: "div",
|
tag: "div",
|
||||||
class: ["editor", "language-json"]
|
class: ["editor", "language-json"]
|
||||||
});
|
});
|
||||||
let saveButton = makeElement({
|
const saveButton = makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: ["uk-button", "uk-button-primary"],
|
class: ["uk-button", "uk-button-primary"],
|
||||||
text: i18next.t("kv_sec_edit_btn")
|
text: i18next.t("kv_sec_edit_btn")
|
||||||
|
@ -51,17 +51,19 @@ export class KeyValueSecretEditPage extends Page {
|
||||||
).then(secretInfo => {
|
).then(secretInfo => {
|
||||||
loadingText.remove();
|
loadingText.remove();
|
||||||
|
|
||||||
const secretsJSON = JSON.stringify(Object.fromEntries(new Map(Object.entries(secretInfo).sort())), null, 4);
|
const secretsJSON = JSON.stringify(sortedObjectMap(secretInfo), null, 4);
|
||||||
|
|
||||||
let jar = CodeJar(editor, () => { }, { tab: ' '.repeat(4) });
|
const jar = CodeJar(editor, () => { }, { tab: ' '.repeat(4) });
|
||||||
jar.updateCode(secretsJSON);
|
jar.updateCode(secretsJSON);
|
||||||
saveButton.onclick = function () {
|
saveButton.onclick = function () {
|
||||||
if (!verifyJSONString(jar.toString())) {
|
if (!verifyJSONString(jar.toString())) {
|
||||||
setErrorText(i18next.t("kv_sec_edit_invalid_json_err"));
|
setErrorText(i18next.t("kv_sec_edit_invalid_json_err"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
createOrUpdateSecret(
|
createOrUpdateSecret(
|
||||||
pageState.currentBaseMount,
|
pageState.currentBaseMount,
|
||||||
|
pageState.currentMountType,
|
||||||
pageState.currentSecretPath,
|
pageState.currentSecretPath,
|
||||||
pageState.currentSecret,
|
pageState.currentSecret,
|
||||||
JSON.parse(jar.toString())
|
JSON.parse(jar.toString())
|
||||||
|
@ -75,11 +77,11 @@ export class KeyValueSecretEditPage extends Page {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get titleSuffix() {
|
get titleSuffix(): string {
|
||||||
return i18next.t("kv_sec_edit_suffix");
|
return i18next.t("kv_sec_edit_suffix");
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name(): string {
|
||||||
return i18next.t("kv_sec_edit_title");
|
return i18next.t("kv_sec_edit_title");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue