web/admin: show outpost warning on application page too
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
b694816e7b
commit
e3e9178ccc
|
@ -1,6 +1,8 @@
|
||||||
"""Outpost API Views"""
|
"""Outpost API Views"""
|
||||||
from dacite.core import from_dict
|
from dacite.core import from_dict
|
||||||
from dacite.exceptions import DaciteError
|
from dacite.exceptions import DaciteError
|
||||||
|
from django_filters.filters import ModelMultipleChoiceFilter
|
||||||
|
from django_filters.filterset import FilterSet
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.fields import BooleanField, CharField, DateTimeField
|
from rest_framework.fields import BooleanField, CharField, DateTimeField
|
||||||
|
@ -99,16 +101,30 @@ class OutpostHealthSerializer(PassiveSerializer):
|
||||||
version_outdated = BooleanField(read_only=True)
|
version_outdated = BooleanField(read_only=True)
|
||||||
|
|
||||||
|
|
||||||
|
class OutpostFilter(FilterSet):
|
||||||
|
"""Filter for Outposts"""
|
||||||
|
|
||||||
|
providers_by_pk = ModelMultipleChoiceFilter(
|
||||||
|
field_name="providers",
|
||||||
|
queryset=Provider.objects.all(),
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = Outpost
|
||||||
|
fields = {
|
||||||
|
"providers": ["isnull"],
|
||||||
|
"name": ["iexact", "icontains"],
|
||||||
|
"service_connection__name": ["iexact", "icontains"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class OutpostViewSet(UsedByMixin, ModelViewSet):
|
class OutpostViewSet(UsedByMixin, ModelViewSet):
|
||||||
"""Outpost Viewset"""
|
"""Outpost Viewset"""
|
||||||
|
|
||||||
queryset = Outpost.objects.all()
|
queryset = Outpost.objects.all()
|
||||||
serializer_class = OutpostSerializer
|
serializer_class = OutpostSerializer
|
||||||
filterset_fields = {
|
filterset_class = OutpostFilter
|
||||||
"providers": ["isnull"],
|
|
||||||
"name": ["iexact", "icontains"],
|
|
||||||
"service_connection__name": ["iexact", "icontains"],
|
|
||||||
}
|
|
||||||
search_fields = [
|
search_fields = [
|
||||||
"name",
|
"name",
|
||||||
"providers__name",
|
"providers__name",
|
||||||
|
|
16
schema.yml
16
schema.yml
|
@ -5764,6 +5764,14 @@ paths:
|
||||||
name: providers__isnull
|
name: providers__isnull
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
- in: query
|
||||||
|
name: providers_by_pk
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
explode: true
|
||||||
|
style: form
|
||||||
- name: search
|
- name: search
|
||||||
required: false
|
required: false
|
||||||
in: query
|
in: query
|
||||||
|
@ -5952,6 +5960,14 @@ paths:
|
||||||
name: providers__isnull
|
name: providers__isnull
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
- in: query
|
||||||
|
name: providers_by_pk
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
explode: true
|
||||||
|
style: form
|
||||||
- name: search
|
- name: search
|
||||||
required: false
|
required: false
|
||||||
in: query
|
in: query
|
||||||
|
|
|
@ -5619,6 +5619,10 @@ msgstr "Wait (min)"
|
||||||
msgid "Warning"
|
msgid "Warning"
|
||||||
msgstr "Warning"
|
msgstr "Warning"
|
||||||
|
|
||||||
|
#: src/pages/applications/ApplicationViewPage.ts
|
||||||
|
msgid "Warning: Application is not used by any Outpost."
|
||||||
|
msgstr "Warning: Application is not used by any Outpost."
|
||||||
|
|
||||||
#: src/pages/stages/invitation/InvitationListPage.ts
|
#: src/pages/stages/invitation/InvitationListPage.ts
|
||||||
msgid "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
msgid "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
||||||
msgstr "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
msgstr "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
||||||
|
|
|
@ -5557,6 +5557,10 @@ msgstr "Attente (min)"
|
||||||
msgid "Warning"
|
msgid "Warning"
|
||||||
msgstr "Avertissement"
|
msgstr "Avertissement"
|
||||||
|
|
||||||
|
#: src/pages/applications/ApplicationViewPage.ts
|
||||||
|
msgid "Warning: Application is not used by any Outpost."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/stages/invitation/InvitationListPage.ts
|
#: src/pages/stages/invitation/InvitationListPage.ts
|
||||||
msgid "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
msgid "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -5599,6 +5599,10 @@ msgstr ""
|
||||||
msgid "Warning"
|
msgid "Warning"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/pages/applications/ApplicationViewPage.ts
|
||||||
|
msgid "Warning: Application is not used by any Outpost."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/stages/invitation/InvitationListPage.ts
|
#: src/pages/stages/invitation/InvitationListPage.ts
|
||||||
msgid "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
msgid "Warning: No invitation stage is bound to any flow. Invitations will not work as expected."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
|
|
||||||
import { CSSResult, LitElement, TemplateResult, html } from "lit";
|
import { CSSResult, LitElement, TemplateResult, html } from "lit";
|
||||||
import { customElement, property } from "lit/decorators.js";
|
import { customElement, property, state } from "lit/decorators.js";
|
||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
import { ifDefined } from "lit/directives/if-defined.js";
|
||||||
|
|
||||||
import AKGlobal from "../../authentik.css";
|
import AKGlobal from "../../authentik.css";
|
||||||
|
import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";
|
||||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||||
import PFCard from "@patternfly/patternfly/components/Card/card.css";
|
import PFCard from "@patternfly/patternfly/components/Card/card.css";
|
||||||
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
||||||
|
@ -13,7 +14,7 @@ import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
||||||
import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css";
|
import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css";
|
||||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||||
|
|
||||||
import { Application, CoreApi } from "@goauthentik/api";
|
import { Application, CoreApi, OutpostsApi } from "@goauthentik/api";
|
||||||
|
|
||||||
import { DEFAULT_CONFIG } from "../../api/Config";
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
||||||
import "../../elements/EmptyState";
|
import "../../elements/EmptyState";
|
||||||
|
@ -36,14 +37,45 @@ export class ApplicationViewPage extends LitElement {
|
||||||
})
|
})
|
||||||
.then((app) => {
|
.then((app) => {
|
||||||
this.application = app;
|
this.application = app;
|
||||||
|
if (
|
||||||
|
app.providerObj &&
|
||||||
|
[
|
||||||
|
"authentik_providers_proxy.proxyprovider",
|
||||||
|
"authentik_providers_ldap.ldapprovider",
|
||||||
|
].includes(app.providerObj.metaModelName)
|
||||||
|
) {
|
||||||
|
new OutpostsApi(DEFAULT_CONFIG)
|
||||||
|
.outpostsInstancesList({
|
||||||
|
providersByPk: [app.provider || 0],
|
||||||
|
pageSize: 1,
|
||||||
|
})
|
||||||
|
.then((outposts) => {
|
||||||
|
if (outposts.pagination.count < 1) {
|
||||||
|
this.missingOutpost = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
application!: Application;
|
application!: Application;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
missingOutpost = false;
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [PFBase, PFPage, PFContent, PFButton, PFDescriptionList, PFGrid, PFCard, AKGlobal];
|
return [
|
||||||
|
PFBase,
|
||||||
|
PFBanner,
|
||||||
|
PFPage,
|
||||||
|
PFContent,
|
||||||
|
PFButton,
|
||||||
|
PFDescriptionList,
|
||||||
|
PFGrid,
|
||||||
|
PFCard,
|
||||||
|
AKGlobal,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): TemplateResult {
|
render(): TemplateResult {
|
||||||
|
@ -62,6 +94,11 @@ export class ApplicationViewPage extends LitElement {
|
||||||
return html`<ak-empty-state ?loading="${true}" header=${t`Loading`}> </ak-empty-state>`;
|
return html`<ak-empty-state ?loading="${true}" header=${t`Loading`}> </ak-empty-state>`;
|
||||||
}
|
}
|
||||||
return html`<ak-tabs>
|
return html`<ak-tabs>
|
||||||
|
${this.missingOutpost
|
||||||
|
? html`<div slot="header" class="pf-c-banner pf-m-warning">
|
||||||
|
${t`Warning: Application is not used by any Outpost.`}
|
||||||
|
</div>`
|
||||||
|
: html``}
|
||||||
<section
|
<section
|
||||||
slot="page-overview"
|
slot="page-overview"
|
||||||
data-tab-title="${t`Overview`}"
|
data-tab-title="${t`Overview`}"
|
||||||
|
@ -88,6 +125,7 @@ export class ApplicationViewPage extends LitElement {
|
||||||
.providerObj?.pk}"
|
.providerObj?.pk}"
|
||||||
>
|
>
|
||||||
${this.application.providerObj?.name}
|
${this.application.providerObj?.name}
|
||||||
|
(${this.application.providerObj?.verboseName})
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
Reference in a new issue