GH-3106 Ability to multi-note/task with action bar (#3137)

* GH-3106 fix activity drawer opener for selected rows hook

* GH-3106 ability to multi note/task with action bar

* GH-3106 use snapshot to get selected row IDs

* GH-3106 format code & fix linting issues

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Deepak Kumar 2023-12-26 22:14:23 +05:30 committed by GitHub
parent 3535ef5053
commit b650b1dca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 14 deletions

View File

@ -20,11 +20,11 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
entityType: ActivityTargetableEntityType,
relatedEntities?: ActivityTargetableEntity[],
) => {
const selectedRowIds = Object.keys(
snapshot.getLoadable(selectedRowIdsSelector).getValue(),
);
const selectedRowIds = snapshot
.getLoadable(selectedRowIdsSelector)
.getValue();
let activityTargetableEntityArray: ActivityTargetableEntity[] =
selectedRowIds.map((id) => ({
selectedRowIds.map((id: string) => ({
type: entityType,
id,
}));

View File

@ -2,6 +2,7 @@ import { useCallback } from 'react';
import { isNonEmptyString } from '@sniptt/guards';
import { useRecoilCallback, useRecoilValue, useSetRecoilState } from 'recoil';
import { useOpenCreateActivityDrawerForSelectedRowIds } from '@/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds';
import { useFavorites } from '@/favorites/hooks/useFavorites';
import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural';
import { useDeleteManyRecords } from '@/object-record/hooks/useDeleteManyRecords';
@ -10,8 +11,10 @@ import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTabl
import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';
import { selectedRowIdsSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsSelector';
import {
IconCheckbox,
IconHeart,
IconHeartOff,
IconNotes,
IconTrash,
IconWand,
} from '@/ui/display/icon';
@ -47,6 +50,13 @@ export const useRecordTableContextMenuEntries = (
objectNamePlural,
});
const objectMetadataType =
objectNameSingular === 'company'
? 'Company'
: objectNameSingular === 'person'
? 'Person'
: 'Custom';
const { createFavorite, deleteFavorite, favorites } = useFavorites({
objectNamePlural,
});
@ -113,6 +123,9 @@ export const useRecordTableContextMenuEntries = (
'IS_QUICK_ACTIONS_ENABLED',
);
const openCreateActivityDrawer =
useOpenCreateActivityDrawerForSelectedRowIds();
return {
setContextMenuEntries: useCallback(() => {
const selectedRowId =
@ -161,16 +174,20 @@ export const useRecordTableContextMenuEntries = (
setActionBarEntries: useRecoilCallback(() => () => {
setActionBarEntriesState([
// {
// label: 'Task',
// Icon: IconCheckbox,
// onClick: () => {},
// },
// {
// label: 'Note',
// Icon: IconNotes,
// onClick: () => {},
// },
{
label: 'Task',
Icon: IconCheckbox,
onClick: () => {
openCreateActivityDrawer('Task', objectMetadataType);
},
},
{
label: 'Note',
Icon: IconNotes,
onClick: () => {
openCreateActivityDrawer('Note', objectMetadataType);
},
},
...(dataExecuteQuickActionOnmentEnabled
? [
{