Rework atom naming (#18240)
## Summary - **Enhanced the `matching-state-variable` ESLint rule** to enforce consistent naming for `ComponentState`, `FamilyState`, and `ComponentFamilyState` hooks — previously it only covered `useAtomState` and `useAtomStateValue` - **The rule now checks 12 hooks** across three categories: value hooks (`useAtomComponentStateValue`, `useAtomFamilyStateValue`, etc.), state hooks (`useAtomComponentState`, `useAtomComponentFamilyState`), and setter hooks (`useSetAtomState`, `useSetAtomComponentState`, `useSetAtomFamilyState`, `useSetAtomComponentFamilyState`) - **Fixed all 225 resulting lint violations** across 151 files, renaming variables to match their state atom names (e.g. `currentViewId` → `contextStoreCurrentViewId`, `selectedRecord` → `recordStore`). Cases where the same state is accessed with different family keys/instance IDs are suppressed with `eslint-disable-next-line`. ## Naming convention | Hook | State argument | Valid | Invalid | |------|---------------|-------|---------| | `useAtomStateValue` | `fooState` | `const foo = ...` | `const bar = ...` | | `useAtomComponentStateValue` | `fooComponentState` | `const foo = ...` | `const bar = ...` | | `useAtomFamilyStateValue` | `fooFamilyState` | `const foo = ...` | `const bar = ...` | | `useAtomComponentFamilyStateValue` | `fooComponentFamilyState` | `const foo = ...` | `const bar = ...` | | `useAtomState` | `fooState` | `const [foo, setFoo] = ...` | `const [bar, setBar] = ...` | | `useAtomComponentState` | `fooComponentState` | `const [foo, setFoo] = ...` | `const [bar, setBar] = ...` | | `useAtomComponentFamilyState` | `fooComponentFamilyState` | `const [foo, setFoo] = ...` | `const [bar, setBar] = ...` | | `useSetAtomState` | `fooState` | `const setFoo = ...` | `const setBar = ...` | | `useSetAtomComponentState` | `fooComponentState` | `const setFoo = ...` | `const setBar = ...` | | `useSetAtomFamilyState` | `fooFamilyState` | `const setFoo = ...` | `const setBar = ...` | | `useSetAtomComponentFamilyState` | `fooComponentFamilyState` | `const setFoo = ...` | `const setBar = ...` |
This commit is contained in:
@@ -45,7 +45,7 @@ export const UpdateViewButtonGroup = () => {
|
||||
|
||||
const { setViewPickerMode } = useViewPickerMode();
|
||||
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -58,14 +58,14 @@ export const UpdateViewButtonGroup = () => {
|
||||
);
|
||||
|
||||
const openViewPickerInCreateMode = () => {
|
||||
if (!currentViewId) {
|
||||
if (!contextStoreCurrentViewId) {
|
||||
return;
|
||||
}
|
||||
|
||||
openViewPickerDropdown({
|
||||
dropdownComponentInstanceIdFromProps: VIEW_PICKER_DROPDOWN_ID,
|
||||
});
|
||||
setViewPickerReferenceViewId(currentViewId);
|
||||
setViewPickerReferenceViewId(contextStoreCurrentViewId);
|
||||
setViewPickerMode('create-from-current');
|
||||
|
||||
closeUpdateViewButtonDropdown(UPDATE_VIEW_BUTTON_DROPDOWN_ID);
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarAnyFieldFilterEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export const ViewBarAnyFieldFilterEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -28,7 +28,7 @@ export const ViewBarAnyFieldFilterEffect = () => {
|
||||
useAtomComponentFamilyState(
|
||||
hasInitializedAnyFieldFilterComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ export const ViewBarAnyFieldFilterEffect = () => {
|
||||
}
|
||||
}, [
|
||||
setAnyFieldFilterValue,
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
hasInitializedAnyFieldFilter,
|
||||
setHasInitializedAnyFieldFilter,
|
||||
currentView,
|
||||
|
||||
@@ -189,7 +189,7 @@ export const ViewBarDetails = ({
|
||||
const shouldShowAdvancedFilterDropdownButton =
|
||||
currentRecordFilterGroups.length > 0;
|
||||
|
||||
const isAnyFieldSearchDropdownOpen = useAtomComponentStateValue(
|
||||
const isDropdownOpen = useAtomComponentStateValue(
|
||||
isDropdownOpenComponentState,
|
||||
ANY_FIELD_SEARCH_DROPDOWN_ID,
|
||||
);
|
||||
@@ -202,7 +202,7 @@ export const ViewBarDetails = ({
|
||||
!hasFiltersQueryParams;
|
||||
|
||||
const shouldShowAnyFieldSearchChip =
|
||||
isNonEmptyString(anyFieldFilterValue) || isAnyFieldSearchDropdownOpen;
|
||||
isNonEmptyString(anyFieldFilterValue) || isDropdownOpen;
|
||||
|
||||
const shouldExpandViewBar =
|
||||
shouldShowAnyFieldSearchChip ||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
|
||||
|
||||
const { t } = useLingui();
|
||||
|
||||
const isSelected = useAtomComponentFamilyStateValue(
|
||||
const isSelectedItemId = useAtomComponentFamilyStateValue(
|
||||
isSelectedItemIdComponentFamilyState,
|
||||
VIEW_BAR_FILTER_BOTTOM_MENU_ITEM_IDS.ADVANCED_FILTER,
|
||||
);
|
||||
@@ -130,7 +130,7 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
|
||||
text={t`Advanced filter`}
|
||||
onClick={handleClick}
|
||||
LeftIcon={IconFilter}
|
||||
focused={isSelected}
|
||||
focused={isSelectedItemId}
|
||||
/>
|
||||
{advancedFilterQuerySubFilterCount > 0 && (
|
||||
<StyledPill label={advancedFilterQuerySubFilterCount.toString()} />
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ export const ViewBarFilterDropdownAnyFieldSearchButtonMenuItem = ({
|
||||
objectFilterDropdownSearchInputComponentState,
|
||||
);
|
||||
|
||||
const isSelected = useAtomComponentFamilyStateValue(
|
||||
const isSelectedItemId = useAtomComponentFamilyStateValue(
|
||||
isSelectedItemIdComponentFamilyState,
|
||||
VIEW_BAR_FILTER_BOTTOM_MENU_ITEM_IDS.SEARCH,
|
||||
);
|
||||
@@ -40,7 +40,7 @@ export const ViewBarFilterDropdownAnyFieldSearchButtonMenuItem = ({
|
||||
onEnter={onClick}
|
||||
>
|
||||
<MenuItem
|
||||
focused={isSelected}
|
||||
focused={isSelectedItemId}
|
||||
onClick={onClick}
|
||||
LeftIcon={IconSearch}
|
||||
text={
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ export const ViewBarFilterDropdownFieldSelectMenuItem = ({
|
||||
}: ViewBarFilterDropdownFieldSelectMenuItemProps) => {
|
||||
const { resetSelectedItem } = useSelectableList(FILTER_FIELD_LIST_ID);
|
||||
|
||||
const isSelectedItem = useAtomComponentFamilyStateValue(
|
||||
const isSelectedItemId = useAtomComponentFamilyStateValue(
|
||||
isSelectedItemIdComponentFamilyState,
|
||||
fieldMetadataItemToSelect.id,
|
||||
);
|
||||
@@ -43,7 +43,7 @@ export const ViewBarFilterDropdownFieldSelectMenuItem = ({
|
||||
onEnter={handleClick}
|
||||
>
|
||||
<MenuItem
|
||||
focused={isSelectedItem}
|
||||
focused={isSelectedItemId}
|
||||
onClick={handleClick}
|
||||
LeftIcon={Icon}
|
||||
text={fieldMetadataItemToSelect.label}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordFieldEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ViewBarRecordFieldEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ViewBarRecordFieldEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordFieldsComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@ export const ViewBarRecordFieldEffect = () => {
|
||||
setHasInitializedCurrentRecordFields(true);
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFields,
|
||||
hasInitializedCurrentRecordFields,
|
||||
setHasInitializedCurrentRecordFields,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordFilterEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ViewBarRecordFilterEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ViewBarRecordFilterEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordFiltersComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -55,7 +55,7 @@ export const ViewBarRecordFilterEffect = () => {
|
||||
setHasInitializedCurrentRecordFilters(true);
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFilters,
|
||||
mapViewFiltersToRecordFilters,
|
||||
hasInitializedCurrentRecordFilters,
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordFilterGroupEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ViewBarRecordFilterGroupEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ViewBarRecordFilterGroupEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordFilterGroupsComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -57,7 +57,7 @@ export const ViewBarRecordFilterGroupEffect = () => {
|
||||
}
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFilterGroups,
|
||||
hasInitializedCurrentRecordFilterGroups,
|
||||
setHasInitializedCurrentRecordFilterGroups,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useEffect } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ViewBarRecordSortEffect = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export const ViewBarRecordSortEffect = () => {
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ export const ViewBarRecordSortEffect = () => {
|
||||
] = useAtomComponentFamilyState(
|
||||
hasInitializedCurrentRecordSortsComponentFamilyState,
|
||||
{
|
||||
viewId: currentViewId ?? undefined,
|
||||
viewId: contextStoreCurrentViewId ?? undefined,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ const meta: Meta<typeof ViewBarFilterDropdown> = {
|
||||
|
||||
const mockCoreView = mockedCoreViewsData[0];
|
||||
|
||||
const setCurrentViewId = useSetAtomComponentState(
|
||||
const setContextStoreCurrentViewId = useSetAtomComponentState(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
MAIN_CONTEXT_STORE_INSTANCE_ID,
|
||||
);
|
||||
@@ -71,12 +71,12 @@ const meta: Meta<typeof ViewBarFilterDropdown> = {
|
||||
|
||||
useEffect(() => {
|
||||
setCoreViews([mockCoreView]);
|
||||
setCurrentViewId(mockCoreView.id);
|
||||
setContextStoreCurrentViewId(mockCoreView.id);
|
||||
setCurrentRecordFields(columns);
|
||||
setIsLoaded(true);
|
||||
}, [
|
||||
setCoreViews,
|
||||
setCurrentViewId,
|
||||
setContextStoreCurrentViewId,
|
||||
setCurrentRecordFields,
|
||||
mockCoreView,
|
||||
columns,
|
||||
|
||||
+9
-9
@@ -97,14 +97,14 @@ describe('useApplyCurrentViewFiltersToCurrentRecordFilters', () => {
|
||||
const { applyCurrentViewFiltersToCurrentRecordFilters } =
|
||||
useApplyCurrentViewFiltersToCurrentRecordFilters();
|
||||
|
||||
const currentFilters = useAtomComponentStateValue(
|
||||
const currentRecordFilters = useAtomComponentStateValue(
|
||||
currentRecordFiltersComponentState,
|
||||
'recordIndexId',
|
||||
);
|
||||
|
||||
return {
|
||||
applyCurrentViewFiltersToCurrentRecordFilters,
|
||||
currentFilters,
|
||||
currentRecordFilters,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -122,7 +122,7 @@ describe('useApplyCurrentViewFiltersToCurrentRecordFilters', () => {
|
||||
result.current.applyCurrentViewFiltersToCurrentRecordFilters();
|
||||
});
|
||||
|
||||
expect(result.current.currentFilters).toEqual([
|
||||
expect(result.current.currentRecordFilters).toEqual([
|
||||
{
|
||||
id: mockViewFilter.id,
|
||||
fieldMetadataId: mockViewFilter.fieldMetadataId,
|
||||
@@ -146,14 +146,14 @@ describe('useApplyCurrentViewFiltersToCurrentRecordFilters', () => {
|
||||
const { applyCurrentViewFiltersToCurrentRecordFilters } =
|
||||
useApplyCurrentViewFiltersToCurrentRecordFilters();
|
||||
|
||||
const currentFilters = useAtomComponentStateValue(
|
||||
const currentRecordFilters = useAtomComponentStateValue(
|
||||
currentRecordFiltersComponentState,
|
||||
'recordIndexId',
|
||||
);
|
||||
|
||||
return {
|
||||
applyCurrentViewFiltersToCurrentRecordFilters,
|
||||
currentFilters,
|
||||
currentRecordFilters,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -178,7 +178,7 @@ describe('useApplyCurrentViewFiltersToCurrentRecordFilters', () => {
|
||||
result.current.applyCurrentViewFiltersToCurrentRecordFilters();
|
||||
});
|
||||
|
||||
expect(result.current.currentFilters).toEqual([]);
|
||||
expect(result.current.currentRecordFilters).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle view with empty filters', () => {
|
||||
@@ -189,14 +189,14 @@ describe('useApplyCurrentViewFiltersToCurrentRecordFilters', () => {
|
||||
const { applyCurrentViewFiltersToCurrentRecordFilters } =
|
||||
useApplyCurrentViewFiltersToCurrentRecordFilters();
|
||||
|
||||
const currentFilters = useAtomComponentStateValue(
|
||||
const currentRecordFilters = useAtomComponentStateValue(
|
||||
currentRecordFiltersComponentState,
|
||||
'recordIndexId',
|
||||
);
|
||||
|
||||
return {
|
||||
applyCurrentViewFiltersToCurrentRecordFilters,
|
||||
currentFilters,
|
||||
currentRecordFilters,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -221,6 +221,6 @@ describe('useApplyCurrentViewFiltersToCurrentRecordFilters', () => {
|
||||
result.current.applyCurrentViewFiltersToCurrentRecordFilters();
|
||||
});
|
||||
|
||||
expect(result.current.currentFilters).toEqual([]);
|
||||
expect(result.current.currentRecordFilters).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
+9
-9
@@ -84,14 +84,14 @@ describe('useApplyCurrentViewSortsToCurrentRecordSorts', () => {
|
||||
const { applyCurrentViewSortsToCurrentRecordSorts } =
|
||||
useApplyCurrentViewSortsToCurrentRecordSorts();
|
||||
|
||||
const currentSorts = useAtomComponentStateValue(
|
||||
const currentRecordSorts = useAtomComponentStateValue(
|
||||
currentRecordSortsComponentState,
|
||||
'recordIndexId',
|
||||
);
|
||||
|
||||
return {
|
||||
applyCurrentViewSortsToCurrentRecordSorts,
|
||||
currentSorts,
|
||||
currentRecordSorts,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -109,7 +109,7 @@ describe('useApplyCurrentViewSortsToCurrentRecordSorts', () => {
|
||||
result.current.applyCurrentViewSortsToCurrentRecordSorts();
|
||||
});
|
||||
|
||||
expect(result.current.currentSorts).toEqual([
|
||||
expect(result.current.currentRecordSorts).toEqual([
|
||||
{
|
||||
id: mockViewSort.id,
|
||||
fieldMetadataId: mockViewSort.fieldMetadataId,
|
||||
@@ -126,14 +126,14 @@ describe('useApplyCurrentViewSortsToCurrentRecordSorts', () => {
|
||||
const { applyCurrentViewSortsToCurrentRecordSorts } =
|
||||
useApplyCurrentViewSortsToCurrentRecordSorts();
|
||||
|
||||
const currentSorts = useAtomComponentStateValue(
|
||||
const currentRecordSorts = useAtomComponentStateValue(
|
||||
currentRecordSortsComponentState,
|
||||
'recordIndexId',
|
||||
);
|
||||
|
||||
return {
|
||||
applyCurrentViewSortsToCurrentRecordSorts,
|
||||
currentSorts,
|
||||
currentRecordSorts,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -158,7 +158,7 @@ describe('useApplyCurrentViewSortsToCurrentRecordSorts', () => {
|
||||
result.current.applyCurrentViewSortsToCurrentRecordSorts();
|
||||
});
|
||||
|
||||
expect(result.current.currentSorts).toEqual([]);
|
||||
expect(result.current.currentRecordSorts).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle view with empty sorts', () => {
|
||||
@@ -174,14 +174,14 @@ describe('useApplyCurrentViewSortsToCurrentRecordSorts', () => {
|
||||
const { applyCurrentViewSortsToCurrentRecordSorts } =
|
||||
useApplyCurrentViewSortsToCurrentRecordSorts();
|
||||
|
||||
const currentSorts = useAtomComponentStateValue(
|
||||
const currentRecordSorts = useAtomComponentStateValue(
|
||||
currentRecordSortsComponentState,
|
||||
'recordIndexId',
|
||||
);
|
||||
|
||||
return {
|
||||
applyCurrentViewSortsToCurrentRecordSorts,
|
||||
currentSorts,
|
||||
currentRecordSorts,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -206,6 +206,6 @@ describe('useApplyCurrentViewSortsToCurrentRecordSorts', () => {
|
||||
result.current.applyCurrentViewSortsToCurrentRecordSorts();
|
||||
});
|
||||
|
||||
expect(result.current.currentSorts).toEqual([]);
|
||||
expect(result.current.currentRecordSorts).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
+6
-6
@@ -42,11 +42,11 @@ describe('useApplyViewFiltersToCurrentRecordFilters', () => {
|
||||
const { applyViewFiltersToCurrentRecordFilters } =
|
||||
useApplyViewFiltersToCurrentRecordFilters();
|
||||
|
||||
const currentFilters = useAtomComponentStateValue(
|
||||
const currentRecordFilters = useAtomComponentStateValue(
|
||||
currentRecordFiltersComponentState,
|
||||
);
|
||||
|
||||
return { applyViewFiltersToCurrentRecordFilters, currentFilters };
|
||||
return { applyViewFiltersToCurrentRecordFilters, currentRecordFilters };
|
||||
},
|
||||
{
|
||||
wrapper: getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
@@ -62,7 +62,7 @@ describe('useApplyViewFiltersToCurrentRecordFilters', () => {
|
||||
result.current.applyViewFiltersToCurrentRecordFilters([mockViewFilter]);
|
||||
});
|
||||
|
||||
expect(result.current.currentFilters).toEqual([
|
||||
expect(result.current.currentRecordFilters).toEqual([
|
||||
{
|
||||
id: mockViewFilter.id,
|
||||
fieldMetadataId: mockViewFilter.fieldMetadataId,
|
||||
@@ -83,11 +83,11 @@ describe('useApplyViewFiltersToCurrentRecordFilters', () => {
|
||||
const { applyViewFiltersToCurrentRecordFilters } =
|
||||
useApplyViewFiltersToCurrentRecordFilters();
|
||||
|
||||
const currentFilters = useAtomComponentStateValue(
|
||||
const currentRecordFilters = useAtomComponentStateValue(
|
||||
currentRecordFiltersComponentState,
|
||||
);
|
||||
|
||||
return { applyViewFiltersToCurrentRecordFilters, currentFilters };
|
||||
return { applyViewFiltersToCurrentRecordFilters, currentRecordFilters };
|
||||
},
|
||||
{
|
||||
wrapper: getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
@@ -103,6 +103,6 @@ describe('useApplyViewFiltersToCurrentRecordFilters', () => {
|
||||
result.current.applyViewFiltersToCurrentRecordFilters([]);
|
||||
});
|
||||
|
||||
expect(result.current.currentFilters).toEqual([]);
|
||||
expect(result.current.currentRecordFilters).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
+6
-6
@@ -45,11 +45,11 @@ describe('useApplyViewSortsToCurrentRecordSorts', () => {
|
||||
const { applyViewSortsToCurrentRecordSorts } =
|
||||
useApplyViewSortsToCurrentRecordSorts();
|
||||
|
||||
const currentSorts = useAtomComponentStateValue(
|
||||
const currentRecordSorts = useAtomComponentStateValue(
|
||||
currentRecordSortsComponentState,
|
||||
);
|
||||
|
||||
return { applyViewSortsToCurrentRecordSorts, currentSorts };
|
||||
return { applyViewSortsToCurrentRecordSorts, currentRecordSorts };
|
||||
},
|
||||
{
|
||||
wrapper: getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
@@ -65,7 +65,7 @@ describe('useApplyViewSortsToCurrentRecordSorts', () => {
|
||||
result.current.applyViewSortsToCurrentRecordSorts([mockViewSort]);
|
||||
});
|
||||
|
||||
expect(result.current.currentSorts).toEqual([
|
||||
expect(result.current.currentRecordSorts).toEqual([
|
||||
{
|
||||
id: mockViewSort.id,
|
||||
fieldMetadataId: mockViewSort.fieldMetadataId,
|
||||
@@ -80,11 +80,11 @@ describe('useApplyViewSortsToCurrentRecordSorts', () => {
|
||||
const { applyViewSortsToCurrentRecordSorts } =
|
||||
useApplyViewSortsToCurrentRecordSorts();
|
||||
|
||||
const currentSorts = useAtomComponentStateValue(
|
||||
const currentRecordSorts = useAtomComponentStateValue(
|
||||
currentRecordSortsComponentState,
|
||||
);
|
||||
|
||||
return { applyViewSortsToCurrentRecordSorts, currentSorts };
|
||||
return { applyViewSortsToCurrentRecordSorts, currentRecordSorts };
|
||||
},
|
||||
{
|
||||
wrapper: getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
@@ -100,6 +100,6 @@ describe('useApplyViewSortsToCurrentRecordSorts', () => {
|
||||
result.current.applyViewSortsToCurrentRecordSorts([]);
|
||||
});
|
||||
|
||||
expect(result.current.currentSorts).toEqual([]);
|
||||
expect(result.current.currentRecordSorts).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ import { useCallback } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useApplyCurrentViewAnyFieldFilterToAnyFieldFilter = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -21,14 +21,14 @@ export const useApplyCurrentViewAnyFieldFilterToAnyFieldFilter = () => {
|
||||
const applyCurrentViewAnyFieldFilterToAnyFieldFilter = useCallback(() => {
|
||||
const currentView = store.get(
|
||||
coreViewFromViewIdFamilySelector.selectorFamily({
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
}),
|
||||
);
|
||||
|
||||
if (isDefined(currentView)) {
|
||||
setAnyFieldFilterValue(currentView.anyFieldFilterValue ?? '');
|
||||
}
|
||||
}, [currentViewId, setAnyFieldFilterValue, store]);
|
||||
}, [contextStoreCurrentViewId, setAnyFieldFilterValue, store]);
|
||||
|
||||
return {
|
||||
applyCurrentViewAnyFieldFilterToAnyFieldFilter,
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
|
||||
export const useApplyCurrentViewFilterGroupsToCurrentRecordFilterGroups =
|
||||
() => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ export const useApplyCurrentViewFilterGroupsToCurrentRecordFilterGroups =
|
||||
useCallback(() => {
|
||||
const currentView = store.get(
|
||||
coreViewFromViewIdFamilySelector.selectorFamily({
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -50,7 +50,7 @@ export const useApplyCurrentViewFilterGroupsToCurrentRecordFilterGroups =
|
||||
}
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
setCurrentRecordFilterGroups,
|
||||
currentRecordFilterGroups,
|
||||
store,
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import { useMapViewFiltersToFilters } from './useMapViewFiltersToFilters';
|
||||
|
||||
export const useApplyCurrentViewFiltersToCurrentRecordFilters = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
@@ -24,7 +24,7 @@ export const useApplyCurrentViewFiltersToCurrentRecordFilters = () => {
|
||||
const applyCurrentViewFiltersToCurrentRecordFilters = useCallback(() => {
|
||||
const currentView = store.get(
|
||||
coreViewFromViewIdFamilySelector.selectorFamily({
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@ export const useApplyCurrentViewFiltersToCurrentRecordFilters = () => {
|
||||
);
|
||||
}
|
||||
}, [
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
mapViewFiltersToRecordFilters,
|
||||
setCurrentRecordFilters,
|
||||
store,
|
||||
|
||||
+2
-2
@@ -7,14 +7,14 @@ import { coreViewFromViewIdFamilySelector } from '@/views/states/selectors/coreV
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useApplyCurrentViewSortsToCurrentRecordSorts = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/use
|
||||
import { coreViewFromViewIdFamilySelector } from '@/views/states/selectors/coreViewFromViewIdFamilySelector';
|
||||
|
||||
export const useGetCurrentViewOnly = () => {
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
|
||||
const currentView = useAtomFamilySelectorValue(
|
||||
coreViewFromViewIdFamilySelector,
|
||||
{
|
||||
viewId: currentViewId ?? '',
|
||||
viewId: contextStoreCurrentViewId ?? '',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ export const useOpenAnyFieldSearchFilterFromViewBar = () => {
|
||||
|
||||
const { objectMetadataItem } = useRecordIndexContextOrThrow();
|
||||
|
||||
const setObjectFilterDropdownAnyFieldSearchIsSelectedComponentState =
|
||||
const setObjectFilterDropdownAnyFieldSearchIsSelected =
|
||||
useSetAtomComponentState(
|
||||
objectFilterDropdownAnyFieldSearchIsSelectedComponentState,
|
||||
);
|
||||
@@ -48,7 +48,7 @@ export const useOpenAnyFieldSearchFilterFromViewBar = () => {
|
||||
setAnyFieldFilterValue(filterValue);
|
||||
}
|
||||
|
||||
setObjectFilterDropdownAnyFieldSearchIsSelectedComponentState(true);
|
||||
setObjectFilterDropdownAnyFieldSearchIsSelected(true);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -13,7 +13,7 @@ export const useQueryVariablesFromParentView = ({
|
||||
}) => {
|
||||
const { objectMetadataItems } = useObjectMetadataItems();
|
||||
|
||||
const recordShowParentView = useAtomComponentStateValue(
|
||||
const contextStoreRecordShowParentView = useAtomComponentStateValue(
|
||||
contextStoreRecordShowParentViewComponentState,
|
||||
MAIN_CONTEXT_STORE_INSTANCE_ID,
|
||||
);
|
||||
@@ -21,9 +21,10 @@ export const useQueryVariablesFromParentView = ({
|
||||
const { filterValueDependencies } = useFilterValueDependencies();
|
||||
|
||||
const { filter, orderBy } = getQueryVariablesFromFiltersAndSorts({
|
||||
recordFilterGroups: recordShowParentView?.parentViewFilterGroups ?? [],
|
||||
recordFilters: recordShowParentView?.parentViewFilters ?? [],
|
||||
recordSorts: recordShowParentView?.parentViewSorts ?? [],
|
||||
recordFilterGroups:
|
||||
contextStoreRecordShowParentView?.parentViewFilterGroups ?? [],
|
||||
recordFilters: contextStoreRecordShowParentView?.parentViewFilters ?? [],
|
||||
recordSorts: contextStoreRecordShowParentView?.parentViewSorts ?? [],
|
||||
objectMetadataItem,
|
||||
objectMetadataItems,
|
||||
filterValueDependencies,
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useStore } from 'jotai';
|
||||
export const useUpdateViewAggregate = () => {
|
||||
const store = useStore();
|
||||
const { canPersistChanges } = useCanPersistViewChanges();
|
||||
const currentViewId = useAtomComponentStateValue(
|
||||
const contextStoreCurrentViewId = useAtomComponentStateValue(
|
||||
contextStoreCurrentViewIdComponentState,
|
||||
);
|
||||
const { performViewAPIUpdate } = usePerformViewAPIUpdate();
|
||||
@@ -47,12 +47,12 @@ export const useUpdateViewAggregate = () => {
|
||||
)
|
||||
: null;
|
||||
|
||||
if (!isDefined(currentViewId)) {
|
||||
if (!isDefined(contextStoreCurrentViewId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedViewResult = await performViewAPIUpdate({
|
||||
id: currentViewId,
|
||||
id: contextStoreCurrentViewId,
|
||||
input: {
|
||||
kanbanAggregateOperationFieldMetadataId,
|
||||
kanbanAggregateOperation: convertedKanbanAggregateOperation,
|
||||
@@ -81,7 +81,7 @@ export const useUpdateViewAggregate = () => {
|
||||
},
|
||||
[
|
||||
canPersistChanges,
|
||||
currentViewId,
|
||||
contextStoreCurrentViewId,
|
||||
performViewAPIUpdate,
|
||||
loadRecordIndexStates,
|
||||
store,
|
||||
|
||||
Reference in New Issue
Block a user