2021-12-10 12:04:02 +01:00
|
|
|
import { capitalize } from '@material-ui/core';
|
2021-10-01 13:49:18 +02:00
|
|
|
import classnames from 'classnames';
|
|
|
|
import { useParams } from 'react-router-dom';
|
2021-10-08 11:23:29 +02:00
|
|
|
import { Link } from 'react-router-dom';
|
2022-03-28 10:49:59 +02:00
|
|
|
import { useFeature } from 'hooks/api/getters/useFeature/useFeature';
|
2022-03-25 12:34:20 +01:00
|
|
|
import { getFeatureTypeIcons } from 'utils/getFeatureTypeIcons';
|
2022-03-28 10:49:59 +02:00
|
|
|
import ConditionallyRender from 'component/common/ConditionallyRender';
|
2021-10-08 11:23:29 +02:00
|
|
|
import { useStyles } from './FeatureOverviewMetadata.styles';
|
2021-10-01 13:49:18 +02:00
|
|
|
|
|
|
|
import { Edit } from '@material-ui/icons';
|
2022-03-28 10:49:59 +02:00
|
|
|
import { IFeatureViewParams } from 'interfaces/params';
|
|
|
|
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
|
|
|
|
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
|
|
|
import useTags from 'hooks/api/getters/useTags/useTags';
|
2021-11-12 11:47:19 +01:00
|
|
|
import FeatureOverviewTags from './FeatureOverviewTags/FeatureOverviewTags';
|
2021-10-01 13:49:18 +02:00
|
|
|
|
2021-10-08 11:23:29 +02:00
|
|
|
const FeatureOverviewMetaData = () => {
|
2021-10-01 13:49:18 +02:00
|
|
|
const styles = useStyles();
|
|
|
|
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
2021-11-12 11:47:19 +01:00
|
|
|
const { tags } = useTags(featureId);
|
2021-10-01 13:49:18 +02:00
|
|
|
|
|
|
|
const { feature } = useFeature(projectId, featureId);
|
|
|
|
|
|
|
|
const { project, description, type } = feature;
|
|
|
|
|
|
|
|
const IconComponent = getFeatureTypeIcons(type);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classnames(styles.container)}>
|
2021-11-12 11:47:19 +01:00
|
|
|
<div className={styles.paddingContainerTop}>
|
|
|
|
<div className={styles.metaDataHeader} data-loading>
|
|
|
|
<IconComponent className={styles.headerIcon} />{' '}
|
2022-04-21 09:52:43 +02:00
|
|
|
<h2 className={styles.header}>
|
2021-11-12 11:47:19 +01:00
|
|
|
{capitalize(type || '')} toggle
|
2022-04-21 09:52:43 +02:00
|
|
|
</h2>
|
2021-11-12 11:47:19 +01:00
|
|
|
</div>
|
|
|
|
<div className={styles.body}>
|
|
|
|
<span className={styles.bodyItem} data-loading>
|
|
|
|
Project: {project}
|
|
|
|
</span>
|
|
|
|
<ConditionallyRender
|
2022-03-03 10:01:04 +01:00
|
|
|
// @ts-expect-error
|
2021-11-12 11:47:19 +01:00
|
|
|
condition={description}
|
|
|
|
show={
|
|
|
|
<span className={styles.bodyItem} data-loading>
|
|
|
|
<div>Description:</div>
|
|
|
|
<div className={styles.descriptionContainer}>
|
|
|
|
<p>{description}</p>
|
|
|
|
<PermissionIconButton
|
|
|
|
projectId={projectId}
|
|
|
|
permission={UPDATE_FEATURE}
|
|
|
|
component={Link}
|
2022-02-04 10:36:08 +01:00
|
|
|
to={`/projects/${projectId}/features/${featureId}/settings`}
|
2021-11-12 11:47:19 +01:00
|
|
|
>
|
2022-04-21 08:26:49 +02:00
|
|
|
<Edit
|
|
|
|
className={styles.editIcon}
|
|
|
|
titleAccess="Settings"
|
|
|
|
/>
|
2021-11-12 11:47:19 +01:00
|
|
|
</PermissionIconButton>
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
elseShow={
|
|
|
|
<span data-loading>
|
|
|
|
<div className={styles.descriptionContainer}>
|
|
|
|
No description.{' '}
|
2021-12-10 12:04:02 +01:00
|
|
|
<PermissionIconButton
|
|
|
|
projectId={projectId}
|
|
|
|
permission={UPDATE_FEATURE}
|
2021-11-12 11:47:19 +01:00
|
|
|
component={Link}
|
2022-02-04 10:36:08 +01:00
|
|
|
to={`/projects/${projectId}/features/${featureId}/settings`}
|
2022-04-21 08:26:49 +02:00
|
|
|
tooltip="Edit description"
|
2021-11-12 11:47:19 +01:00
|
|
|
>
|
2021-12-10 12:04:02 +01:00
|
|
|
<Edit className={styles.editIcon} />
|
|
|
|
</PermissionIconButton>
|
2021-11-12 11:47:19 +01:00
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-10-01 13:49:18 +02:00
|
|
|
</div>
|
2021-11-12 11:47:19 +01:00
|
|
|
<ConditionallyRender
|
|
|
|
condition={tags.length > 0}
|
|
|
|
show={
|
|
|
|
<div className={styles.paddingContainerBottom}>
|
2022-01-14 15:50:02 +01:00
|
|
|
<FeatureOverviewTags projectId={projectId} />
|
2021-11-12 11:47:19 +01:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
2021-10-01 13:49:18 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-10-08 11:23:29 +02:00
|
|
|
export default FeatureOverviewMetaData;
|