From ec3ebe335660a8d0ceea2c19e0e16a720f6e9d69 Mon Sep 17 00:00:00 2001 From: Kitteh Date: Tue, 18 May 2021 11:28:05 +0100 Subject: [PATCH] Add access home page. --- src/allPages.ts | 3 ++ src/pages/Access/AccessHome.ts | 70 ++++++++++++++++++++++++++++++++++ src/pages/Home.ts | 10 ++++- src/translations/en.js | 14 +++++++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/pages/Access/AccessHome.ts diff --git a/src/allPages.ts b/src/allPages.ts index 06b2923..27d1994 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -26,6 +26,8 @@ import { TransitViewPage } from "./pages/Secrets/Transit/TransitView"; import { TransitViewSecretPage } from "./pages/Secrets/Transit/TransitViewSecret"; import { UnsealPage } from "./pages/Unseal"; import { getObjectKeys } from "./utils"; +import { AccessHomePage } from "./pages/Access/AccessHome"; + /* eslint-disable */ import { PageType } from "z-pagerouter"; @@ -38,6 +40,7 @@ type pagesList = { export const allPages: pagesList = { HOME: new HomePage(), SECRETS_HOME: new SecretsHomePage(), + ACCESS_HOME: new AccessHomePage(), ME: new MePage(), TOTP: new TOTPViewPage(), NEW_TOTP: new NewTOTPPage(), diff --git a/src/pages/Access/AccessHome.ts b/src/pages/Access/AccessHome.ts new file mode 100644 index 0000000..398ff0c --- /dev/null +++ b/src/pages/Access/AccessHome.ts @@ -0,0 +1,70 @@ +import { MountType, getMounts } from "../../api/sys/getMounts"; +import { Page } from "../../types/Page"; +import { getCapabilitiesPath } from "../../api/sys/getCapabilities"; +import { makeElement } from "z-makeelement"; +import { prePageChecks, setErrorText } from "../../pageUtils"; +import { sortedObjectMap } from "../../utils"; +import i18next from "i18next"; +import { Tile } from "../../elements/Tile"; + +export class AccessHomePage extends Page { + constructor() { + super(); + } + async goBack(): Promise { + await this.router.changePage("HOME"); + } + async render(): Promise { + await this.router.setPageContent(""); + if (!(await prePageChecks(this.router))) return; + + this.router.setPageContent( + makeElement({ + tag: "div", + class: "uk-child-width-1-1@s uk-child-width-1-2@m uk-grid-small uk-grid-match", + attributes: { "uk-grid": "" }, + children: [ + Tile({ + title: i18next.t("access_auth_methods_title"), + description: i18next.t("access_auth_methods_description"), + icon: "sign-in", + onclick: async () => { + setErrorText(i18next.t("not_implemented")); + //await this.router.changePage("SECRETS_HOME"); + }, + }), + Tile({ + title: i18next.t("access_entities_title"), + description: i18next.t("access_entities_description"), + icon: "user", + onclick: async () => { + setErrorText(i18next.t("not_implemented")); + //await this.router.changePage("SECRETS_HOME"); + }, + }), + Tile({ + title: i18next.t("access_groups_title"), + description: i18next.t("access_groups_description"), + icon: "users", + onclick: async () => { + setErrorText(i18next.t("not_implemented")); + //await this.router.changePage("SECRETS_HOME"); + }, + }), + Tile({ + title: i18next.t("access_leases_title"), + description: i18next.t("access_leases_description"), + icon: "unlock", + onclick: async () => { + setErrorText(i18next.t("not_implemented")); + //await this.router.changePage("SECRETS_HOME"); + }, + }), + ], + }), + ); + } + get name(): string { + return i18next.t("access_home_page_title"); + } +} diff --git a/src/pages/Home.ts b/src/pages/Home.ts index f1734c6..b6cb06d 100644 --- a/src/pages/Home.ts +++ b/src/pages/Home.ts @@ -59,7 +59,7 @@ export class HomePage extends Page { } } - textList.appendChild( + homePageContent.appendChild( makeElement({ tag: "div", class: @@ -74,6 +74,14 @@ export class HomePage extends Page { await this.router.changePage("SECRETS_HOME"); }, }), + Tile({ + title: i18next.t("home_access_title"), + description: i18next.t("home_access_description"), + icon: "users", + onclick: async () => { + await this.router.changePage("ACCESS_HOME"); + }, + }), ], }), ); diff --git a/src/translations/en.js b/src/translations/en.js index a05a388..9123856 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -12,6 +12,7 @@ module.exports = { // General Notification Messages notification_copy_success: "Copied to clipboard.", + not_implemented: "Not Yet Implemented", // Copyable Modal copy_modal_download_btn: "Download", @@ -39,6 +40,8 @@ module.exports = { home_your_token_expires_in: "Your token expires in {{date, until_date}}", home_secrets_title: "Secrets", home_secrets_description: "View, create and manage secrets.", + home_access_title: "Access", + home_access_description: "Manage who and what has access to vault and how they can authenticate.", // Secrets Home Page secrets_home_page_title: "Secrets", @@ -203,4 +206,15 @@ module.exports = { transit_rewrap_input_placeholder: "Cyphertext", transit_rewrap_rewrap_btn: "Rewrap", transit_rewrap_result_modal_title: "Rewrap Result", + + // Access Home + access_home_page_title: "Access", + access_auth_methods_title: "Authentication Methods", + access_auth_methods_description: "View and manage the allowed authentication methods.", + access_entities_title: "Entities", + access_entities_description: "View and manage who and what can access the vault.", + access_groups_title: "Groups", + access_groups_description: "View and manage groups of entities.", + access_leases_title: "Leases", + access_leases_description: "View and manage the leases of entities.", };