Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions web/src/admin/blueprints/BlueprintListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "#elements/forms/DeleteBulkForm";
import "#elements/forms/ModalForm";
import "#elements/tasks/TaskList";
import "@patternfly/elements/pf-tooltip/pf-tooltip.js";
import "#elements/ak-mdx/ak-mdx";

import { DEFAULT_CONFIG } from "#common/api/config";
import { EVENT_REFRESH } from "#common/constants";
Expand Down Expand Up @@ -44,6 +45,16 @@ export function BlueprintStatus(blueprint?: BlueprintInstance): string {
return msg("Unknown");
}

const BlueprintDescriptionProperty = "blueprints.goauthentik.io/description";

export function formatBlueprintDescription(item: BlueprintInstance): string | null {
const { labels = {} } = (item.metadata || {}) as {
labels?: Record<string, string | undefined>;
};

return labels[BlueprintDescriptionProperty] || null;
}

@customElement("ak-blueprint-list")
export class BlueprintListPage extends TablePage<BlueprintInstance> {
protected override searchEnabled = true;
Expand Down Expand Up @@ -133,18 +144,13 @@ export class BlueprintListPage extends TablePage<BlueprintInstance> {
}

row(item: BlueprintInstance): SlottedTemplateResult[] {
let description = undefined;
const descKey = "blueprints.goauthentik.io/description";
if (
item.metadata &&
item.metadata.labels &&
Object.hasOwn(item.metadata?.labels, descKey)
) {
description = item.metadata?.labels[descKey];
}
const description = formatBlueprintDescription(item);

return [
html`<div>${item.name}</div>
${description ? html`<small>${description}</small>` : nothing}`,
${description
? html`<small><ak-mdx .content=${description}></ak-mdx></small>`
: nothing}`,
html`${BlueprintStatus(item)}`,
Timestamp(item.lastApplied),
html`<ak-status-label ?good=${item.enabled}></ak-status-label>`,
Expand Down
7 changes: 5 additions & 2 deletions web/src/admin/groups/GroupViewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "#elements/Tabs";
import "#elements/buttons/ActionButton/index";
import "#elements/buttons/SpinnerButton/index";
import "#elements/forms/ModalForm";
import "#elements/ak-mdx/ak-mdx";

import { DEFAULT_CONFIG } from "#common/api/config";
import { EVENT_REFRESH } from "#common/constants";
Expand Down Expand Up @@ -159,8 +160,10 @@ export class GroupViewPage extends AKElement {
>
<div class="pf-c-card__title">${msg("Notes")}</div>
<div class="pf-c-card__body">
${Object.hasOwn(this.group?.attributes || {}, "notes")
? html`${this.group.attributes?.notes}`
${this.group?.attributes?.notes
? html`<ak-mdx
.content=${this.group.attributes.notes}
></ak-mdx>`
: html`
<p>
${msg(
Expand Down
5 changes: 3 additions & 2 deletions web/src/admin/users/UserViewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import "#elements/user/UserConsentList";
import "#elements/user/UserReputationList";
import "#elements/user/sources/SourceSettings";
import "./UserDevicesTable.js";
import "#elements/ak-mdx/ak-mdx";

import { DEFAULT_CONFIG } from "#common/api/config";
import { EVENT_REFRESH } from "#common/constants";
Expand Down Expand Up @@ -420,8 +421,8 @@ export class UserViewPage extends WithCapabilitiesConfig(AKElement) {
>
<div class="pf-c-card__title">${msg("Notes")}</div>
<div class="pf-c-card__body">
${Object.hasOwn(this.user?.attributes || {}, "notes")
? html`${this.user.attributes?.notes}`
${this.user?.attributes?.notes
? html`<ak-mdx .content=${this.user.attributes.notes}></ak-mdx>`
: html`
<p>
${msg(
Expand Down
4 changes: 2 additions & 2 deletions web/src/elements/ak-mdx/ak-mdx.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "#elements/Alert";

import { globalAK } from "#common/global";
import { BrandedHTMLPolicy } from "#common/purify";
import OneDark from "#common/styles/one-dark.css";

import { MDXAnchor } from "#elements/ak-mdx/components/MDXAnchor";
Expand Down Expand Up @@ -98,7 +99,7 @@ export class AKMDX extends AKElement {
nextMDXModule = await fetchMDXModule(pathname);
} else {
nextMDXModule = {
content: this.content || "",
content: `${BrandedHTMLPolicy.createHTML(this.content || "")}`,
};
}

Expand Down Expand Up @@ -144,7 +145,6 @@ export class AKMDX extends AKElement {
});

const { frontmatter = {} } = mdxExports;

this.#reactRoot.render(
<MDXModuleContext.Provider value={mdxModule}>
<Content
Expand Down
12 changes: 10 additions & 2 deletions web/src/elements/ak-mdx/components/MDXWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ export const MDXWrapper = ({ children, frontmatter }: MDXWrapperProps) => {
const nextChildren = React.Children.toArray(children);

if (title) {
nextChildren.unshift(<h1 key="header-title">{title}</h1>);
nextChildren.unshift(
<h1 key="header-title" part="title">
{title}
</h1>,
);
}

return <div className="pf-c-content">{nextChildren}</div>;
return (
<div className="pf-c-content" part="content">
{nextChildren}
</div>
);
};
8 changes: 8 additions & 0 deletions web/src/elements/table/Table.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
}
}

td.pf-c-table__toggle:first-child > .pf-c-button {
--pf-c-button--PaddingLeft: 0;
}

td ak-mdx::part(content) {
--pf-c-content--FontSize: 1em;
}

/**
* TODO: Row actions need a better approach to alignment,
* but this will at least get the buttons in a grid-like layout.
Expand Down
Loading