Skip to content

Commit

Permalink
Add warning when attempting to remove user from non-standard group (#346
Browse files Browse the repository at this point in the history
)

* add group deletion warning

add modal that warns the user when attempting to
remove a user from a non-standard group, which isn't
supported by the dapla team API yet.
  • Loading branch information
skykanin authored Oct 15, 2024
1 parent 8bdbab6 commit 8737d08
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/pages/TeamDetail/EditTeamMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import DeleteLink from '../../components/DeleteLink/DeleteLink'
import { renderSidebarModalInfo, renderSidebarModalWarning } from './teamDetailDialog'
import { displayGroupItem, standardGroups } from './common'

import { Dropdown, Tag, Link, Button } from '@statisticsnorway/ssb-component-library'
import { Dialog, Dropdown, Tag, Link, Button } from '@statisticsnorway/ssb-component-library'
import { CircularProgress } from '@mui/material'
import { XCircle, Trash2 } from 'react-feather'

Expand Down Expand Up @@ -53,6 +53,7 @@ const EditTeamMember = ({
const [showEditUserSpinner, setShowEditUserSpinner] = useState<EditUserStates>({})

const [openDeleteUserConfirmation, setOpenDeleteUserConfirmation] = useState<boolean>(false)
const [managedGroupsWarning, setManagedGroupsWarning] = useState(false)

useEffect(() => {
if (teamDetailData) {
Expand Down Expand Up @@ -224,13 +225,7 @@ const EditTeamMember = ({
footer={
<>
<span>
<Link
onClick={() => {
setOpenDeleteUserConfirmation(false)
}}
>
Avbryt
</Link>
<Link onClick={() => setOpenDeleteUserConfirmation(false)}>Avbryt</Link>
</span>
<Button onClick={handleDeleteUser} primary>
Fjern
Expand All @@ -245,7 +240,10 @@ const EditTeamMember = ({
return (
<SidebarModal
open={open}
onClose={() => onClose()}
onClose={() => {
setManagedGroupsWarning(false)
onClose()
}}
header={teamModalHeader}
footer={{
submitButtonText: 'Oppdater tilgang',
Expand All @@ -269,12 +267,17 @@ const EditTeamMember = ({
<Tag
key={`user-group-tag-${group.id}`}
icon={<XCircle size={14} />}
onClick={() => (group.disabled ? undefined : handleDeleteGroupTag(group))}
onClick={() => (group.disabled ? setManagedGroupsWarning(true) : handleDeleteGroupTag(group))}
>
{group.title}
</Tag>
))}
</div>
{managedGroupsWarning && (
<Dialog type='warning' title='Bare standard grupper kan fjernes'>
Dapla Ctrl støtter ikke å fjerne andre grupper enn "data-admins", "developers" og "managers".
</Dialog>
)}
<div className={styles.modalBodyDialog}>
<DeleteLink handleDeleteUser={() => setOpenDeleteUserConfirmation(true)} icon>
Fjern fra teamet
Expand Down

0 comments on commit 8737d08

Please sign in to comment.