Add the ability to create new Transit engines.
This commit is contained in:
parent
ceaa2e8783
commit
66a67ca7cf
|
@ -11,6 +11,7 @@ import { NewKVEnginePage } from "./pages/NewEngines/NewKVEngine";
|
||||||
import { NewSecretsEnginePage } from "./pages/NewSecretsEngine";
|
import { NewSecretsEnginePage } from "./pages/NewSecretsEngine";
|
||||||
import { NewTOTPEnginePage } from "./pages/NewEngines/NewTOTPEngine";
|
import { NewTOTPEnginePage } from "./pages/NewEngines/NewTOTPEngine";
|
||||||
import { NewTOTPPage } from "./pages/TOTP/NewTOTP";
|
import { NewTOTPPage } from "./pages/TOTP/NewTOTP";
|
||||||
|
import { NewTransitEnginePage } from "./pages/NewEngines/NewTransitEngine";
|
||||||
import { Page } from "./types/Page";
|
import { Page } from "./types/Page";
|
||||||
import { PwGenPage } from "./pages/PwGen";
|
import { PwGenPage } from "./pages/PwGen";
|
||||||
import { SetLanguagePage } from "./pages/SetLanguage";
|
import { SetLanguagePage } from "./pages/SetLanguage";
|
||||||
|
@ -51,4 +52,5 @@ export const allPages: pagesList = {
|
||||||
NEW_SECRETS_ENGINE: new NewSecretsEnginePage(),
|
NEW_SECRETS_ENGINE: new NewSecretsEnginePage(),
|
||||||
NEW_KV_ENGINE: new NewKVEnginePage(),
|
NEW_KV_ENGINE: new NewKVEnginePage(),
|
||||||
NEW_TOTP_ENGINE: new NewTOTPEnginePage(),
|
NEW_TOTP_ENGINE: new NewTOTPEnginePage(),
|
||||||
|
NEW_TRANSIT_ENGINE: new NewTransitEnginePage(),
|
||||||
};
|
};
|
||||||
|
|
70
src/pages/NewEngines/NewTransitEngine.ts
Normal file
70
src/pages/NewEngines/NewTransitEngine.ts
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
import { Margin } from "../../elements/Margin";
|
||||||
|
import { Page } from "../../types/Page";
|
||||||
|
import { changePage, setErrorText, setPageContent } from "../../pageUtils";
|
||||||
|
import { makeElement } from "../../htmlUtils";
|
||||||
|
import { newMount } from "../../api/sys/newMount";
|
||||||
|
import { pageState } from "../../globalPageState";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
export class NewTransitEnginePage extends Page {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
async render(): Promise<void> {
|
||||||
|
const newEngineForm = makeElement({
|
||||||
|
tag: "form",
|
||||||
|
children: [
|
||||||
|
Margin(
|
||||||
|
makeElement({
|
||||||
|
tag: "input",
|
||||||
|
class: ["uk-input", "uk-form-width-medium"],
|
||||||
|
attributes: {
|
||||||
|
required: "true",
|
||||||
|
type: "text",
|
||||||
|
placeholder: i18next.t("new_transit_engine_name_input"),
|
||||||
|
name: "name",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
makeElement({
|
||||||
|
tag: "p",
|
||||||
|
id: "errorText",
|
||||||
|
class: "uk-text-danger",
|
||||||
|
}),
|
||||||
|
makeElement({
|
||||||
|
tag: "button",
|
||||||
|
class: ["uk-button", "uk-button-primary"],
|
||||||
|
text: i18next.t("new_transit_engine_create_btn"),
|
||||||
|
attributes: {
|
||||||
|
type: "submit",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}) as HTMLFormElement;
|
||||||
|
|
||||||
|
setPageContent(newEngineForm);
|
||||||
|
|
||||||
|
newEngineForm.addEventListener("submit", async function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const formData = new FormData(newEngineForm);
|
||||||
|
|
||||||
|
const name = formData.get("name") as string;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await newMount({
|
||||||
|
name: name,
|
||||||
|
type: "transit",
|
||||||
|
});
|
||||||
|
pageState.currentMountType = "transit";
|
||||||
|
pageState.currentBaseMount = name + "/";
|
||||||
|
await changePage("TRANSIT_VIEW");
|
||||||
|
} catch (e) {
|
||||||
|
const error = e as Error;
|
||||||
|
setErrorText(error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
get name(): string {
|
||||||
|
return i18next.t("new_transit_engine_title");
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,13 @@ export class NewSecretsEnginePage extends Page {
|
||||||
void changePage("NEW_TOTP_ENGINE");
|
void changePage("NEW_TOTP_ENGINE");
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
Tile({
|
||||||
|
title: i18next.t("new_secrets_engine_transit_title"),
|
||||||
|
description: i18next.t("new_secrets_engine_transit_description"),
|
||||||
|
onclick: () => {
|
||||||
|
void changePage("NEW_TRANSIT_ENGINE");
|
||||||
|
},
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
8
src/translations/en.js
vendored
8
src/translations/en.js
vendored
|
@ -45,6 +45,9 @@ module.exports = {
|
||||||
new_secrets_engine_kv_description: "For storing key/value mapped secrets.",
|
new_secrets_engine_kv_description: "For storing key/value mapped secrets.",
|
||||||
new_secrets_engine_totp_title: "TOTP",
|
new_secrets_engine_totp_title: "TOTP",
|
||||||
new_secrets_engine_totp_description: "For handing Time-based One Time Pass (TOTP) codes.",
|
new_secrets_engine_totp_description: "For handing Time-based One Time Pass (TOTP) codes.",
|
||||||
|
new_secrets_engine_transit_title: "Transit",
|
||||||
|
new_secrets_engine_transit_description:
|
||||||
|
"For doing encryption/decryption without storing the data.",
|
||||||
|
|
||||||
// New KV Engine Page
|
// New KV Engine Page
|
||||||
new_kv_engine_title: "New Key/Value Engine",
|
new_kv_engine_title: "New Key/Value Engine",
|
||||||
|
@ -58,6 +61,11 @@ module.exports = {
|
||||||
new_totp_engine_name_input: "Name",
|
new_totp_engine_name_input: "Name",
|
||||||
new_totp_engine_create_btn: "Create",
|
new_totp_engine_create_btn: "Create",
|
||||||
|
|
||||||
|
// New Transit Engine Page
|
||||||
|
new_transit_engine_title: "New Transit Engine",
|
||||||
|
new_transit_engine_name_input: "Name",
|
||||||
|
new_transit_engine_create_btn: "Create",
|
||||||
|
|
||||||
// Unseal Page
|
// Unseal Page
|
||||||
unseal_vault_text: "Unseal the Vault",
|
unseal_vault_text: "Unseal the Vault",
|
||||||
submit_key_btn: "Submit Key",
|
submit_key_btn: "Submit Key",
|
||||||
|
|
Loading…
Reference in a new issue