static: add multiple active paths to sidebar
This commit is contained in:
parent
81a2c3992a
commit
7efed56acc
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,4 @@
|
||||||
export class Application {
|
export class Application {
|
||||||
|
|
||||||
pk: string;
|
pk: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
|
@ -13,8 +12,7 @@ export class Application {
|
||||||
|
|
||||||
static get(slug: string): Promise<Application> {
|
static get(slug: string): Promise<Application> {
|
||||||
return fetch(`/api/v2beta/core/applications/${slug}/`)
|
return fetch(`/api/v2beta/core/applications/${slug}/`)
|
||||||
.then(r => r.json())
|
.then((r) => r.json())
|
||||||
.then(r => <Application>r);
|
.then((r) => <Application>r);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
export class NotFoundError extends Error {
|
export class NotFoundError extends Error {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { me, User } from "../api/user";
|
||||||
|
|
||||||
export interface SidebarItem {
|
export interface SidebarItem {
|
||||||
name: string;
|
name: string;
|
||||||
path?: string;
|
path?: string[];
|
||||||
children?: SidebarItem[];
|
children?: SidebarItem[];
|
||||||
condition?: (sb: Sidebar) => boolean;
|
condition?: (sb: Sidebar) => boolean;
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@ export interface SidebarItem {
|
||||||
export const SIDEBAR_ITEMS: SidebarItem[] = [
|
export const SIDEBAR_ITEMS: SidebarItem[] = [
|
||||||
{
|
{
|
||||||
name: "Library",
|
name: "Library",
|
||||||
path: "/-/overview/",
|
path: ["/-/overview/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Monitor",
|
name: "Monitor",
|
||||||
path: "/audit/audit/",
|
path: ["/audit/audit/"],
|
||||||
condition: (sb: Sidebar) => {
|
condition: (sb: Sidebar) => {
|
||||||
return sb.user?.is_superuser!;
|
return sb.user?.is_superuser!;
|
||||||
},
|
},
|
||||||
|
@ -42,36 +42,36 @@ export const SIDEBAR_ITEMS: SidebarItem[] = [
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: "Overview",
|
name: "Overview",
|
||||||
path: "/administration/overview/",
|
path: ["/administration/overview/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "System Tasks",
|
name: "System Tasks",
|
||||||
path: "/administration/tasks/",
|
path: ["/administration/tasks/"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Applications",
|
name: "Applications",
|
||||||
path: "/administration/applications/",
|
path: ["/administration/applications/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Sources",
|
name: "Sources",
|
||||||
path: "/administration/sources/",
|
path: ["/administration/sources/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Providers",
|
name: "Providers",
|
||||||
path: "/administration/providers/",
|
path: ["/administration/providers/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "User Management",
|
name: "User Management",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: "User",
|
name: "User",
|
||||||
path: "/administration/users/",
|
path: ["/administration/users/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Groups",
|
name: "Groups",
|
||||||
path: "/administration/groups/",
|
path: ["/administration/groups/"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -80,50 +80,50 @@ export const SIDEBAR_ITEMS: SidebarItem[] = [
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: "Outposts",
|
name: "Outposts",
|
||||||
path: "/administration/outposts/",
|
path: ["/administration/outposts/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Service Connections",
|
name: "Service Connections",
|
||||||
path: "/administration/outposts/service_connections/",
|
path: ["/administration/outposts/service_connections/"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Policies",
|
name: "Policies",
|
||||||
path: "/administration/policies/",
|
path: ["/administration/policies/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Property Mappings",
|
name: "Property Mappings",
|
||||||
path: "/administration/property-mappings/",
|
path: ["/administration/property-mappings/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Flows",
|
name: "Flows",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: "Flows",
|
name: "Flows",
|
||||||
path: "/administration/flows/",
|
path: ["/administration/flows/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Stages",
|
name: "Stages",
|
||||||
path: "/administration/stages/",
|
path: ["/administration/stages/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Prompts",
|
name: "Prompts",
|
||||||
path: "/administration/stages/prompts/",
|
path: ["/administration/stages/prompts/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invitations",
|
name: "Invitations",
|
||||||
path: "/administration/stages/invitations/",
|
path: ["/administration/stages/invitations/"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Certificates",
|
name: "Certificates",
|
||||||
path: "/administration/crypto/certificates/",
|
path: ["/administration/crypto/certificates/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Tokens",
|
name: "Tokens",
|
||||||
path: "/administration/tokens/",
|
path: ["/administration/tokens/"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
condition: (sb: Sidebar) => {
|
condition: (sb: Sidebar) => {
|
||||||
|
@ -188,7 +188,9 @@ export class Sidebar extends LitElement {
|
||||||
${item.path
|
${item.path
|
||||||
? html`<a
|
? html`<a
|
||||||
href="#${item.path}"
|
href="#${item.path}"
|
||||||
class="pf-c-nav__link ${item.path === this.activePath
|
class="pf-c-nav__link ${item.path.some(
|
||||||
|
(v) => v === this.activePath
|
||||||
|
)
|
||||||
? "pf-m-current"
|
? "pf-m-current"
|
||||||
: ""}"
|
: ""}"
|
||||||
>
|
>
|
||||||
|
|
|
@ -17,7 +17,7 @@ export class Route {
|
||||||
url: RegExp;
|
url: RegExp;
|
||||||
|
|
||||||
private element?: TemplateResult;
|
private element?: TemplateResult;
|
||||||
private callback?: (args: { [key: string]: string; }) => TemplateResult;
|
private callback?: (args: { [key: string]: string }) => TemplateResult;
|
||||||
|
|
||||||
constructor(url: RegExp, element?: TemplateResult) {
|
constructor(url: RegExp, element?: TemplateResult) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
@ -33,12 +33,12 @@ export class Route {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
then(render: (args: { [key: string]: string; }) => TemplateResult): Route {
|
then(render: (args: { [key: string]: string }) => TemplateResult): Route {
|
||||||
this.callback = render;
|
this.callback = render;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
render(args: { [key: string]: string; }): TemplateResult {
|
render(args: { [key: string]: string }): TemplateResult {
|
||||||
if (this.callback) {
|
if (this.callback) {
|
||||||
return this.callback(args);
|
return this.callback(args);
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,13 @@ export const ROUTES: Route[] = [
|
||||||
// Prevent infinite Shell loops
|
// Prevent infinite Shell loops
|
||||||
new Route(new RegExp(`^/$`)).redirect("/-/overview/"),
|
new Route(new RegExp(`^/$`)).redirect("/-/overview/"),
|
||||||
new Route(new RegExp(`^/applications/$`), html`<h1>test</h1>`),
|
new Route(new RegExp(`^/applications/$`), html`<h1>test</h1>`),
|
||||||
new Route(new RegExp(`^/applications/(?<slug>${SLUG_REGEX})/$`)).then((args) => {
|
new Route(new RegExp(`^/applications/(?<slug>${SLUG_REGEX})/$`)).then(
|
||||||
return html`<pb-application-view .args=${args}></pb-application-view>`;
|
(args) => {
|
||||||
}),
|
return html`<pb-application-view
|
||||||
|
.args=${args}
|
||||||
|
></pb-application-view>`;
|
||||||
|
}
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
class RouteMatch {
|
class RouteMatch {
|
||||||
|
@ -112,7 +116,7 @@ export class RouterOutlet extends LitElement {
|
||||||
}
|
}
|
||||||
let matchedRoute: RouteMatch | null = null;
|
let matchedRoute: RouteMatch | null = null;
|
||||||
ROUTES.forEach((route) => {
|
ROUTES.forEach((route) => {
|
||||||
console.log(`matching ${activeUrl} against ${route.url}`);
|
console.debug(`passbook/router: matching ${activeUrl} against ${route.url}`);
|
||||||
const match = route.url.exec(activeUrl);
|
const match = route.url.exec(activeUrl);
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
matchedRoute = new RouteMatch(route);
|
matchedRoute = new RouteMatch(route);
|
||||||
|
@ -122,7 +126,7 @@ export class RouterOutlet extends LitElement {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!matchedRoute) {
|
if (!matchedRoute) {
|
||||||
console.log(
|
console.debug(
|
||||||
`passbook/router: route "${activeUrl}" not defined, defaulting to shell`
|
`passbook/router: route "${activeUrl}" not defined, defaulting to shell`
|
||||||
);
|
);
|
||||||
const route = new Route(
|
const route = new Route(
|
||||||
|
|
|
@ -5,13 +5,13 @@ import { COMMON_STYLES } from "../../common/styles";
|
||||||
@customElement("pb-application-view")
|
@customElement("pb-application-view")
|
||||||
export class ApplicationViewPage extends LitElement {
|
export class ApplicationViewPage extends LitElement {
|
||||||
@property()
|
@property()
|
||||||
set args(value: { [key: string]: string; }) {
|
set args(value: { [key: string]: string }) {
|
||||||
this.applicationSlug = value.slug;
|
this.applicationSlug = value.slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
set applicationSlug(value: string) {
|
set applicationSlug(value: string) {
|
||||||
Application.get(value).then(app => this.application = app);
|
Application.get(value).then((app) => (this.application = app));
|
||||||
}
|
}
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
|
@ -28,7 +28,11 @@ export class ApplicationViewPage extends LitElement {
|
||||||
<i class="pf-icon pf-icon-applications"></i>
|
<i class="pf-icon pf-icon-applications"></i>
|
||||||
${this.application?.name}
|
${this.application?.name}
|
||||||
</h1>
|
</h1>
|
||||||
<p>External Applications which use passbook as Identity-Provider, utilizing protocols like OAuth2 and SAML.</p>
|
<p>
|
||||||
|
External Applications which use passbook as
|
||||||
|
Identity-Provider, utilizing protocols like OAuth2 and
|
||||||
|
SAML.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="pf-c-page__main-section pf-m-no-padding-mobile">
|
<section class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
|
@ -43,5 +47,4 @@ export class ApplicationViewPage extends LitElement {
|
||||||
</div>
|
</div>
|
||||||
</section>`;
|
</section>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue