From b0b842b931c620683a5476677ddb0b8019b49126 Mon Sep 17 00:00:00 2001 From: Amit Amrutiya Date: Tue, 19 Nov 2024 15:37:28 +0530 Subject: [PATCH] feat: add AuthorCell component and integrate it into CatalogDesignTable Signed-off-by: Amit Amrutiya --- src/custom/CatalogDesignTable/AuthorCell.tsx | 66 +++++++++++++++++++ .../CatalogDesignTable/CatalogDesignTable.tsx | 11 ++-- .../CatalogDesignTable/columnConfig.tsx | 51 +++----------- src/custom/CatalogDesignTable/index.ts | 3 +- 4 files changed, 80 insertions(+), 51 deletions(-) create mode 100644 src/custom/CatalogDesignTable/AuthorCell.tsx diff --git a/src/custom/CatalogDesignTable/AuthorCell.tsx b/src/custom/CatalogDesignTable/AuthorCell.tsx new file mode 100644 index 00000000..bf8a7ed8 --- /dev/null +++ b/src/custom/CatalogDesignTable/AuthorCell.tsx @@ -0,0 +1,66 @@ +import React from 'react'; +import { Avatar, Box, Grid, Typography } from '../../base'; +import { CLOUD_URL } from '../../constants/constants'; +import { PersonIcon } from '../../icons'; +import { CustomTooltip } from '../CustomTooltip'; + +interface AuthorCellProps { + firstName: string; + lastName: string; + avatarUrl: string; + userId: string; + maxWidth?: boolean; +} + +const AuthorCell: React.FC = ({ + firstName, + lastName, + avatarUrl, + userId, + maxWidth = true +}) => { + const displayName = + firstName && lastName + ? `${firstName} ${lastName}` + : firstName + ? firstName + : lastName + ? lastName + : ''; + + return ( + img': { mr: 2, flexShrink: 0 } }}> + + + + +
+ { + window.open(`${CLOUD_URL}/user/${userId}`, '_blank'); + }} + > + {!avatarUrl && } + +
+
+
+
+ {maxWidth && ( + + {displayName} + + )} +
+
+ ); +}; + +export default AuthorCell; diff --git a/src/custom/CatalogDesignTable/CatalogDesignTable.tsx b/src/custom/CatalogDesignTable/CatalogDesignTable.tsx index 74f4e441..42d9c111 100644 --- a/src/custom/CatalogDesignTable/CatalogDesignTable.tsx +++ b/src/custom/CatalogDesignTable/CatalogDesignTable.tsx @@ -4,7 +4,7 @@ import { useCallback, useMemo, useRef } from 'react'; import { PublishIcon } from '../../icons'; import { CHARCOAL, useTheme } from '../../theme'; import { Pattern } from '../CustomCatalog/CustomCard'; -import { useWindowDimensions } from '../Helpers/Dimension'; +import { ErrorBoundary } from '../ErrorBoundary'; import PromptComponent from '../Prompt'; import { PromptRef } from '../Prompt/promt-component'; import ResponsiveDataTable from '../ResponsiveDataTable'; @@ -47,8 +47,6 @@ export const CatalogDesignsTable: React.FC = ({ handleBulkDeleteModal, handleBulkpatternsDataUnpublishModal }) => { - const { width } = useWindowDimensions(); - const smallScreen = width <= 360; const theme = useTheme(); const modalRef = useRef(null); @@ -133,7 +131,7 @@ export const CatalogDesignsTable: React.FC = ({ selectableRows: _.isNil(filter) ? 'none' : 'multiple', serverSide: true, filterType: 'multiselect', - responsive: smallScreen ? 'vertical' : 'standard', + responsive: 'standard', count: totalCount, rowsPerPage: pageSize, page, @@ -163,7 +161,6 @@ export const CatalogDesignsTable: React.FC = ({ }), [ filter, - smallScreen, totalCount, pageSize, page, @@ -179,7 +176,7 @@ export const CatalogDesignsTable: React.FC = ({ } return ( - <> + = ({ : theme.palette.background.secondary } /> - + ); }; diff --git a/src/custom/CatalogDesignTable/columnConfig.tsx b/src/custom/CatalogDesignTable/columnConfig.tsx index 84416a36..549fd081 100644 --- a/src/custom/CatalogDesignTable/columnConfig.tsx +++ b/src/custom/CatalogDesignTable/columnConfig.tsx @@ -2,8 +2,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables'; import { FacebookShareButton, LinkedinShareButton, TwitterShareButton } from 'react-share'; -import { Avatar, Box, Grid, Typography } from '../../base'; -import { CLOUD_URL } from '../../constants/constants'; import { iconMedium } from '../../constants/iconsSizes'; import { ChainIcon, @@ -12,16 +10,15 @@ import { FacebookIcon, KanvasIcon, LinkedinIcon, - PersonIcon, PublishIcon, TwitterIcon } from '../../icons'; import { downloadFilter, downloadYaml } from '../CatalogDetail/helper'; import { RESOURCE_TYPES } from '../CatalogDetail/types'; import { Pattern } from '../CustomCatalog/CustomCard'; -import { CustomTooltip } from '../CustomTooltip'; import { ConditionalTooltip } from '../Helpers/CondtionalTooltip'; import { DataTableEllipsisMenu } from '../ResponsiveDataTable'; +import AuthorCell from './AuthorCell'; import { NameDiv } from './style'; export type ColView = [string, 'na' | 'xs' | 'l']; @@ -141,47 +138,15 @@ export const createDesignColumns = ({ const lastName = getColumnValue(tableMeta, 'last_name'); const avatar_url = getColumnValue(tableMeta, 'avatar_url'); const user_id = getColumnValue(tableMeta, 'user_id'); - const displayName = - firstName && lastName - ? `${firstName} ${lastName}` - : firstName - ? firstName - : lastName - ? lastName - : ''; return ( - img': { mr: 2, flexShrink: 0 } }}> - - - - -
- { - window.open(`${CLOUD_URL}/user/${user_id}`, '_blank'); - }} - > - {!avatar_url && } - -
-
-
-
- {maxWidth && ( - - {displayName} - - )} -
-
+ ); } } diff --git a/src/custom/CatalogDesignTable/index.ts b/src/custom/CatalogDesignTable/index.ts index fcab0208..98c1393f 100644 --- a/src/custom/CatalogDesignTable/index.ts +++ b/src/custom/CatalogDesignTable/index.ts @@ -1,5 +1,6 @@ +import AuthorCell from './AuthorCell'; import CatalogDesignsTable from './CatalogDesignTable'; import { colViews, createDesignColumns } from './columnConfig'; export { TableVisibilityControl } from './TableVisibilityControl'; export { ViewSwitch } from './ViewSwitch'; -export { CatalogDesignsTable, colViews, createDesignColumns }; +export { AuthorCell, CatalogDesignsTable, colViews, createDesignColumns };