diff --git a/web/src/admin/groups/GroupForm.ts b/web/src/admin/groups/GroupForm.ts index 84fcc8b21..5a4024512 100644 --- a/web/src/admin/groups/GroupForm.ts +++ b/web/src/admin/groups/GroupForm.ts @@ -7,7 +7,6 @@ import "@goauthentik/elements/chips/ChipGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import "@goauthentik/elements/forms/SearchSelect"; -import { UserOption } from "@goauthentik/elements/user/utils"; import YAML from "yaml"; import { t } from "@lingui/macro"; @@ -15,9 +14,8 @@ import { t } from "@lingui/macro"; import { CSSResult, TemplateResult, css, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; -import { until } from "lit/directives/until.js"; -import { CoreApi, CoreGroupsListRequest, Group, User } from "@goauthentik/api"; +import { CoreApi, CoreGroupsListRequest, Group } from "@goauthentik/api"; @customElement("ak-group-form") export class GroupForm extends ModelForm { @@ -48,9 +46,9 @@ export class GroupForm extends ModelForm { send = (data: Group): Promise => { if (this.instance?.pk) { - return new CoreApi(DEFAULT_CONFIG).coreGroupsUpdate({ + return new CoreApi(DEFAULT_CONFIG).coreGroupsPartialUpdate({ groupUuid: this.instance.pk, - groupRequest: data, + patchedGroupRequest: data, }); } else { data.users = Array.from(this.instance?.users || []); @@ -113,63 +111,6 @@ export class GroupForm extends ModelForm { > - -
- { - // Because the model only has the IDs, map the user list to IDs - const ids = items.map((u) => u.pk || 0); - if (!this.instance) this.instance = {} as Group; - this.instance.users = Array.from(this.instance?.users || []).concat( - ids, - ); - this.requestUpdate(); - return Promise.resolve(); - }} - > - - -
- - ${until( - new CoreApi(DEFAULT_CONFIG) - .coreUsersList({ - ordering: "username", - }) - .then((users) => { - return users.results.map((user) => { - const selected = Array.from( - this.instance?.users || [], - ).some((su) => { - return su == user.pk; - }); - if (!selected) return; - return html` { - if (!this.instance) return; - const users = Array.from( - this.instance?.users || [], - ); - const idx = users.indexOf(user.pk || 0); - users.splice(idx, 1); - this.instance.users = users; - this.requestUpdate(); - }} - > - ${UserOption(user)} - `; - }); - }), - html``, - )} - -
-
-
{ @@ -44,9 +43,9 @@ export class UserForm extends ModelForm { send = (data: User): Promise => { if (this.instance?.pk) { - return new CoreApi(DEFAULT_CONFIG).coreUsersUpdate({ + return new CoreApi(DEFAULT_CONFIG).coreUsersPartialUpdate({ id: this.instance.pk, - userRequest: data, + patchedUserRequest: data, }); } else { return new CoreApi(DEFAULT_CONFIG).coreUsersCreate({ @@ -110,63 +109,6 @@ export class UserForm extends ModelForm { ${t`Designates whether this user should be treated as active. Unselect this instead of deleting accounts.`}

- -
- { - // Because the model only has the IDs, map the group list to IDs - const ids = items.map((g) => g.pk); - if (!this.instance) this.instance = {} as User; - this.instance.groups = Array.from(this.instance?.groups || []).concat( - ids, - ); - this.requestUpdate(); - return Promise.resolve(); - }} - > - - -
- - ${until( - new CoreApi(DEFAULT_CONFIG) - .coreGroupsList({ - ordering: "name", - }) - .then((groups) => { - return groups.results.map((group) => { - const selected = Array.from( - this.instance?.groups || [], - ).some((sg) => { - return sg == group.pk; - }); - if (!selected) return; - return html` { - if (!this.instance) return; - const groups = Array.from( - this.instance?.groups || [], - ); - const idx = groups.indexOf(group.pk); - groups.splice(idx, 1); - this.instance.groups = groups; - this.requestUpdate(); - }} - > - ${group.name} - `; - }); - }), - html``, - )} - -
-
-