Refactor duplication of hard coded soft delete filter logic (#10058)
This PR adds a useCheckIsSoftDeleteFilter hook instead of the undocumented in-place logic to retrieve the soft delete filter. Also took the opportunity to refactor a recent change of @prastoin with it. Split VariantFilterChip into SoftDeleteFilterChip and RecordFilterChip to separate concerns about this soft delete filtering.
This commit is contained in:
@ -8,8 +8,8 @@ import { BACKEND_BATCH_REQUEST_MAX_COUNT } from '@/object-record/constants/Backe
|
||||
import { DEFAULT_QUERY_PAGE_SIZE } from '@/object-record/constants/DefaultQueryPageSize';
|
||||
import { useDeleteManyRecords } from '@/object-record/hooks/useDeleteManyRecords';
|
||||
import { useLazyFetchAllRecords } from '@/object-record/hooks/useLazyFetchAllRecords';
|
||||
import { useCheckIsSoftDeleteFilter } from '@/object-record/record-filter/hooks/useCheckIsSoftDeleteFilter';
|
||||
import { useFilterValueDependencies } from '@/object-record/record-filter/hooks/useFilterValueDependencies';
|
||||
import { RecordFilterOperand } from '@/object-record/record-filter/types/RecordFilterOperand';
|
||||
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
|
||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
@ -50,14 +50,10 @@ export const useDeleteMultipleRecordsAction: ActionHookWithObjectMetadataItem =
|
||||
filterValueDependencies,
|
||||
);
|
||||
|
||||
const deletedAtFieldMetadata = objectMetadataItem.fields.find(
|
||||
(field) => field.name === 'deletedAt',
|
||||
);
|
||||
const { checkIsSoftDeleteFilter } = useCheckIsSoftDeleteFilter();
|
||||
|
||||
const isDeletedFilterActive = contextStoreFilters.some(
|
||||
(filter) =>
|
||||
filter.fieldMetadataId === deletedAtFieldMetadata?.id &&
|
||||
filter.operand === RecordFilterOperand.IsNotEmpty,
|
||||
checkIsSoftDeleteFilter,
|
||||
);
|
||||
|
||||
const { fetchAllRecords: fetchAllRecordIds } = useLazyFetchAllRecords({
|
||||
|
||||
Reference in New Issue
Block a user