rename state to settings
This commit is contained in:
parent
12eb745d2c
commit
1d037f0f19
|
@ -1,14 +1,14 @@
|
||||||
import { BaseAPIResponse } from "./types/api";
|
import { BaseAPIResponse } from "./types/api";
|
||||||
import { DoesNotExistError } from "../types/internalErrors";
|
import { DoesNotExistError } from "../types/internalErrors";
|
||||||
import { pageState } from "../globalPageState";
|
import { settings } from "../globalSettings";
|
||||||
|
|
||||||
export function getHeaders(): Record<string, string> {
|
export function getHeaders(): Record<string, string> {
|
||||||
return {
|
return {
|
||||||
"X-Vault-Token": pageState.token,
|
"X-Vault-Token": settings.token,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const appendAPIURL = (url: string): string => pageState.apiURL + url;
|
export const appendAPIURL = (url: string): string => settings.apiURL + url;
|
||||||
|
|
||||||
export async function checkResponse(resp: Response): Promise<void> {
|
export async function checkResponse(resp: Response): Promise<void> {
|
||||||
if (resp.ok) return;
|
if (resp.ok) return;
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import { PageState } from "./state/PageState";
|
|
||||||
export const pageState = new PageState();
|
|
2
src/globalSettings.ts
Normal file
2
src/globalSettings.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import { Settings } from "./settings/Settings";
|
||||||
|
export const settings = new Settings();
|
|
@ -27,13 +27,13 @@ import { getSealStatus } from "./api/sys/getSealStatus";
|
||||||
//import { pageList } from "./allPages";
|
//import { pageList } from "./allPages";
|
||||||
import { render } from "preact";
|
import { render } from "preact";
|
||||||
import { NavBar } from "./ui/elements/NavBar";
|
import { NavBar } from "./ui/elements/NavBar";
|
||||||
import { pageState } from "./globalPageState";
|
import { settings } from "./globalSettings";
|
||||||
import { playground } from "./playground";
|
import { playground } from "./playground";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { Main } from "./pages";
|
import { Main } from "./pages";
|
||||||
|
|
||||||
async function onLoad(): Promise<void> {
|
async function onLoad(): Promise<void> {
|
||||||
document.documentElement.dir = pageState.pageDirection;
|
document.documentElement.dir = settings.pageDirection;
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<>
|
<>
|
||||||
|
@ -74,7 +74,7 @@ document.addEventListener(
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
console.log("Build Data:", BUILD_STRING);
|
console.log("Build Data:", BUILD_STRING);
|
||||||
await i18next.init({
|
await i18next.init({
|
||||||
lng: pageState.language,
|
lng: settings.language,
|
||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
debug: true,
|
debug: true,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -87,7 +87,7 @@ document.addEventListener(
|
||||||
},
|
},
|
||||||
format: function (value: unknown, format, _): string {
|
format: function (value: unknown, format, _): string {
|
||||||
if (format === "until_date" && value instanceof Date)
|
if (format === "until_date" && value instanceof Date)
|
||||||
return formatDistance(new Date(), new Date(value), pageState.language);
|
return formatDistance(new Date(), new Date(value), settings.language);
|
||||||
return value as string;
|
return value as string;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PageState } from "./state/PageState";
|
import { Settings } from "./settings/Settings";
|
||||||
import { getSealStatus } from "./api/sys/getSealStatus";
|
import { getSealStatus } from "./api/sys/getSealStatus";
|
||||||
import { lookupSelf } from "./api/sys/lookupSelf";
|
import { lookupSelf } from "./api/sys/lookupSelf";
|
||||||
import { route } from "preact-router";
|
import { route } from "preact-router";
|
||||||
|
@ -6,13 +6,13 @@ import ClipboardJS from "clipboard";
|
||||||
import UIkit from "uikit";
|
import UIkit from "uikit";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
async function prePageChecksReal(state: PageState) {
|
async function prePageChecksReal(settings: Settings) {
|
||||||
if (state.language.length == 0) {
|
if (settings.language.length == 0) {
|
||||||
route("/set_language", true);
|
route("/set_language", true);
|
||||||
throw new Error("Language Not Set");
|
throw new Error("Language Not Set");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.apiURL) {
|
if (!settings.apiURL) {
|
||||||
route("/set_vault_url", true);
|
route("/set_vault_url", true);
|
||||||
throw new Error("Vault URL Not Set");
|
throw new Error("Vault URL Not Set");
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ async function prePageChecksReal(state: PageState) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function prePageChecks(state: PageState): Promise<boolean> {
|
export async function prePageChecks(settings: Settings): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await prePageChecksReal(state);
|
await prePageChecksReal(settings);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("OHNO", e);
|
console.log("OHNO", e);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Router from "preact-router";
|
import Router from "preact-router";
|
||||||
import { pageState } from "./globalPageState";
|
import { settings } from "./globalSettings";
|
||||||
|
|
||||||
import { DeleteSecretsEngine } from "./ui/pages/Secrets/DeleteSecretsEngine";
|
import { DeleteSecretsEngine } from "./ui/pages/Secrets/DeleteSecretsEngine";
|
||||||
import { Home } from "./ui/pages/Home";
|
import { Home } from "./ui/pages/Home";
|
||||||
|
@ -44,54 +44,54 @@ import { UserPassUserEdit } from "./ui/pages/Access/Auth/userpass/UserPassUserEd
|
||||||
|
|
||||||
export const Main = () => (
|
export const Main = () => (
|
||||||
<Router>
|
<Router>
|
||||||
<Home path="/" state={pageState} />
|
<Home path="/" settings={settings} />
|
||||||
<Me path="/me" state={pageState} />
|
<Me path="/me" settings={settings} />
|
||||||
<Login path="/login" state={pageState} />
|
<Login path="/login" settings={settings} />
|
||||||
<PasswordGenerator path="/pw_gen" />
|
<PasswordGenerator path="/pw_gen" />
|
||||||
<SetVaultURL path="/set_vault_url" state={pageState} />
|
<SetVaultURL path="/set_vault_url" settings={settings} />
|
||||||
<Unseal path="/unseal" state={pageState} />
|
<Unseal path="/unseal" settings={settings} />
|
||||||
<SetLanguage path="/set_language" state={pageState} />
|
<SetLanguage path="/set_language" settings={settings} />
|
||||||
|
|
||||||
<Secrets path="/secrets" state={pageState} />
|
<Secrets path="/secrets" settings={settings} />
|
||||||
<DeleteSecretsEngine path="/secrets/delete_engine/:mount" state={pageState} />
|
<DeleteSecretsEngine path="/secrets/delete_engine/:mount" settings={settings} />
|
||||||
|
|
||||||
<NewSecretsEngine path="/secrets/new_secrets_engine" />
|
<NewSecretsEngine path="/secrets/new_secrets_engine" />
|
||||||
<NewKVEngine path="/secrets/new_secrets_engine/kv" />
|
<NewKVEngine path="/secrets/new_secrets_engine/kv" />
|
||||||
<NewTOTPEngine path="/secrets/new_secrets_engine/totp" />
|
<NewTOTPEngine path="/secrets/new_secrets_engine/totp" />
|
||||||
<NewTransitEngine path="/secrets/new_secrets_engine/trasit" />
|
<NewTransitEngine path="/secrets/new_secrets_engine/trasit" />
|
||||||
|
|
||||||
<KeyValueNew path="/secrets/kv/new/:baseMount/:secretPath*?" state={pageState} />
|
<KeyValueNew path="/secrets/kv/new/:baseMount/:secretPath*?" settings={settings} />
|
||||||
<KeyValueList path="/secrets/kv/list/:baseMount/:secretPath*?" state={pageState} />
|
<KeyValueList path="/secrets/kv/list/:baseMount/:secretPath*?" settings={settings} />
|
||||||
<KeyValueView path="/secrets/kv/view/:item/:baseMount/:secretPath*?" state={pageState} />
|
<KeyValueView path="/secrets/kv/view/:item/:baseMount/:secretPath*?" settings={settings} />
|
||||||
<KeyValueEdit path="/secrets/kv/edit/:item/:baseMount/:secretPath*?" state={pageState} />
|
<KeyValueEdit path="/secrets/kv/edit/:item/:baseMount/:secretPath*?" settings={settings} />
|
||||||
<KeyValueDelete path="/secrets/kv/delete/:item/:baseMount/:secretPath*?" state={pageState} />
|
<KeyValueDelete path="/secrets/kv/delete/:item/:baseMount/:secretPath*?" settings={settings} />
|
||||||
|
|
||||||
<TOTPList path="/secrets/totp/list/:baseMount" state={pageState} />
|
<TOTPList path="/secrets/totp/list/:baseMount" settings={settings} />
|
||||||
<TOTPNew path="/secrets/totp/new/:baseMount" state={pageState} />
|
<TOTPNew path="/secrets/totp/new/:baseMount" settings={settings} />
|
||||||
<TOTPDelete path="/secrets/totp/delete/:baseMount/:item" state={pageState} />
|
<TOTPDelete path="/secrets/totp/delete/:baseMount/:item" settings={settings} />
|
||||||
|
|
||||||
<TransitNew path="/secrets/transit/new/:baseMount" state={pageState} />
|
<TransitNew path="/secrets/transit/new/:baseMount" settings={settings} />
|
||||||
<TransitList path="/secrets/transit/list/:baseMount" state={pageState} />
|
<TransitList path="/secrets/transit/list/:baseMount" settings={settings} />
|
||||||
<TransitView path="/secrets/transit/view/:baseMount/:secretItem" state={pageState} />
|
<TransitView path="/secrets/transit/view/:baseMount/:secretItem" settings={settings} />
|
||||||
<TransitEncrypt path="/secrets/transit/encrypt/:baseMount/:secretItem" state={pageState} />
|
<TransitEncrypt path="/secrets/transit/encrypt/:baseMount/:secretItem" settings={settings} />
|
||||||
<TransitDecrypt path="/secrets/transit/decrypt/:baseMount/:secretItem" state={pageState} />
|
<TransitDecrypt path="/secrets/transit/decrypt/:baseMount/:secretItem" settings={settings} />
|
||||||
<TransitRewrap path="/secrets/transit/rewrap/:baseMount/:secretItem" state={pageState} />
|
<TransitRewrap path="/secrets/transit/rewrap/:baseMount/:secretItem" settings={settings} />
|
||||||
|
|
||||||
<PoliciesHome path="/policies" state={pageState} />
|
<PoliciesHome path="/policies" settings={settings} />
|
||||||
<PolicyNew path="/policies/new" state={pageState} />
|
<PolicyNew path="/policies/new" settings={settings} />
|
||||||
<PolicyView path="/policies/view/:policyName" state={pageState} />
|
<PolicyView path="/policies/view/:policyName" settings={settings} />
|
||||||
<PolicyEdit path="/policies/edit/:policyName" state={pageState} />
|
<PolicyEdit path="/policies/edit/:policyName" settings={settings} />
|
||||||
<PolicyDelete path="/policies/delete/:policyName" state={pageState} />
|
<PolicyDelete path="/policies/delete/:policyName" settings={settings} />
|
||||||
|
|
||||||
<AccessHomePage path="/access" state={pageState} />
|
<AccessHomePage path="/access" settings={settings} />
|
||||||
<AuthHome path="/access/auth" state={pageState} />
|
<AuthHome path="/access/auth" settings={settings} />
|
||||||
<AuthViewConfig path="/access/auth/view/:baseMount" state={pageState} />
|
<AuthViewConfig path="/access/auth/view/:baseMount" settings={settings} />
|
||||||
|
|
||||||
<UserPassUsersList path="/access/auth/userpass/list/:baseMount" state={pageState} />
|
<UserPassUsersList path="/access/auth/userpass/list/:baseMount" settings={settings} />
|
||||||
<UserPassUserNew path="/access/auth/userpass/new/:baseMount" state={pageState} />
|
<UserPassUserNew path="/access/auth/userpass/new/:baseMount" settings={settings} />
|
||||||
<UserPassUserView path="/access/auth/userpass/view/:baseMount/:user" state={pageState} />
|
<UserPassUserView path="/access/auth/userpass/view/:baseMount/:user" settings={settings} />
|
||||||
<UserPassUserEdit path="/access/auth/userpass/edit/:baseMount/:user" state={pageState} />
|
<UserPassUserEdit path="/access/auth/userpass/edit/:baseMount/:user" settings={settings} />
|
||||||
<UserPassUserDelete path="/access/auth/userpass/delete/:baseMount/:user" state={pageState} />
|
<UserPassUserDelete path="/access/auth/userpass/delete/:baseMount/:user" settings={settings} />
|
||||||
|
|
||||||
<div default>
|
<div default>
|
||||||
<p>PAGE NOT YET IMPLEMENTED</p>
|
<p>PAGE NOT YET IMPLEMENTED</p>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { StorageType } from "./storage/StorageType";
|
import { StorageType } from "./storage/StorageType";
|
||||||
|
|
||||||
export class PageState {
|
export class Settings {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.storage = localStorage;
|
this.storage = localStorage;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import { PageState } from "../state/PageState";
|
import { Settings } from "../settings/Settings";
|
||||||
|
|
||||||
export type DefaultPageProps = {
|
export type DefaultPageProps = {
|
||||||
state: PageState;
|
settings: Settings;
|
||||||
matches?: { [key: string]: string };
|
matches?: { [key: string]: string };
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { PageTitle } from "../../elements/PageTitle";
|
||||||
|
|
||||||
export class AccessHomePage extends Component<DefaultPageProps> {
|
export class AccessHomePage extends Component<DefaultPageProps> {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!(await prePageChecks(this.props.state))) return;
|
if (!(await prePageChecks(this.props.settings))) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Component, JSX, render } from "preact";
|
import { Component, JSX, render } from "preact";
|
||||||
import { Grid, GridSizes } from "../elements/Grid";
|
import { Grid, GridSizes } from "../elements/Grid";
|
||||||
import { Margin } from "../elements/Margin";
|
import { Margin } from "../elements/Margin";
|
||||||
import { PageState } from "../../state/PageState";
|
|
||||||
import { PageTitle } from "../elements/PageTitle";
|
import { PageTitle } from "../elements/PageTitle";
|
||||||
import { Tile } from "../elements/Tile";
|
import { Tile } from "../elements/Tile";
|
||||||
import { TokenInfo } from "../../api/types/token";
|
import { TokenInfo } from "../../api/types/token";
|
||||||
|
@ -10,10 +9,7 @@ import { lookupSelf } from "../../api/sys/lookupSelf";
|
||||||
import { prePageChecks, setErrorText } from "../../pageUtils";
|
import { prePageChecks, setErrorText } from "../../pageUtils";
|
||||||
import { route } from "preact-router";
|
import { route } from "preact-router";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
import { DefaultPageProps } from "../../types/DefaultPageProps";
|
||||||
type HomeProps = {
|
|
||||||
state: PageState;
|
|
||||||
};
|
|
||||||
|
|
||||||
type HomeState = {
|
type HomeState = {
|
||||||
selfTokenInfo: TokenInfo;
|
selfTokenInfo: TokenInfo;
|
||||||
|
@ -21,9 +17,9 @@ type HomeState = {
|
||||||
policiesCaps: string[];
|
policiesCaps: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Home extends Component<HomeProps, HomeState> {
|
export class Home extends Component<DefaultPageProps, HomeState> {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!(await prePageChecks(this.props.state))) return;
|
if (!(await prePageChecks(this.props.settings))) return;
|
||||||
|
|
||||||
let selfTokenInfo: TokenInfo;
|
let selfTokenInfo: TokenInfo;
|
||||||
try {
|
try {
|
||||||
|
@ -32,7 +28,7 @@ export class Home extends Component<HomeProps, HomeState> {
|
||||||
const error = e as Error;
|
const error = e as Error;
|
||||||
setErrorText(error.message);
|
setErrorText(error.message);
|
||||||
if (error.message == "permission denied") {
|
if (error.message == "permission denied") {
|
||||||
this.props.state.token = "";
|
this.props.settings.token = "";
|
||||||
route("/login", true);
|
route("/login", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,11 +49,11 @@ export class Home extends Component<HomeProps, HomeState> {
|
||||||
return (
|
return (
|
||||||
this.state.selfTokenInfo && (
|
this.state.selfTokenInfo && (
|
||||||
<>
|
<>
|
||||||
<PageTitle title={this.name} />
|
<PageTitle title={i18next.t("home_page_title")} />
|
||||||
<div>
|
<div>
|
||||||
<ul id="textList" class="uk-nav">
|
<ul id="textList" class="uk-nav">
|
||||||
<li>
|
<li>
|
||||||
<span>{i18next.t("home_vaulturl_text", { text: this.props.state.apiURL })}</span>
|
<span>{i18next.t("home_vaulturl_text", { text: this.props.settings.apiURL })}</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/pw_gen">{i18next.t("home_password_generator_btn")}</a>
|
<a href="/pw_gen">{i18next.t("home_password_generator_btn")}</a>
|
||||||
|
@ -105,8 +101,4 @@ export class Home extends Component<HomeProps, HomeState> {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string {
|
|
||||||
return i18next.t("home_page_title");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { DefaultPageProps } from "../../types/DefaultPageProps";
|
||||||
import { Form } from "../elements/Form";
|
import { Form } from "../elements/Form";
|
||||||
import { Margin } from "../elements/Margin";
|
import { Margin } from "../elements/Margin";
|
||||||
import { MarginInline } from "../elements/MarginInline";
|
import { MarginInline } from "../elements/MarginInline";
|
||||||
import { PageState } from "../../state/PageState";
|
|
||||||
import { PageTitle } from "../elements/PageTitle";
|
import { PageTitle } from "../elements/PageTitle";
|
||||||
import { lookupSelf } from "../../api/sys/lookupSelf";
|
import { lookupSelf } from "../../api/sys/lookupSelf";
|
||||||
import { route } from "preact-router";
|
import { route } from "preact-router";
|
||||||
|
@ -11,7 +10,7 @@ import { setErrorText } from "../../pageUtils";
|
||||||
import { usernameLogin } from "../../api/auth/usernameLogin";
|
import { usernameLogin } from "../../api/auth/usernameLogin";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
export class TokenLoginForm extends Component<{ state: PageState }, unknown> {
|
export class TokenLoginForm extends Component<DefaultPageProps> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +39,7 @@ export class TokenLoginForm extends Component<{ state: PageState }, unknown> {
|
||||||
|
|
||||||
async onSubmit(data: FormData): Promise<void> {
|
async onSubmit(data: FormData): Promise<void> {
|
||||||
const token = data.get("token");
|
const token = data.get("token");
|
||||||
this.props.state.token = token as string;
|
this.props.settings.token = token as string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await lookupSelf();
|
await lookupSelf();
|
||||||
|
@ -57,7 +56,7 @@ export class TokenLoginForm extends Component<{ state: PageState }, unknown> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UsernameLoginForm extends Component<{ state: PageState }, unknown> {
|
export class UsernameLoginForm extends Component<DefaultPageProps> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,7 @@ export class UsernameLoginForm extends Component<{ state: PageState }, unknown>
|
||||||
data.get("username") as string,
|
data.get("username") as string,
|
||||||
data.get("password") as string,
|
data.get("password") as string,
|
||||||
);
|
);
|
||||||
this.props.state.token = res;
|
this.props.settings.token = res;
|
||||||
route("/");
|
route("/");
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const error = e as Error;
|
const error = e as Error;
|
||||||
|
@ -128,10 +127,10 @@ export class Login extends Component<DefaultPageProps> {
|
||||||
<p id="errorText" class="uk-text-danger" />
|
<p id="errorText" class="uk-text-danger" />
|
||||||
<ul class="uk-switcher uk-margin switcher-container">
|
<ul class="uk-switcher uk-margin switcher-container">
|
||||||
<li>
|
<li>
|
||||||
<TokenLoginForm state={this.props.state} />
|
<TokenLoginForm settings={this.props.settings} />
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<UsernameLoginForm state={this.props.state} />
|
<UsernameLoginForm settings={this.props.settings} />
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class Me extends Component<DefaultPageProps, MeState> {
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
this.props.state.token = "";
|
this.props.settings.token = "";
|
||||||
route("/");
|
route("/");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -74,7 +74,7 @@ export class Me extends Component<DefaultPageProps, MeState> {
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<CopyLink text={i18next.t("me_copy_token_btn")} data={this.props.state.token} />
|
<CopyLink text={i18next.t("me_copy_token_btn")} data={this.props.settings.token} />
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { policyNewURL, policyViewURL } from "../pageLinks";
|
||||||
|
|
||||||
export class PoliciesHome extends Component<DefaultPageProps, { policies: string[] }> {
|
export class PoliciesHome extends Component<DefaultPageProps, { policies: string[] }> {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!(await prePageChecks(this.props.state))) return;
|
if (!(await prePageChecks(this.props.settings))) return;
|
||||||
|
|
||||||
let policies = await getPolicies();
|
let policies = await getPolicies();
|
||||||
policies = policies.sort();
|
policies = policies.sort();
|
||||||
|
|
|
@ -14,7 +14,7 @@ export class PolicyView extends Component<
|
||||||
{ policy: string; policyName: string }
|
{ policy: string; policyName: string }
|
||||||
> {
|
> {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!(await prePageChecks(this.props.state))) return;
|
if (!(await prePageChecks(this.props.settings))) return;
|
||||||
console.log(this.props);
|
console.log(this.props);
|
||||||
const policyName = this.props.matches["policyName"];
|
const policyName = this.props.matches["policyName"];
|
||||||
const policy = await getPolicy(policyName);
|
const policy = await getPolicy(policyName);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { route } from "preact-router";
|
||||||
import { setErrorText } from "../../../../pageUtils";
|
import { setErrorText } from "../../../../pageUtils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
export type KVKeysListProps = DefaultPageProps & {
|
export type KVKeysListProps = {
|
||||||
baseMount: string;
|
baseMount: string;
|
||||||
secretPath: string[];
|
secretPath: string[];
|
||||||
};
|
};
|
||||||
|
@ -201,7 +201,7 @@ export class KeyValueList extends Component<DefaultPageProps, KeyValueListState>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
{this.state.mountType == "cubbyhole" && <p>{i18next.t("kv_view_cubbyhole_text")}</p>}
|
{this.state.mountType == "cubbyhole" && <p>{i18next.t("kv_view_cubbyhole_text")}</p>}
|
||||||
<KVKeysList baseMount={baseMount} secretPath={secretPath} state={this.props.state} />
|
<KVKeysList baseMount={baseMount} secretPath={secretPath} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Component, JSX, render } from "preact";
|
import { Component, JSX, render } from "preact";
|
||||||
import { DefaultPageProps } from "../../../types/DefaultPageProps";
|
import { DefaultPageProps } from "../../../types/DefaultPageProps";
|
||||||
import { MountType, getMounts } from "../../../api/sys/getMounts";
|
import { MountType, getMounts } from "../../../api/sys/getMounts";
|
||||||
import { PageState } from "../../../state/PageState";
|
|
||||||
import { PageTitle } from "../../elements/PageTitle";
|
import { PageTitle } from "../../elements/PageTitle";
|
||||||
import { getCapsPath } from "../../../api/sys/getCapabilities";
|
import { getCapsPath } from "../../../api/sys/getCapabilities";
|
||||||
import { prePageChecks } from "../../../pageUtils";
|
import { prePageChecks } from "../../../pageUtils";
|
||||||
|
@ -20,7 +19,6 @@ export function isSupportedMount(mount: MountType): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MountLinkProps = {
|
export type MountLinkProps = {
|
||||||
state: PageState;
|
|
||||||
mount: MountType;
|
mount: MountType;
|
||||||
baseMount: string;
|
baseMount: string;
|
||||||
};
|
};
|
||||||
|
@ -61,7 +59,7 @@ type SecretsState = {
|
||||||
|
|
||||||
export class Secrets extends Component<DefaultPageProps, SecretsState> {
|
export class Secrets extends Component<DefaultPageProps, SecretsState> {
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!(await prePageChecks(this.props.state))) return;
|
if (!(await prePageChecks(this.props.settings))) return;
|
||||||
|
|
||||||
const mountsCapabilities = await getCapsPath("/sys/mounts");
|
const mountsCapabilities = await getCapsPath("/sys/mounts");
|
||||||
const mounts = await getMounts();
|
const mounts = await getMounts();
|
||||||
|
@ -102,7 +100,7 @@ export class Secrets extends Component<DefaultPageProps, SecretsState> {
|
||||||
console.log(baseMount, mount);
|
console.log(baseMount, mount);
|
||||||
if (isSupportedMount(mount)) {
|
if (isSupportedMount(mount)) {
|
||||||
return (
|
return (
|
||||||
<MountLink state={this.props.state} mount={mount} baseMount={baseMount} />
|
<MountLink mount={mount} baseMount={baseMount} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -44,10 +44,10 @@ export class SetLanguage extends Component<DefaultPageProps> {
|
||||||
|
|
||||||
async onSubmit(data: FormData): Promise<void> {
|
async onSubmit(data: FormData): Promise<void> {
|
||||||
const language = data.get("language") as string;
|
const language = data.get("language") as string;
|
||||||
this.props.state.language = language;
|
this.props.settings.language = language;
|
||||||
|
|
||||||
const t = await i18next.changeLanguage(language);
|
const t = await i18next.changeLanguage(language);
|
||||||
this.props.state.pageDirection = t("language_direction");
|
this.props.settings.pageDirection = t("language_direction");
|
||||||
// TODO: make navbar somethingy
|
// TODO: make navbar somethingy
|
||||||
//reloadNavBar(this.router);
|
//reloadNavBar(this.router);
|
||||||
route("/");
|
route("/");
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class SetVaultURL extends Component<DefaultPageProps> {
|
||||||
|
|
||||||
async onSubmit(data: FormData): Promise<void> {
|
async onSubmit(data: FormData): Promise<void> {
|
||||||
// TODO: check if vault is actually working here.
|
// TODO: check if vault is actually working here.
|
||||||
this.props.state.apiURL = data.get("vaultURL") as string;
|
this.props.settings.apiURL = data.get("vaultURL") as string;
|
||||||
route("/");
|
route("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue