web/admin: only show flows with an invitation stage configured instead of all enrollment flows
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> #1720
This commit is contained in:
parent
b14b9cb0dd
commit
738e4d5c74
|
@ -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"]
|
||||
|
||||
|
|
|
@ -17143,6 +17143,10 @@ paths:
|
|||
name: name
|
||||
schema:
|
||||
type: string
|
||||
- in: query
|
||||
name: no_flows
|
||||
schema:
|
||||
type: boolean
|
||||
- name: ordering
|
||||
required: false
|
||||
in: query
|
||||
|
|
|
@ -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`<option
|
||||
value=${flow.slug}
|
||||
?selected=${flow.slug === this.selectedFlow}
|
||||
>
|
||||
${flow.slug}
|
||||
</option>`;
|
||||
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`<option
|
||||
value=${flow.slug}
|
||||
?selected=${flow.slug === this.selectedFlow}
|
||||
>
|
||||
${flow.slug}
|
||||
</option>`;
|
||||
});
|
||||
});
|
||||
}),
|
||||
html`<option>${t`Loading...`}</option>`,
|
||||
|
|
Reference in New Issue