From c9f5440e2d5dc49362b6835ca899efc7946f432f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Gyebrovszki?= Date: Fri, 17 Nov 2023 02:57:21 +0100 Subject: [PATCH] Conditional "Delete" iconbutton. --- .../src/components/settings/content-card.tsx | 53 +++++++++++++++---- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/apps/sensenet/src/components/settings/content-card.tsx b/apps/sensenet/src/components/settings/content-card.tsx index 358692b45..0462938ea 100644 --- a/apps/sensenet/src/components/settings/content-card.tsx +++ b/apps/sensenet/src/components/settings/content-card.tsx @@ -1,9 +1,10 @@ -import { createStyles, makeStyles, Theme, Tooltip } from '@material-ui/core' +import { createStyles, IconButton, makeStyles, Theme, Tooltip } from '@material-ui/core' import Button from '@material-ui/core/Button' import Card from '@material-ui/core/Card' import CardActions from '@material-ui/core/CardActions' import CardContent from '@material-ui/core/CardContent' import Typography from '@material-ui/core/Typography' +import DeleteIcon from '@material-ui/icons/Delete' import { Settings } from '@sensenet/default-content-types' import { useRepository } from '@sensenet/hooks-react' import { clsx } from 'clsx' @@ -12,6 +13,7 @@ import { Link, useHistory } from 'react-router-dom' import { ResponsivePersonalSettings } from '../../context' import { useLocalization } from '../../hooks' import { getPrimaryActionUrl } from '../../services' +import { useDialog } from '../dialogs' const useStyles = makeStyles((theme: Theme) => { return createStyles({ @@ -52,6 +54,20 @@ type ContentCardProps = { } const hasDocumentation = ['Portal', 'OAuth', 'DocumentPreview', 'OfficeOnline', 'Indexing', 'Sharing'] +const isSystemSettings = [ + 'OAuth', + 'OfficeOnline', + 'Indexing', + 'Sharing', + 'Logging', + 'Portal', + 'Permission', + 'MailProcessor', + 'UserProfile', + 'ColumnSettings', + 'TaskManagement', + 'MultiFactorAuthentication', +] export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => { const localization = useLocalization().settings @@ -60,7 +76,8 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => { const history = useHistory() const classes = useStyles() const settingsName = settings.DisplayName || settings.Name - const settingsTitle = settingsName.replace(/.settings/gi, '') + const settingsTitle = settingsName.replace(/\.settings/gi, '') + const { openDialog } = useDialog() return ( { /> + {!isSystemSettings.includes(settingsTitle) && ( + { + openDialog({ + name: 'delete', + props: { content: [settings] }, + dialogProps: { disableBackdropClick: true, disableEscapeKeyDown: true }, + }) + }}> + + + )} @@ -90,17 +121,17 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => { aria-label={localization.edit} size="small" className={classes.button} - style={{ marginRight: '35px' }} + //style={{ marginRight: '35px' }} data-test={`${settings.Name.replace(/\s+/g, '-').toLowerCase()}-edit-button`}> {localization.edit} - - {hasDocumentation.includes(settingsTitle) && ( + {hasDocumentation.includes(settingsTitle) && ( + - )} - + + )} )