Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/prod-beta' into prod-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dlabrecq committed Jan 11, 2024
2 parents e76b0a5 + 77fad70 commit c811fc2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/routes/settings/platformProjects/platformProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@ const PlatformProjects: React.FC<PlatformProjectsProps> = ({ canWrite }) => {
};

const getToolbar = (categories: SettingsData[]) => {
const hasEnabledItem = selectedItems.find(item => item.enabled);
const hasDisabledItem = selectedItems.find(item => !item.enabled);
const hasEnabledPlatformGroup = selectedItems.find(item => item.group === 'Platform' && !item.default);
const hasDisabledPlatformGroup = selectedItems.find(item => item.group !== 'Platform' && !item.default);
const itemsTotal = settings?.meta ? settings.meta.count : 0;
const unAvailableCategories = categories.filter(item => item.default);

return (
<PlatformProjectsToolbar
canWrite={canWrite}
isDisabled={categories.length === 0}
isPrimaryActionDisabled={!hasDisabledItem}
isSecondaryActionDisabled={!hasEnabledItem}
itemsPerPage={categories.length}
isPrimaryActionDisabled={!hasDisabledPlatformGroup}
isSecondaryActionDisabled={!hasEnabledPlatformGroup}
itemsPerPage={categories.length - unAvailableCategories.length}
itemsTotal={itemsTotal}
onAdd={handleOnAdd}
onBulkSelected={handleOnBulkSelected}
Expand All @@ -138,7 +139,7 @@ const PlatformProjects: React.FC<PlatformProjectsProps> = ({ canWrite }) => {
} else if (action === 'page') {
const newSelectedItems = [...selectedItems];
getCategories().map(val => {
if (!newSelectedItems.find(item => item.project === val.project)) {
if (!newSelectedItems.find(item => item.project === val.project) && !val.default) {
newSelectedItems.push(val);
}
});
Expand Down Expand Up @@ -175,10 +176,14 @@ const PlatformProjects: React.FC<PlatformProjectsProps> = ({ canWrite }) => {

const handleOnRemove = () => {
if (selectedItems.length > 0) {
const payload = selectedItems.map(item => ({
project: item.project,
group: null,
}));
const payload = selectedItems.map(item => {
if (!item.default) {
return {
project: item.project,
group: item.group,
};
}
});
setSelectedItems([], () => {
dispatch(settingsActions.updateSettings(SettingsType.platformProjectsRemove, payload as any));
});
Expand Down

0 comments on commit c811fc2

Please sign in to comment.