[Refactor] Activity morph: first phase (#1075)

* Add company and person on update and create

* Enable reading with error management on commentable ID

* [CHECKPOINT] backward-compatible

* Migrate data for activity targets

* Revert "Migrate data for activity targets"

This reverts commit f89bc30689655c83cd5370331fec41b59d03fdb9.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Emilien Chauvet
2023-08-05 00:33:50 +02:00
committed by GitHub
parent 04297b0556
commit ed1662223a
11 changed files with 80 additions and 18 deletions

View File

@ -27,7 +27,10 @@ import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '../utils/flatMa
type OwnProps = {
activity?: Pick<Activity, 'id'> & {
activityTargets: Array<
Pick<ActivityTarget, 'id' | 'commentableId' | 'commentableType'>
Pick<
ActivityTarget,
'id' | 'commentableId' | 'commentableType' | 'companyId' | 'personId'
>
>;
};
};
@ -87,7 +90,7 @@ export function ActivityRelationPicker({ activity }: OwnProps) {
() =>
activity?.activityTargets
?.filter((relation) => relation.commentableType === 'Person')
.map((relation) => relation.commentableId)
.map((relation) => relation.personId || relation.commentableId)
.filter(assertNotNull) ?? [],
[activity?.activityTargets],
);
@ -96,7 +99,7 @@ export function ActivityRelationPicker({ activity }: OwnProps) {
() =>
activity?.activityTargets
?.filter((relation) => relation.commentableType === 'Company')
.map((relation) => relation.commentableId)
.map((relation) => relation.companyId || relation.commentableId)
.filter(assertNotNull) ?? [],
[activity?.activityTargets],
);

View File

@ -68,7 +68,9 @@ export function TaskRow({ task }: { task: TaskForList }) {
in: task?.activityTargets
? task?.activityTargets
.filter((target) => target.commentableType === 'Person')
.map((target) => target.commentableId ?? '')
.map(
(target) => (target.personId || target.commentableId) ?? '',
)
: [],
},
},
@ -82,7 +84,9 @@ export function TaskRow({ task }: { task: TaskForList }) {
in: task?.activityTargets
? task?.activityTargets
.filter((target) => target.commentableType === 'Company')
.map((target) => target.commentableId ?? '')
.map(
(target) => (target.companyId || target.commentableId) ?? '',
)
: [],
},
},