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 1 commit
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 @@ -29,7 +29,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,35 +178,35 @@ describe('useFilterDropdown', () => {
});
});

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

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

expect(result.current.objectFilterDropdownSelectedEntityId).toBeNull();

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

await waitFor(() => {
expect(result.current.objectFilterDropdownSelectedEntityId).toBe(
mockResult,
);
});
});
// it('should set objectFilterDropdownSelectedEntityId', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok we should get rid of objectFilterDropdownSelectedEntityId state, but we should rewrite this test for objectFilterDropdownSelectedRecordIdsState

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what should I in this case, keep test cases as it is and create a new issue to rewrite the tests?
What do u suggest?

// const mockResult = 'value';
// const { result } = renderHook(() => {
// useFilterDropdown({ filterDropdownId });
// const { objectFilterDropdownSelectedEntityIdState } =
// useFilterDropdownStates(filterDropdownId);

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

// expect(result.current.objectFilterDropdownSelectedEntityId).toBeNull();

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

// await waitFor(() => {
// expect(result.current.objectFilterDropdownSelectedEntityId).toBe(
// mockResult,
// );
// });
// });

it('should set objectFilterDropdownSelectedRecordIds', async () => {
const mockResult = ['id-0', 'id-1', 'id-2'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
availableFilterDefinitionsState,
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
// objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
objectFilterDropdownSelectedOptionValuesState,
isObjectFilterDropdownOperandSelectUnfoldedState,
Expand All @@ -46,13 +46,13 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
({ set }) =>
() => {
set(objectFilterDropdownSearchInputState, '');
set(objectFilterDropdownSelectedEntityIdState, null);
// set(objectFilterDropdownSelectedEntityIdState, null);
set(objectFilterDropdownSelectedRecordIdsState, []);
set(selectedFilterState, undefined);
},
[
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
// objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
selectedFilterState,
],
Expand All @@ -62,7 +62,7 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
({ set }) =>
() => {
set(objectFilterDropdownSearchInputState, '');
set(objectFilterDropdownSelectedEntityIdState, null);
// set(objectFilterDropdownSelectedEntityIdState, null);
set(objectFilterDropdownSelectedRecordIdsState, []);
set(selectedFilterState, undefined);
set(filterDefinitionUsedInDropdownState, null);
Expand All @@ -71,7 +71,7 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
[
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
// objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
selectedFilterState,
selectedOperandInDropdownState,
Expand All @@ -91,9 +91,9 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
const setObjectFilterDropdownSearchInput = useSetRecoilState(
objectFilterDropdownSearchInputState,
);
const setObjectFilterDropdownSelectedEntityId = useSetRecoilState(
objectFilterDropdownSelectedEntityIdState,
);
// const setObjectFilterDropdownSelectedEntityId = useSetRecoilState(
// objectFilterDropdownSelectedEntityIdState,
// );
const setObjectFilterDropdownSelectedRecordIds = useSetRecoilState(
objectFilterDropdownSelectedRecordIdsState,
);
Expand All @@ -117,7 +117,7 @@ export const useFilterDropdown = (props?: UseFilterDropdownProps) => {
setAvailableFilterDefinitions,
setFilterDefinitionUsedInDropdown,
setObjectFilterDropdownSearchInput,
setObjectFilterDropdownSelectedEntityId,
// setObjectFilterDropdownSelectedEntityId,
setObjectFilterDropdownSelectedRecordIds,
setObjectFilterDropdownSelectedOptionValues,
setIsObjectFilterDropdownOperandSelectUnfolded,
Expand All @@ -127,7 +127,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,7 @@ 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 { 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,10 +27,10 @@ export const useFilterDropdownStates = (scopeId: string) => {
scopeId,
);

const objectFilterDropdownSelectedEntityIdState = extractComponentState(
objectFilterDropdownSelectedEntityIdComponentState,
scopeId,
);
// const objectFilterDropdownSelectedEntityIdState = extractComponentState(
// objectFilterDropdownSelectedEntityIdComponentState,
// scopeId,
// );

const objectFilterDropdownSelectedRecordIdsState = extractComponentState(
objectFilterDropdownSelectedRecordIdsComponentState,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const useFilterDropdownStates = (scopeId: string) => {
availableFilterDefinitionsState,
filterDefinitionUsedInDropdownState,
objectFilterDropdownSearchInputState,
objectFilterDropdownSelectedEntityIdState,
// objectFilterDropdownSelectedEntityIdState,
objectFilterDropdownSelectedRecordIdsState,
objectFilterDropdownSelectedOptionValuesState,
isObjectFilterDropdownOperandSelectUnfoldedState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
// import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';

export const objectFilterDropdownSelectedEntityIdComponentState =
createComponentState<string | null>({
key: 'objectFilterDropdownSelectedEntityIdComponentState',
defaultValue: null,
});
// export const objectFilterDropdownSelectedEntityIdComponentState =
// createComponentState<string | null>({
// key: 'objectFilterDropdownSelectedEntityIdComponentState',
// defaultValue: null,
// });
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const RecordBoardCard = () => {
>
<FieldContext.Provider
value={{
entityId: recordId,
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 @@ -53,12 +53,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 @@ -67,21 +67,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 @@ -106,7 +106,7 @@ const getWrapper =
<FieldContext.Provider
value={{
fieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
useUpdateRecord: useUpdateOneRecordMutation,
Expand All @@ -126,7 +126,7 @@ describe('usePersistField', () => {
const { result } = renderHook(
() => {
const entityFields = useRecoilValue(
recordStoreFamilySelector({ recordId: entityId, fieldName: 'phone' }),
recordStoreFamilySelector({ recordId: recordId, fieldName: 'phone' }),
);

return {
Expand All @@ -151,7 +151,7 @@ describe('usePersistField', () => {
() => {
const entityFields = useRecoilValue(
recordStoreFamilySelector({
recordId: entityId,
recordId: 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 @@ -60,14 +60,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 @@ -95,7 +95,7 @@ const Wrapper = ({ children }: { children: ReactNode }) => {
<FieldContext.Provider
value={{
fieldDefinition: booleanFieldDefinition,
entityId,
recordId,
hotkeyScope: 'hotkeyScope',
isLabelIdentifier: false,
useUpdateRecord: useUpdateOneRecordMutation,
Expand Down
Loading
Loading