Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#2081 from kris6673/dev
Browse files Browse the repository at this point in the history
Add and remove to/from groups in EditUser and more
  • Loading branch information
KelvinTegelaar committed Feb 4, 2024
2 parents 17461b2 + 2c7bce3 commit 64228e5
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion src/views/identity/administration/EditUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'src/components/forms'
import countryList from 'src/data/countryList'
import { useListUserQuery, useListUsersQuery } from 'src/store/api/users'
import { useListGroupsQuery } from 'src/store/api/groups'
import { useListDomainsQuery } from 'src/store/api/domains'
import { useListLicensesQuery } from 'src/store/api/licenses'
import { CippCodeBlock, ModalService } from 'src/components/utilities'
Expand Down Expand Up @@ -45,6 +46,12 @@ const EditUser = () => {
error: usersError,
} = useListUsersQuery({ tenantDomain })

const {
data: groups = [],
isFetching: groupsIsFetching,
error: groupsError,
} = useListGroupsQuery({ tenantDomain })

const {
data: domains = [],
isFetching: domainsIsFetching,
Expand All @@ -70,8 +77,11 @@ const EditUser = () => {
}, [userId, tenantDomain, dispatch])
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()
const onSubmit = (values) => {
console.log(values.AddToGroups)
const shippedValues = {
AddedAliases: values.addedAliases,
AddToGroups: Array.isArray(values.AddToGroups) ? values.AddToGroups : [],
RemoveFromGroups: Array.isArray(values.RemoveFromGroups) ? values.RemoveFromGroups : [],
BusinessPhone: values.businessPhones,
RemoveAllLicenses: values.RemoveAllLicenses,
City: values.city,
Expand All @@ -80,6 +90,7 @@ const EditUser = () => {
Country: values.country,
Department: values.department,
DisplayName: values.displayName,
userPrincipalName: values.userPrincipalName,
Domain: values.primDomain,
firstName: values.givenName,
Jobtitle: values.jobTitle,
Expand All @@ -97,7 +108,7 @@ const EditUser = () => {
addedAttributes: values.addedAttributes,
...(values.licenses ? values.license : ''),
}
//window.alert(JSON.stringify(shippedValues))
// window.alert(JSON.stringify(shippedValues))
genericPostRequest({ path: '/api/EditUser', values: shippedValues })
}
const usageLocation = useSelector((state) => state.app.usageLocation)
Expand Down Expand Up @@ -414,6 +425,42 @@ const EditUser = () => {
</CCol>
</CRow>
<CRow className="mb-3">
<CCol md={12}>
<RFFSelectSearch
multi={true}
label="Add user to group"
disabled={formDisabled}
values={groups?.map((group) => ({
value: {
groupid: group.id,
groupType: group.calculatedGroupType,
groupName: group.displayName,
},
name: `${group.displayName} - ${group.calculatedGroupType} `,
}))}
placeholder={!groupsIsFetching ? 'Select groups' : 'Loading...'}
name="AddToGroups"
/>
{groupsError && <span>Failed to load list of groups</span>}
</CCol>
<CCol md={12}>
<RFFSelectSearch
multi={true}
label="Remove user from group"
disabled={formDisabled}
values={groups?.map((group) => ({
value: {
groupid: group.id,
groupType: group.calculatedGroupType,
groupName: group.displayName,
},
name: `${group.displayName} - ${group.calculatedGroupType} `,
}))}
placeholder={!groupsIsFetching ? 'Select groups' : 'Loading...'}
name="RemoveFromGroups"
/>
{groupsError && <span>Failed to load list of groups</span>}
</CCol>
<CCol md={12}>
<RFFSelectSearch
label="Copy group membership from other user"
Expand Down

0 comments on commit 64228e5

Please sign in to comment.