Remove activityType and Id (#1179)

* Remove activityType and Id

* Fix tests

* Fix tests
This commit is contained in:
Charles Bochet 2023-08-12 02:31:54 +02:00 committed by GitHub
parent a30222fe76
commit 35ea6b5a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 360 additions and 822 deletions

View File

@ -117,8 +117,6 @@ export type ActivityTarget = {
__typename?: 'ActivityTarget'; __typename?: 'ActivityTarget';
activity: Activity; activity: Activity;
activityId: Scalars['String']; activityId: Scalars['String'];
commentableId?: Maybe<Scalars['String']>;
commentableType?: Maybe<CommentableType>;
company?: Maybe<Company>; company?: Maybe<Company>;
companyId?: Maybe<Scalars['String']>; companyId?: Maybe<Scalars['String']>;
createdAt: Scalars['DateTime']; createdAt: Scalars['DateTime'];
@ -129,8 +127,6 @@ export type ActivityTarget = {
}; };
export type ActivityTargetCreateManyActivityInput = { export type ActivityTargetCreateManyActivityInput = {
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
companyId?: InputMaybe<Scalars['String']>; companyId?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
@ -145,8 +141,6 @@ export type ActivityTargetCreateManyActivityInputEnvelope = {
export type ActivityTargetCreateManyCompanyInput = { export type ActivityTargetCreateManyCompanyInput = {
activityId: Scalars['String']; activityId: Scalars['String'];
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
personId?: InputMaybe<Scalars['String']>; personId?: InputMaybe<Scalars['String']>;
@ -160,8 +154,6 @@ export type ActivityTargetCreateManyCompanyInputEnvelope = {
export type ActivityTargetCreateManyPersonInput = { export type ActivityTargetCreateManyPersonInput = {
activityId: Scalars['String']; activityId: Scalars['String'];
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
companyId?: InputMaybe<Scalars['String']>; companyId?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
@ -175,8 +167,6 @@ export type ActivityTargetCreateManyPersonInputEnvelope = {
export type ActivityTargetCreateManyWorkspaceInput = { export type ActivityTargetCreateManyWorkspaceInput = {
activityId: Scalars['String']; activityId: Scalars['String'];
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
companyId?: InputMaybe<Scalars['String']>; companyId?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
@ -231,8 +221,6 @@ export type ActivityTargetCreateOrConnectWithoutWorkspaceInput = {
}; };
export type ActivityTargetCreateWithoutActivityInput = { export type ActivityTargetCreateWithoutActivityInput = {
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
company?: InputMaybe<CompanyCreateNestedOneWithoutActivityTargetInput>; company?: InputMaybe<CompanyCreateNestedOneWithoutActivityTargetInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
@ -242,8 +230,6 @@ export type ActivityTargetCreateWithoutActivityInput = {
export type ActivityTargetCreateWithoutCompanyInput = { export type ActivityTargetCreateWithoutCompanyInput = {
activity: ActivityCreateNestedOneWithoutActivityTargetsInput; activity: ActivityCreateNestedOneWithoutActivityTargetsInput;
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
person?: InputMaybe<PersonCreateNestedOneWithoutActivityTargetInput>; person?: InputMaybe<PersonCreateNestedOneWithoutActivityTargetInput>;
@ -252,8 +238,6 @@ export type ActivityTargetCreateWithoutCompanyInput = {
export type ActivityTargetCreateWithoutPersonInput = { export type ActivityTargetCreateWithoutPersonInput = {
activity: ActivityCreateNestedOneWithoutActivityTargetsInput; activity: ActivityCreateNestedOneWithoutActivityTargetsInput;
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
company?: InputMaybe<CompanyCreateNestedOneWithoutActivityTargetInput>; company?: InputMaybe<CompanyCreateNestedOneWithoutActivityTargetInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
@ -262,8 +246,6 @@ export type ActivityTargetCreateWithoutPersonInput = {
export type ActivityTargetCreateWithoutWorkspaceInput = { export type ActivityTargetCreateWithoutWorkspaceInput = {
activity: ActivityCreateNestedOneWithoutActivityTargetsInput; activity: ActivityCreateNestedOneWithoutActivityTargetsInput;
commentableId?: InputMaybe<Scalars['String']>;
commentableType?: InputMaybe<CommentableType>;
company?: InputMaybe<CompanyCreateNestedOneWithoutActivityTargetInput>; company?: InputMaybe<CompanyCreateNestedOneWithoutActivityTargetInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
@ -286,8 +268,6 @@ export type ActivityTargetScalarWhereInput = {
NOT?: InputMaybe<Array<ActivityTargetScalarWhereInput>>; NOT?: InputMaybe<Array<ActivityTargetScalarWhereInput>>;
OR?: InputMaybe<Array<ActivityTargetScalarWhereInput>>; OR?: InputMaybe<Array<ActivityTargetScalarWhereInput>>;
activityId?: InputMaybe<StringFilter>; activityId?: InputMaybe<StringFilter>;
commentableId?: InputMaybe<StringNullableFilter>;
commentableType?: InputMaybe<EnumCommentableTypeNullableFilter>;
companyId?: InputMaybe<StringNullableFilter>; companyId?: InputMaybe<StringNullableFilter>;
createdAt?: InputMaybe<DateTimeFilter>; createdAt?: InputMaybe<DateTimeFilter>;
id?: InputMaybe<StringFilter>; id?: InputMaybe<StringFilter>;
@ -345,8 +325,6 @@ export type ActivityTargetWhereInput = {
OR?: InputMaybe<Array<ActivityTargetWhereInput>>; OR?: InputMaybe<Array<ActivityTargetWhereInput>>;
activity?: InputMaybe<ActivityRelationFilter>; activity?: InputMaybe<ActivityRelationFilter>;
activityId?: InputMaybe<StringFilter>; activityId?: InputMaybe<StringFilter>;
commentableId?: InputMaybe<StringNullableFilter>;
commentableType?: InputMaybe<EnumCommentableTypeNullableFilter>;
company?: InputMaybe<CompanyRelationFilter>; company?: InputMaybe<CompanyRelationFilter>;
companyId?: InputMaybe<StringNullableFilter>; companyId?: InputMaybe<StringNullableFilter>;
createdAt?: InputMaybe<DateTimeFilter>; createdAt?: InputMaybe<DateTimeFilter>;
@ -632,11 +610,6 @@ export type CommentWhereUniqueInput = {
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
}; };
export enum CommentableType {
Company = 'Company',
Person = 'Person'
}
export type Company = { export type Company = {
__typename?: 'Company'; __typename?: 'Company';
ActivityTarget?: Maybe<Array<ActivityTarget>>; ActivityTarget?: Maybe<Array<ActivityTarget>>;
@ -837,13 +810,6 @@ export type EnumColorSchemeFilter = {
notIn?: InputMaybe<Array<ColorScheme>>; notIn?: InputMaybe<Array<ColorScheme>>;
}; };
export type EnumCommentableTypeNullableFilter = {
equals?: InputMaybe<CommentableType>;
in?: InputMaybe<Array<CommentableType>>;
not?: InputMaybe<NestedEnumCommentableTypeNullableFilter>;
notIn?: InputMaybe<Array<CommentableType>>;
};
export type EnumPipelineProgressableTypeFilter = { export type EnumPipelineProgressableTypeFilter = {
equals?: InputMaybe<PipelineProgressableType>; equals?: InputMaybe<PipelineProgressableType>;
in?: InputMaybe<Array<PipelineProgressableType>>; in?: InputMaybe<Array<PipelineProgressableType>>;
@ -1286,13 +1252,6 @@ export type NestedEnumColorSchemeFilter = {
notIn?: InputMaybe<Array<ColorScheme>>; notIn?: InputMaybe<Array<ColorScheme>>;
}; };
export type NestedEnumCommentableTypeNullableFilter = {
equals?: InputMaybe<CommentableType>;
in?: InputMaybe<Array<CommentableType>>;
not?: InputMaybe<NestedEnumCommentableTypeNullableFilter>;
notIn?: InputMaybe<Array<CommentableType>>;
};
export type NestedEnumPipelineProgressableTypeFilter = { export type NestedEnumPipelineProgressableTypeFilter = {
equals?: InputMaybe<PipelineProgressableType>; equals?: InputMaybe<PipelineProgressableType>;
in?: InputMaybe<Array<PipelineProgressableType>>; in?: InputMaybe<Array<PipelineProgressableType>>;
@ -2694,7 +2653,9 @@ export type CreateActivityMutationVariables = Exact<{
}>; }>;
export type CreateActivityMutation = { __typename?: 'Mutation', createOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, authorId: string, type: ActivityType, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, activityId: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null, comments?: Array<{ __typename?: 'Comment', id: string, createdAt: string, updatedAt: string, body: string, author: { __typename?: 'User', id: string } }> | null } }; export type CreateActivityMutation = { __typename?: 'Mutation', createOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, authorId: string, type: ActivityType, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, activityId: string, companyId?: string | null, personId?: string | null }> | null, comments?: Array<{ __typename?: 'Comment', id: string, createdAt: string, updatedAt: string, body: string, author: { __typename?: 'User', id: string } }> | null } };
export type ActivityQueryFragmentFragment = { __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, companyId?: string | null, personId?: string | null, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null, person?: { __typename?: 'Person', id: string, displayName: string, avatarUrl?: string | null } | null }> | null };
export type GetActivitiesByTargetsQueryVariables = Exact<{ export type GetActivitiesByTargetsQueryVariables = Exact<{
activityTargetIds: Array<Scalars['String']> | Scalars['String']; activityTargetIds: Array<Scalars['String']> | Scalars['String'];
@ -2702,7 +2663,7 @@ export type GetActivitiesByTargetsQueryVariables = Exact<{
}>; }>;
export type GetActivitiesByTargetsQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null }> }; export type GetActivitiesByTargetsQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, companyId?: string | null, personId?: string | null, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null, person?: { __typename?: 'Person', id: string, displayName: string, avatarUrl?: string | null } | null }> | null }> };
export type GetActivitiesQueryVariables = Exact<{ export type GetActivitiesQueryVariables = Exact<{
where: ActivityWhereInput; where: ActivityWhereInput;
@ -2710,14 +2671,14 @@ export type GetActivitiesQueryVariables = Exact<{
}>; }>;
export type GetActivitiesQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null }> }; export type GetActivitiesQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, companyId?: string | null, personId?: string | null, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null, person?: { __typename?: 'Person', id: string, displayName: string, avatarUrl?: string | null } | null }> | null }> };
export type GetActivityQueryVariables = Exact<{ export type GetActivityQueryVariables = Exact<{
activityId: Scalars['String']; activityId: Scalars['String'];
}>; }>;
export type GetActivityQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, body?: string | null, title?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null }> }; export type GetActivityQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, companyId?: string | null, personId?: string | null, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null, person?: { __typename?: 'Person', id: string, displayName: string, avatarUrl?: string | null } | null }> | null }> };
export type AddActivityTargetsOnActivityMutationVariables = Exact<{ export type AddActivityTargetsOnActivityMutationVariables = Exact<{
activityId: Scalars['String']; activityId: Scalars['String'];
@ -2725,7 +2686,7 @@ export type AddActivityTargetsOnActivityMutationVariables = Exact<{
}>; }>;
export type AddActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null } }; export type AddActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, companyId?: string | null, personId?: string | null }> | null } };
export type RemoveActivityTargetsOnActivityMutationVariables = Exact<{ export type RemoveActivityTargetsOnActivityMutationVariables = Exact<{
activityId: Scalars['String']; activityId: Scalars['String'];
@ -2733,7 +2694,7 @@ export type RemoveActivityTargetsOnActivityMutationVariables = Exact<{
}>; }>;
export type RemoveActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null } }; export type RemoveActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, companyId?: string | null, personId?: string | null }> | null } };
export type DeleteActivityMutationVariables = Exact<{ export type DeleteActivityMutationVariables = Exact<{
activityId: Scalars['String']; activityId: Scalars['String'];
@ -3223,6 +3184,58 @@ export type DeleteCurrentWorkspaceMutationVariables = Exact<{ [key: string]: nev
export type DeleteCurrentWorkspaceMutation = { __typename?: 'Mutation', deleteCurrentWorkspace: { __typename?: 'Workspace', id: string } }; export type DeleteCurrentWorkspaceMutation = { __typename?: 'Mutation', deleteCurrentWorkspace: { __typename?: 'Workspace', id: string } };
export const ActivityQueryFragmentFragmentDoc = gql`
fragment ActivityQueryFragment on Activity {
id
createdAt
title
body
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
body
createdAt
updatedAt
author {
id
displayName
firstName
lastName
avatarUrl
}
}
activityTargets {
id
companyId
personId
company {
id
name
domainName
}
person {
id
displayName
avatarUrl
}
}
}
`;
export const ActivityUpdatePartsFragmentDoc = gql` export const ActivityUpdatePartsFragmentDoc = gql`
fragment ActivityUpdateParts on Activity { fragment ActivityUpdateParts on Activity {
id id
@ -3319,8 +3332,6 @@ export const CreateActivityDocument = gql`
createdAt createdAt
updatedAt updatedAt
activityId activityId
commentableType
commentableId
companyId companyId
personId personId
} }
@ -3366,51 +3377,12 @@ export const GetActivitiesByTargetsDocument = gql`
query GetActivitiesByTargets($activityTargetIds: [String!]!, $orderBy: [ActivityOrderByWithRelationInput!]) { query GetActivitiesByTargets($activityTargetIds: [String!]!, $orderBy: [ActivityOrderByWithRelationInput!]) {
findManyActivities( findManyActivities(
orderBy: $orderBy orderBy: $orderBy
where: {activityTargets: {some: {commentableId: {in: $activityTargetIds}}}} where: {activityTargets: {some: {OR: [{personId: {in: $activityTargetIds}}, {companyId: {in: $activityTargetIds}}]}}}
) { ) {
id ...ActivityQueryFragment
createdAt
title
body
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
body
createdAt
updatedAt
author {
id
displayName
firstName
lastName
avatarUrl
}
}
activityTargets {
id
commentableType
commentableId
companyId
personId
}
} }
} }
`; ${ActivityQueryFragmentFragmentDoc}`;
/** /**
* __useGetActivitiesByTargetsQuery__ * __useGetActivitiesByTargetsQuery__
@ -3443,39 +3415,10 @@ export type GetActivitiesByTargetsQueryResult = Apollo.QueryResult<GetActivities
export const GetActivitiesDocument = gql` export const GetActivitiesDocument = gql`
query GetActivities($where: ActivityWhereInput!, $orderBy: [ActivityOrderByWithRelationInput!]) { query GetActivities($where: ActivityWhereInput!, $orderBy: [ActivityOrderByWithRelationInput!]) {
findManyActivities(orderBy: $orderBy, where: $where) { findManyActivities(orderBy: $orderBy, where: $where) {
id ...ActivityQueryFragment
createdAt
title
body
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
}
activityTargets {
id
commentableType
commentableId
companyId
personId
}
} }
} }
`; ${ActivityQueryFragmentFragmentDoc}`;
/** /**
* __useGetActivitiesQuery__ * __useGetActivitiesQuery__
@ -3508,49 +3451,10 @@ export type GetActivitiesQueryResult = Apollo.QueryResult<GetActivitiesQuery, Ge
export const GetActivityDocument = gql` export const GetActivityDocument = gql`
query GetActivity($activityId: String!) { query GetActivity($activityId: String!) {
findManyActivities(where: {id: {equals: $activityId}}) { findManyActivities(where: {id: {equals: $activityId}}) {
id ...ActivityQueryFragment
createdAt
body
title
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
body
createdAt
updatedAt
author {
id
displayName
firstName
lastName
avatarUrl
}
}
activityTargets {
id
commentableType
commentableId
companyId
personId
}
} }
} }
`; ${ActivityQueryFragmentFragmentDoc}`;
/** /**
* __useGetActivityQuery__ * __useGetActivityQuery__
@ -3592,8 +3496,6 @@ export const AddActivityTargetsOnActivityDocument = gql`
id id
createdAt createdAt
updatedAt updatedAt
commentableType
commentableId
companyId companyId
personId personId
} }
@ -3640,8 +3542,6 @@ export const RemoveActivityTargetsOnActivityDocument = gql`
id id
createdAt createdAt
updatedAt updatedAt
commentableType
commentableId
companyId companyId
personId personId
} }

View File

@ -72,9 +72,7 @@ type OwnProps = {
'id' | 'firstName' | 'lastName' | 'displayName' 'id' | 'firstName' | 'lastName' | 'displayName'
> | null; > | null;
} & { } & {
activityTargets?: Array< activityTargets?: Array<Pick<ActivityTarget, 'id'>> | null;
Pick<ActivityTarget, 'id' | 'commentableId' | 'commentableType'>
> | null;
}; };
showComment?: boolean; showComment?: boolean;
autoFillTitle?: boolean; autoFillTitle?: boolean;

View File

@ -1,251 +0,0 @@
import { useCallback, useMemo, useState } from 'react';
import styled from '@emotion/styled';
import {
autoUpdate,
flip,
offset,
size,
useFloating,
} from '@floating-ui/react';
import { CompanyChip } from '@/companies/components/CompanyChip';
import { useFilteredSearchCompanyQuery } from '@/companies/queries';
import { PersonChip } from '@/people/components/PersonChip';
import { useFilteredSearchPeopleQuery } from '@/people/queries';
import { MultipleEntitySelect } from '@/ui/input/relation-picker/components/MultipleEntitySelect';
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
import { Activity, ActivityTarget, CommentableType } from '~/generated/graphql';
import { assertNotNull } from '~/utils/assert';
import { useHandleCheckableActivityTargetChange } from '../hooks/useHandleCheckableActivityTargetChange';
import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '../utils/flatMapAndSortEntityForSelectArrayByName';
type OwnProps = {
activity?: Pick<Activity, 'id'> & {
activityTargets: Array<
Pick<
ActivityTarget,
'id' | 'commentableId' | 'commentableType' | 'companyId' | 'personId'
>
>;
};
};
const StyledContainer = styled.div`
align-items: flex-start;
display: flex;
flex-direction: row;
gap: ${({ theme }) => theme.spacing(2)};
justify-content: flex-start;
width: 100%;
`;
const StyledRelationContainer = styled.div`
--horizontal-padding: ${({ theme }) => theme.spacing(1)};
--vertical-padding: ${({ theme }) => theme.spacing(1.5)};
border: 1px solid transparent;
cursor: pointer;
display: flex;
flex-wrap: wrap;
gap: ${({ theme }) => theme.spacing(2)};
&:hover {
background-color: ${({ theme }) => theme.background.secondary};
border: 1px solid ${({ theme }) => theme.border.color.light};
}
min-height: calc(32px - 2 * var(--vertical-padding));
overflow: hidden;
padding: var(--vertical-padding) var(--horizontal-padding);
width: calc(100% - 2 * var(--horizontal-padding));
`;
const StyledMenuWrapper = styled.div`
z-index: ${({ theme }) => theme.lastLayerZIndex};
`;
export function ActivityRelationPicker({ activity }: OwnProps) {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const [searchFilter, setSearchFilter] = useState('');
const [selectedEntityIds, setSelectedEntityIds] = useState<
Record<string, boolean>
>({});
const {
setHotkeyScopeAndMemorizePreviousScope,
goBackToPreviousHotkeyScope,
} = usePreviousHotkeyScope();
const initialPeopleIds = useMemo(
() =>
activity?.activityTargets
?.filter((relation) => relation.commentableType === 'Person')
.map((relation) => relation.personId || relation.commentableId)
.filter(assertNotNull) ?? [],
[activity?.activityTargets],
);
const initialCompanyIds = useMemo(
() =>
activity?.activityTargets
?.filter((relation) => relation.commentableType === 'Company')
.map((relation) => relation.companyId || relation.commentableId)
.filter(assertNotNull) ?? [],
[activity?.activityTargets],
);
const initialSelectedEntityIds = useMemo(
() =>
[...initialPeopleIds, ...initialCompanyIds].reduce<
Record<string, boolean>
>((result, entityId) => ({ ...result, [entityId]: true }), {}),
[initialPeopleIds, initialCompanyIds],
);
const personsForMultiSelect = useFilteredSearchPeopleQuery({
searchFilter,
selectedIds: initialPeopleIds,
});
const companiesForMultiSelect = useFilteredSearchCompanyQuery({
searchFilter,
selectedIds: initialCompanyIds,
});
const selectedEntities = flatMapAndSortEntityForSelectArrayOfArrayByName([
personsForMultiSelect.selectedEntities,
companiesForMultiSelect.selectedEntities,
]);
const filteredSelectedEntities =
flatMapAndSortEntityForSelectArrayOfArrayByName([
personsForMultiSelect.filteredSelectedEntities,
companiesForMultiSelect.filteredSelectedEntities,
]);
const entitiesToSelect = flatMapAndSortEntityForSelectArrayOfArrayByName([
personsForMultiSelect.entitiesToSelect,
companiesForMultiSelect.entitiesToSelect,
]);
const handleCheckItemsChange = useHandleCheckableActivityTargetChange({
activity,
});
const exitEditMode = useCallback(() => {
goBackToPreviousHotkeyScope();
setIsMenuOpen(false);
setSearchFilter('');
if (Object.values(selectedEntityIds).some((value) => !!value)) {
handleCheckItemsChange(selectedEntityIds, entitiesToSelect);
}
}, [
entitiesToSelect,
selectedEntityIds,
goBackToPreviousHotkeyScope,
handleCheckItemsChange,
]);
const handleRelationContainerClick = useCallback(() => {
if (isMenuOpen) {
exitEditMode();
} else {
setIsMenuOpen(true);
setSelectedEntityIds(initialSelectedEntityIds);
setHotkeyScopeAndMemorizePreviousScope(
RelationPickerHotkeyScope.RelationPicker,
);
}
}, [
initialSelectedEntityIds,
exitEditMode,
isMenuOpen,
setHotkeyScopeAndMemorizePreviousScope,
]);
useScopedHotkeys(
['esc', 'enter'],
() => {
exitEditMode();
},
RelationPickerHotkeyScope.RelationPicker,
[exitEditMode],
);
const { refs, floatingStyles } = useFloating({
strategy: 'absolute',
middleware: [
offset(({ rects }) => {
return -rects.reference.height;
}),
flip(),
size(),
],
whileElementsMounted: autoUpdate,
open: isMenuOpen,
placement: 'bottom-start',
});
useListenClickOutside({
refs: [refs.floating, refs.domReference],
callback: () => {
exitEditMode();
},
});
return (
<StyledContainer>
<StyledRelationContainer
ref={refs.setReference}
onClick={handleRelationContainerClick}
>
{selectedEntities?.map((entity) =>
entity.entityType === CommentableType.Company ? (
<CompanyChip
key={entity.id}
id={entity.id}
name={entity.name}
pictureUrl={entity.avatarUrl}
/>
) : (
<PersonChip
key={entity.id}
name={entity.name}
id={entity.id}
pictureUrl={entity.avatarUrl ?? ''}
/>
),
)}
</StyledRelationContainer>
{isMenuOpen && (
<RecoilScope>
<StyledMenuWrapper ref={refs.setFloating} style={floatingStyles}>
<MultipleEntitySelect
entities={{
entitiesToSelect,
filteredSelectedEntities,
selectedEntities,
loading: false, // TODO implement skeleton loading
}}
onChange={setSelectedEntityIds}
onSearchFilterChange={setSearchFilter}
searchFilter={searchFilter}
value={selectedEntityIds}
/>
</StyledMenuWrapper>
</RecoilScope>
)}
</StyledContainer>
);
}

View File

@ -2,7 +2,7 @@ import styled from '@emotion/styled';
import { CompanyChip } from '@/companies/components/CompanyChip'; import { CompanyChip } from '@/companies/components/CompanyChip';
import { PersonChip } from '@/people/components/PersonChip'; import { PersonChip } from '@/people/components/PersonChip';
import { GetCompaniesQuery, GetPeopleQuery } from '~/generated/graphql'; import { ActivityTarget, Company, Person } from '~/generated/graphql';
import { getLogoUrlFromDomainName } from '~/utils'; import { getLogoUrlFromDomainName } from '~/utils';
const StyledContainer = styled.div` const StyledContainer = styled.div`
@ -12,32 +12,44 @@ const StyledContainer = styled.div`
`; `;
export function ActivityTargetChips({ export function ActivityTargetChips({
targetCompanies, targets,
targetPeople,
}: { }: {
targetCompanies?: GetCompaniesQuery; targets?: Array<
targetPeople?: GetPeopleQuery; Pick<ActivityTarget, 'id'> & {
person?: Pick<Person, 'id' | 'displayName' | 'avatarUrl'> | null;
company?: Pick<Company, 'id' | 'domainName' | 'name'> | null;
}
> | null;
}) { }) {
if (!targets) {
return null;
}
return ( return (
<StyledContainer> <StyledContainer>
{targetCompanies?.companies && {targets.map(({ company, person }) => {
targetCompanies.companies.map((company) => ( if (company) {
<CompanyChip return (
key={company.id} <CompanyChip
id={company.id} key={company.id}
name={company.name} id={company.id}
pictureUrl={getLogoUrlFromDomainName(company.domainName)} name={company.name}
/> pictureUrl={getLogoUrlFromDomainName(company.domainName)}
))} />
{targetPeople?.people && );
targetPeople.people.map((person) => ( }
<PersonChip if (person) {
key={person.id} return (
id={person.id} <PersonChip
name={person.displayName} key={person.id}
pictureUrl={person.avatarUrl ?? ''} id={person.id}
/> name={person.displayName}
))} pictureUrl={person.avatarUrl ?? undefined}
/>
);
}
return <></>;
})}
</StyledContainer> </StyledContainer>
); );
} }

View File

@ -9,7 +9,6 @@ import {
CheckboxShape, CheckboxShape,
} from '@/ui/input/checkbox/components/Checkbox'; } from '@/ui/input/checkbox/components/Checkbox';
import { OverflowingTextWithTooltip } from '@/ui/tooltip/OverflowingTextWithTooltip'; import { OverflowingTextWithTooltip } from '@/ui/tooltip/OverflowingTextWithTooltip';
import { useGetCompaniesQuery, useGetPeopleQuery } from '~/generated/graphql';
import { beautifyExactDate } from '~/utils/date-utils'; import { beautifyExactDate } from '~/utils/date-utils';
import { useCompleteTask } from '../hooks/useCompleteTask'; import { useCompleteTask } from '../hooks/useCompleteTask';
@ -62,37 +61,7 @@ const StyledFieldsContainer = styled.div`
export function TaskRow({ task }: { task: TaskForList }) { export function TaskRow({ task }: { task: TaskForList }) {
const theme = useTheme(); const theme = useTheme();
const openActivityRightDrawer = useOpenActivityRightDrawer(); const openActivityRightDrawer = useOpenActivityRightDrawer();
const { data: targetPeople } = useGetPeopleQuery({
variables: {
where: {
id: {
in: task?.activityTargets
? task?.activityTargets
.filter((target) => target.commentableType === 'Person')
.map(
(target) => (target.personId || target.commentableId) ?? '',
)
: [],
},
},
},
});
const { data: targetCompanies } = useGetCompaniesQuery({
variables: {
where: {
id: {
in: task?.activityTargets
? task?.activityTargets
.filter((target) => target.commentableType === 'Company')
.map(
(target) => (target.companyId || target.commentableId) ?? '',
)
: [],
},
},
},
});
const body = JSON.parse(task.body ?? '{}')[0]?.content[0]?.text; const body = JSON.parse(task.body ?? '{}')[0]?.content[0]?.text;
const { completeTask } = useCompleteTask(task); const { completeTask } = useCompleteTask(task);
@ -123,10 +92,7 @@ export function TaskRow({ task }: { task: TaskForList }) {
)} )}
</StyledTaskBody> </StyledTaskBody>
<StyledFieldsContainer> <StyledFieldsContainer>
<ActivityTargetChips <ActivityTargetChips targets={task.activityTargets} />
targetCompanies={targetCompanies}
targetPeople={targetPeople}
/>
<StyledDueDate> <StyledDueDate>
<IconCalendar size={theme.icon.size.md} /> <IconCalendar size={theme.icon.size.md} />
{task.dueAt && beautifyExactDate(task.dueAt)} {task.dueAt && beautifyExactDate(task.dueAt)}

View File

@ -1,37 +0,0 @@
import { MemoryRouter } from 'react-router-dom';
import styled from '@emotion/styled';
import type { Meta, StoryObj } from '@storybook/react';
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
import { graphqlMocks } from '~/testing/graphqlMocks';
import { mockedActivities } from '~/testing/mock-data/activities';
import { ActivityRelationPicker } from '../ActivityRelationPicker';
const StyledContainer = styled.div`
width: 400px;
`;
const meta: Meta<typeof ActivityRelationPicker> = {
title: 'Modules/Comments/ActivityRelationPicker',
component: ActivityRelationPicker,
decorators: [
(Story) => (
<MemoryRouter>
<StyledContainer>
<Story />
</StyledContainer>
</MemoryRouter>
),
ComponentDecorator,
],
args: { activity: mockedActivities[0] },
parameters: {
msw: graphqlMocks,
},
};
export default meta;
type Story = StoryObj<typeof ActivityRelationPicker>;
export const Default: Story = {};

View File

@ -4,59 +4,22 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { IconArrowUpRight } from '@/ui/icon'; import { IconArrowUpRight } from '@/ui/icon';
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope'; import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
import { import { Activity, ActivityTarget, Company, Person } from '~/generated/graphql';
Activity,
ActivityTarget,
useGetCompaniesQuery,
useGetPeopleQuery,
} from '~/generated/graphql';
import { ActivityRelationEditableFieldEditMode } from './ActivityRelationEditableFieldEditMode'; import { ActivityRelationEditableFieldEditMode } from './ActivityRelationEditableFieldEditMode';
type OwnProps = { type OwnProps = {
activity?: Pick<Activity, 'id'> & { activity?: Pick<Activity, 'id'> & {
activityTargets?: Array< activityTargets?: Array<
Pick< Pick<ActivityTarget, 'id' | 'personId' | 'companyId'> & {
ActivityTarget, person?: Pick<Person, 'id' | 'displayName'>;
'id' | 'commentableId' | 'commentableType' | 'personId' | 'companyId' company?: Pick<Company, 'id' | 'domainName' | 'name'>;
> }
> | null; > | null;
}; };
}; };
export function ActivityRelationEditableField({ activity }: OwnProps) { export function ActivityRelationEditableField({ activity }: OwnProps) {
const { data: targetPeople } = useGetPeopleQuery({
variables: {
where: {
id: {
in: activity?.activityTargets
? activity?.activityTargets
.filter((target) => target.commentableType === 'Person')
.map(
(target) => (target.personId || target.commentableId) ?? '',
)
: [],
},
},
},
});
const { data: targetCompanies } = useGetCompaniesQuery({
variables: {
where: {
id: {
in: activity?.activityTargets
? activity?.activityTargets
.filter((target) => target.commentableType === 'Company')
.map(
(target) => (target.companyId || target.commentableId) ?? '',
)
: [],
},
},
},
});
return ( return (
<RecoilScope SpecificContext={FieldContext}> <RecoilScope SpecificContext={FieldContext}>
<RecoilScope> <RecoilScope>
@ -71,10 +34,7 @@ export function ActivityRelationEditableField({ activity }: OwnProps) {
} }
label="Relations" label="Relations"
displayModeContent={ displayModeContent={
<ActivityTargetChips <ActivityTargetChips targets={activity?.activityTargets} />
targetCompanies={targetCompanies}
targetPeople={targetPeople}
/>
} }
/> />
</RecoilScope> </RecoilScope>

View File

@ -13,10 +13,7 @@ import { assertNotNull } from '~/utils/assert';
type OwnProps = { type OwnProps = {
activity?: Pick<Activity, 'id'> & { activity?: Pick<Activity, 'id'> & {
activityTargets?: Array< activityTargets?: Array<
Pick< Pick<ActivityTarget, 'id' | 'personId' | 'companyId'>
ActivityTarget,
'id' | 'commentableId' | 'commentableType' | 'personId' | 'companyId'
>
> | null; > | null;
}; };
}; };
@ -33,8 +30,8 @@ export function ActivityRelationEditableFieldEditMode({ activity }: OwnProps) {
const initialPeopleIds = useMemo( const initialPeopleIds = useMemo(
() => () =>
activity?.activityTargets activity?.activityTargets
?.filter((relation) => relation.commentableType === 'Person') ?.filter((relation) => relation.personId !== null)
.map((relation) => relation.personId || relation.commentableId) .map((relation) => relation.personId)
.filter(assertNotNull) ?? [], .filter(assertNotNull) ?? [],
[activity?.activityTargets], [activity?.activityTargets],
); );
@ -42,8 +39,8 @@ export function ActivityRelationEditableFieldEditMode({ activity }: OwnProps) {
const initialCompanyIds = useMemo( const initialCompanyIds = useMemo(
() => () =>
activity?.activityTargets activity?.activityTargets
?.filter((relation) => relation.commentableType === 'Company') ?.filter((relation) => relation.companyId !== null)
.map((relation) => relation.companyId || relation.commentableId) .map((relation) => relation.companyId)
.filter(assertNotNull) ?? [], .filter(assertNotNull) ?? [],
[activity?.activityTargets], [activity?.activityTargets],
); );

View File

@ -6,20 +6,20 @@ import { GET_PEOPLE } from '@/people/queries';
import { import {
Activity, Activity,
ActivityTarget, ActivityTarget,
CommentableType,
useAddActivityTargetsOnActivityMutation, useAddActivityTargetsOnActivityMutation,
useRemoveActivityTargetsOnActivityMutation, useRemoveActivityTargetsOnActivityMutation,
} from '~/generated/graphql'; } from '~/generated/graphql';
import { GET_ACTIVITY } from '../queries'; import { GET_ACTIVITY } from '../queries';
import { CommentableEntityForSelect } from '../types/CommentableEntityForSelect'; import { ActivityTargetableEntityType } from '../types/ActivityTargetableEntity';
import { ActivityTargetableEntityForSelect } from '../types/ActivityTargetableEntityForSelect';
export function useHandleCheckableActivityTargetChange({ export function useHandleCheckableActivityTargetChange({
activity, activity,
}: { }: {
activity?: Pick<Activity, 'id'> & { activity?: Pick<Activity, 'id'> & {
activityTargets?: Array< activityTargets?: Array<
Pick<ActivityTarget, 'id' | 'commentableId' | 'commentableType'> Pick<ActivityTarget, 'id' | 'personId' | 'companyId'>
> | null; > | null;
}; };
}) { }) {
@ -43,14 +43,16 @@ export function useHandleCheckableActivityTargetChange({
return async function handleCheckItemsChange( return async function handleCheckItemsChange(
entityValues: Record<string, boolean>, entityValues: Record<string, boolean>,
entities: CommentableEntityForSelect[], entities: ActivityTargetableEntityForSelect[],
) { ) {
if (!activity) { if (!activity) {
return; return;
} }
const currentEntityIds = activity.activityTargets const currentEntityIds = activity.activityTargets
? activity.activityTargets.map(({ commentableId }) => commentableId) ? activity.activityTargets.map(
({ personId, companyId }) => personId ?? companyId,
)
: []; : [];
const entitiesToAdd = entities.filter( const entitiesToAdd = entities.filter(
@ -64,12 +66,14 @@ export function useHandleCheckableActivityTargetChange({
activityTargetInputs: entitiesToAdd.map((entity) => ({ activityTargetInputs: entitiesToAdd.map((entity) => ({
id: v4(), id: v4(),
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
commentableType: entity.entityType,
commentableId: entity.id,
companyId: companyId:
entity.entityType === CommentableType.Company ? entity.id : null, entity.entityType === ActivityTargetableEntityType.Company
? entity.id
: null,
personId: personId:
entity.entityType === CommentableType.Person ? entity.id : null, entity.entityType === ActivityTargetableEntityType.Person
? entity.id
: null,
})), })),
}, },
}); });
@ -77,8 +81,9 @@ export function useHandleCheckableActivityTargetChange({
const activityTargetIdsToDelete = activity.activityTargets const activityTargetIdsToDelete = activity.activityTargets
? activity.activityTargets ? activity.activityTargets
.filter( .filter(
({ commentableId }) => ({ personId, companyId }) =>
commentableId && !entityValues[commentableId], (personId ?? companyId) &&
!entityValues[personId ?? companyId ?? ''],
) )
.map(({ id }) => id) .map(({ id }) => id)
: []; : [];

View File

@ -9,20 +9,19 @@ import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope'; import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages'; import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope'; import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { import { ActivityType, useCreateActivityMutation } from '~/generated/graphql';
ActivityType,
CommentableType,
useCreateActivityMutation,
} from '~/generated/graphql';
import { import {
GET_ACTIVITIES, GET_ACTIVITIES,
GET_ACTIVITIES_BY_TARGETS, GET_ACTIVITIES_BY_TARGETS,
GET_ACTIVITY, GET_ACTIVITY,
} from '../queries'; } from '../queries';
import { commentableEntityArrayState } from '../states/commentableEntityArrayState'; import { activityTargetableEntityArrayState } from '../states/activityTargetableEntityArrayState';
import { viewableActivityIdState } from '../states/viewableActivityIdState'; import { viewableActivityIdState } from '../states/viewableActivityIdState';
import { CommentableEntity } from '../types/CommentableEntity'; import {
ActivityTargetableEntity,
ActivityTargetableEntityType,
} from '../types/ActivityTargetableEntity';
export function useOpenCreateActivityDrawer() { export function useOpenCreateActivityDrawer() {
const { openRightDrawer } = useRightDrawer(); const { openRightDrawer } = useRightDrawer();
@ -30,14 +29,14 @@ export function useOpenCreateActivityDrawer() {
const currentUser = useRecoilValue(currentUserState); const currentUser = useRecoilValue(currentUserState);
const setHotkeyScope = useSetHotkeyScope(); const setHotkeyScope = useSetHotkeyScope();
const [, setCommentableEntityArray] = useRecoilState( const [, setActivityTargetableEntityArray] = useRecoilState(
commentableEntityArrayState, activityTargetableEntityArrayState,
); );
const [, setViewableActivityId] = useRecoilState(viewableActivityIdState); const [, setViewableActivityId] = useRecoilState(viewableActivityIdState);
return function openCreateActivityDrawer( return function openCreateActivityDrawer(
type: ActivityType, type: ActivityType,
entities?: CommentableEntity[], entities?: ActivityTargetableEntity[],
) { ) {
const now = new Date().toISOString(); const now = new Date().toISOString();
@ -54,14 +53,14 @@ export function useOpenCreateActivityDrawer() {
createMany: { createMany: {
data: entities data: entities
? entities.map((entity) => ({ ? entities.map((entity) => ({
commentableId: entity.id,
commentableType: entity.type,
companyId: companyId:
entity.type === CommentableType.Company entity.type === ActivityTargetableEntityType.Company
? entity.id ? entity.id
: null, : null,
personId: personId:
entity.type === CommentableType.Person ? entity.id : null, entity.type === ActivityTargetableEntityType.Person
? entity.id
: null,
id: v4(), id: v4(),
createdAt: now, createdAt: now,
})) }))
@ -81,7 +80,7 @@ export function useOpenCreateActivityDrawer() {
onCompleted(data) { onCompleted(data) {
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false }); setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
setViewableActivityId(data.createOneActivity.id); setViewableActivityId(data.createOneActivity.id);
setCommentableEntityArray(entities ?? []); setActivityTargetableEntityArray(entities ?? []);
openRightDrawer(RightDrawerPages.CreateActivity); openRightDrawer(RightDrawerPages.CreateActivity);
}, },
}); });

View File

@ -1,9 +1,12 @@
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector'; import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
import { ActivityType, CommentableType } from '~/generated/graphql'; import { ActivityType } from '~/generated/graphql';
import { CommentableEntity } from '../types/CommentableEntity'; import {
ActivityTargetableEntity,
ActivityTargetableEntityType,
} from '../types/ActivityTargetableEntity';
import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer'; import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer';
@ -14,14 +17,13 @@ export function useOpenCreateActivityDrawerForSelectedRowIds() {
return function openCreateCommentDrawerForSelectedRowIds( return function openCreateCommentDrawerForSelectedRowIds(
type: ActivityType, type: ActivityType,
entityType: CommentableType, entityType: ActivityTargetableEntityType,
) { ) {
const commentableEntityArray: CommentableEntity[] = selectedEntityIds.map( const activityTargetableEntityArray: ActivityTargetableEntity[] =
(id) => ({ selectedEntityIds.map((id) => ({
type: entityType, type: entityType,
id, id,
}), }));
); openCreateActivityDrawer(type, activityTargetableEntityArray);
openCreateActivityDrawer(type, commentableEntityArray);
}; };
} }

View File

@ -5,22 +5,22 @@ import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotke
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages'; import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope'; import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { commentableEntityArrayState } from '../states/commentableEntityArrayState'; import { activityTargetableEntityArrayState } from '../states/activityTargetableEntityArrayState';
import { CommentableEntity } from '../types/CommentableEntity'; import { ActivityTargetableEntity } from '../types/ActivityTargetableEntity';
// TODO: refactor with recoil callback to avoid rerender // TODO: refactor with recoil callback to avoid rerender
export function useOpenTimelineRightDrawer() { export function useOpenTimelineRightDrawer() {
const { openRightDrawer } = useRightDrawer(); const { openRightDrawer } = useRightDrawer();
const [, setCommentableEntityArray] = useRecoilState( const [, setActivityTargetableEntityArray] = useRecoilState(
commentableEntityArrayState, activityTargetableEntityArrayState,
); );
const setHotkeyScope = useSetHotkeyScope(); const setHotkeyScope = useSetHotkeyScope();
return function openTimelineRightDrawer( return function openTimelineRightDrawer(
commentableEntityArray: CommentableEntity[], activityTargetableEntityArray: ActivityTargetableEntity[],
) { ) {
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false }); setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
setCommentableEntityArray(commentableEntityArray); setActivityTargetableEntityArray(activityTargetableEntityArray);
openRightDrawer(RightDrawerPages.Timeline); openRightDrawer(RightDrawerPages.Timeline);
}; };
} }

View File

@ -45,8 +45,6 @@ export const CREATE_ACTIVITY_WITH_COMMENT = gql`
createdAt createdAt
updatedAt updatedAt
activityId activityId
commentableType
commentableId
companyId companyId
personId personId
} }

View File

@ -1,5 +1,58 @@
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
export const ACTIVITY_QUERY_FRAGMENT = gql`
fragment ActivityQueryFragment on Activity {
id
createdAt
title
body
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
body
createdAt
updatedAt
author {
id
displayName
firstName
lastName
avatarUrl
}
}
activityTargets {
id
companyId
personId
company {
id
name
domainName
}
person {
id
displayName
avatarUrl
}
}
}
`;
export const GET_ACTIVITIES_BY_TARGETS = gql` export const GET_ACTIVITIES_BY_TARGETS = gql`
query GetActivitiesByTargets( query GetActivitiesByTargets(
$activityTargetIds: [String!]! $activityTargetIds: [String!]!
@ -8,49 +61,17 @@ export const GET_ACTIVITIES_BY_TARGETS = gql`
findManyActivities( findManyActivities(
orderBy: $orderBy orderBy: $orderBy
where: { where: {
activityTargets: { some: { commentableId: { in: $activityTargetIds } } } activityTargets: {
} some: {
) { OR: [
id { personId: { in: $activityTargetIds } }
createdAt { companyId: { in: $activityTargetIds } }
title ]
body }
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
body
createdAt
updatedAt
author {
id
displayName
firstName
lastName
avatarUrl
} }
} }
activityTargets { ) {
id ...ActivityQueryFragment
commentableType
commentableId
companyId
personId
}
} }
} }
`; `;
@ -61,36 +82,7 @@ export const GET_ACTIVITIES = gql`
$orderBy: [ActivityOrderByWithRelationInput!] $orderBy: [ActivityOrderByWithRelationInput!]
) { ) {
findManyActivities(orderBy: $orderBy, where: $where) { findManyActivities(orderBy: $orderBy, where: $where) {
id ...ActivityQueryFragment
createdAt
title
body
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
}
activityTargets {
id
commentableType
commentableId
companyId
personId
}
} }
} }
`; `;
@ -98,46 +90,7 @@ export const GET_ACTIVITIES = gql`
export const GET_ACTIVITY = gql` export const GET_ACTIVITY = gql`
query GetActivity($activityId: String!) { query GetActivity($activityId: String!) {
findManyActivities(where: { id: { equals: $activityId } }) { findManyActivities(where: { id: { equals: $activityId } }) {
id ...ActivityQueryFragment
createdAt
body
title
type
completedAt
dueAt
assignee {
id
firstName
lastName
displayName
avatarUrl
}
author {
id
firstName
lastName
displayName
}
comments {
id
body
createdAt
updatedAt
author {
id
displayName
firstName
lastName
avatarUrl
}
}
activityTargets {
id
commentableType
commentableId
companyId
personId
}
} }
} }
`; `;

View File

@ -16,8 +16,6 @@ export const ADD_ACTIVITY_TARGETS = gql`
id id
createdAt createdAt
updatedAt updatedAt
commentableType
commentableId
companyId companyId
personId personId
} }
@ -43,8 +41,6 @@ export const REMOVE_ACTIVITY_TARGETS = gql`
id id
createdAt createdAt
updatedAt updatedAt
commentableType
commentableId
companyId companyId
personId personId
} }

View File

@ -1,19 +1,21 @@
import { useRecoilState } from 'recoil'; import { useRecoilValue } from 'recoil';
import { commentableEntityArrayState } from '@/activities/states/commentableEntityArrayState'; import { activityTargetableEntityArrayState } from '@/activities/states/activityTargetableEntityArrayState';
import { Timeline } from '@/activities/timeline/components/Timeline'; import { Timeline } from '@/activities/timeline/components/Timeline';
export function RightDrawerTimeline() { export function RightDrawerTimeline() {
const [commentableEntityArray] = useRecoilState(commentableEntityArrayState); const activityTargetableEntityArray = useRecoilValue(
activityTargetableEntityArrayState,
);
return ( return (
<> <>
{commentableEntityArray.map((commentableEntity) => ( {activityTargetableEntityArray.map((targetableEntity) => (
<Timeline <Timeline
key={commentableEntity.id} key={targetableEntity.id}
entity={{ entity={{
id: commentableEntity?.id ?? '', id: targetableEntity?.id ?? '',
type: commentableEntity.type, type: targetableEntity.type,
}} }}
/> />
))} ))}

View File

@ -0,0 +1,10 @@
import { atom } from 'recoil';
import { ActivityTargetableEntity } from '../types/ActivityTargetableEntity';
export const activityTargetableEntityArrayState = atom<
ActivityTargetableEntity[]
>({
key: 'activities/targetable-entity-array',
default: [],
});

View File

@ -1,8 +0,0 @@
import { atom } from 'recoil';
import { CommentableEntity } from '../types/CommentableEntity';
export const commentableEntityArrayState = atom<CommentableEntity[]>({
key: 'activities/commentable-entity-array',
default: [],
});

View File

@ -5,7 +5,7 @@ import styled from '@emotion/styled';
import { ActivityCreateButton } from '@/activities/components/ActivityCreateButton'; import { ActivityCreateButton } from '@/activities/components/ActivityCreateButton';
import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateActivityDrawer'; import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateActivityDrawer';
import { ActivityForDrawer } from '@/activities/types/ActivityForDrawer'; import { ActivityForDrawer } from '@/activities/types/ActivityForDrawer';
import { CommentableEntity } from '@/activities/types/CommentableEntity'; import { ActivityTargetableEntity } from '@/activities/types/ActivityTargetableEntity';
import { IconCircleDot } from '@/ui/icon'; import { IconCircleDot } from '@/ui/icon';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { import {
@ -93,7 +93,7 @@ const StyledStartIcon = styled.div`
width: 20px; width: 20px;
`; `;
export function Timeline({ entity }: { entity: CommentableEntity }) { export function Timeline({ entity }: { entity: ActivityTargetableEntity }) {
const theme = useTheme(); const theme = useTheme();
const { data: queryResult, loading } = useGetActivitiesByTargetsQuery({ const { data: queryResult, loading } = useGetActivitiesByTargetsQuery({

View File

@ -0,0 +1,9 @@
export enum ActivityTargetableEntityType {
Person = 'Person',
Company = 'Company',
}
export type ActivityTargetableEntity = {
id: string;
type: ActivityTargetableEntityType;
};

View File

@ -0,0 +1,7 @@
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
import { ActivityTargetableEntityType } from './ActivityTargetableEntity';
export type ActivityTargetableEntityForSelect = EntityForSelect & {
entityType: ActivityTargetableEntityType;
};

View File

@ -1,6 +0,0 @@
import { CommentableType } from '~/generated/graphql';
export type CommentableEntity = {
id: string;
type: CommentableType;
};

View File

@ -1,6 +0,0 @@
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
import { CommentableType } from '~/generated/graphql';
export type CommentableEntityForSelect = EntityForSelect & {
entityType: CommentableType;
};

View File

@ -1,10 +1,10 @@
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import { CommentableEntityForSelect } from '@/activities/types/CommentableEntityForSelect'; import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery'; import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
import { SelectedSortType } from '@/ui/filter-n-sort/types/interface'; import { SelectedSortType } from '@/ui/filter-n-sort/types/interface';
import { import {
CommentableType,
CompanyOrderByWithRelationInput as Companies_Order_By, CompanyOrderByWithRelationInput as Companies_Order_By,
CompanyWhereInput as Companies_Bool_Exp, CompanyWhereInput as Companies_Bool_Exp,
SortOrder as Order_By, SortOrder as Order_By,
@ -65,11 +65,11 @@ export function useFilteredSearchCompanyQuery({
mappingFunction: (company) => mappingFunction: (company) =>
({ ({
id: company.id, id: company.id,
entityType: CommentableType.Company, entityType: ActivityTargetableEntityType.Company,
name: company.name, name: company.name,
avatarUrl: getLogoUrlFromDomainName(company.domainName), avatarUrl: getLogoUrlFromDomainName(company.domainName),
avatarType: 'squared', avatarType: 'squared',
} as CommentableEntityForSelect), } as ActivityTargetableEntityForSelect),
searchFilter, searchFilter,
limit, limit,
}); });

View File

@ -1,14 +1,15 @@
import { useOpenCreateActivityDrawerForSelectedRowIds } from '@/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds'; import { useOpenCreateActivityDrawerForSelectedRowIds } from '@/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds';
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { TableActionBarButtonToggleComments } from '@/ui/table/action-bar/components/TableActionBarButtonOpenComments'; import { TableActionBarButtonToggleComments } from '@/ui/table/action-bar/components/TableActionBarButtonOpenComments';
import { TableActionBarButtonToggleTasks } from '@/ui/table/action-bar/components/TableActionBarButtonOpenTasks'; import { TableActionBarButtonToggleTasks } from '@/ui/table/action-bar/components/TableActionBarButtonOpenTasks';
import { ActivityType, CommentableType } from '~/generated/graphql'; import { ActivityType } from '~/generated/graphql';
export function TableActionBarButtonCreateActivityCompany() { export function TableActionBarButtonCreateActivityCompany() {
const openCreateActivityRightDrawer = const openCreateActivityRightDrawer =
useOpenCreateActivityDrawerForSelectedRowIds(); useOpenCreateActivityDrawerForSelectedRowIds();
async function handleButtonClick(type: ActivityType) { async function handleButtonClick(type: ActivityType) {
openCreateActivityRightDrawer(type, CommentableType.Company); openCreateActivityRightDrawer(type, ActivityTargetableEntityType.Company);
} }
return ( return (

View File

@ -1,10 +1,10 @@
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import { CommentableEntityForSelect } from '@/activities/types/CommentableEntityForSelect'; import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { ActivityTargetableEntityForSelect } from '@/activities/types/ActivityTargetableEntityForSelect';
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery'; import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
import { SelectedSortType } from '@/ui/filter-n-sort/types/interface'; import { SelectedSortType } from '@/ui/filter-n-sort/types/interface';
import { import {
CommentableType,
PersonOrderByWithRelationInput as People_Order_By, PersonOrderByWithRelationInput as People_Order_By,
PersonWhereInput as People_Bool_Exp, PersonWhereInput as People_Bool_Exp,
SortOrder, SortOrder,
@ -69,11 +69,11 @@ export function useFilteredSearchPeopleQuery({
mappingFunction: (entity) => mappingFunction: (entity) =>
({ ({
id: entity.id, id: entity.id,
entityType: CommentableType.Person, entityType: ActivityTargetableEntityType.Person,
name: `${entity.firstName} ${entity.lastName}`, name: `${entity.firstName} ${entity.lastName}`,
avatarUrl: entity.avatarUrl, avatarUrl: entity.avatarUrl,
avatarType: 'rounded', avatarType: 'rounded',
} as CommentableEntityForSelect), } as ActivityTargetableEntityForSelect),
searchFilter, searchFilter,
limit, limit,
}); });

View File

@ -1,14 +1,15 @@
import { useOpenCreateActivityDrawerForSelectedRowIds } from '@/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds'; import { useOpenCreateActivityDrawerForSelectedRowIds } from '@/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds';
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { TableActionBarButtonToggleComments } from '@/ui/table/action-bar/components/TableActionBarButtonOpenComments'; import { TableActionBarButtonToggleComments } from '@/ui/table/action-bar/components/TableActionBarButtonOpenComments';
import { TableActionBarButtonToggleTasks } from '@/ui/table/action-bar/components/TableActionBarButtonOpenTasks'; import { TableActionBarButtonToggleTasks } from '@/ui/table/action-bar/components/TableActionBarButtonOpenTasks';
import { ActivityType, CommentableType } from '~/generated/graphql'; import { ActivityType } from '~/generated/graphql';
export function TableActionBarButtonCreateActivityPeople() { export function TableActionBarButtonCreateActivityPeople() {
const openCreateActivityRightDrawer = const openCreateActivityRightDrawer =
useOpenCreateActivityDrawerForSelectedRowIds(); useOpenCreateActivityDrawerForSelectedRowIds();
async function handleButtonClick(type: ActivityType) { async function handleButtonClick(type: ActivityType) {
openCreateActivityRightDrawer(type, CommentableType.Person); openCreateActivityRightDrawer(type, ActivityTargetableEntityType.Person);
} }
return ( return (

View File

@ -1,4 +1,5 @@
import { CommentableType, PipelineProgressableType } from '~/generated/graphql'; import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { PipelineProgressableType } from '~/generated/graphql';
export enum Entity { export enum Entity {
Company = 'Company', Company = 'Company',
@ -7,6 +8,6 @@ export enum Entity {
} }
export type EntityTypeForSelect = export type EntityTypeForSelect =
| CommentableType | ActivityTargetableEntityType
| PipelineProgressableType | PipelineProgressableType
| Entity; | Entity;

View File

@ -2,6 +2,7 @@ import { useParams } from 'react-router-dom';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import { Timeline } from '@/activities/timeline/components/Timeline'; import { Timeline } from '@/activities/timeline/components/Timeline';
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { CompanyTeam } from '@/companies/components/CompanyTeam'; import { CompanyTeam } from '@/companies/components/CompanyTeam';
import { useCompanyQuery } from '@/companies/queries'; import { useCompanyQuery } from '@/companies/queries';
import { useFavorites } from '@/favorites/hooks/useFavorites'; import { useFavorites } from '@/favorites/hooks/useFavorites';
@ -15,10 +16,7 @@ import { WithTopBarContainer } from '@/ui/layout/components/WithTopBarContainer'
import { ShowPageLeftContainer } from '@/ui/layout/show-page/components/ShowPageLeftContainer'; import { ShowPageLeftContainer } from '@/ui/layout/show-page/components/ShowPageLeftContainer';
import { ShowPageRightContainer } from '@/ui/layout/show-page/components/ShowPageRightContainer'; import { ShowPageRightContainer } from '@/ui/layout/show-page/components/ShowPageRightContainer';
import { ShowPageSummaryCard } from '@/ui/layout/show-page/components/ShowPageSummaryCard'; import { ShowPageSummaryCard } from '@/ui/layout/show-page/components/ShowPageSummaryCard';
import { import { useUpdateOneCompanyMutation } from '~/generated/graphql';
CommentableType,
useUpdateOneCompanyMutation,
} from '~/generated/graphql';
import { getLogoUrlFromDomainName } from '~/utils'; import { getLogoUrlFromDomainName } from '~/utils';
import { CompanyNameEditableField } from '../../modules/companies/editable-field/components/CompanyNameEditableField'; import { CompanyNameEditableField } from '../../modules/companies/editable-field/components/CompanyNameEditableField';
@ -85,7 +83,10 @@ export function CompanyShow() {
</ShowPageLeftContainer> </ShowPageLeftContainer>
<ShowPageRightContainer> <ShowPageRightContainer>
<Timeline <Timeline
entity={{ id: company.id ?? '', type: CommentableType.Company }} entity={{
id: company.id,
type: ActivityTargetableEntityType.Company,
}}
/> />
</ShowPageRightContainer> </ShowPageRightContainer>
</ShowPageContainer> </ShowPageContainer>

View File

@ -3,6 +3,7 @@ import { getOperationName } from '@apollo/client/utilities';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import { Timeline } from '@/activities/timeline/components/Timeline'; import { Timeline } from '@/activities/timeline/components/Timeline';
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { useFavorites } from '@/favorites/hooks/useFavorites'; import { useFavorites } from '@/favorites/hooks/useFavorites';
import { GET_PERSON, usePersonQuery } from '@/people/queries'; import { GET_PERSON, usePersonQuery } from '@/people/queries';
import { GenericEditableField } from '@/ui/editable-field/components/GenericEditableField'; import { GenericEditableField } from '@/ui/editable-field/components/GenericEditableField';
@ -16,7 +17,6 @@ import { ShowPageLeftContainer } from '@/ui/layout/show-page/components/ShowPage
import { ShowPageRightContainer } from '@/ui/layout/show-page/components/ShowPageRightContainer'; import { ShowPageRightContainer } from '@/ui/layout/show-page/components/ShowPageRightContainer';
import { ShowPageSummaryCard } from '@/ui/layout/show-page/components/ShowPageSummaryCard'; import { ShowPageSummaryCard } from '@/ui/layout/show-page/components/ShowPageSummaryCard';
import { import {
CommentableType,
useUpdateOnePersonMutation, useUpdateOnePersonMutation,
useUploadPersonPictureMutation, useUploadPersonPictureMutation,
} from '~/generated/graphql'; } from '~/generated/graphql';
@ -100,7 +100,10 @@ export function PersonShow() {
</ShowPageLeftContainer> </ShowPageLeftContainer>
<ShowPageRightContainer> <ShowPageRightContainer>
<Timeline <Timeline
entity={{ id: person.id ?? '', type: CommentableType.Person }} entity={{
id: person.id ?? '',
type: ActivityTargetableEntityType.Person,
}}
/> />
</ShowPageRightContainer> </ShowPageRightContainer>
</ShowPageContainer> </ShowPageContainer>

View File

@ -3,6 +3,7 @@ import { matchPath, useLocation, useNavigate } from 'react-router-dom';
import { IconCheckbox, IconNotes } from '@tabler/icons-react'; import { IconCheckbox, IconNotes } from '@tabler/icons-react';
import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateActivityDrawer'; import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateActivityDrawer';
import { ActivityTargetableEntityType } from '@/activities/types/ActivityTargetableEntity';
import { useEventTracker } from '@/analytics/hooks/useEventTracker'; import { useEventTracker } from '@/analytics/hooks/useEventTracker';
import { useOnboardingStatus } from '@/auth/hooks/useOnboardingStatus'; import { useOnboardingStatus } from '@/auth/hooks/useOnboardingStatus';
import { OnboardingStatus } from '@/auth/utils/getOnboardingStatus'; import { OnboardingStatus } from '@/auth/utils/getOnboardingStatus';
@ -16,7 +17,7 @@ import { useSnackBar } from '@/ui/snack-bar/hooks/useSnackBar';
import { TableHotkeyScope } from '@/ui/table/types/TableHotkeyScope'; import { TableHotkeyScope } from '@/ui/table/types/TableHotkeyScope';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope'; import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { useGetWorkspaceFromInviteHashLazyQuery } from '~/generated/graphql'; import { useGetWorkspaceFromInviteHashLazyQuery } from '~/generated/graphql';
import { ActivityType, CommentableType } from '~/generated/graphql'; import { ActivityType } from '~/generated/graphql';
import { useIsMatchingLocation } from '../hooks/useIsMatchingLocation'; import { useIsMatchingLocation } from '../hooks/useIsMatchingLocation';
@ -177,7 +178,7 @@ export function AuthAutoRouter() {
)?.params.id; )?.params.id;
const entity = !!companyId const entity = !!companyId
? { id: companyId, type: CommentableType.Company } ? { id: companyId, type: ActivityTargetableEntityType.Company }
: undefined; : undefined;
addToCommandMenu([ addToCommandMenu([
@ -211,7 +212,7 @@ export function AuthAutoRouter() {
?.params.id; ?.params.id;
const entity = !!personId const entity = !!personId
? { id: personId, type: CommentableType.Person } ? { id: personId, type: ActivityTargetableEntityType.Person }
: undefined; : undefined;
addToCommandMenu([ addToCommandMenu([

View File

@ -3,7 +3,9 @@ import {
ActivityTarget, ActivityTarget,
ActivityType, ActivityType,
Comment, Comment,
CommentableType, Company,
Person,
User,
} from '~/generated/graphql'; } from '~/generated/graphql';
type MockedActivity = Pick< type MockedActivity = Pick<
@ -33,7 +35,11 @@ type MockedActivity = Pick<
lastName: string; lastName: string;
displayName: string; displayName: string;
}; };
comments: Array<Pick<Comment, 'body' | 'id'>>; comments: Array<
Pick<Comment, 'body' | 'id' | 'createdAt' | 'updatedAt'> & {
author: Pick<User, 'id' | 'displayName' | 'avatarUrl'>;
}
>;
activityTargets: Array< activityTargets: Array<
Pick< Pick<
ActivityTarget, ActivityTarget,
@ -42,9 +48,13 @@ type MockedActivity = Pick<
| 'createdAt' | 'createdAt'
| 'updatedAt' | 'updatedAt'
| 'activityId' | 'activityId'
| 'commentableId' | 'personId'
| 'commentableType' | 'companyId'
> & { activity: Pick<Activity, 'id' | 'createdAt' | 'updatedAt'> } > & {
activity: Pick<Activity, 'id' | 'createdAt' | 'updatedAt'>;
person?: Pick<Person, 'id' | 'displayName'>;
company?: Pick<Company, 'id' | 'name' | 'domainName'>;
}
>; >;
}; };
@ -106,8 +116,13 @@ export const mockedActivities: Array<MockedActivity> = [
id: '89bb825c-171e-4bcc-9cf7-43448d6fb300', id: '89bb825c-171e-4bcc-9cf7-43448d6fb300',
createdAt: '2023-04-26T10:12:42.33625+00:00', createdAt: '2023-04-26T10:12:42.33625+00:00',
updatedAt: '2023-04-26T10:23:42.33625+00:00', updatedAt: '2023-04-26T10:23:42.33625+00:00',
commentableType: CommentableType.Company, personId: null,
commentableId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', // airbnb companyId: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
company: {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
name: 'Airbnb',
domainName: 'airbnb.com',
},
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb230', activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb230',
activity: { activity: {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb230', id: '89bb825c-171e-4bcc-9cf7-43448d6fb230',
@ -120,8 +135,13 @@ export const mockedActivities: Array<MockedActivity> = [
id: '89bb825c-171e-4bcc-9cf7-43448d6fb301', id: '89bb825c-171e-4bcc-9cf7-43448d6fb301',
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
commentableType: CommentableType.Company, personId: null,
commentableId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae', // aircall companyId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
company: {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
name: 'Aircall',
domainName: 'aircall.io',
},
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb231', activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb231',
activity: { activity: {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb231', id: '89bb825c-171e-4bcc-9cf7-43448d6fb231',
@ -161,8 +181,12 @@ export const mockedActivities: Array<MockedActivity> = [
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278', id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
createdAt: '2023-04-26T10:12:42.33625+00:00', createdAt: '2023-04-26T10:12:42.33625+00:00',
updatedAt: '2023-04-26T10:23:42.33625+00:00', updatedAt: '2023-04-26T10:23:42.33625+00:00',
commentableType: CommentableType.Person, personId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b', // Alexandre
commentableId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b', // Alexandre person: {
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
displayName: 'Alexandre Test',
},
companyId: null,
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
activity: { activity: {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278', id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
@ -175,8 +199,8 @@ export const mockedActivities: Array<MockedActivity> = [
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278', id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
commentableType: CommentableType.Person, personId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6d', // Jean d'Eau
commentableId: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6d', // Jean d'Eau companyId: null,
activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', activityId: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
activity: { activity: {
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278', id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',

View File

@ -29,8 +29,7 @@ export class CompanyRelationsResolver {
where: { where: {
activityTargets: { activityTargets: {
some: { some: {
commentableType: 'Company', companyId: company.id,
commentableId: company.id,
}, },
}, },
}, },
@ -51,8 +50,7 @@ export class CompanyRelationsResolver {
activity: { activity: {
activityTargets: { activityTargets: {
some: { some: {
commentableType: 'Company', companyId: company.id,
commentableId: company.id,
}, },
}, },
}, },
@ -69,8 +67,7 @@ export class CompanyRelationsResolver {
where: { where: {
activityTargets: { activityTargets: {
some: { some: {
commentableType: 'Company', companyId: company.id,
commentableId: company.id,
}, },
}, },
}, },

View File

@ -29,8 +29,7 @@ export class PersonRelationsResolver {
where: { where: {
activityTargets: { activityTargets: {
some: { some: {
commentableType: 'Person', personId: person.id,
commentableId: person.id,
}, },
}, },
}, },
@ -51,8 +50,7 @@ export class PersonRelationsResolver {
activity: { activity: {
activityTargets: { activityTargets: {
some: { some: {
commentableType: 'Person', personId: person.id,
commentableId: person.id,
}, },
}, },
}, },
@ -69,8 +67,7 @@ export class PersonRelationsResolver {
where: { where: {
activityTargets: { activityTargets: {
some: { some: {
commentableType: 'Person', personId: person.id,
commentableId: person.id,
}, },
}, },
}, },

View File

@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `commentableId` on the `activity_targets` table. All the data in the column will be lost.
- You are about to drop the column `commentableType` on the `activity_targets` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "activity_targets" DROP COLUMN "commentableId",
DROP COLUMN "commentableType";
-- DropEnum
DROP TYPE "CommentableType";

View File

@ -364,11 +364,6 @@ model Activity {
@@map("activities") @@map("activities")
} }
enum CommentableType {
Person
Company
}
model Comment { model Comment {
/// @Validator.IsString() /// @Validator.IsString()
/// @Validator.IsOptional() /// @Validator.IsOptional()
@ -400,14 +395,12 @@ model ActivityTarget {
/// @Validator.IsOptional() /// @Validator.IsOptional()
id String @id @default(uuid()) id String @id @default(uuid())
activity Activity @relation(fields: [activityId], references: [id], onDelete: Cascade) activity Activity @relation(fields: [activityId], references: [id], onDelete: Cascade)
activityId String activityId String
commentableType CommentableType?
commentableId String?
/// @TypeGraphQL.omit(input: true, output: true) /// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id]) workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true) /// @TypeGraphQL.omit(input: true, output: true)
workspaceId String workspaceId String
personId String? personId String?
person Person? @relation(fields: [personId], references: [id], onDelete: Cascade) person Person? @relation(fields: [personId], references: [id], onDelete: Cascade)

View File

@ -18,8 +18,8 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb600', id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb600',
commentableType: 'Company', personId: null,
commentableId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
@ -71,8 +71,8 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-a76aa0bfb600', id: 'twenty-fe256b39-3ec3-4fe3-8997-a76aa0bfb600',
commentableType: 'Person', personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
commentableId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1', companyId: null,
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
@ -108,8 +108,8 @@ export const seedComments = async (prisma: PrismaClient) => {
update: {}, update: {},
create: { create: {
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-a76aa0bfba00', id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-a76aa0bfba00',
commentableType: 'Company', personId: null,
commentableId: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e', companyId: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e',
activityId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408', activityId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420', workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
}, },