Surface record selection limit in Workflow Manual Trigger and in Search Node (#15785)
fixes https://github.com/twentyhq/twenty/issues/15704 Take over: https://github.com/twentyhq/twenty/pull/15738 based on [KhademOHAli1](https://github.com/KhademOHAli1) work --------- Co-authored-by: Ali Khadem <ali.kh@pitant.de>
This commit is contained in:
+25
-3
@@ -5,13 +5,16 @@ import { ActionType } from '@/action-menu/actions/types/ActionType';
|
||||
import { contextStoreTargetedRecordsRuleComponentState } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
|
||||
import { useActiveWorkflowVersionsWithManualTrigger } from '@/workflow/hooks/useActiveWorkflowVersionsWithManualTrigger';
|
||||
import { useRunWorkflowVersion } from '@/workflow/hooks/useRunWorkflowVersion';
|
||||
|
||||
import { type WorkflowVersion } from '@/workflow/types/Workflow';
|
||||
import { COMMAND_MENU_DEFAULT_ICON } from '@/workflow/workflow-trigger/constants/CommandMenuDefaultIcon';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { QUERY_MAX_RECORDS } from 'twenty-shared/constants';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
|
||||
@@ -23,6 +26,7 @@ export const useRunWorkflowRecordActions = ({
|
||||
skip?: boolean;
|
||||
}) => {
|
||||
const { getIcon } = useIcons();
|
||||
const { enqueueWarningSnackBar } = useSnackBar();
|
||||
const contextStoreTargetedRecordsRule = useRecoilComponentValue(
|
||||
contextStoreTargetedRecordsRuleComponentState,
|
||||
);
|
||||
@@ -49,12 +53,30 @@ export const useRunWorkflowRecordActions = ({
|
||||
'id' | 'workflowId' | 'trigger'
|
||||
>,
|
||||
) => {
|
||||
if (selectedRecordIds.length > QUERY_MAX_RECORDS) {
|
||||
const selectedCountFormatted =
|
||||
selectedRecordIds.length.toLocaleString();
|
||||
const limitFormatted = QUERY_MAX_RECORDS.toLocaleString();
|
||||
|
||||
enqueueWarningSnackBar({
|
||||
message: t`You selected ${selectedCountFormatted} records but manual triggers can run on at most ${limitFormatted} records at once. Only the first ${limitFormatted} records will be processed.`,
|
||||
options: {
|
||||
dedupeKey: 'workflow-manual-trigger-selection-limit',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const limitedSelectedRecordIds = selectedRecordIds.slice(
|
||||
0,
|
||||
QUERY_MAX_RECORDS,
|
||||
);
|
||||
|
||||
if (
|
||||
isDefined(activeWorkflowVersion?.trigger) &&
|
||||
isBulkRecordsManualTrigger(activeWorkflowVersion.trigger)
|
||||
) {
|
||||
const objectNamePlural = objectMetadataItem.namePlural;
|
||||
const selectedRecords = selectedRecordIds
|
||||
const selectedRecords = limitedSelectedRecordIds
|
||||
.map((recordId) =>
|
||||
snapshot.getLoadable(recordStoreFamilyState(recordId)).getValue(),
|
||||
)
|
||||
@@ -68,7 +90,7 @@ export const useRunWorkflowRecordActions = ({
|
||||
},
|
||||
});
|
||||
} else {
|
||||
for (const selectedRecordId of selectedRecordIds) {
|
||||
for (const selectedRecordId of limitedSelectedRecordIds) {
|
||||
const selectedRecord = snapshot
|
||||
.getLoadable(recordStoreFamilyState(selectedRecordId))
|
||||
.getValue();
|
||||
@@ -85,7 +107,7 @@ export const useRunWorkflowRecordActions = ({
|
||||
}
|
||||
}
|
||||
},
|
||||
[runWorkflowVersion, objectMetadataItem],
|
||||
[runWorkflowVersion, objectMetadataItem, enqueueWarningSnackBar],
|
||||
);
|
||||
|
||||
return activeWorkflowVersions
|
||||
|
||||
Reference in New Issue
Block a user