Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasbordeau committed Sep 12, 2024
1 parent 9401a64 commit 8410e3b
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { ViewType } from '@/views/types/ViewType';
import { mapViewFieldsToColumnDefinitions } from '@/views/utils/mapViewFieldsToColumnDefinitions';
import { mapViewFiltersToFilters } from '@/views/utils/mapViewFiltersToFilters';
import { mapViewSortsToSorts } from '@/views/utils/mapViewSortsToSorts';
import { useState } from 'react';
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';

const StyledContainer = styled.div`
Expand All @@ -57,6 +58,7 @@ export const RecordIndexContainer = ({
recordIndexId,
objectNamePlural,
}: RecordIndexContainerProps) => {
const [currentViewId, setCurrentViewId] = useState<string | null>(null);
const [recordIndexViewType, setRecordIndexViewType] = useRecoilState(
recordIndexViewTypeState,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ export const QueryParamsViewIdEffect = () => {
lastVisitedObjectMetadataItemId,
);

// TODO: scope view bar per view id if possible
const { resetCurrentView } = useResetCurrentView();

useEffect(() => {
if (isDefined(currentViewId)) {
resetCurrentView();
}
}, [resetCurrentView, currentViewId]);
// useEffect(() => {
// if (isDefined(currentViewId)) {
// resetCurrentView();
// }
// }, [resetCurrentView, currentViewId]);

useEffect(() => {
const indexView = viewsOnCurrentObject.find((view) => view.key === 'INDEX');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotV
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2';
import { useGetViewFromCache } from '@/views/hooks/useGetViewFromCache';
import { currentViewIdComponentState } from '@/views/states/currentViewIdComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsFamilyState';
import { unsavedToUpsertViewSortsComponentState } from '@/views/states/unsavedToUpsertViewSortsComponentState';
import { ViewSort } from '@/views/types/ViewSort';
import { isDefined } from '~/utils/isDefined';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewCompon
import { currentViewIdComponentState } from '@/views/states/currentViewIdComponentState';
import { isCurrentViewKeyIndexComponentState } from '@/views/states/isCurrentViewIndexComponentState';
import { unsavedToDeleteViewFilterIdsComponentState } from '@/views/states/unsavedToDeleteViewFilterIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsFamilyState';
import { unsavedToUpsertViewFiltersComponentState } from '@/views/states/unsavedToUpsertViewFiltersComponentState';
import { unsavedToUpsertViewSortsComponentState } from '@/views/states/unsavedToUpsertViewSortsComponentState';
import { viewObjectMetadataIdComponentState } from '@/views/states/viewObjectMetadataIdComponentState';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { unsavedToDeleteViewFilterIdsComponentState } from '@/views/states/unsavedToDeleteViewFilterIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsFamilyState';
import { unsavedToUpsertViewFiltersComponentState } from '@/views/states/unsavedToUpsertViewFiltersComponentState';
import { unsavedToUpsertViewSortsComponentState } from '@/views/states/unsavedToUpsertViewSortsComponentState';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useGetViewFromCache } from '@/views/hooks/useGetViewFromCache';
import { useResetCurrentView } from '@/views/hooks/useResetCurrentView';
import { currentViewIdComponentState } from '@/views/states/currentViewIdComponentState';
import { unsavedToDeleteViewFilterIdsComponentState } from '@/views/states/unsavedToDeleteViewFilterIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsFamilyState';
import { unsavedToUpsertViewFiltersComponentState } from '@/views/states/unsavedToUpsertViewFiltersComponentState';
import { unsavedToUpsertViewSortsComponentState } from '@/views/states/unsavedToUpsertViewSortsComponentState';
import { isDefined } from '~/utils/isDefined';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2';
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
import { unsavedToDeleteViewFilterIdsComponentState } from '@/views/states/unsavedToDeleteViewFilterIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsComponentState';
import { unsavedToDeleteViewSortIdsComponentState } from '@/views/states/unsavedToDeleteViewSortIdsFamilyState';
import { unsavedToUpsertViewFiltersComponentState } from '@/views/states/unsavedToUpsertViewFiltersComponentState';
import { unsavedToUpsertViewSortsComponentState } from '@/views/states/unsavedToUpsertViewSortsComponentState';

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
import { selectorFamily } from 'recoil';

export const canResetViewSelector = selectorFamily({
key: 'canResetViewSelector',
get:
({ viewId }: { viewId: string }) =>
({ get }) => {
return (
get(unsavedToUpsertViewFiltersComponentFamilyState(viewId)).length ===
0 &&
get(unsavedToUpsertViewFiltersComponentFamilyState(viewId)).length ===
0 &&
get(unsavedToUpsertViewFiltersComponentFamilyState(viewId)).length ===
0 &&
get(unsavedToUpsertViewFiltersComponentFamilyState(viewId)).length === 0
);
},
instanceContext: ViewComponentInstanceContext,
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';

// TODO: turn this into a family state per view id
export const unsavedToDeleteViewFilterIdsFamilyState =
createFamilyState<string[], string>({
key: 'unsavedToDeleteViewFilterIdsFamilyState',
defaultValue: [],
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';

export const unsavedToDeleteViewSortIdsFamilyState =
createFamilyState<string[], string>({
key: 'unsavedToDeleteViewSortIdsFamilyState',
defaultValue: [],
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
import { ViewFilter } from '../types/ViewFilter';

export const unsavedToUpsertViewFiltersFamilyState =
createFamilyState<ViewFilter[], string>({
key: 'unsavedToUpsertViewFiltersFamilyState',
defaultValue: [],
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ViewSort } from '../types/ViewSort';

export const unsavedToUpsertViewSortsFamilyState = createFamilyState<
ViewSort[],
string
>({
key: 'unsavedToUpsertViewSortsFamilyState',
defaultValue: [],
});

0 comments on commit 8410e3b

Please sign in to comment.