Implemented CRUD for view filter group and removed old states (#10590)
This PR implements CRUD for view filter groups with the new logic as already done for view filters and view sorts. It also completely removes the old combined view filter group states and usage. This PR is quite big but the impact is limited since it only changes advanced filters module, which is under feature flag at the moment, and it is already in a broken state so unusable, even if someone activates the feature flag.
This commit is contained in:
@ -6,14 +6,10 @@ import { prefetchIndexViewIdFromObjectMetadataItemFamilySelector } from '@/prefe
|
||||
import { prefetchViewFromViewIdFamilySelector } from '@/prefetch/states/selector/prefetchViewFromViewIdFamilySelector';
|
||||
import { prefetchViewsFromObjectMetadataItemFamilySelector } from '@/prefetch/states/selector/prefetchViewsFromObjectMetadataItemFamilySelector';
|
||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||
import { useRecoilComponentFamilyValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValueV2';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
|
||||
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
|
||||
import { isCurrentViewKeyIndexComponentState } from '@/views/states/isCurrentViewIndexComponentState';
|
||||
import { unsavedToDeleteViewFilterGroupIdsComponentFamilyState } from '@/views/states/unsavedToDeleteViewFilterGroupIdsComponentFamilyState';
|
||||
import { unsavedToUpsertViewFilterGroupsComponentFamilyState } from '@/views/states/unsavedToUpsertViewFilterGroupsComponentFamilyState';
|
||||
import { getCombinedViewFilterGroups } from '@/views/utils/getCombinedViewFilterGroups';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
@ -52,7 +48,6 @@ export const useGetCurrentView = (viewBarInstanceId?: string) => {
|
||||
instanceId,
|
||||
);
|
||||
|
||||
const viewId = currentViewId ?? indexView?.id;
|
||||
const currentView = currentViewFromViewId ?? indexView;
|
||||
|
||||
useEffect(() => {
|
||||
@ -65,18 +60,6 @@ export const useGetCurrentView = (viewBarInstanceId?: string) => {
|
||||
}),
|
||||
);
|
||||
|
||||
const unsavedToUpsertViewFilterGroups = useRecoilComponentFamilyValueV2(
|
||||
unsavedToUpsertViewFilterGroupsComponentFamilyState,
|
||||
{ viewId },
|
||||
instanceId,
|
||||
);
|
||||
|
||||
const unsavedToDeleteViewFilterGroupIds = useRecoilComponentFamilyValueV2(
|
||||
unsavedToDeleteViewFilterGroupIdsComponentFamilyState,
|
||||
{ viewId },
|
||||
instanceId,
|
||||
);
|
||||
|
||||
if (!isDefined(currentView)) {
|
||||
return {
|
||||
instanceId,
|
||||
@ -86,18 +69,8 @@ export const useGetCurrentView = (viewBarInstanceId?: string) => {
|
||||
};
|
||||
}
|
||||
|
||||
const currentViewWithCombinedFiltersAndSorts = {
|
||||
...currentView,
|
||||
viewFilterGroups: getCombinedViewFilterGroups(
|
||||
currentView.viewFilterGroups ?? [],
|
||||
unsavedToUpsertViewFilterGroups,
|
||||
unsavedToDeleteViewFilterGroupIds,
|
||||
),
|
||||
};
|
||||
|
||||
return {
|
||||
instanceId,
|
||||
currentViewWithCombinedFiltersAndSorts,
|
||||
viewsOnCurrentObject: viewsOnCurrentObject ?? [],
|
||||
currentViewId,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user