1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00
unleash.unleash/frontend/src/component/admin/users/UsersAdmin.tsx

75 lines
3.1 KiB
TypeScript
Raw Normal View History

import { useContext, useState } from 'react';
2022-01-27 16:03:03 +01:00
import UsersList from './UsersList/UsersList';
import AdminMenu from '../menu/AdminMenu';
import { PageContent } from 'component/common/PageContent/PageContent';
2022-03-28 10:49:59 +02:00
import AccessContext from 'contexts/AccessContext';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
2022-03-28 10:49:59 +02:00
import { ADMIN } from 'component/providers/AccessProvider/permissions';
import { Button } from '@mui/material';
import { TableActions } from 'component/common/Table/TableActions/TableActions';
import { PageHeader } from 'component/common/PageHeader/PageHeader';
import { useStyles } from './UserAdmin.styles';
import { useNavigate } from 'react-router-dom';
import { AdminAlert } from 'component/common/AdminAlert/AdminAlert';
2022-01-27 16:03:03 +01:00
const UsersAdmin = () => {
const [search, setSearch] = useState('');
const { hasAccess } = useContext(AccessContext);
const navigate = useNavigate();
const { classes: styles } = useStyles();
return (
<div>
<AdminMenu />
<PageContent
bodyClass={styles.userListBody}
header={
<PageHeader
title="Users"
actions={
<ConditionallyRender
condition={hasAccess(ADMIN)}
show={
<div className={styles.tableActions}>
<TableActions
Feature list table (#908) * experiment with generic table * feat: example implementation of sortable table interfaces * add enhanced table header Co-authored-by: Nuno Góis <github@nunogois.com> * table cleanup Co-authored-by: Nuno Góis Co-authored-by: Fredrik Strand Oseberg * useSort hook interface surface Co-authored-by: Nuno Góis <github@nunogois.com> * sort handler initial implementation Co-authored-by: Tymoteusz Czech <Tymek@users.noreply.github.com> * new table unified components * feature flags table components Co-authored-by: Nuno Góis <github@nunogois.com> * feat: new table sort hook * feat: table sort * useSearch hook implementation * update new sort hook tests * sortable headers hook * feat: add sort to other table features * move experimental table hooks to a directory * update new table header styles * fix: header, tableActions * add some details like pagination and highlighter so we keep them in mind * feature table cells * update new table sort logic * new pagination * fix formatting and remove unused component * fix: adapt useSearch default search to text instead of regex (PR #924) * fix: update table title based on visible rows * fix: remove test route * refactor: move table experiment files * features table experimentation * feat: enhanced feature flags table * fix: features default sort * feat: enhanced table loading * fix: table theme after mui5 update * features list placeholder * add react-table * update snapshots after theme change * remove unused files * fix: improve features table after review * refactor: rename feature type cell variables Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com> Co-authored-by: Nuno Góis <github@nunogois.com> Co-authored-by: Tymoteusz Czech <Tymek@users.noreply.github.com>
2022-05-05 15:34:46 +02:00
initialSearchValue={search}
onSearch={search =>
setSearch(search)
}
/>
<Button
sx={{
ml: 1.5,
}}
variant="contained"
color="primary"
onClick={() =>
navigate('/admin/create-user')
}
>
New user
</Button>
</div>
}
elseShow={
<small>
PS! Only admins can add/remove users.
</small>
}
/>
}
/>
}
>
<ConditionallyRender
condition={hasAccess(ADMIN)}
show={<UsersList search={search} />}
elseShow={<AdminAlert />}
/>
</PageContent>
</div>
);
};
export default UsersAdmin;