1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-29 01:15:48 +02:00
unleash.unleash/frontend/src/component/common/PageHeader/PageHeader.tsx
Nuno Góis df6208e309 feat: add user groups (#1130)
* feat: add user groups table

* add groups and group view

* fix top level await on mock data

* add UG flag

* create group files, refactor group cards

* add generic badge component

* adapt hooks to use endpoints

* implement basic create group

* fix: update snap

* fix: type id as string for now

* implement create group, use api, refactoring

* add stars to group owners

* refactor GroupForm.tsx to use styled components

* feat: remove group

* add edit group

* add group card actions

* feat: edit and remove group users

* add users to groups

* Initial commit

* refine project access table

* add project access group view

* Take users and groups from backend

* Add onsubmit

* new project access, assign and edit

* fix EditGroup, Group

* Finish assigning roles in project

* List assigned projects in group card

* Run prettier

* Add added column to project access table

Co-authored-by: Jaanus Sellin <jaanus@getunleash.ai>
Co-authored-by: sighphyre <liquidwicked64@gmail.com>
2022-07-22 07:31:08 +00:00

89 lines
2.4 KiB
TypeScript

import { ReactNode, FC, VFC } from 'react';
import classnames from 'classnames';
import {
Divider,
styled,
SxProps,
Theme,
Typography,
TypographyProps,
} from '@mui/material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { useStyles } from './PageHeader.styles';
import { usePageTitle } from 'hooks/usePageTitle';
const StyledDivider = styled(Divider)(({ theme }) => ({
height: '100%',
borderColor: theme.palette.dividerAlternative,
width: '1px',
display: 'inline-block',
marginLeft: theme.spacing(2),
marginRight: theme.spacing(2),
padding: '10px 0',
verticalAlign: 'middle',
}));
interface IPageHeaderProps {
title?: string;
titleElement?: ReactNode;
subtitle?: string;
variant?: TypographyProps['variant'];
loading?: boolean;
actions?: ReactNode;
className?: string;
secondary?: boolean;
}
const PageHeaderComponent: FC<IPageHeaderProps> & {
Divider: typeof PageHeaderDivider;
} = ({
title,
titleElement,
actions,
subtitle,
variant,
loading,
className = '',
secondary,
children,
}) => {
const { classes: styles } = useStyles();
const headerClasses = classnames({ skeleton: loading });
usePageTitle(secondary ? '' : title);
return (
<div className={styles.headerContainer}>
<div className={styles.topContainer}>
<div
className={classnames(styles.header, headerClasses)}
data-loading
>
<Typography
variant={variant || secondary ? 'h2' : 'h1'}
className={classnames(styles.headerTitle, className)}
>
{titleElement || title}
</Typography>
{subtitle && <small>{subtitle}</small>}
</div>
<ConditionallyRender
condition={Boolean(actions)}
show={<div className={styles.headerActions}>{actions}</div>}
/>
</div>
{children}
</div>
);
};
const PageHeaderDivider: VFC<{ sx?: SxProps<Theme> }> = ({ sx }) => {
return <StyledDivider orientation="vertical" variant="middle" sx={sx} />;
};
PageHeaderComponent.Divider = PageHeaderDivider;
export const PageHeader = PageHeaderComponent;