Skip to content

Commit 7a09818

Browse files
committed
fix: workspace back card layout
Signed-off-by: amitamrutiya <[email protected]>
1 parent 19bf270 commit 7a09818

File tree

5 files changed

+61
-22
lines changed

5 files changed

+61
-22
lines changed

src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ interface ColumnConfigProps {
3939
isFromWorkspaceTable?: boolean;
4040
isRemoveAllowed?: boolean;
4141
theme?: Theme;
42+
isVisibilityEnabled: boolean;
43+
handleVisibilityChange: (visibility: VIEW_VISIBILITY) => void;
4244
}
4345

4446
export const colViews: ColView[] = [
@@ -68,7 +70,9 @@ export const createDesignsColumnsConfig = ({
6870
isDownloadAllowed,
6971
isRemoveAllowed,
7072
theme,
71-
isFromWorkspaceTable = false
73+
isFromWorkspaceTable = false,
74+
isVisibilityEnabled,
75+
handleVisibilityChange
7276
}: ColumnConfigProps): MUIDataTableColumn[] => {
7377
return [
7478
{

src/custom/Workspaces/DesignTable.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export interface DesignTableProps {
5656
isAssignAllowed: boolean;
5757
isRemoveAllowed: boolean;
5858
setDesignSearch: (value: string) => void;
59+
isVisibilityEnabled: boolean;
60+
handleVisibilityChange: (visibility: string) => void;
5961
}
6062

6163
export interface PublishModalState {
@@ -96,7 +98,9 @@ const DesignTable: React.FC<DesignTableProps> = ({
9698
isAssignAllowed,
9799
isRemoveAllowed,
98100
useGetWorkspaceDesignsQuery,
99-
setDesignSearch
101+
setDesignSearch,
102+
isVisibilityEnabled,
103+
handleVisibilityChange
100104
}) => {
101105
const [publishModal, setPublishModal] = useState<PublishModalState>({
102106
open: false,
@@ -132,7 +136,9 @@ const DesignTable: React.FC<DesignTableProps> = ({
132136
isUnpublishAllowed,
133137
isFromWorkspaceTable: true,
134138
isRemoveAllowed,
135-
theme
139+
theme,
140+
isVisibilityEnabled: isVisibilityEnabled,
141+
handleVisibilityChange: handleVisibilityChange
136142
});
137143

138144
const [publishSchema, setPublishSchema] = useState<{

src/custom/Workspaces/WorkspaceCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useTheme } from '@mui/material';
22
import { Backdrop, CircularProgress, Grid } from '../../base';
3+
import { getRelativeTime } from '../../utils';
34
import { FlipCard } from '../FlipCard';
45
import { RecordRow, RedirectButton, TransferButton } from './WorkspaceTransferButton';
5-
import { formattoLongDate } from './helper';
66
import {
77
AllocationColumnGrid,
88
AllocationWorkspace,
@@ -408,12 +408,12 @@ const CardBack = ({
408408
<DateGrid xs={12}>
409409
<DateColumnGrid xs={6}>
410410
<DateLabel onClick={(e) => e.stopPropagation()}>
411-
Updated At: {formattoLongDate(updatedDate)}
411+
Updated At: {getRelativeTime(updatedDate)}
412412
</DateLabel>
413413
</DateColumnGrid>
414414
<DateColumnGrid xs={6}>
415415
<DateLabel onClick={(e) => e.stopPropagation()}>
416-
Created At: {formattoLongDate(createdDate)}
416+
Created At: {getRelativeTime(createdDate)}
417417
</DateLabel>
418418
</DateColumnGrid>
419419
</DateGrid>

src/custom/Workspaces/WorkspaceTransferButton.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { SyncAlt as SyncAltIcon } from '@mui/icons-material';
2-
import { Grid, Tooltip, Typography } from '../../base';
2+
import { Grid, Typography } from '../../base';
33
import { useTheme } from '../../theme';
4-
import { formatShortDate, formatShortDateTime } from './helper';
4+
import { getFullFormattedTime, getRelativeTime } from '../../utils';
5+
import { CustomTooltip } from '../CustomTooltip';
56
import { PopupButton, Record, TabCount, TabTitle } from './styles';
67

78
interface TransferButtonProps {
@@ -89,25 +90,32 @@ export const RecordRow: React.FC<RecordRowProps> = ({ title, name, date }) => {
8990
{title}
9091
</Typography>
9192
<Typography
92-
sx={{ ml: 1, fontStyle: 'italic', color: theme.palette.background.brand?.default }}
93+
sx={{
94+
marginInline: '0.5rem',
95+
fontStyle: 'italic',
96+
color: theme.palette.background.brand?.default,
97+
textWrap: 'nowrap'
98+
}}
9399
>
94100
{name}
95101
</Typography>
96102
</Grid>
97103
<Grid xs={2} sx={{ display: 'flex', justifyContent: 'flex-end' }}>
98-
<Tooltip title={date ? formatShortDateTime(date) : ''} placement="top">
99-
<Typography
100-
sx={{
101-
fontSize: 14,
102-
fontStyle: 'italic',
103-
color: `${theme.palette.text.disabled}`,
104-
paddingRight: '12px',
105-
textAlign: 'end'
106-
}}
107-
>
108-
{date ? formatShortDate(date) : '-'}
109-
</Typography>
110-
</Tooltip>
104+
<CustomTooltip title={date ? getFullFormattedTime(date as string) : ''} placement="top">
105+
<div>
106+
<Typography
107+
sx={{
108+
fontSize: 14,
109+
fontStyle: 'italic',
110+
color: `${theme.palette.text.disabled}`,
111+
paddingRight: '12px',
112+
textAlign: 'end'
113+
}}
114+
>
115+
{date ? getRelativeTime(date as string) : '-'}
116+
</Typography>
117+
</div>
118+
</CustomTooltip>
111119
</Grid>
112120
</Record>
113121
);

src/utils/time.utils.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
import moment from 'moment';
22
import { CustomTooltip } from '../custom';
33

4+
/**
5+
* Returns the relative time (e.g. "2 hours ago") from a given date string
6+
* @param {string} date - ISO format date string
7+
* @returns {string} Human-readable relative time
8+
*/
49
export const getRelativeTime = (date: string): string => {
510
return moment(date).fromNow();
611
};
712

13+
/**
14+
* Returns a fully formatted date and time string
15+
* @param {string} date - ISO format date string
16+
* @returns {string} Formatted date in "ddd, MMM D, YYYY h:mm A" format (e.g. "Mon, Jan 1, 2025 3:45 PM")
17+
*/
818
export const getFullFormattedTime = (date: string): string => {
919
return moment(date).format('ddd, MMM D, YYYY h:mm A');
1020
};
1121

22+
/**
23+
* Formats a date string into a short date format
24+
* @param {string} date - ISO format date string
25+
* @returns {string} Formatted date in "Month Day, Year" format (e.g. "Jan 1, 2025")
26+
*/
1227
export const getFormatDate = (date: string) => {
1328
const options = { year: 'numeric' as const, month: 'short' as const, day: 'numeric' as const };
1429
const formattedDate = new Date(date).toLocaleDateString('en-US', options);
1530
return formattedDate;
1631
};
1732

33+
/**
34+
* React component that displays relative time with a tooltip showing the full date and time
35+
* @param {Object} props - Component props
36+
* @param {string} props.date - ISO format date string
37+
* @returns {JSX.Element} Formatted time component with tooltip
38+
*/
1839
export const FormattedTime = ({ date }: { date: string }) => {
1940
return (
2041
<CustomTooltip title={getFullFormattedTime(date)} disableInteractive>

0 commit comments

Comments
 (0)