1+ import { Theme } from '@mui/material' ;
12import { MUIDataTableColumn , MUIDataTableMeta } from 'mui-datatables' ;
23import { PLAYGROUND_MODES } from '../../constants/constants' ;
34import { ChainIcon , CopyIcon , KanvasIcon , PublishIcon } from '../../icons' ;
45import Download from '../../icons/Download/Download' ;
5- import { CHARCOAL } from '../../theme' ;
66import { downloadPattern , slugify } from '../CatalogDetail/helper' ;
77import { RESOURCE_TYPES } from '../CatalogDetail/types' ;
88import { Pattern } from '../CustomCatalog/CustomCard' ;
99import { ConditionalTooltip } from '../Helpers/CondtionalTooltip' ;
1010import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx' ;
1111import { DataTableEllipsisMenu } from '../ResponsiveDataTable' ;
12- import AuthorCell from './AuthorCell ' ;
12+ import { UserTableAvatarInfo } from '../UsersTable ' ;
1313import { getColumnValue } from './helper' ;
1414import { L5DeleteIcon , NameDiv } from './style' ;
1515
@@ -25,7 +25,8 @@ interface ColumnConfigProps {
2525 handleCopyUrl : ( type : string , name : string , id : string ) => void ;
2626 handleClone : ( name : string , id : string ) => void ;
2727 handleShowDetails : ( designId : string , designName : string ) => void ;
28- getDownloadUrl : ( id : string ) => string ;
28+ handleDownload ?: ( design : Pattern ) => void ;
29+ getDownloadUrl ?: ( id : string ) => string ;
2930 isDownloadAllowed : boolean ;
3031 isCopyLinkAllowed : boolean ;
3132 isDeleteAllowed : boolean ;
@@ -34,6 +35,7 @@ interface ColumnConfigProps {
3435 // for workspace designs table page only
3536 isFromWorkspaceTable ?: boolean ;
3637 isRemoveAllowed ?: boolean ;
38+ theme ?: Theme ;
3739}
3840
3941export const colViews : ColView [ ] = [
@@ -55,12 +57,14 @@ export const createDesignsColumnsConfig = ({
5557 handleClone,
5658 handleShowDetails,
5759 getDownloadUrl,
60+ handleDownload,
5861 isUnpublishAllowed,
5962 isCopyLinkAllowed,
6063 isDeleteAllowed,
6164 isPublishAllowed,
6265 isDownloadAllowed,
6366 isRemoveAllowed,
67+ theme,
6468 isFromWorkspaceTable = false
6569} : ColumnConfigProps ) : MUIDataTableColumn [ ] => {
6670 return [
@@ -99,13 +103,14 @@ export const createDesignsColumnsConfig = ({
99103 const lastName = getColumnValue ( tableMeta as TableMeta , 'last_name' ) ;
100104 const avatar_url = getColumnValue ( tableMeta as TableMeta , 'avatar_url' ) ;
101105 const user_id = getColumnValue ( tableMeta as TableMeta , 'user_id' ) ;
106+ const userEmail = getColumnValue ( tableMeta as TableMeta , 'email' ) ;
102107
103108 return (
104- < AuthorCell
105- firstName = { firstName }
106- lastName = { lastName }
107- avatarUrl = { avatar_url }
109+ < UserTableAvatarInfo
110+ userEmail = { userEmail }
108111 userId = { user_id }
112+ userName = { `${ firstName } ${ lastName } ` }
113+ profileUrl = { avatar_url }
109114 />
110115 ) ;
111116 }
@@ -153,6 +158,17 @@ export const createDesignsColumnsConfig = ({
153158 searchable : false
154159 }
155160 } ,
161+
162+ {
163+ name : 'email' ,
164+ label : 'email' ,
165+ options : {
166+ filter : false ,
167+ sort : false ,
168+ searchable : false
169+ }
170+ } ,
171+
156172 {
157173 name : 'actions' ,
158174 label : 'Actions' ,
@@ -165,21 +181,22 @@ export const createDesignsColumnsConfig = ({
165181 customBodyRender : function CustomBody ( _ , tableMeta : MUIDataTableMeta ) {
166182 const rowIndex = ( tableMeta as TableMeta ) . rowIndex ;
167183 const rowData = ( tableMeta as TableMeta ) . tableData [ rowIndex ] ;
168-
169184 const actionsList = [
170185 {
171186 title : 'Download' ,
172- onClick : ( ) => downloadPattern ( rowData . id , rowData . name , getDownloadUrl ) ,
187+ onClick : getDownloadUrl
188+ ? ( ) => downloadPattern ( rowData . id , rowData . name , getDownloadUrl )
189+ : ( ) => handleDownload && handleDownload ( rowData ) ,
173190 disabled : ! isDownloadAllowed ,
174- icon : < Download width = { 24 } height = { 24 } fill = { CHARCOAL } />
191+ icon : < Download width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
175192 } ,
176193 {
177194 title : 'Copy Link' ,
178195 disabled : rowData . visibility === 'private' || ! isCopyLinkAllowed ,
179196 onClick : ( ) => {
180197 handleCopyUrl ( RESOURCE_TYPES . DESIGN , rowData ?. name , rowData ?. id ) ;
181198 } ,
182- icon : < ChainIcon width = { '24' } height = { '24' } fill = { CHARCOAL } />
199+ icon : < ChainIcon width = { '24' } height = { '24' } fill = { theme ?. palette . icon . secondary } />
183200 } ,
184201 {
185202 title : 'Open in playground' ,
@@ -191,7 +208,9 @@ export const createDesignsColumnsConfig = ({
191208 '_blank'
192209 ) ;
193210 } ,
194- icon : < KanvasIcon width = { 24 } height = { 24 } primaryFill = { CHARCOAL } />
211+ icon : (
212+ < KanvasIcon width = { 24 } height = { 24 } primaryFill = { theme ?. palette . icon . secondary } />
213+ )
195214 } ,
196215 {
197216 title : isFromWorkspaceTable ? 'Remove Design' : 'Delete' ,
@@ -205,20 +224,20 @@ export const createDesignsColumnsConfig = ({
205224 title : 'Publish' ,
206225 disabled : ! isPublishAllowed ,
207226 onClick : ( ) => handlePublishModal ( rowData ) ,
208- icon : < PublishIcon width = { 24 } height = { 24 } fill = { CHARCOAL } />
227+ icon : < PublishIcon width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
209228 } ;
210229
211230 const unpublishAction = {
212231 title : 'Unpublish' ,
213232 onClick : ( ) => handleUnpublishModal ( rowData ) ( ) ,
214233 disabled : ! isUnpublishAllowed ,
215- icon : < PublishIcon width = { 24 } height = { 24 } fill = { CHARCOAL } />
234+ icon : < PublishIcon width = { 24 } height = { 24 } fill = { theme ?. palette . icon . secondary } />
216235 } ;
217236
218237 const cloneAction = {
219238 title : 'Clone' ,
220239 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 } />
222241 } ;
223242
224243 if ( rowData . visibility === 'published' ) {
@@ -228,7 +247,7 @@ export const createDesignsColumnsConfig = ({
228247 actionsList . splice ( 1 , 0 , publishAction ) ;
229248 }
230249
231- return < DataTableEllipsisMenu actionsList = { actionsList } /> ;
250+ return < DataTableEllipsisMenu actionsList = { actionsList } theme = { theme } /> ;
232251 }
233252 }
234253 }
0 commit comments