1
+ import { Theme } from '@mui/material' ;
1
2
import { MUIDataTableColumn , MUIDataTableMeta } from 'mui-datatables' ;
2
3
import { PLAYGROUND_MODES } from '../../constants/constants' ;
3
4
import { ChainIcon , CopyIcon , KanvasIcon , PublishIcon } from '../../icons' ;
4
5
import Download from '../../icons/Download/Download' ;
5
- import { CHARCOAL } from '../../theme' ;
6
6
import { downloadPattern , slugify } from '../CatalogDetail/helper' ;
7
7
import { RESOURCE_TYPES } from '../CatalogDetail/types' ;
8
8
import { Pattern } from '../CustomCatalog/CustomCard' ;
9
9
import { ConditionalTooltip } from '../Helpers/CondtionalTooltip' ;
10
10
import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx' ;
11
11
import { DataTableEllipsisMenu } from '../ResponsiveDataTable' ;
12
- import AuthorCell from './AuthorCell ' ;
12
+ import { UserTableAvatarInfo } from '../UsersTable ' ;
13
13
import { getColumnValue } from './helper' ;
14
14
import { L5DeleteIcon , NameDiv } from './style' ;
15
15
@@ -25,7 +25,8 @@ interface ColumnConfigProps {
25
25
handleCopyUrl : ( type : string , name : string , id : string ) => void ;
26
26
handleClone : ( name : string , id : string ) => void ;
27
27
handleShowDetails : ( designId : string , designName : string ) => void ;
28
- getDownloadUrl : ( id : string ) => string ;
28
+ handleDownload ?: ( design : Pattern ) => void ;
29
+ getDownloadUrl ?: ( id : string ) => string ;
29
30
isDownloadAllowed : boolean ;
30
31
isCopyLinkAllowed : boolean ;
31
32
isDeleteAllowed : boolean ;
@@ -34,6 +35,7 @@ interface ColumnConfigProps {
34
35
// for workspace designs table page only
35
36
isFromWorkspaceTable ?: boolean ;
36
37
isRemoveAllowed ?: boolean ;
38
+ theme ?: Theme ;
37
39
}
38
40
39
41
export const colViews : ColView [ ] = [
@@ -55,12 +57,14 @@ export const createDesignsColumnsConfig = ({
55
57
handleClone,
56
58
handleShowDetails,
57
59
getDownloadUrl,
60
+ handleDownload,
58
61
isUnpublishAllowed,
59
62
isCopyLinkAllowed,
60
63
isDeleteAllowed,
61
64
isPublishAllowed,
62
65
isDownloadAllowed,
63
66
isRemoveAllowed,
67
+ theme,
64
68
isFromWorkspaceTable = false
65
69
} : ColumnConfigProps ) : MUIDataTableColumn [ ] => {
66
70
return [
@@ -99,13 +103,14 @@ export const createDesignsColumnsConfig = ({
99
103
const lastName = getColumnValue ( tableMeta as TableMeta , 'last_name' ) ;
100
104
const avatar_url = getColumnValue ( tableMeta as TableMeta , 'avatar_url' ) ;
101
105
const user_id = getColumnValue ( tableMeta as TableMeta , 'user_id' ) ;
106
+ const userEmail = getColumnValue ( tableMeta as TableMeta , 'email' ) ;
102
107
103
108
return (
104
- < AuthorCell
105
- firstName = { firstName }
106
- lastName = { lastName }
107
- avatarUrl = { avatar_url }
109
+ < UserTableAvatarInfo
110
+ userEmail = { userEmail }
108
111
userId = { user_id }
112
+ userName = { `${ firstName } ${ lastName } ` }
113
+ profileUrl = { avatar_url }
109
114
/>
110
115
) ;
111
116
}
@@ -153,6 +158,17 @@ export const createDesignsColumnsConfig = ({
153
158
searchable : false
154
159
}
155
160
} ,
161
+
162
+ {
163
+ name : 'email' ,
164
+ label : 'email' ,
165
+ options : {
166
+ filter : false ,
167
+ sort : false ,
168
+ searchable : false
169
+ }
170
+ } ,
171
+
156
172
{
157
173
name : 'actions' ,
158
174
label : 'Actions' ,
@@ -165,21 +181,22 @@ export const createDesignsColumnsConfig = ({
165
181
customBodyRender : function CustomBody ( _ , tableMeta : MUIDataTableMeta ) {
166
182
const rowIndex = ( tableMeta as TableMeta ) . rowIndex ;
167
183
const rowData = ( tableMeta as TableMeta ) . tableData [ rowIndex ] ;
168
-
169
184
const actionsList = [
170
185
{
171
186
title : 'Download' ,
172
- onClick : ( ) => downloadPattern ( rowData . id , rowData . name , getDownloadUrl ) ,
187
+ onClick : getDownloadUrl
188
+ ? ( ) => downloadPattern ( rowData . id , rowData . name , getDownloadUrl )
189
+ : ( ) => handleDownload && handleDownload ( rowData ) ,
173
190
disabled : ! isDownloadAllowed ,
174
- icon : < Download width = { 24 } height = { 24 } fill = { CHARCOAL } />
191
+ icon : < Download width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
175
192
} ,
176
193
{
177
194
title : 'Copy Link' ,
178
195
disabled : rowData . visibility === 'private' || ! isCopyLinkAllowed ,
179
196
onClick : ( ) => {
180
197
handleCopyUrl ( RESOURCE_TYPES . DESIGN , rowData ?. name , rowData ?. id ) ;
181
198
} ,
182
- icon : < ChainIcon width = { '24' } height = { '24' } fill = { CHARCOAL } />
199
+ icon : < ChainIcon width = { '24' } height = { '24' } fill = { theme ?. palette . icon . secondary } />
183
200
} ,
184
201
{
185
202
title : 'Open in playground' ,
@@ -191,7 +208,9 @@ export const createDesignsColumnsConfig = ({
191
208
'_blank'
192
209
) ;
193
210
} ,
194
- icon : < KanvasIcon width = { 24 } height = { 24 } primaryFill = { CHARCOAL } />
211
+ icon : (
212
+ < KanvasIcon width = { 24 } height = { 24 } primaryFill = { theme ?. palette . icon . secondary } />
213
+ )
195
214
} ,
196
215
{
197
216
title : isFromWorkspaceTable ? 'Remove Design' : 'Delete' ,
@@ -205,20 +224,20 @@ export const createDesignsColumnsConfig = ({
205
224
title : 'Publish' ,
206
225
disabled : ! isPublishAllowed ,
207
226
onClick : ( ) => handlePublishModal ( rowData ) ,
208
- icon : < PublishIcon width = { 24 } height = { 24 } fill = { CHARCOAL } />
227
+ icon : < PublishIcon width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
209
228
} ;
210
229
211
230
const unpublishAction = {
212
231
title : 'Unpublish' ,
213
232
onClick : ( ) => handleUnpublishModal ( rowData ) ( ) ,
214
233
disabled : ! isUnpublishAllowed ,
215
- icon : < PublishIcon width = { 24 } height = { 24 } fill = { CHARCOAL } />
234
+ icon : < PublishIcon width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
216
235
} ;
217
236
218
237
const cloneAction = {
219
238
title : 'Clone' ,
220
239
onClick : ( ) => handleClone ( rowData ?. name , rowData ?. id ) ,
221
- icon : < CopyIcon width = { 24 } height = { 24 } fill = { CHARCOAL } />
240
+ icon : < CopyIcon width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
222
241
} ;
223
242
224
243
if ( rowData . visibility === 'published' ) {
@@ -228,7 +247,7 @@ export const createDesignsColumnsConfig = ({
228
247
actionsList . splice ( 1 , 0 , publishAction ) ;
229
248
}
230
249
231
- return < DataTableEllipsisMenu actionsList = { actionsList } /> ;
250
+ return < DataTableEllipsisMenu actionsList = { actionsList } theme = { theme } /> ;
232
251
}
233
252
}
234
253
}
0 commit comments