-
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/improve-charts
- Loading branch information
Showing
131 changed files
with
3,386 additions
and
1,000 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...d/src/component/admin/users/InactiveUsersList/DeleteInactiveUsers/DeleteInactiveUsers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Dialogue } from '../../../../common/Dialogue/Dialogue'; | ||
import useLoading from '../../../../../hooks/useLoading'; | ||
import { Alert, Typography } from '@mui/material'; | ||
import { DEL_INACTIVE_USERS_ERROR } from '../../../../../hooks/api/actions/useInactiveUsersApi/useInactiveUsersApi'; | ||
import { ConditionallyRender } from '../../../../common/ConditionallyRender/ConditionallyRender'; | ||
import { IInactiveUser } from '../../../../../hooks/api/getters/useInactiveUsers/useInactiveUsers'; | ||
import { flexRow } from '../../../../../themes/themeStyles'; | ||
|
||
interface IDeleteInactiveUsersProps { | ||
showDialog: boolean; | ||
closeDialog: () => void; | ||
inactiveUsersLoading: boolean; | ||
removeInactiveUsers: () => void; | ||
inactiveUserApiErrors: Record<string, string>; | ||
inactiveUsers: IInactiveUser[]; | ||
} | ||
export const DeleteInactiveUsers = ({ | ||
showDialog, | ||
closeDialog, | ||
inactiveUsersLoading, | ||
removeInactiveUsers, | ||
inactiveUserApiErrors, | ||
inactiveUsers, | ||
}: IDeleteInactiveUsersProps) => { | ||
const ref = useLoading(inactiveUsersLoading); | ||
return ( | ||
<Dialogue | ||
open={showDialog} | ||
title={`Really delete all inactive users?`} | ||
onClose={closeDialog} | ||
onClick={removeInactiveUsers} | ||
primaryButtonText={'Delete all inactive users'} | ||
secondaryButtonText={'Cancel'} | ||
> | ||
<div ref={ref}> | ||
<ConditionallyRender | ||
condition={Boolean( | ||
inactiveUserApiErrors[DEL_INACTIVE_USERS_ERROR], | ||
)} | ||
show={ | ||
<Alert | ||
data-loading | ||
severity='error' | ||
style={{ margin: '1rem 0' }} | ||
> | ||
{inactiveUserApiErrors[DEL_INACTIVE_USERS_ERROR]} | ||
</Alert> | ||
} | ||
/> | ||
<div style={flexRow}> | ||
<Typography variant='subtitle1'> | ||
You will be deleting{' '} | ||
{inactiveUsers.length === 1 | ||
? `1 inactive user` | ||
: `${inactiveUsers.length} inactive users`} | ||
</Typography> | ||
</div> | ||
</div> | ||
</Dialogue> | ||
); | ||
}; |
80 changes: 80 additions & 0 deletions
80
frontend/src/component/admin/users/InactiveUsersList/DeleteUser/DeleteUser.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Dialogue } from 'component/common/Dialogue/Dialogue'; | ||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; | ||
import { REMOVE_USER_ERROR } from 'hooks/api/actions/useAdminUsersApi/useAdminUsersApi'; | ||
import { Alert, styled } from '@mui/material'; | ||
import useLoading from 'hooks/useLoading'; | ||
import { Typography } from '@mui/material'; | ||
import { useThemeStyles } from 'themes/themeStyles'; | ||
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar'; | ||
import { IInactiveUser } from '../../../../../hooks/api/getters/useInactiveUsers/useInactiveUsers'; | ||
|
||
const StyledUserAvatar = styled(UserAvatar)(({ theme }) => ({ | ||
width: theme.spacing(5), | ||
height: theme.spacing(5), | ||
margin: 0, | ||
})); | ||
|
||
interface IDeleteUserProps { | ||
showDialog: boolean; | ||
closeDialog: () => void; | ||
user: IInactiveUser; | ||
userLoading: boolean; | ||
removeUser: () => void; | ||
userApiErrors: Record<string, string>; | ||
} | ||
|
||
const DeleteUser = ({ | ||
showDialog, | ||
closeDialog, | ||
user, | ||
userLoading, | ||
removeUser, | ||
userApiErrors, | ||
}: IDeleteUserProps) => { | ||
const ref = useLoading(userLoading); | ||
const { classes: themeStyles } = useThemeStyles(); | ||
|
||
return ( | ||
<Dialogue | ||
open={showDialog} | ||
title='Really delete user?' | ||
onClose={closeDialog} | ||
onClick={removeUser} | ||
primaryButtonText='Delete user' | ||
secondaryButtonText='Cancel' | ||
> | ||
<div ref={ref}> | ||
<ConditionallyRender | ||
condition={Boolean(userApiErrors[REMOVE_USER_ERROR])} | ||
show={ | ||
<Alert | ||
data-loading | ||
severity='error' | ||
style={{ margin: '1rem 0' }} | ||
> | ||
{userApiErrors[REMOVE_USER_ERROR]} | ||
</Alert> | ||
} | ||
/> | ||
<div data-loading className={themeStyles.flexRow}> | ||
<Typography | ||
variant='subtitle1' | ||
style={{ marginLeft: '1rem' }} | ||
> | ||
{user.username || user.email} | ||
</Typography> | ||
</div> | ||
<Typography | ||
data-loading | ||
variant='body1' | ||
style={{ marginTop: '1rem' }} | ||
> | ||
Are you sure you want to delete{' '} | ||
{`${user.name || 'user'} (${user.email || user.username})`} | ||
</Typography> | ||
</div> | ||
</Dialogue> | ||
); | ||
}; | ||
|
||
export default DeleteUser; |
32 changes: 32 additions & 0 deletions
32
...mponent/admin/users/InactiveUsersList/InactiveUsersActionCell/InactiveUsersActionCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { VFC } from 'react'; | ||
import { Box, styled } from '@mui/material'; | ||
import PermissionIconButton from '../../../../common/PermissionIconButton/PermissionIconButton'; | ||
import { ADMIN } from '../../../../providers/AccessProvider/permissions'; | ||
import { Delete } from '@mui/icons-material'; | ||
|
||
const StyledBox = styled(Box)(() => ({ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
})); | ||
interface IInactiveUsersActionsCellProps { | ||
onDelete: (event: React.SyntheticEvent) => void; | ||
} | ||
|
||
export const InactiveUsersActionCell: VFC<IInactiveUsersActionsCellProps> = ({ | ||
onDelete, | ||
}) => { | ||
return ( | ||
<StyledBox> | ||
<PermissionIconButton | ||
data-loading | ||
onClick={onDelete} | ||
permission={ADMIN} | ||
tooltipProps={{ | ||
title: 'Remove user', | ||
}} | ||
> | ||
<Delete /> | ||
</PermissionIconButton> | ||
</StyledBox> | ||
); | ||
}; |
Oops, something went wrong.