mirror of
https://github.com/lingble/twenty.git
synced 2026-03-20 01:04:29 +00:00
add callback when in right drawer
This commit is contained in:
@@ -2,7 +2,16 @@ import { DeleteRecordsActionEffect } from '@/action-menu/actions/record-actions/
|
||||
import { ExportRecordsActionEffect } from '@/action-menu/actions/record-actions/components/ExportRecordsActionEffect';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
|
||||
const actionEffects = [ExportRecordsActionEffect, DeleteRecordsActionEffect];
|
||||
const actions = [
|
||||
{
|
||||
ActionEffect: ExportRecordsActionEffect,
|
||||
onActionExecutedCallback: () => {},
|
||||
},
|
||||
{
|
||||
ActionEffect: DeleteRecordsActionEffect,
|
||||
onActionExecutedCallback: () => {},
|
||||
},
|
||||
];
|
||||
|
||||
export const MultipleRecordsActionMenuEntriesSetter = ({
|
||||
objectMetadataItem,
|
||||
@@ -11,11 +20,12 @@ export const MultipleRecordsActionMenuEntriesSetter = ({
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
{actionEffects.map((ActionEffect, index) => (
|
||||
{actions.map(({ ActionEffect, onActionExecutedCallback }, index) => (
|
||||
<ActionEffect
|
||||
key={index}
|
||||
position={index}
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
onActionExecutedCallback={onActionExecutedCallback}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
|
||||
@@ -5,7 +5,11 @@ import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-sto
|
||||
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
|
||||
export const RecordActionMenuEntriesSetter = () => {
|
||||
export const RecordActionMenuEntriesSetter = ({
|
||||
isInRightDrawer = false,
|
||||
}: {
|
||||
isInRightDrawer?: boolean;
|
||||
}) => {
|
||||
const contextStoreNumberOfSelectedRecords = useRecoilComponentValueV2(
|
||||
contextStoreNumberOfSelectedRecordsComponentState,
|
||||
);
|
||||
@@ -32,6 +36,7 @@ export const RecordActionMenuEntriesSetter = () => {
|
||||
return (
|
||||
<SingleRecordActionMenuEntriesSetter
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
isInRightDrawer={isInRightDrawer}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,44 @@
|
||||
import { DeleteRecordsActionEffect } from '@/action-menu/actions/record-actions/components/DeleteRecordsActionEffect';
|
||||
import { ExportRecordsActionEffect } from '@/action-menu/actions/record-actions/components/ExportRecordsActionEffect';
|
||||
import { ManageFavoritesActionEffect } from '@/action-menu/actions/record-actions/components/ManageFavoritesActionEffect';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export const SingleRecordActionMenuEntriesSetter = ({
|
||||
objectMetadataItem,
|
||||
isInRightDrawer = false,
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
isInRightDrawer?: boolean;
|
||||
}) => {
|
||||
const actionEffects = [
|
||||
ManageFavoritesActionEffect,
|
||||
ExportRecordsActionEffect,
|
||||
DeleteRecordsActionEffect,
|
||||
];
|
||||
const { closeRightDrawer } = useRightDrawer();
|
||||
|
||||
const actions = useMemo(
|
||||
() => [
|
||||
{
|
||||
ActionEffect: ExportRecordsActionEffect,
|
||||
onActionExecutedCallback: isInRightDrawer
|
||||
? closeRightDrawer
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
ActionEffect: DeleteRecordsActionEffect,
|
||||
onActionExecutedCallback: isInRightDrawer
|
||||
? closeRightDrawer
|
||||
: undefined,
|
||||
},
|
||||
],
|
||||
[isInRightDrawer, closeRightDrawer],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{actionEffects.map((ActionEffect, index) => (
|
||||
{actions.map(({ ActionEffect, onActionExecutedCallback }, index) => (
|
||||
<ActionEffect
|
||||
key={index}
|
||||
position={index}
|
||||
objectMetadataItem={objectMetadataItem}
|
||||
onActionExecutedCallback={onActionExecutedCallback}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
|
||||
@@ -69,7 +69,7 @@ export const RecordShowContainer = ({
|
||||
{contextStoreCurrentObjectMetadataId && (
|
||||
<>
|
||||
<ActionMenuConfirmationModals />
|
||||
<RecordActionMenuEntriesSetter />
|
||||
<RecordActionMenuEntriesSetter isInRightDrawer={isInRightDrawer} />
|
||||
</>
|
||||
)}
|
||||
{recordFromStore && recordFromStore.deletedAt && (
|
||||
|
||||
Reference in New Issue
Block a user