forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes Empty Label Identifer Preview in Settings/DataModel/Object/Edit (…
…twentyhq#6370) fixes twentyhq#6143 --------- Co-authored-by: Félix Malfait <[email protected]>
- Loading branch information
1 parent
320742c
commit b4e2ada
Showing
11 changed files
with
149 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 18 additions & 3 deletions
21
...odules/settings/data-model/fields/preview/components/SettingsDataModelSetRecordEffect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import { useEffect } from 'react'; | ||
|
||
import { useSetRecordFieldValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext'; | ||
import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore'; | ||
import { ObjectRecord } from '@/object-record/types/ObjectRecord'; | ||
import { previewRecordIdState } from '@/settings/data-model/fields/preview/states/previewRecordIdState'; | ||
import { useEffect } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
|
||
type SettingsDataModelSetRecordEffectProps = { | ||
record: ObjectRecord; | ||
fieldName: string; | ||
}; | ||
|
||
export const SettingsDataModelSetRecordEffect = ({ | ||
record, | ||
fieldName, | ||
}: SettingsDataModelSetRecordEffectProps) => { | ||
const { upsertRecords: upsertRecordsInStore } = useUpsertRecordsInStore(); | ||
const setRecordFieldValue = useSetRecordFieldValue(); | ||
|
||
const setPreviewRecordId = useSetRecoilState(previewRecordIdState); | ||
|
||
useEffect(() => { | ||
upsertRecordsInStore([record]); | ||
}, [record, upsertRecordsInStore]); | ||
setRecordFieldValue(record.id, fieldName, record[fieldName]); | ||
setPreviewRecordId(record.id); | ||
}, [ | ||
record, | ||
upsertRecordsInStore, | ||
setRecordFieldValue, | ||
fieldName, | ||
setPreviewRecordId, | ||
]); | ||
|
||
return null; | ||
}; |
6 changes: 6 additions & 0 deletions
6
...wenty-front/src/modules/settings/data-model/fields/preview/states/previewRecordIdState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createState } from 'twenty-ui'; | ||
|
||
export const previewRecordIdState = createState<string | null>({ | ||
key: 'previewRecordId', | ||
defaultValue: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/twenty-front/src/modules/ui/input/components/Select.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ges/twenty-server/src/modules/contact-creation-manager/services/create-company.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters