73733b20b6
* build(deps): bump @trivago/prettier-plugin-sort-imports in /web Bumps [@trivago/prettier-plugin-sort-imports](https://github.com/trivago/prettier-plugin-sort-imports) from 2.0.4 to 3.0.0. - [Release notes](https://github.com/trivago/prettier-plugin-sort-imports/releases) - [Changelog](https://github.com/trivago/prettier-plugin-sort-imports/blob/master/CHANGELOG.md) - [Commits](https://github.com/trivago/prettier-plugin-sort-imports/commits) --- updated-dependencies: - dependency-name: "@trivago/prettier-plugin-sort-imports" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * web: update prettier config Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens.langhammer@beryju.org>
146 lines
5.1 KiB
TypeScript
146 lines
5.1 KiB
TypeScript
import { t } from "@lingui/macro";
|
|
|
|
import { CSSResult, TemplateResult, css, html } from "lit";
|
|
import { customElement, property } from "lit/decorators";
|
|
|
|
import PFAvatar from "@patternfly/patternfly/components/Avatar/avatar.css";
|
|
|
|
import { Application, CoreApi } from "@goauthentik/api";
|
|
|
|
import { AKResponse } from "../../api/Client";
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
|
import { uiConfig } from "../../common/config";
|
|
import "../../elements/buttons/SpinnerButton";
|
|
import "../../elements/forms/DeleteBulkForm";
|
|
import "../../elements/forms/ModalForm";
|
|
import { TableColumn } from "../../elements/table/Table";
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
import "./ApplicationForm";
|
|
|
|
@customElement("ak-application-list")
|
|
export class ApplicationListPage extends TablePage<Application> {
|
|
searchEnabled(): boolean {
|
|
return true;
|
|
}
|
|
pageTitle(): string {
|
|
return t`Applications`;
|
|
}
|
|
pageDescription(): string {
|
|
return t`External Applications which use authentik as Identity-Provider, utilizing 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;
|
|
|
|
@property()
|
|
order = "name";
|
|
|
|
async apiEndpoint(page: number): Promise<AKResponse<Application>> {
|
|
return new CoreApi(DEFAULT_CONFIG).coreApplicationsList({
|
|
ordering: this.order,
|
|
page: page,
|
|
pageSize: (await uiConfig()).pagination.perPage,
|
|
search: this.search || "",
|
|
superuserFullList: true,
|
|
});
|
|
}
|
|
|
|
static get styles(): CSSResult[] {
|
|
return super.styles.concat(
|
|
PFAvatar,
|
|
css`
|
|
tr td:first-child {
|
|
width: auto;
|
|
min-width: 0px;
|
|
text-align: center;
|
|
vertical-align: middle;
|
|
}
|
|
`,
|
|
);
|
|
}
|
|
|
|
columns(): TableColumn[] {
|
|
return [
|
|
new TableColumn(""),
|
|
new TableColumn(t`Name`, "name"),
|
|
new TableColumn(t`Slug`, "slug"),
|
|
new TableColumn(t`Provider`),
|
|
new TableColumn(t`Provider Type`),
|
|
new TableColumn(t`Actions`),
|
|
];
|
|
}
|
|
|
|
renderToolbarSelected(): TemplateResult {
|
|
const disabled = this.selectedElements.length < 1;
|
|
return html`<ak-forms-delete-bulk
|
|
objectLabel=${t`Application(s)`}
|
|
.objects=${this.selectedElements}
|
|
.usedBy=${(item: Application) => {
|
|
return new CoreApi(DEFAULT_CONFIG).coreApplicationsUsedByList({
|
|
slug: item.slug,
|
|
});
|
|
}}
|
|
.delete=${(item: Application) => {
|
|
return new CoreApi(DEFAULT_CONFIG).coreApplicationsDestroy({
|
|
slug: item.slug,
|
|
});
|
|
}}
|
|
>
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
${t`Delete`}
|
|
</button>
|
|
</ak-forms-delete-bulk>`;
|
|
}
|
|
|
|
row(item: Application): TemplateResult[] {
|
|
return [
|
|
item.metaIcon
|
|
? html`<img
|
|
class="app-icon pf-c-avatar"
|
|
src="${item.metaIcon}"
|
|
alt="${t`Application Icon`}"
|
|
/>`
|
|
: html`<i class="fas fa-question-circle"></i>`,
|
|
html`<a href="#/core/applications/${item.slug}">
|
|
<div>${item.name}</div>
|
|
${item.metaPublisher ? html`<small>${item.metaPublisher}</small>` : html``}
|
|
</a>`,
|
|
html`<code>${item.slug}</code>`,
|
|
item.provider
|
|
? html`<a href="#/core/providers/${item.providerObj?.pk}">
|
|
${item.providerObj?.name}
|
|
</a>`
|
|
: html`-`,
|
|
html`${item.providerObj?.verboseName || t`-`}`,
|
|
html` <ak-forms-modal>
|
|
<span slot="submit"> ${t`Update`} </span>
|
|
<span slot="header"> ${t`Update Application`} </span>
|
|
<ak-application-form slot="form" .instancePk=${item.slug}>
|
|
</ak-application-form>
|
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
|
<i class="fas fa-edit"></i>
|
|
</button>
|
|
</ak-forms-modal>
|
|
${item.launchUrl
|
|
? html`<a href=${item.launchUrl} target="_blank" class="pf-c-button pf-m-plain">
|
|
<i class="fas fas fa-share-square"></i>
|
|
</a>`
|
|
: html``}`,
|
|
];
|
|
}
|
|
|
|
renderToolbar(): TemplateResult {
|
|
return html`
|
|
<ak-forms-modal>
|
|
<span slot="submit"> ${t`Create`} </span>
|
|
<span slot="header"> ${t`Create Application`} </span>
|
|
<ak-application-form slot="form"> </ak-application-form>
|
|
<button slot="trigger" class="pf-c-button pf-m-primary">${t`Create`}</button>
|
|
</ak-forms-modal>
|
|
${super.renderToolbar()}
|
|
`;
|
|
}
|
|
}
|