Skip to content

Commit 19bf270

Browse files
committed
feat: update visibility chip
Signed-off-by: amitamrutiya <[email protected]>
1 parent 83e9fa1 commit 19bf270

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { Theme } from '@mui/material';
22
import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables';
33
import { Typography } from '../../base';
44
import { PLAYGROUND_MODES } from '../../constants/constants';
5-
import { ChainIcon, CopyIcon, KanvasIcon, PublishIcon } from '../../icons';
5+
import { ChainIcon, CopyIcon, KanvasIcon, LockIcon, PublicIcon, PublishIcon } from '../../icons';
66
import Download from '../../icons/Download/Download';
77
import { downloadPattern, slugify } from '../CatalogDetail/helper';
88
import { RESOURCE_TYPES } from '../CatalogDetail/types';
99
import { Pattern } from '../CustomCatalog/CustomCard';
1010
import { ConditionalTooltip } from '../Helpers/CondtionalTooltip';
1111
import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx';
1212
import { DataTableEllipsisMenu } from '../ResponsiveDataTable';
13+
import { VisibilityChipMenu } from '../VisibilityChipMenu';
14+
import { VIEW_VISIBILITY } from '../VisibilityChipMenu/VisibilityChipMenu';
1315
import AuthorCell from './AuthorCell';
1416
import { getColumnValue } from './helper';
1517
import { L5DeleteIcon, NameDiv } from './style';
@@ -146,7 +148,20 @@ export const createDesignsColumnsConfig = ({
146148
options: {
147149
filter: false,
148150
sort: false,
149-
searchable: true
151+
searchable: true,
152+
customBodyRender: (value: VIEW_VISIBILITY) => {
153+
return (
154+
<VisibilityChipMenu
155+
value={value}
156+
onChange={(value) => handleVisibilityChange(value as VIEW_VISIBILITY)}
157+
enabled={isVisibilityEnabled}
158+
options={[
159+
[VIEW_VISIBILITY.PUBLIC, PublicIcon],
160+
[VIEW_VISIBILITY.PRIVATE, LockIcon]
161+
]}
162+
/>
163+
);
164+
}
150165
}
151166
},
152167
{
@@ -180,8 +195,7 @@ export const createDesignsColumnsConfig = ({
180195
filter: false,
181196
sort: false,
182197
searchable: false,
183-
setCellHeaderProps: () => ({ align: 'center' as const }),
184-
setCellProps: () => ({ align: 'center' as const }),
198+
185199
customBodyRender: function CustomBody(_, tableMeta: MUIDataTableMeta) {
186200
const rowIndex = (tableMeta as TableMeta).rowIndex;
187201
const rowData = (tableMeta as TableMeta).tableData[rowIndex];
@@ -203,7 +217,7 @@ export const createDesignsColumnsConfig = ({
203217
icon: <ChainIcon width={'24'} height={'24'} fill={theme?.palette.icon.secondary} />
204218
},
205219
{
206-
title: 'Open in playground',
220+
title: 'Open in Playground',
207221
onClick: () => {
208222
window.open(
209223
`https://playground.meshery.io/extension/meshmap?mode=${

src/custom/VisibilityChipMenu/VisibilityChipMenu.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export type VIEW_VISIBILITY = (typeof VIEW_VISIBILITY)[keyof typeof VIEW_VISIBIL
1515

1616
interface VisibilityChipMenuProps {
1717
value: VIEW_VISIBILITY;
18-
onChange: (value: string) => void;
19-
options: [string, React.ElementType][];
18+
onChange?: (value: string) => void;
19+
options?: [string, React.ElementType][];
2020
enabled: boolean;
2121
}
2222

@@ -95,7 +95,9 @@ const VisibilityChipMenu: React.FC<VisibilityChipMenuProps> = ({
9595
};
9696
const handleChange = (e: MouseEvent, value: string) => {
9797
e.stopPropagation();
98-
onChange(value);
98+
if (onChange) {
99+
onChange(value);
100+
}
99101
close(e);
100102
};
101103
const theme = useTheme();
@@ -122,7 +124,7 @@ const VisibilityChipMenu: React.FC<VisibilityChipMenuProps> = ({
122124
left: (anchorEl?.getBoundingClientRect().left ?? 0) + 5
123125
}}
124126
>
125-
{options.map(([visibility, Icon], index) => (
127+
{options?.map(([visibility, Icon], index) => (
126128
<StyledMenuItem
127129
key={index}
128130
data-testid={`visibility-toggle-${visibility.toLowerCase()}`}

src/custom/Workspaces/WorkspaceViewsTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import ResponsiveDataTable, { IconWrapper } from '../ResponsiveDataTable';
1818
import SearchBar from '../SearchBar';
1919
import { TooltipIcon } from '../TooltipIconButton';
2020
import { UserTableAvatarInfo } from '../UsersTable';
21+
import VisibilityChipMenu, { VIEW_VISIBILITY } from '../VisibilityChipMenu/VisibilityChipMenu';
2122
import AssignmentModal from './AssignmentModal';
2223
import useViewAssignment from './hooks/useViewsAssignment';
2324
import {
@@ -211,8 +212,8 @@ const WorkspaceViewsTable: React.FC<ViewsTableProps> = ({
211212
filter: false,
212213
sort: false,
213214
searchable: true,
214-
setCellHeaderProps: () => {
215-
return { align: 'center' };
215+
customBodyRender: (value: VIEW_VISIBILITY) => {
216+
return <VisibilityChipMenu value={value} enabled={false} />;
216217
}
217218
}
218219
},

0 commit comments

Comments
 (0)