Skip to content

Commit

Permalink
Merge branch 'master' into update-url
Browse files Browse the repository at this point in the history
  • Loading branch information
amitamrutiya authored Nov 13, 2024
2 parents 15eb7be + c552754 commit 970c987
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/custom/CatalogDesignTable/columnConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface ColumnConfigProps {
type?: string;
theme?: any;
showUnpublish?: boolean;
showOpenPlayground?: boolean;
currentUserId?: string;
isCloneDisabled?: boolean;
isUnpublishDisabled?: boolean;
Expand Down Expand Up @@ -80,7 +81,8 @@ export const createDesignColumns = ({
showUnpublish,
currentUserId,
isCloneDisabled,
isUnpublishDisabled
isUnpublishDisabled,
showOpenPlayground
}: ColumnConfigProps): MUIDataTableColumn[] => {
const cleanedType = type?.replace('my-', '').replace(/s$/, '');
const getColumnValue = (tableMeta: MUIDataTableMeta, targetColumn: string): any => {
Expand Down Expand Up @@ -342,27 +344,27 @@ export const createDesignColumns = ({
</FacebookShareButton>
</div>
)
},
{
title: 'Open in playground',
onClick: () => handleOpenPlayground(rowData.id, rowData.name),
icon: <KanvasIcon width={24} height={24} primaryFill={theme.palette.text.primary} />
}
];
// Conditionally add playground and unpublish buttons
const actionsList = [...baseActions];

const actionsList = showUnpublish
? [
...baseActions.slice(0, 2),
{
title: 'Unpublish',
onClick: () => handleUnpublish(rowData),
disabled: isUnpublishDisabled,
icon: <PublishIcon width={24} height={24} fill={theme.palette.text.primary} />
},
...baseActions.slice(2)
]
: baseActions;
if (showUnpublish) {
actionsList.splice(2, 0, {
title: 'Unpublish',
onClick: () => handleUnpublish(rowData),
disabled: isUnpublishDisabled,
icon: <PublishIcon width={24} height={24} fill={theme.palette.text.primary} />
});
}

if (showOpenPlayground) {
actionsList.splice(2, 0, {
title: 'Open in playground',
onClick: () => handleOpenPlayground(rowData.id, rowData.name),
icon: <KanvasIcon width={24} height={24} primaryFill={theme.palette.text.primary} />
});
}
//@ts-ignore
return <DataTableEllipsisMenu actionsList={actionsList} theme={theme} />;
}
Expand Down

0 comments on commit 970c987

Please sign in to comment.