Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'Open in Playground' action button conditionally in action … #807

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading