diff --git a/authentik/stages/invitation/api.py b/authentik/stages/invitation/api.py index ccf8f4a61..8e85bcb1b 100644 --- a/authentik/stages/invitation/api.py +++ b/authentik/stages/invitation/api.py @@ -1,4 +1,6 @@ """Invitation Stage API Views""" +from django_filters.filters import BooleanFilter +from django_filters.filterset import FilterSet from rest_framework.fields import JSONField from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet @@ -21,12 +23,23 @@ class InvitationStageSerializer(StageSerializer): ] +class InvitationStageFilter(FilterSet): + """invitation filter""" + + no_flows = BooleanFilter("flow", "isnull") + + class Meta: + + model = InvitationStage + fields = ["name", "no_flows", "continue_flow_without_invitation", "stage_uuid"] + + class InvitationStageViewSet(UsedByMixin, ModelViewSet): """InvitationStage Viewset""" queryset = InvitationStage.objects.all() serializer_class = InvitationStageSerializer - filterset_fields = "__all__" + filterset_class = InvitationStageFilter ordering = ["name"] @@ -53,7 +66,7 @@ class InvitationViewSet(UsedByMixin, ModelViewSet): queryset = Invitation.objects.all() serializer_class = InvitationSerializer - order = ["-expires"] + ordering = ["-expires"] search_fields = ["created_by__username", "expires"] filterset_fields = ["created_by__username", "expires"] diff --git a/schema.yml b/schema.yml index e856e624c..42e213bc8 100644 --- a/schema.yml +++ b/schema.yml @@ -17143,6 +17143,10 @@ paths: name: name schema: type: string + - in: query + name: no_flows + schema: + type: boolean - name: ordering required: false in: query diff --git a/web/src/pages/stages/invitation/InvitationListLink.ts b/web/src/pages/stages/invitation/InvitationListLink.ts index 22c2fec9b..a4d674e33 100644 --- a/web/src/pages/stages/invitation/InvitationListLink.ts +++ b/web/src/pages/stages/invitation/InvitationListLink.ts @@ -11,7 +11,7 @@ import PFFormControl from "@patternfly/patternfly/components/FormControl/form-co import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import { FlowsApi, FlowsInstancesListDesignationEnum } from "@goauthentik/api"; +import { StagesApi } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../../api/Config"; @@ -47,22 +47,33 @@ export class InvitationListLink extends LitElement { }} > ${until( - new FlowsApi(DEFAULT_CONFIG) - .flowsInstancesList({ + new StagesApi(DEFAULT_CONFIG) + .stagesInvitationStagesList({ ordering: "pk", - designation: FlowsInstancesListDesignationEnum.Enrollment, + noFlows: false, }) - .then((flows) => { - if (!this.selectedFlow && flows.results.length > 0) { - this.selectedFlow = flows.results[0].slug; + .then((stages) => { + if ( + !this.selectedFlow && + stages.results.length > 0 && + stages.results[0].flowSet + ) { + this.selectedFlow = stages.results[0].flowSet[0].slug; } - return flows.results.map((flow) => { - return html``; + const seenFlowSlugs: string[] = []; + return stages.results.map((stage) => { + return stage.flowSet?.map((flow) => { + if (seenFlowSlugs.includes(flow.slug)) { + return html``; + } + seenFlowSlugs.push(flow.slug); + return html``; + }); }); }), html``,