diff --git a/src/main.tsx b/src/main.tsx index a08196e..4997a22 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -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 { - const Main = () => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

PAGE NOT YET IMPLEMENTED

-
-
- ); + document.documentElement.dir = pageState.pageDirection; render( <> @@ -115,22 +48,8 @@ async function onLoad(): Promise { 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); diff --git a/src/pages.tsx b/src/pages.tsx new file mode 100644 index 0000000..f9827f6 --- /dev/null +++ b/src/pages.tsx @@ -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 = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

PAGE NOT YET IMPLEMENTED

+
+
+ ); \ No newline at end of file diff --git a/src/playground.tsx b/src/playground.tsx index 38ca770..761b31a 100644 --- a/src/playground.tsx +++ b/src/playground.tsx @@ -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 { +export async function playground(): Promise { console.log("Welcome to Playground!"); - window.pageState = router.state as PageState; - window.i18next = i18next; - window.router = router; } diff --git a/src/types/Page.tsx b/src/types/Page.tsx index f248eae..5c6338c 100644 --- a/src/types/Page.tsx +++ b/src/types/Page.tsx @@ -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 { render( <> - {this.name} - + {this.name} + , this.router.pageTitleElement, ); @@ -34,4 +34,4 @@ export class Page { this.router = router; this.state = state; } -} +} \ No newline at end of file diff --git a/src/ui/pages/Home.tsx b/src/ui/pages/Home.tsx index 73b66b9..a250a41 100644 --- a/src/ui/pages/Home.tsx +++ b/src/ui/pages/Home.tsx @@ -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"; diff --git a/src/ui/pages/Login.tsx b/src/ui/pages/Login.tsx index dfdeedc..b486b0f 100644 --- a/src/ui/pages/Login.tsx +++ b/src/ui/pages/Login.tsx @@ -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"; diff --git a/src/ui/pages/Me.tsx b/src/ui/pages/Me.tsx index 86680fd..df180f4 100644 --- a/src/ui/pages/Me.tsx +++ b/src/ui/pages/Me.tsx @@ -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"; diff --git a/src/ui/pages/Policies/PoliciesHome.tsx b/src/ui/pages/Policies/PoliciesHome.tsx index 4e2dbd6..3a83482 100644 --- a/src/ui/pages/Policies/PoliciesHome.tsx +++ b/src/ui/pages/Policies/PoliciesHome.tsx @@ -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 { - await this.router.changePage("HOME"); - } - async render(): Promise { - await this.router.setPageContent(""); - if (!(await prePageChecks(this.router.state as PageState))) return; +export class PoliciesHome extends Component { + 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( -
-

- -

+ render() { + if (!this.state.policies) return; - - - -
, - this.router.pageContentElement, + return ( + <> + +
+

+ +

+ + + + +
+ ); } - - get name(): string { - return i18next.t("policies_home_title"); - } } diff --git a/src/ui/pages/Policies/PolicyDelete.tsx b/src/ui/pages/Policies/PolicyDelete.tsx index f7683b3..f1e0627 100644 --- a/src/ui/pages/Policies/PolicyDelete.tsx +++ b/src/ui/pages/Policies/PolicyDelete.tsx @@ -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 { - await this.router.changePage("POLICY_VIEW"); - } - async render(): Promise { - render( -
-
{i18next.t("policy_delete_text")}
- -
, - this.router.pageContentElement, +export class PolicyDelete extends Component { + render() { + const policyName = this.props.matches["policyName"]; + return ( + <> + +
+
{i18next.t("policy_delete_text")}
+ +
+ ); } - - get name(): string { - return i18next.t("policy_delete_title", { - policy: this.state.policyItem, - }); - } } diff --git a/src/ui/pages/Policies/PolicyEdit.tsx b/src/ui/pages/Policies/PolicyEdit.tsx index 0e42246..bc59fa7 100644 --- a/src/ui/pages/Policies/PolicyEdit.tsx +++ b/src/ui/pages/Policies/PolicyEdit.tsx @@ -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 { constructor() { @@ -35,8 +38,8 @@ export class PolicyEditor extends Component { - 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 { - await this.router.changePage("POLICY_VIEW"); - } - async render(): Promise { - render( -
- -
, - this.router.pageContentElement, +export class PolicyEdit extends Component { + render() { + const policyName = this.props.matches["policyName"]; + return ( + <> + +
+ +
+ ); } - - get name(): string { - return i18next.t("policy_edit_title", { - policy: this.state.policyItem, - }); - } } diff --git a/src/ui/pages/Policies/PolicyNew.tsx b/src/ui/pages/Policies/PolicyNew.tsx index 4dc3289..49acd54 100644 --- a/src/ui/pages/Policies/PolicyNew.tsx +++ b/src/ui/pages/Policies/PolicyNew.tsx @@ -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 { - await this.router.changePage("POLICIES_HOME"); - } - async render(): Promise { - render( -
-
{ - 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 { + render() { + return ( + <> + +
+ { + 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); - } - }} - > - - - -

- -

-
, - this.router.pageContentElement, + try { + await createOrUpdatePolicy(name, " "); + route(policyViewURL(name)); + } catch (e: unknown) { + const error = e as Error; + setErrorText(error.message); + } + }} + > + + + +

+ + +

+ ); } - - get name(): string { - return i18next.t("policy_new_title"); - } } diff --git a/src/ui/pages/Policies/PolicyView.tsx b/src/ui/pages/Policies/PolicyView.tsx index bdd77d2..ce1d135 100644 --- a/src/ui/pages/Policies/PolicyView.tsx +++ b/src/ui/pages/Policies/PolicyView.tsx @@ -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 { + 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 { - await this.router.changePage("POLICIES_HOME"); - } - async render(): Promise { - 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 ( + <> +

- {this.state.policyItem !== "default" && ( + {this.state.policyName !== "default" && (

, - this.router.pageContentElement, + + ); } - - get name(): string { - return i18next.t("policy_view_title", { - policy: this.state.policyItem, - }); - } } diff --git a/src/ui/pages/Secrets/DeleteSecretsEngine.tsx b/src/ui/pages/Secrets/DeleteSecretsEngine.tsx index 9f17e5e..93954c8 100644 --- a/src/ui/pages/Secrets/DeleteSecretsEngine.tsx +++ b/src/ui/pages/Secrets/DeleteSecretsEngine.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/KeyValue/KeyValueDelete.tsx b/src/ui/pages/Secrets/KeyValue/KeyValueDelete.tsx index 9df08fc..d48be02 100644 --- a/src/ui/pages/Secrets/KeyValue/KeyValueDelete.tsx +++ b/src/ui/pages/Secrets/KeyValue/KeyValueDelete.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/KeyValue/KeyValueEdit.tsx b/src/ui/pages/Secrets/KeyValue/KeyValueEdit.tsx index 6303b32..69fbf9a 100644 --- a/src/ui/pages/Secrets/KeyValue/KeyValueEdit.tsx +++ b/src/ui/pages/Secrets/KeyValue/KeyValueEdit.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/KeyValue/KeyValueList.tsx b/src/ui/pages/Secrets/KeyValue/KeyValueList.tsx index 5dd41bd..8d0ccef 100644 --- a/src/ui/pages/Secrets/KeyValue/KeyValueList.tsx +++ b/src/ui/pages/Secrets/KeyValue/KeyValueList.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/NewEngines/NewKVEngine.tsx b/src/ui/pages/Secrets/NewEngines/NewKVEngine.tsx index cfeb622..c68c1df 100644 --- a/src/ui/pages/Secrets/NewEngines/NewKVEngine.tsx +++ b/src/ui/pages/Secrets/NewEngines/NewKVEngine.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/NewEngines/NewTOTPEngine.tsx b/src/ui/pages/Secrets/NewEngines/NewTOTPEngine.tsx index 7c5032a..65fca88 100644 --- a/src/ui/pages/Secrets/NewEngines/NewTOTPEngine.tsx +++ b/src/ui/pages/Secrets/NewEngines/NewTOTPEngine.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/NewEngines/NewTransitEngine.tsx b/src/ui/pages/Secrets/NewEngines/NewTransitEngine.tsx index 6ad9a58..37a98c9 100644 --- a/src/ui/pages/Secrets/NewEngines/NewTransitEngine.tsx +++ b/src/ui/pages/Secrets/NewEngines/NewTransitEngine.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/NewSecretsEngine.tsx b/src/ui/pages/Secrets/NewSecretsEngine.tsx index da8b985..ee5297a 100644 --- a/src/ui/pages/Secrets/NewSecretsEngine.tsx +++ b/src/ui/pages/Secrets/NewSecretsEngine.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/SecretsHome.tsx b/src/ui/pages/Secrets/SecretsHome.tsx index a0fc0e8..deaffa0 100644 --- a/src/ui/pages/Secrets/SecretsHome.tsx +++ b/src/ui/pages/Secrets/SecretsHome.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/TOTP/TOTPDelete.tsx b/src/ui/pages/Secrets/TOTP/TOTPDelete.tsx index 5b54ef9..c2b2b6e 100644 --- a/src/ui/pages/Secrets/TOTP/TOTPDelete.tsx +++ b/src/ui/pages/Secrets/TOTP/TOTPDelete.tsx @@ -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"; diff --git a/src/ui/pages/Secrets/TOTP/TOTPNew.tsx b/src/ui/pages/Secrets/TOTP/TOTPNew.tsx index c611eed..0b50657 100644 --- a/src/ui/pages/Secrets/TOTP/TOTPNew.tsx +++ b/src/ui/pages/Secrets/TOTP/TOTPNew.tsx @@ -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"; diff --git a/src/ui/pages/pageLinks.tsx b/src/ui/pages/pageLinks.tsx index 19d2480..c40919d 100644 --- a/src/ui/pages/pageLinks.tsx +++ b/src/ui/pages/pageLinks.tsx @@ -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}`; +} \ No newline at end of file