1
0
Fork 0

add all policy pages

This commit is contained in:
ChaotiCryptidz 2022-01-07 13:14:25 +00:00
parent ee93d882c8
commit 6089fe9501
24 changed files with 277 additions and 304 deletions

View file

@ -26,82 +26,15 @@ import { PageRouter } from "./pagerouter/PageRouter";
import { formatDistance } from "./formatDistance";
import { getSealStatus } from "./api/sys/getSealStatus";
//import { pageList } from "./allPages";
import { Component, render } from "preact";
import { DeleteSecretsEngine } from "./ui/pages/Secrets/DeleteSecretsEngine";
import { Home } from "./ui/pages/Home";
import { KeyValueDelete } from "./ui/pages/Secrets/KeyValue/KeyValueDelete";
import { KeyValueView } from "./ui/pages/Secrets/KeyValue/KeyValueView";
import { KeyValueEdit } from "./ui/pages/Secrets/KeyValue/KeyValueEdit";
import { KeyValueList } from "./ui/pages/Secrets/KeyValue/KeyValueList";
import { Login } from "./ui/pages/Login";
import { Me } from "./ui/pages/Me";
import { render } from "preact";
import { NavBar } from "./ui/elements/NavBar";
import { NewKVEngine } from "./ui/pages/Secrets/NewEngines/NewKVEngine";
import { NewSecretsEngine } from "./ui/pages/Secrets/NewSecretsEngine";
import { NewTOTPEngine } from "./ui/pages/Secrets/NewEngines/NewTOTPEngine";
import { NewTransitEngine } from "./ui/pages/Secrets/NewEngines/NewTransitEngine";
import { TransitNew } from "./ui/pages/Secrets/Transit/TransitNew";
import { PasswordGenerator } from "./ui/pages/PwGen";
import { Secrets } from "./ui/pages/Secrets/SecretsHome";
import { SetLanguage } from "./ui/pages/SetLanguage";
import { SetVaultURL } from "./ui/pages/SetVaultURL";
import { TOTPDelete } from "./ui/pages/Secrets/TOTP/TOTPDelete";
import { TOTPNew } from "./ui/pages/Secrets/TOTP/TOTPNew";
import { TOTPList } from "./ui/pages/Secrets/TOTP/TOTPList";
import { TransitList } from "./ui/pages/Secrets/Transit/TransitList";
import { TransitView } from "./ui/pages/Secrets/Transit/TransitView";
import { Unseal } from "./ui/pages/Unseal";
import { pageState } from "./globalPageState";
import { playground } from "./playground";
import Router from "preact-router";
import i18next from "i18next";
import { KeyValueNew } from "./ui/pages/Secrets/KeyValue/KeyValueNew";
import { TransitDecrypt } from "./ui/pages/Secrets/Transit/TransitDecrypt";
import { TransitEncrypt } from "./ui/pages/Secrets/Transit/TransitEncrypt";
import { TransitRewrap } from "./ui/pages/Secrets/Transit/TransitRewrap";
import { Main } from "./pages";
async function onLoad(): Promise<void> {
const Main = () => (
<Router>
<Home path="/" state={pageState} />
<Me path="/me" state={pageState} />
<Login path="/login" state={pageState} />
<PasswordGenerator path="/pw_gen" />
<SetVaultURL path="/set_vault_url" state={pageState} />
<Unseal path="/unseal" state={pageState} />
<SetLanguage path="/set_language" state={pageState} />
<Secrets path="/secrets" state={pageState} />
<DeleteSecretsEngine path="/secrets/delete_engine/:mount" state={pageState} />
<NewSecretsEngine path="/secrets/new_secrets_engine" />
<NewKVEngine path="/secrets/new_secrets_engine/kv" />
<NewTOTPEngine path="/secrets/new_secrets_engine/totp" />
<NewTransitEngine path="/secrets/new_secrets_engine/trasit" />
<KeyValueNew path="/secrets/kv/new/:baseMount/:secretPath*?" state={pageState} />
<KeyValueList path="/secrets/kv/list/:baseMount/:secretPath*?" state={pageState} />
<KeyValueView path="/secrets/kv/view/:item/:baseMount/:secretPath*?" state={pageState} />
<KeyValueEdit path="/secrets/kv/edit/:item/:baseMount/:secretPath*?" state={pageState} />
<KeyValueDelete path="/secrets/kv/delete/:item/:baseMount/:secretPath*?" state={pageState} />
<TOTPList path="/secrets/totp/list/:baseMount" state={pageState} />
<TOTPNew path="/secrets/totp/new/:baseMount" state={pageState} />
<TOTPDelete path="/secrets/totp/delete/:baseMount/:item" state={pageState} />
<TransitNew path="/secrets/transit/new/:baseMount" state={pageState} />
<TransitList path="/secrets/transit/list/:baseMount" state={pageState} />
<TransitView path="/secrets/transit/view/:baseMount/:secretItem" state={pageState} />
<TransitEncrypt path="/secrets/transit/encrypt/:baseMount/:secretItem" state={pageState} />
<TransitDecrypt path="/secrets/transit/decrypt/:baseMount/:secretItem" state={pageState} />
<TransitRewrap path="/secrets/transit/rewrap/:baseMount/:secretItem" state={pageState} />
<div default>
<p>PAGE NOT YET IMPLEMENTED</p>
</div>
</Router>
);
document.documentElement.dir = pageState.pageDirection;
render(
<>
@ -115,22 +48,8 @@ async function onLoad(): Promise<void> {
document.body,
);
//const pageRouter = new PageRouter({
// pageList: pageList,
// state: pageState,
// pageTitleElement: document.querySelector("#pageTitle"),
// pageContentElement: document.querySelector("#pageContent"),
// resetElementContent: !true,
// onPageChange: async function () {
// pageState.currentPage = await pageRouter.getCurrentPageID();
// document.documentElement.dir = pageState.pageDirection;
// },
//});
//
//reloadNavBar(pageRouter);
if (process.env.NODE_ENV == "development") {
// await playground(pageRouter);
await playground();
}
//await pageRouter.changePage(pageState.currentPage);

84
src/pages.tsx Normal file
View file

@ -0,0 +1,84 @@
import Router from "preact-router";
import { pageState } from "./globalPageState";
import { DeleteSecretsEngine } from "./ui/pages/Secrets/DeleteSecretsEngine";
import { Home } from "./ui/pages/Home";
import { KeyValueDelete } from "./ui/pages/Secrets/KeyValue/KeyValueDelete";
import { KeyValueView } from "./ui/pages/Secrets/KeyValue/KeyValueView";
import { KeyValueEdit } from "./ui/pages/Secrets/KeyValue/KeyValueEdit";
import { KeyValueList } from "./ui/pages/Secrets/KeyValue/KeyValueList";
import { Login } from "./ui/pages/Login";
import { Me } from "./ui/pages/Me";
import { NewKVEngine } from "./ui/pages/Secrets/NewEngines/NewKVEngine";
import { NewSecretsEngine } from "./ui/pages/Secrets/NewSecretsEngine";
import { NewTOTPEngine } from "./ui/pages/Secrets/NewEngines/NewTOTPEngine";
import { NewTransitEngine } from "./ui/pages/Secrets/NewEngines/NewTransitEngine";
import { TransitNew } from "./ui/pages/Secrets/Transit/TransitNew";
import { PasswordGenerator } from "./ui/pages/PwGen";
import { Secrets } from "./ui/pages/Secrets/SecretsHome";
import { SetLanguage } from "./ui/pages/SetLanguage";
import { SetVaultURL } from "./ui/pages/SetVaultURL";
import { TOTPDelete } from "./ui/pages/Secrets/TOTP/TOTPDelete";
import { TOTPNew } from "./ui/pages/Secrets/TOTP/TOTPNew";
import { TOTPList } from "./ui/pages/Secrets/TOTP/TOTPList";
import { TransitList } from "./ui/pages/Secrets/Transit/TransitList";
import { TransitView } from "./ui/pages/Secrets/Transit/TransitView";
import { Unseal } from "./ui/pages/Unseal";
import { KeyValueNew } from "./ui/pages/Secrets/KeyValue/KeyValueNew";
import { TransitDecrypt } from "./ui/pages/Secrets/Transit/TransitDecrypt";
import { TransitEncrypt } from "./ui/pages/Secrets/Transit/TransitEncrypt";
import { TransitRewrap } from "./ui/pages/Secrets/Transit/TransitRewrap";
import { PoliciesHome } from "./ui/pages/Policies/PoliciesHome";
import { PolicyView } from "./ui/pages/Policies/PolicyView";
import { PolicyNew } from "./ui/pages/Policies/PolicyNew";
import { PolicyDelete } from "./ui/pages/Policies/PolicyDelete";
import { PolicyEdit } from "./ui/pages/Policies/PolicyEdit";
export const Main = () => (
<Router>
<Home path="/" state={pageState} />
<Me path="/me" state={pageState} />
<Login path="/login" state={pageState} />
<PasswordGenerator path="/pw_gen" />
<SetVaultURL path="/set_vault_url" state={pageState} />
<Unseal path="/unseal" state={pageState} />
<SetLanguage path="/set_language" state={pageState} />
<Secrets path="/secrets" state={pageState} />
<DeleteSecretsEngine path="/secrets/delete_engine/:mount" state={pageState} />
<NewSecretsEngine path="/secrets/new_secrets_engine" />
<NewKVEngine path="/secrets/new_secrets_engine/kv" />
<NewTOTPEngine path="/secrets/new_secrets_engine/totp" />
<NewTransitEngine path="/secrets/new_secrets_engine/trasit" />
<KeyValueNew path="/secrets/kv/new/:baseMount/:secretPath*?" state={pageState} />
<KeyValueList path="/secrets/kv/list/:baseMount/:secretPath*?" state={pageState} />
<KeyValueView path="/secrets/kv/view/:item/:baseMount/:secretPath*?" state={pageState} />
<KeyValueEdit path="/secrets/kv/edit/:item/:baseMount/:secretPath*?" state={pageState} />
<KeyValueDelete path="/secrets/kv/delete/:item/:baseMount/:secretPath*?" state={pageState} />
<TOTPList path="/secrets/totp/list/:baseMount" state={pageState} />
<TOTPNew path="/secrets/totp/new/:baseMount" state={pageState} />
<TOTPDelete path="/secrets/totp/delete/:baseMount/:item" state={pageState} />
<TransitNew path="/secrets/transit/new/:baseMount" state={pageState} />
<TransitList path="/secrets/transit/list/:baseMount" state={pageState} />
<TransitView path="/secrets/transit/view/:baseMount/:secretItem" state={pageState} />
<TransitEncrypt path="/secrets/transit/encrypt/:baseMount/:secretItem" state={pageState} />
<TransitDecrypt path="/secrets/transit/decrypt/:baseMount/:secretItem" state={pageState} />
<TransitRewrap path="/secrets/transit/rewrap/:baseMount/:secretItem" state={pageState} />
<PoliciesHome path="/policies" state={pageState} />
<PolicyNew path="/policies/new" state={pageState} />
<PolicyView path="/policies/view/:policyName" state={pageState} />
<PolicyEdit path="/policies/edit/:policyName" state={pageState} />
<PolicyDelete path="/policies/delete/:policyName" state={pageState} />
<div default>
<p>PAGE NOT YET IMPLEMENTED</p>
</div>
</Router>
);

View file

@ -7,18 +7,7 @@ import i18next from "i18next";
// before rendering.
// Also it only runs when process.env.NODE_ENV == "development"
declare global {
interface Window {
pageState: PageState;
i18next: unknown;
router: PageRouter;
}
}
// Please empty this function before committing.
export async function playground(router: PageRouter): Promise<void> {
export async function playground(): Promise<void> {
console.log("Welcome to Playground!");
window.pageState = router.state as PageState;
window.i18next = i18next;
window.router = router;
}

View file

@ -1,7 +1,7 @@
import { CopyStateLinkButton } from "../ui/elements/CopyStateLinkButton";
import { render } from "preact";
import { PageRouter } from "../pagerouter/PageRouter";
import { PageState } from "../state/PageState";
import { render } from "preact";
import { CopyStateLinkButton } from "../ui/elements/CopyStateLinkButton";
export class Page {
constructor() {
@ -18,8 +18,8 @@ export class Page {
async renderPageTitle(): Promise<void> {
render(
<>
<span>{this.name}</span>
<CopyStateLinkButton state={this.state} />
<span>{this.name}</span>
<CopyStateLinkButton state={this.state} />
</>,
this.router.pageTitleElement,
);

View file

@ -1,7 +1,6 @@
import { Component, JSX, render } from "preact";
import { Grid, GridSizes } from "../elements/Grid";
import { Margin } from "../elements/Margin";
import { Page } from "../../types/Page";
import { PageState } from "../../state/PageState";
import { PageTitle } from "../elements/PageTitle";
import { Tile } from "../elements/Tile";

View file

@ -3,7 +3,6 @@ import { DefaultPageProps } from "../../types/DefaultPageProps";
import { Form } from "../elements/Form";
import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline";
import { Page } from "../../types/Page";
import { PageState } from "../../state/PageState";
import { PageTitle } from "../elements/PageTitle";
import { lookupSelf } from "../../api/sys/lookupSelf";

View file

@ -1,7 +1,7 @@
import { Component, JSX, createRef } from "preact";
import { DefaultPageProps } from "../../types/DefaultPageProps";
import { PageTitle } from "../elements/PageTitle";
import { addClipboardNotifications, prePageChecks, setErrorText } from "../../pageUtils";
import { addClipboardNotifications, setErrorText } from "../../pageUtils";
import { getCapsPath } from "../../api/sys/getCapabilities";
import { renewSelf } from "../../api/sys/renewSelf";
import { route } from "preact-router";

View file

@ -1,63 +1,62 @@
import { Margin } from "../../elements/Margin";
import { Page } from "../../../types/Page";
import { PageState } from "../../../state/PageState";
import { getPolicies } from "../../../api/sys/policies/getPolicies";
import { prePageChecks } from "../../../pageUtils";
import { render } from "preact";
import { Component } from "preact";
import i18next from "i18next";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { PageTitle } from "../../elements/PageTitle";
import { route } from "preact-router";
import { policyNewURL, policyViewURL } from "../pageLinks";
export class PoliciesHomePage extends Page {
constructor() {
super();
}
async goBack(): Promise<void> {
await this.router.changePage("HOME");
}
async render(): Promise<void> {
await this.router.setPageContent("");
if (!(await prePageChecks(this.router.state as PageState))) return;
export class PoliciesHome extends Component<DefaultPageProps, { policies: string[] }> {
async componentDidMount() {
if (!(await prePageChecks(this.props.state))) return;
let policies = await getPolicies();
policies = policies.sort();
policies = policies.filter(function (policy_name) {
return policy_name !== "root";
});
this.setState({
policies: policies
})
}
render(
<div>
<p>
<button
class="uk-button uk-button-primary"
onClick={async () => {
await this.router.changePage("POLICY_NEW");
}}
>
{i18next.t("policies_home_new_btn")}
</button>
</p>
render() {
if (!this.state.policies) return;
<Margin>
<ul class="uk-nav uk-nav-default">
{policies.map((policy: string) => (
<li>
<a
onClick={async () => {
this.state.policyItem = policy;
await this.router.changePage("POLICY_VIEW");
}}
>
{policy}
</a>
</li>
))}
</ul>
</Margin>
</div>,
this.router.pageContentElement,
return (
<>
<PageTitle title={i18next.t("policies_home_title")} />
<div>
<p>
<button
class="uk-button uk-button-primary"
onClick={async () => {
route(policyNewURL())
}}
>
{i18next.t("policies_home_new_btn")}
</button>
</p>
<Margin>
<ul class="uk-nav uk-nav-default">
{this.state.policies.map((policyName: string) => (
<li>
<a
onClick={async () => {
route(policyViewURL(policyName))
}}
>
{policyName}
</a>
</li>
))}
</ul>
</Margin>
</div>
</>
);
}
get name(): string {
return i18next.t("policies_home_title");
}
}

View file

@ -1,42 +1,35 @@
import { Page } from "../../../types/Page";
import { deletePolicy } from "../../../api/sys/policies/deletePolicy";
import { render } from "preact";
import { Component, render } from "preact";
import { setErrorText } from "../../../pageUtils";
import i18next from "i18next";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { PageTitle } from "../../elements/PageTitle";
import { route } from "preact-router";
export class PolicyDeletePage extends Page {
constructor() {
super();
}
async goBack(): Promise<void> {
await this.router.changePage("POLICY_VIEW");
}
async render(): Promise<void> {
render(
<div>
<h5>{i18next.t("policy_delete_text")}</h5>
<button
class="uk-button uk-button-danger"
onClick={async () => {
try {
await deletePolicy(this.state.policyItem);
await this.router.changePage("POLICIES_HOME");
} catch (e: unknown) {
const error = e as Error;
setErrorText(error.message);
}
}}
>
{i18next.t("policy_delete_btn")}
</button>
</div>,
this.router.pageContentElement,
export class PolicyDelete extends Component<DefaultPageProps> {
render() {
const policyName = this.props.matches["policyName"];
return (
<>
<PageTitle title={i18next.t("policy_delete_title", {policy: policyName})} />
<div>
<h5>{i18next.t("policy_delete_text")}</h5>
<button
class="uk-button uk-button-danger"
onClick={async () => {
try {
await deletePolicy(policyName);
route("/policies");
} catch (e: unknown) {
const error = e as Error;
setErrorText(error.message);
}
}}
>
{i18next.t("policy_delete_btn")}
</button>
</div>
</>
);
}
get name(): string {
return i18next.t("policy_delete_title", {
policy: this.state.policyItem,
});
}
}

View file

@ -7,21 +7,24 @@ import { createOrUpdatePolicy } from "../../../api/sys/policies/createOrUpdatePo
import { getPolicy } from "../../../api/sys/policies/getPolicy";
import { setErrorText } from "../../../pageUtils";
import i18next from "i18next";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { PageTitle } from "../../elements/PageTitle";
import { route } from "preact-router";
import { policyViewURL } from "../pageLinks";
type PolicyEditorProps = {
page: Page;
policy_name: string;
policyName: string;
};
type PolicyEditorState =
| {
dataLoaded: false;
}
dataLoaded: false;
}
| {
dataLoaded: true;
policyData: string;
code: string;
};
dataLoaded: true;
policyData: string;
code: string;
};
export class PolicyEditor extends Component<PolicyEditorProps, PolicyEditorState> {
constructor() {
@ -35,8 +38,8 @@ export class PolicyEditor extends Component<PolicyEditorProps, PolicyEditorState
if (!this.state.dataLoaded) return;
try {
await createOrUpdatePolicy(this.props.policy_name, this.state.code);
await this.props.page.router.changePage("POLICY_VIEW");
await createOrUpdatePolicy(this.props.policyName, this.state.code);
route(policyViewURL(this.props.policyName))
} catch (e: unknown) {
const error = e as Error;
setErrorText(error.message);
@ -50,7 +53,7 @@ export class PolicyEditor extends Component<PolicyEditorProps, PolicyEditorState
}
async loadData(): Promise<void> {
const policyData = await getPolicy(this.props.policy_name);
const policyData = await getPolicy(this.props.policyName);
this.setState({
dataLoaded: true,
policyData: policyData,
@ -91,25 +94,16 @@ export class PolicyEditor extends Component<PolicyEditorProps, PolicyEditorState
}
}
export class PolicyEditPage extends Page {
constructor() {
super();
}
async goBack(): Promise<void> {
await this.router.changePage("POLICY_VIEW");
}
async render(): Promise<void> {
render(
<div>
<PolicyEditor page={this} policy_name={this.state.policyItem} />
</div>,
this.router.pageContentElement,
export class PolicyEdit extends Component<DefaultPageProps> {
render() {
const policyName = this.props.matches["policyName"];
return (
<>
<PageTitle title={i18next.t("policy_edit_title", {policy: policyName})} />
<div>
<PolicyEditor policyName={policyName} />
</div>
</>
);
}
get name(): string {
return i18next.t("policy_edit_title", {
policy: this.state.policyItem,
});
}
}

View file

@ -1,59 +1,53 @@
import { Form } from "../../elements/Form";
import { Margin } from "../../elements/Margin";
import { Page } from "../../../types/Page";
import { createOrUpdatePolicy } from "../../../api/sys/policies/createOrUpdatePolicy";
import { getPolicies } from "../../../api/sys/policies/getPolicies";
import { render } from "preact";
import { Component } from "preact";
import { setErrorText } from "../../../pageUtils";
import i18next from "i18next";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { PageTitle } from "../../elements/PageTitle";
import { route } from "preact-router";
import { policyViewURL } from "../pageLinks";
export class PolicyNewPage extends Page {
constructor() {
super();
}
async goBack(): Promise<void> {
await this.router.changePage("POLICIES_HOME");
}
async render(): Promise<void> {
render(
<div>
<Form
onSubmit={async (formData) => {
const name = formData.get("name") as string;
if ((await getPolicies()).includes(name)) {
setErrorText(i18next.t("policy_new_already_exists"));
return;
}
export class PolicyNew extends Component<DefaultPageProps> {
render() {
return (
<>
<PageTitle title={i18next.t("policy_new_title")} />
<div>
<Form
onSubmit={async (formData) => {
const name = formData.get("name") as string;
if ((await getPolicies()).includes(name)) {
setErrorText(i18next.t("policy_new_already_exists"));
return;
}
try {
await createOrUpdatePolicy(name, " ");
this.state.policyItem = name;
await this.router.changePage("POLICY_VIEW");
} catch (e: unknown) {
const error = e as Error;
setErrorText(error.message);
}
}}
>
<Margin>
<input
class="uk-input uk-form-width-medium"
name="name"
placeholder={i18next.t("policy_new_name_placeholder")}
required
/>
</Margin>
<p class="uk-text-danger" id="errorText" />
<button class="uk-button uk-button-primary" type="submit">
{i18next.t("policy_new_create_btn")}
</button>
</Form>
</div>,
this.router.pageContentElement,
try {
await createOrUpdatePolicy(name, " ");
route(policyViewURL(name));
} catch (e: unknown) {
const error = e as Error;
setErrorText(error.message);
}
}}
>
<Margin>
<input
class="uk-input uk-form-width-medium"
name="name"
placeholder={i18next.t("policy_new_name_placeholder")}
required
/>
</Margin>
<p class="uk-text-danger" id="errorText" />
<button class="uk-button uk-button-primary" type="submit">
{i18next.t("policy_new_create_btn")}
</button>
</Form>
</div>
</>
);
}
get name(): string {
return i18next.t("policy_new_title");
}
}

View file

@ -1,41 +1,45 @@
import { CodeBlock } from "../../elements/CodeBlock";
import { Margin } from "../../elements/Margin";
import { Page } from "../../../types/Page";
import { PageState } from "../../../state/PageState";
import { getPolicy } from "../../../api/sys/policies/getPolicy";
import { prePageChecks } from "../../../pageUtils";
import { render } from "preact";
import { Component } from "preact";
import i18next from "i18next";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { PageTitle } from "../../elements/PageTitle";
import { route } from "preact-router";
import { policyDeleteURL, policyEditURL } from "../pageLinks";
export class PolicyViewPage extends Page {
constructor() {
super();
export class PolicyView extends Component<DefaultPageProps, {policy: string, policyName: string}> {
async componentDidMount() {
if (!(await prePageChecks(this.props.state))) return;
console.log(this.props)
const policyName = this.props.matches["policyName"];
const policy = await getPolicy(policyName);
this.setState({
policy, policyName
})
}
async goBack(): Promise<void> {
await this.router.changePage("POLICIES_HOME");
}
async render(): Promise<void> {
await this.router.setPageContent("");
if (!(await prePageChecks(this.router.state as PageState))) return;
const policy = await getPolicy(this.state.policyItem);
render(
render() {
if (!this.state.policy) return;
return (
<>
<PageTitle title={i18next.t("policy_view_title", {policy: this.state.policyName})} />
<div>
<p>
<button
class="uk-button uk-button-primary"
onClick={async () => {
await this.router.changePage("POLICY_EDIT");
route(policyEditURL(this.state.policyName));
}}
>
{i18next.t("policy_view_edit_btn")}
</button>
{this.state.policyItem !== "default" && (
{this.state.policyName !== "default" && (
<button
class="uk-button uk-button-danger"
onClick={async () => {
await this.router.changePage("POLICY_DELETE");
route(policyDeleteURL(this.state.policyName));
}}
>
{i18next.t("policy_view_delete_btn")}
@ -44,16 +48,10 @@ export class PolicyViewPage extends Page {
</p>
<Margin>
<CodeBlock language="hcl" code={policy} />
<CodeBlock language="hcl" code={this.state.policy} />
</Margin>
</div>,
this.router.pageContentElement,
</div>
</>
);
}
get name(): string {
return i18next.t("policy_view_title", {
policy: this.state.policyItem,
});
}
}

View file

@ -2,7 +2,6 @@ import { Component, render } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { Form } from "../../elements/Form";
import { MarginInline } from "../../elements/MarginInline";
import { Page } from "../../../types/Page";
import { PageTitle } from "../../elements/PageTitle";
import { deleteMount } from "../../../api/sys/deleteMount";
import { route } from "preact-router";

View file

@ -1,6 +1,5 @@
import { Component, render } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { Page } from "../../../../types/Page";
import { SecretTitleElement } from "../SecretTitleElement";
import { deleteSecret } from "../../../../api/kv/deleteSecret";
import i18next from "i18next";

View file

@ -1,7 +1,6 @@
import { CodeEditor } from "../../../elements/CodeEditor";
import { Component, JSX, render } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { Page } from "../../../../types/Page";
import { SecretTitleElement } from "../SecretTitleElement";
import { createOrUpdateSecret } from "../../../../api/kv/createOrUpdateSecret";
import { getSecret } from "../../../../api/kv/getSecret";

View file

@ -2,7 +2,6 @@ import { CapabilitiesType, getCapabilitiesPath } from "../../../../api/sys/getCa
import { Component, JSX, createRef, render } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { DoesNotExistError } from "../../../../types/internalErrors";
import { Page } from "../../../../types/Page";
import { SecretTitleElement } from "../SecretTitleElement";
import { delSecretsEngineURL, kvListURL, kvNewURL, kvViewURL } from "../../pageLinks";
import { getMount } from "../../../../api/sys/getMounts";

View file

@ -2,7 +2,6 @@ import { Component, render } from "preact";
import { Form } from "../../../elements/Form";
import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline";
import { Page } from "../../../../types/Page";
import { PageTitle } from "../../../elements/PageTitle";
import { kvListURL } from "../../pageLinks";
import { newMount } from "../../../../api/sys/newMount";

View file

@ -2,7 +2,6 @@ import { Component, render } from "preact";
import { Form } from "../../../elements/Form";
import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline";
import { Page } from "../../../../types/Page";
import { PageTitle } from "../../../elements/PageTitle";
import { newMount } from "../../../../api/sys/newMount";
import { route } from "preact-router";

View file

@ -2,7 +2,6 @@ import { Component, render } from "preact";
import { Form } from "../../../elements/Form";
import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline";
import { Page } from "../../../../types/Page";
import { PageTitle } from "../../../elements/PageTitle";
import { newMount } from "../../../../api/sys/newMount";
import { route } from "preact-router";

View file

@ -1,6 +1,5 @@
import { Component, render } from "preact";
import { Grid, GridSizes } from "../../elements/Grid";
import { Page } from "../../../types/Page";
import { PageTitle } from "../../elements/PageTitle";
import { Tile } from "../../elements/Tile";
import { route } from "preact-router";

View file

@ -1,7 +1,6 @@
import { Component, JSX, render } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { MountType, getMounts } from "../../../api/sys/getMounts";
import { Page } from "../../../types/Page";
import { PageState } from "../../../state/PageState";
import { PageTitle } from "../../elements/PageTitle";
import { getCapsPath } from "../../../api/sys/getCapabilities";

View file

@ -1,6 +1,5 @@
import { Component, render } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { Page } from "../../../../types/Page";
import { SecretTitleElement } from "../SecretTitleElement";
import { deleteTOTP } from "../../../../api/totp/deleteTOTP";
import { route } from "preact-router";

View file

@ -3,7 +3,6 @@ import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { Form } from "../../../elements/Form";
import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline";
import { Page } from "../../../../types/Page";
import { QRScanner } from "../../../elements/QRScanner";
import { SecretTitleElement } from "../SecretTitleElement";
import { addNewTOTP } from "../../../../api/totp/addNewTOTP";

View file

@ -67,4 +67,20 @@ export function transitRewrapSecretURL(baseMount: string, secret: string): strin
return `/secrets/transit/rewrap/${baseMount}/${secret}`;
}
//
// Policies
export function policyNewURL(): string {
return `/policies/new`;
}
export function policyViewURL(policyName: string): string {
return `/policies/view/${policyName}`;
}
export function policyEditURL(policyName: string): string {
return `/policies/edit/${policyName}`;
}
export function policyDeleteURL(policyName: string): string {
return `/policies/delete/${policyName}`;
}