stages/prompt: field name (#4497)
* add prompt field name Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove numerical prefix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix missing name Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use text field Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add description label Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add migrate blueprint to remove old stages Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add task to remove unretrievable blueprints Signed-off-by: Jens Langhammer <jens@goauthentik.io> * lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix blueprint test paths Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * actually fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests even more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix fixtures Signed-off-by: Jens Langhammer <jens@goauthentik.io> Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		@ -13,9 +13,11 @@ import { TablePage } from "@goauthentik/elements/table/TablePage";
 | 
			
		||||
 | 
			
		||||
import { t } from "@lingui/macro";
 | 
			
		||||
 | 
			
		||||
import { TemplateResult, html } from "lit";
 | 
			
		||||
import { CSSResult, TemplateResult, html } from "lit";
 | 
			
		||||
import { customElement, property } from "lit/decorators.js";
 | 
			
		||||
 | 
			
		||||
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
 | 
			
		||||
 | 
			
		||||
import { BlueprintInstance, BlueprintInstanceStatusEnum, ManagedApi } from "@goauthentik/api";
 | 
			
		||||
 | 
			
		||||
export function BlueprintStatus(blueprint?: BlueprintInstance): string {
 | 
			
		||||
@ -32,6 +34,7 @@ export function BlueprintStatus(blueprint?: BlueprintInstance): string {
 | 
			
		||||
    }
 | 
			
		||||
    return t`Unknown`;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@customElement("ak-blueprint-list")
 | 
			
		||||
export class BlueprintListPage extends TablePage<BlueprintInstance> {
 | 
			
		||||
    searchEnabled(): boolean {
 | 
			
		||||
@ -47,11 +50,16 @@ export class BlueprintListPage extends TablePage<BlueprintInstance> {
 | 
			
		||||
        return "pf-icon pf-icon-blueprint";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    expandable = true;
 | 
			
		||||
    checkbox = true;
 | 
			
		||||
 | 
			
		||||
    @property()
 | 
			
		||||
    order = "name";
 | 
			
		||||
 | 
			
		||||
    static get styles(): CSSResult[] {
 | 
			
		||||
        return super.styles.concat(PFDescriptionList);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async apiEndpoint(page: number): Promise<PaginatedResponse<BlueprintInstance>> {
 | 
			
		||||
        return new ManagedApi(DEFAULT_CONFIG).managedBlueprintsList({
 | 
			
		||||
            ordering: this.order,
 | 
			
		||||
@ -96,9 +104,34 @@ export class BlueprintListPage extends TablePage<BlueprintInstance> {
 | 
			
		||||
        </ak-forms-delete-bulk>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    renderExpanded(item: BlueprintInstance): TemplateResult {
 | 
			
		||||
        return html`<td role="cell" colspan="4">
 | 
			
		||||
            <div class="pf-c-table__expandable-row-content">
 | 
			
		||||
                <dl class="pf-c-description-list pf-m-horizontal">
 | 
			
		||||
                    <div class="pf-c-description-list__group">
 | 
			
		||||
                        <dt class="pf-c-description-list__term">
 | 
			
		||||
                            <span class="pf-c-description-list__text">${t`Path`}</span>
 | 
			
		||||
                        </dt>
 | 
			
		||||
                        <dd class="pf-c-description-list__description">
 | 
			
		||||
                            <div class="pf-c-description-list__text">
 | 
			
		||||
                                <pre>${item.path}</pre>
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </dd>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </dl>
 | 
			
		||||
            </div>
 | 
			
		||||
        </td>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    row(item: BlueprintInstance): TemplateResult[] {
 | 
			
		||||
        let description = undefined;
 | 
			
		||||
        const descKey = "blueprints.goauthentik.io/description";
 | 
			
		||||
        if (Object.hasOwn(item.metadata.labels, descKey)) {
 | 
			
		||||
            description = item.metadata.labels[descKey];
 | 
			
		||||
        }
 | 
			
		||||
        return [
 | 
			
		||||
            html`${item.name}`,
 | 
			
		||||
            html`<div>${item.name}</div>
 | 
			
		||||
                ${description ? html`<small>${description}</small>` : html``}`,
 | 
			
		||||
            html`${BlueprintStatus(item)}`,
 | 
			
		||||
            html`${item.lastApplied.toLocaleString()}`,
 | 
			
		||||
            html`<ak-label color=${item.enabled ? PFColor.Green : PFColor.Red}>
 | 
			
		||||
 | 
			
		||||
@ -132,6 +132,17 @@ export class PromptForm extends ModelForm<Prompt, string> {
 | 
			
		||||
 | 
			
		||||
    renderForm(): TemplateResult {
 | 
			
		||||
        return html`<form class="pf-c-form pf-m-horizontal">
 | 
			
		||||
            <ak-form-element-horizontal label=${t`Name`} ?required=${true} name="name">
 | 
			
		||||
                <input
 | 
			
		||||
                    type="text"
 | 
			
		||||
                    value="${ifDefined(this.instance?.name)}"
 | 
			
		||||
                    class="pf-c-form-control"
 | 
			
		||||
                    required
 | 
			
		||||
                />
 | 
			
		||||
                <p class="pf-c-form__helper-text">
 | 
			
		||||
                    ${t`Unique name of this field, used for selecting fields in prompt stages.`}
 | 
			
		||||
                </p>
 | 
			
		||||
            </ak-form-element-horizontal>
 | 
			
		||||
            <ak-form-element-horizontal label=${t`Field Key`} ?required=${true} name="fieldKey">
 | 
			
		||||
                <input
 | 
			
		||||
                    type="text"
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,6 @@
 | 
			
		||||
import "@goauthentik/admin/stages/prompt/PromptForm";
 | 
			
		||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
 | 
			
		||||
import { uiConfig } from "@goauthentik/common/ui/config";
 | 
			
		||||
import { truncate } from "@goauthentik/common/utils";
 | 
			
		||||
import "@goauthentik/elements/buttons/ModalButton";
 | 
			
		||||
import "@goauthentik/elements/buttons/SpinnerButton";
 | 
			
		||||
import "@goauthentik/elements/forms/DeleteBulkForm";
 | 
			
		||||
@ -35,7 +34,7 @@ export class PromptListPage extends TablePage<Prompt> {
 | 
			
		||||
    checkbox = true;
 | 
			
		||||
 | 
			
		||||
    @property()
 | 
			
		||||
    order = "order";
 | 
			
		||||
    order = "name";
 | 
			
		||||
 | 
			
		||||
    async apiEndpoint(page: number): Promise<PaginatedResponse<Prompt>> {
 | 
			
		||||
        return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsList({
 | 
			
		||||
@ -48,8 +47,8 @@ export class PromptListPage extends TablePage<Prompt> {
 | 
			
		||||
 | 
			
		||||
    columns(): TableColumn[] {
 | 
			
		||||
        return [
 | 
			
		||||
            new TableColumn(t`Name`, "name"),
 | 
			
		||||
            new TableColumn(t`Field`, "field_key"),
 | 
			
		||||
            new TableColumn(t`Label`, "label"),
 | 
			
		||||
            new TableColumn(t`Type`, "type"),
 | 
			
		||||
            new TableColumn(t`Order`, "order"),
 | 
			
		||||
            new TableColumn(t`Stages`),
 | 
			
		||||
@ -81,8 +80,8 @@ export class PromptListPage extends TablePage<Prompt> {
 | 
			
		||||
 | 
			
		||||
    row(item: Prompt): TemplateResult[] {
 | 
			
		||||
        return [
 | 
			
		||||
            html`${item.fieldKey}`,
 | 
			
		||||
            html`${truncate(item.label, 20)}`,
 | 
			
		||||
            html`${item.name}`,
 | 
			
		||||
            html`<code>${item.fieldKey}</code>`,
 | 
			
		||||
            html`${item.type}`,
 | 
			
		||||
            html`${item.order}`,
 | 
			
		||||
            html`${item.promptstageSet?.map((stage) => {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user