Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace entityId by recordId in the front end. #6355

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const CalendarEventDetails = ({
<StyledPropertyBox key={fieldName}>
<FieldContext.Provider
value={{
entityId: calendarEvent.id,
recordId: calendarEvent.id,
hotkeyScope: 'calendar-event-details',
recoilScopeId: `${calendarEvent.id}-${fieldName}`,
isLabelIdentifier: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const EventFieldDiffValue = ({
<StyledEventFieldDiffValue>
<FieldContext.Provider
value={{
entityId: diffArtificialRecordStoreId,
recordId: diffArtificialRecordStoreId,
isLabelIdentifier: isLabelIdentifierField({
fieldMetadataItem,
objectMetadataItem: mainObjectMetadataItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const useFieldContext = ({
basePathToShowPage: isLabelIdentifier
? basePathToShowPage
: undefined,
entityId: objectRecordId,
recordId: objectRecordId,
recoilScopeId: objectRecordId + fieldMetadataItem.id,
isLabelIdentifier,
fieldDefinition: formatFieldMetadataItemAsColumnDefinition({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,31 +178,33 @@ describe('useFilterDropdown', () => {
});
});

it('should set objectFilterDropdownSelectedEntityId', async () => {
const mockResult = 'value';
it('should set objectFilterDropdownSelectedRecordId', async () => {
const mockResult = ['value'];
const { result } = renderHook(() => {
useFilterDropdown({ filterDropdownId });
const { objectFilterDropdownSelectedEntityIdState } =
const { objectFilterDropdownSelectedRecordIdsState } =
useFilterDropdownStates(filterDropdownId);

const [
objectFilterDropdownSelectedEntityId,
setObjectFilterDropdownSelectedEntityId,
] = useRecoilState(objectFilterDropdownSelectedEntityIdState);
objectFilterDropdownSelectedRecordIds,
setObjectFilterDropdownSelectedRecordIds,
] = useRecoilState(objectFilterDropdownSelectedRecordIdsState);
return {
objectFilterDropdownSelectedEntityId,
setObjectFilterDropdownSelectedEntityId,
objectFilterDropdownSelectedRecordIds,
setObjectFilterDropdownSelectedRecordIds,
};
}, renderHookConfig);

expect(result.current.objectFilterDropdownSelectedEntityId).toBeNull();
expect(
JSON.stringify(result.current.objectFilterDropdownSelectedRecordIds),
).toBe(JSON.stringify([]));

act(() => {
result.current.setObjectFilterDropdownSelectedEntityId(mockResult);
result.current.setObjectFilterDropdownSelectedRecordIds(mockResult);
});

await waitFor(() => {
expect(result.current.objectFilterDropdownSelectedEntityId).toBe(
expect(result.current.objectFilterDropdownSelectedRecordIds).toBe(
mockResult,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
availableFilterDefinitionsState,
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
objectFilterDropdownSelectedOptionValuesState,
isObjectFilterDropdownOperandSelectUnfoldedState,
Expand All @@ -46,13 +45,11 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
({ set }) =>
() => {
set(objectFilterDropdownSearchInputState, '');
set(objectFilterDropdownSelectedEntityIdState, null);
set(objectFilterDropdownSelectedRecordIdsState, []);
set(selectedFilterState, undefined);
},
[
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
selectedFilterState,
],
Expand All @@ -62,7 +59,6 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
({ set }) =>
() => {
set(objectFilterDropdownSearchInputState, '');
set(objectFilterDropdownSelectedEntityIdState, null);
set(objectFilterDropdownSelectedRecordIdsState, []);
set(selectedFilterState, undefined);
set(filterDefinitionUsedInDropdownState, null);
Expand All @@ -71,7 +67,6 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
[
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
selectedFilterState,
selectedOperandInDropdownState,
Expand All @@ -91,9 +86,6 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
const setObjectFilterDropdownSearchInput = useSetRecoilState(
objectFilterDropdownSearchInputState,
);
const setObjectFilterDropdownSelectedEntityId = useSetRecoilState(
objectFilterDropdownSelectedEntityIdState,
);
const setObjectFilterDropdownSelectedRecordIds = useSetRecoilState(
objectFilterDropdownSelectedRecordIdsState,
);
Expand All @@ -117,7 +109,7 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
setAvailableFilterDefinitions,
setFilterDefinitionUsedInDropdown,
setObjectFilterDropdownSearchInput,
setObjectFilterDropdownSelectedEntityId,
// setObjectFilterDropdownSelectedEntityId,
setObjectFilterDropdownSelectedRecordIds,
setObjectFilterDropdownSelectedOptionValues,
setIsObjectFilterDropdownOperandSelectUnfolded,
Expand All @@ -127,7 +119,7 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
availableFilterDefinitionsState,
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
// objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
objectFilterDropdownSelectedOptionValuesState,
isObjectFilterDropdownOperandSelectUnfoldedState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { filterDefinitionUsedInDropdownComponentState } from '@/object-record/ob
import { isObjectFilterDropdownOperandSelectUnfoldedComponentState } from '@/object-record/object-filter-dropdown/states/isObjectFilterDropdownOperandSelectUnfoldedComponentState';
import { isObjectFilterDropdownUnfoldedComponentState } from '@/object-record/object-filter-dropdown/states/isObjectFilterDropdownUnfoldedComponentState';
import { objectFilterDropdownSearchInputComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownSearchInputComponentState';
import { objectFilterDropdownSelectedEntityIdComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedEntityIdComponentState';
import { objectFilterDropdownSelectedOptionValuesComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedOptionValuesComponentState';
import { objectFilterDropdownSelectedRecordIdsComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedRecordIdsComponentState';
import { onFilterSelectComponentState } from '@/object-record/object-filter-dropdown/states/onFilterSelectComponentState';
Expand All @@ -27,11 +26,6 @@ export const useFilterDropdownStates = (scopeId: string) => {
scopeId,
);

const objectFilterDropdownSelectedEntityIdState = extractComponentState(
objectFilterDropdownSelectedEntityIdComponentState,
scopeId,
);

const objectFilterDropdownSelectedRecordIdsState = extractComponentState(
objectFilterDropdownSelectedRecordIdsComponentState,
scopeId,
Expand Down Expand Up @@ -72,7 +66,6 @@ export const useFilterDropdownStates = (scopeId: string) => {
availableFilterDefinitionsState,
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
objectFilterDropdownSelectedOptionValuesState,
isObjectFilterDropdownOperandSelectUnfoldedState,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export const RecordBoardCard = () => {
>
<FieldContext.Provider
value={{
entityId: recordId,
recordId,
maxWidth: 156,
recoilScopeId: recordId + fieldDefinition.fieldMetadataId,
isLabelIdentifier: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type RecordUpdateHook = () => [
export type GenericFieldContextType = {
fieldDefinition: FieldDefinition<FieldMetadata>;
useUpdateRecord?: RecordUpdateHook;
entityId: string;
recordId: string;
recoilScopeId?: string;
hotkeyScope: string;
isLabelIdentifier: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { useGetButtonIcon } from '@/object-record/record-field/hooks/useGetButto
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';

const entityId = 'entityId';
const recordId = 'recordId';

const getWrapper =
(fieldDefinition: FieldDefinition<FieldMetadata>) =>
({ children }: { children: ReactNode }) => (
<FieldContext.Provider
value={{
fieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { FieldContext } from '@/object-record/record-field/contexts/FieldContext
import { useIsFieldEmpty } from '@/object-record/record-field/hooks/useIsFieldEmpty';
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';

const entityId = 'entityId';
const recordId = 'recordId';

const Wrapper = ({ children }: { children: ReactNode }) => (
<FieldContext.Provider
value={{
fieldDefinition: phoneFieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
}}
Expand All @@ -27,7 +27,7 @@ describe('useIsFieldEmpty', () => {
const { result } = renderHook(
() => {
const setFieldState = useSetRecoilState(
recordStoreFamilyState(entityId),
recordStoreFamilyState(recordId),
);
return {
setFieldState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { useIsFieldInputOnly } from '@/object-record/record-field/hooks/useIsFie
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';

const entityId = 'entityId';
const recordId = 'recordId';

const getWrapper =
(fieldDefinition: FieldDefinition<FieldMetadata>) =>
({ children }: { children: ReactNode }) => (
<FieldContext.Provider
value={{
fieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ const mocks: MockedResponse[] = [
{
request: {
query,
variables: { idToUpdate: 'entityId', input: { phone: '+1 123 456' } },
variables: { idToUpdate: 'recordId', input: { phone: '+1 123 456' } },
},
result: jest.fn(() => ({
data: {
updatePerson: {
id: 'entityId',
id: 'recordId',
},
},
})),
Expand All @@ -69,21 +69,21 @@ const mocks: MockedResponse[] = [
request: {
query,
variables: {
idToUpdate: 'entityId',
idToUpdate: 'recordId',
input: { companyId: 'companyId' },
},
},
result: jest.fn(() => ({
data: {
updatePerson: {
id: 'entityId',
id: 'recordId',
},
},
})),
},
];

const entityId = 'entityId';
const recordId = 'recordId';

const getWrapper =
(fieldDefinition: FieldDefinition<FieldMetadata>) =>
Expand All @@ -108,7 +108,7 @@ const getWrapper =
<FieldContext.Provider
value={{
fieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
useUpdateRecord: useUpdateOneRecordMutation,
Expand All @@ -128,7 +128,7 @@ describe('usePersistField', () => {
const { result } = renderHook(
() => {
const entityFields = useRecoilValue(
recordStoreFamilySelector({ recordId: entityId, fieldName: 'phone' }),
recordStoreFamilySelector({ recordId, fieldName: 'phone' }),
);

return {
Expand All @@ -153,7 +153,7 @@ describe('usePersistField', () => {
() => {
const entityFields = useRecoilValue(
recordStoreFamilySelector({
recordId: entityId,
recordId,
fieldName: 'company',
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@/object-record/record-field/contexts/FieldContext';
import { useToggleEditOnlyInput } from '@/object-record/record-field/hooks/useToggleEditOnlyInput';

const entityId = 'entityId';
const recordId = 'recordId';

const mocks: MockedResponse[] = [
{
Expand Down Expand Up @@ -66,14 +66,14 @@ const mocks: MockedResponse[] = [
}
`,
variables: {
idToUpdate: 'entityId',
idToUpdate: 'recordId',
input: { idealCustomerProfile: true },
},
},
result: jest.fn(() => ({
data: {
updateWorkspaceMember: {
id: 'entityId',
id: 'recordId',
},
},
})),
Expand Down Expand Up @@ -101,7 +101,7 @@ const Wrapper = ({ children }: { children: ReactNode }) => {
<FieldContext.Provider
value={{
fieldDefinition: booleanFieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
useUpdateRecord: useUpdateOneRecordMutation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FieldContext } from '../contexts/FieldContext';

export const useClearField = () => {
const {
entityId,
recordId,
fieldDefinition,
useUpdateRecord = () => [],
} = useContext(FieldContext);
Expand Down Expand Up @@ -45,22 +45,22 @@ export const useClearField = () => {
const emptyFieldValue = generateEmptyFieldValue(foundFieldMetadataItem);

set(
recordStoreFamilySelector({ recordId: entityId, fieldName }),
recordStoreFamilySelector({ recordId, fieldName }),
emptyFieldValue,
);

setRecordFieldValue(entityId, fieldName, emptyFieldValue);
setRecordFieldValue(recordId, fieldName, emptyFieldValue);

updateRecord?.({
variables: {
where: { id: entityId },
where: { id: recordId },
updateOneRecordInput: {
[fieldName]: emptyFieldValue,
},
},
});
},
[entityId, fieldDefinition, updateRecord, setRecordFieldValue],
[recordId, fieldDefinition, updateRecord, setRecordFieldValue],
);

return clearField;
Expand Down
Loading
Loading