Make csv export unavailable when only one record is selected (#8409)

Make csv export unavailable when only one record is selected
This commit is contained in:
Raphaël Bosi 2024-11-08 14:50:04 +01:00 committed by GitHub
parent a7a7d62502
commit aa270950d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,14 +8,17 @@ import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMeta
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
const globalRecordActionEffects = [ExportRecordsActionEffect]; const noSelectionRecordActionEffects = [ExportRecordsActionEffect];
const singleRecordActionEffects = [ const singleRecordActionEffects = [
ManageFavoritesActionEffect, ManageFavoritesActionEffect,
DeleteRecordsActionEffect, DeleteRecordsActionEffect,
]; ];
const multipleRecordActionEffects = [DeleteRecordsActionEffect]; const multipleRecordActionEffects = [
ExportRecordsActionEffect,
DeleteRecordsActionEffect,
];
export const RecordActionMenuEntriesSetter = () => { export const RecordActionMenuEntriesSetter = () => {
const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2( const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2(
@ -39,23 +42,18 @@ export const RecordActionMenuEntriesSetter = () => {
} }
const actions = const actions =
contextStoreNumberOfSelectedRecords === 1 contextStoreNumberOfSelectedRecords === 0
? singleRecordActionEffects ? noSelectionRecordActionEffects
: multipleRecordActionEffects; : contextStoreNumberOfSelectedRecords === 1
? singleRecordActionEffects
: multipleRecordActionEffects;
return ( return (
<> <>
{globalRecordActionEffects.map((ActionEffect, index) => (
<ActionEffect
key={index}
position={index}
objectMetadataItem={objectMetadataItem}
/>
))}
{actions.map((ActionEffect, index) => ( {actions.map((ActionEffect, index) => (
<ActionEffect <ActionEffect
key={index} key={index}
position={globalRecordActionEffects.length + index} position={index}
objectMetadataItem={objectMetadataItem} objectMetadataItem={objectMetadataItem}
/> />
))} ))}