1
- import { createStyles , makeStyles , Theme , Tooltip } from '@material-ui/core'
1
+ import { createStyles , IconButton , makeStyles , Theme , Tooltip } from '@material-ui/core'
2
2
import Button from '@material-ui/core/Button'
3
3
import Card from '@material-ui/core/Card'
4
4
import CardActions from '@material-ui/core/CardActions'
5
5
import CardContent from '@material-ui/core/CardContent'
6
6
import Typography from '@material-ui/core/Typography'
7
+ import DeleteIcon from '@material-ui/icons/Delete'
7
8
import { Settings } from '@sensenet/default-content-types'
8
9
import { useRepository } from '@sensenet/hooks-react'
9
10
import { clsx } from 'clsx'
@@ -12,6 +13,7 @@ import { Link, useHistory } from 'react-router-dom'
12
13
import { ResponsivePersonalSettings } from '../../context'
13
14
import { useLocalization } from '../../hooks'
14
15
import { getPrimaryActionUrl } from '../../services'
16
+ import { useDialog } from '../dialogs'
15
17
16
18
const useStyles = makeStyles ( ( theme : Theme ) => {
17
19
return createStyles ( {
@@ -52,6 +54,20 @@ type ContentCardProps = {
52
54
}
53
55
54
56
const hasDocumentation = [ 'Portal' , 'OAuth' , 'DocumentPreview' , 'OfficeOnline' , 'Indexing' , 'Sharing' ]
57
+ const isSystemSettings = [
58
+ 'OAuth' ,
59
+ 'OfficeOnline' ,
60
+ 'Indexing' ,
61
+ 'Sharing' ,
62
+ 'Logging' ,
63
+ 'Portal' ,
64
+ 'Permission' ,
65
+ 'MailProcessor' ,
66
+ 'UserProfile' ,
67
+ 'ColumnSettings' ,
68
+ 'TaskManagement' ,
69
+ 'MultiFactorAuthentication' ,
70
+ ]
55
71
56
72
export const ContentCard = ( { settings, onContextMenu } : ContentCardProps ) => {
57
73
const localization = useLocalization ( ) . settings
@@ -60,7 +76,8 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
60
76
const history = useHistory ( )
61
77
const classes = useStyles ( )
62
78
const settingsName = settings . DisplayName || settings . Name
63
- const settingsTitle = settingsName . replace ( / .s e t t i n g s / gi, '' )
79
+ const settingsTitle = settingsName . replace ( / \. s e t t i n g s / gi, '' )
80
+ const { openDialog } = useDialog ( )
64
81
65
82
return (
66
83
< Card
@@ -83,33 +100,47 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
83
100
/>
84
101
</ CardContent >
85
102
< CardActions style = { { justifyContent : 'flex-end' } } >
103
+ { ! isSystemSettings . includes ( settingsTitle ) && (
104
+ < IconButton
105
+ data-test = "batch-delete"
106
+ aria-label = "delete"
107
+ onClick = { ( ) => {
108
+ openDialog ( {
109
+ name : 'delete' ,
110
+ props : { content : [ settings ] } ,
111
+ dialogProps : { disableBackdropClick : true , disableEscapeKeyDown : true } ,
112
+ } )
113
+ } } >
114
+ < DeleteIcon />
115
+ </ IconButton >
116
+ ) }
86
117
< Link
87
118
to = { getPrimaryActionUrl ( { content : settings , repository, uiSettings, location : history . location } ) }
88
119
style = { { textDecoration : 'none' } } >
89
120
< Button
90
121
aria-label = { localization . edit }
91
122
size = "small"
92
123
className = { classes . button }
93
- style = { { marginRight : '35px' } }
124
+ // style={{ marginRight: '35px' }}
94
125
data-test = { `${ settings . Name . replace ( / \s + / g, '-' ) . toLowerCase ( ) } -edit-button` } >
95
126
{ localization . edit }
96
127
</ Button >
97
128
</ Link >
98
- < a
99
- target = "_blank"
100
- rel = "noopener noreferrer "
101
- href = { ` ${ SETUP_DOCS_URL } ${ createAnchorFromName ( settings . Name ) } ` }
102
- style = { { textDecoration : 'none' } } >
103
- { hasDocumentation . includes ( settingsTitle ) && (
129
+ { hasDocumentation . includes ( settingsTitle ) && (
130
+ < a
131
+ target = "_blank "
132
+ rel = "noopener noreferrer"
133
+ href = { ` ${ SETUP_DOCS_URL } ${ createAnchorFromName ( settings . Name ) } ` }
134
+ style = { { textDecoration : 'none' } } >
104
135
< Button
105
136
aria-label = { localization . learnMore }
106
137
size = "small"
107
138
className = { classes . button }
108
139
data-test = "content-card-learnmore-button" >
109
140
{ localization . learnMore }
110
141
</ Button >
111
- ) }
112
- </ a >
142
+ </ a >
143
+ ) }
113
144
</ CardActions >
114
145
</ Card >
115
146
)
0 commit comments