import "#admin/applications/ApplicationForm"; import { DEFAULT_CONFIG } from "#common/api/config"; import "#elements/AppIcon"; import "#elements/ak-mdx/ak-mdx"; import "#elements/buttons/SpinnerButton/ak-spinner-button"; import "#elements/forms/DeleteBulkForm"; import "#elements/forms/ModalForm"; import { WithBrandConfig } from "#elements/mixins/branding"; import { getURLParam } from "#elements/router/RouteMatch"; import { PaginatedResponse } from "#elements/table/Table"; import { TableColumn } from "#elements/table/Table"; import { TablePage } from "#elements/table/TablePage"; import "@patternfly/elements/pf-tooltip/pf-tooltip.js"; import MDApplication from "~docs/add-secure-apps/applications/index.md"; import { msg, str } from "@lit/localize"; import { CSSResult, TemplateResult, css, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import PFCard from "@patternfly/patternfly/components/Card/card.css"; import { Application, CoreApi, PoliciesApi } from "@goauthentik/api"; import "./ApplicationWizardHint.js"; export const applicationListStyle = css` /* Fix alignment issues with images in tables */ .pf-c-table tbody > tr > * { vertical-align: middle; } tr td:first-child { width: auto; min-width: 0px; text-align: center; vertical-align: middle; } .pf-c-sidebar.pf-m-gutter > .pf-c-sidebar__main > * + * { margin-left: calc(var(--pf-c-sidebar__main--child--MarginLeft) / 2); } `; @customElement("ak-application-list") export class ApplicationListPage extends WithBrandConfig(TablePage) { searchEnabled(): boolean { return true; } pageTitle(): string { return msg("Applications"); } pageDescription(): string { return msg( str`External applications that use ${this.brandingTitle} as an identity provider via protocols like OAuth2 and SAML. All applications are shown here, even ones you cannot access.`, ); } pageIcon(): string { return "pf-icon pf-icon-applications"; } checkbox = true; clearOnRefresh = true; @property() order = "name"; async apiEndpoint(): Promise> { return new CoreApi(DEFAULT_CONFIG).coreApplicationsList({ ...(await this.defaultEndpointConfig()), superuserFullList: true, }); } static get styles(): CSSResult[] { return TablePage.styles.concat(PFCard, applicationListStyle); } columns(): TableColumn[] { return [ new TableColumn(""), new TableColumn(msg("Name"), "name"), new TableColumn(msg("Group"), "group"), new TableColumn(msg("Provider")), new TableColumn(msg("Provider Type")), new TableColumn(msg("Actions")), ]; } renderSidebarAfter(): TemplateResult { return html`
`; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new CoreApi(DEFAULT_CONFIG).coreApplicationsUsedByList({ slug: item.slug, }); }} .delete=${(item: Application) => { return new CoreApi(DEFAULT_CONFIG).coreApplicationsDestroy({ slug: item.slug, }); }} > `; } row(item: Application): TemplateResult[] { return [ html``, html`
${item.name}
${item.metaPublisher ? html`${item.metaPublisher}` : html``}
`, html`${item.group || msg("-")}`, item.provider ? html` ${item.providerObj?.name} ` : html`-`, html`${item.providerObj?.verboseName || msg("-")}`, html` ${msg("Update")} ${msg("Update Application")} ${item.launchUrl ? html` ` : html``}`, ]; } renderObjectCreate(): TemplateResult { return html` ${msg("Create")} ${msg("Create Application")} `; } renderToolbar(): TemplateResult { return html` ${super.renderToolbar()} { return new PoliciesApi(DEFAULT_CONFIG).policiesAllCacheClearCreate(); }} > ${msg("Clear Application cache")}

${msg( "Are you sure you want to clear the application cache? This will cause all policies to be re-evaluated on their next usage.", )}

`; } } declare global { interface HTMLElementTagNameMap { "ak-application-list": ApplicationListPage; } }