Skip to content

Commit 35c394e

Browse files
thaisguigonAdityaPimpalkar
authored andcommitted
eat: create ViewField model (twentyhq#961)
* feat: create ViewField model - Created ViewField prisma model - Added ViewField server resolvers for findMany/updateOne - Added getViewFields/updateViewField graphql queries Closes twentyhq#849 * chore: update node version in .nvmrc files
1 parent 17e991e commit 35c394e

File tree

17 files changed

+510
-2
lines changed

17 files changed

+510
-2
lines changed

front/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.6.0
1+
18.16.0

front/src/generated/graphql.tsx

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,17 @@ export enum FileFolder {
789789
WorkspaceLogo = 'WorkspaceLogo'
790790
}
791791

792+
export type IntFilter = {
793+
equals?: InputMaybe<Scalars['Int']>;
794+
gt?: InputMaybe<Scalars['Int']>;
795+
gte?: InputMaybe<Scalars['Int']>;
796+
in?: InputMaybe<Array<Scalars['Int']>>;
797+
lt?: InputMaybe<Scalars['Int']>;
798+
lte?: InputMaybe<Scalars['Int']>;
799+
not?: InputMaybe<NestedIntFilter>;
800+
notIn?: InputMaybe<Array<Scalars['Int']>>;
801+
};
802+
792803
export type IntNullableFilter = {
793804
equals?: InputMaybe<Scalars['Int']>;
794805
gt?: InputMaybe<Scalars['Int']>;
@@ -843,6 +854,7 @@ export type Mutation = {
843854
updateOnePerson?: Maybe<Person>;
844855
updateOnePipelineProgress?: Maybe<PipelineProgress>;
845856
updateOnePipelineStage?: Maybe<PipelineStage>;
857+
updateOneViewField: ViewField;
846858
updateUser: User;
847859
updateWorkspace: Workspace;
848860
uploadAttachment: Scalars['String'];
@@ -964,6 +976,12 @@ export type MutationUpdateOnePipelineStageArgs = {
964976
};
965977

966978

979+
export type MutationUpdateOneViewFieldArgs = {
980+
data: ViewFieldUpdateInput;
981+
where: ViewFieldWhereUniqueInput;
982+
};
983+
984+
967985
export type MutationUpdateUserArgs = {
968986
data: UserUpdateInput;
969987
where: UserWhereUniqueInput;
@@ -1069,6 +1087,17 @@ export type NestedEnumPipelineProgressableTypeFilter = {
10691087
notIn?: InputMaybe<Array<PipelineProgressableType>>;
10701088
};
10711089

1090+
export type NestedIntFilter = {
1091+
equals?: InputMaybe<Scalars['Int']>;
1092+
gt?: InputMaybe<Scalars['Int']>;
1093+
gte?: InputMaybe<Scalars['Int']>;
1094+
in?: InputMaybe<Array<Scalars['Int']>>;
1095+
lt?: InputMaybe<Scalars['Int']>;
1096+
lte?: InputMaybe<Scalars['Int']>;
1097+
not?: InputMaybe<NestedIntFilter>;
1098+
notIn?: InputMaybe<Array<Scalars['Int']>>;
1099+
};
1100+
10721101
export type NestedIntNullableFilter = {
10731102
equals?: InputMaybe<Scalars['Int']>;
10741103
gt?: InputMaybe<Scalars['Int']>;
@@ -1590,6 +1619,7 @@ export type Query = {
15901619
findManyPipelineProgress: Array<PipelineProgress>;
15911620
findManyPipelineStage: Array<PipelineStage>;
15921621
findManyUser: Array<User>;
1622+
findManyViewField: Array<ViewField>;
15931623
findManyWorkspaceMember: Array<WorkspaceMember>;
15941624
findUniqueCompany: Company;
15951625
findUniquePerson: Person;
@@ -1676,6 +1706,16 @@ export type QueryFindManyUserArgs = {
16761706
};
16771707

16781708

1709+
export type QueryFindManyViewFieldArgs = {
1710+
cursor?: InputMaybe<ViewFieldWhereUniqueInput>;
1711+
distinct?: InputMaybe<Array<ViewFieldScalarFieldEnum>>;
1712+
orderBy?: InputMaybe<Array<ViewFieldOrderByWithRelationInput>>;
1713+
skip?: InputMaybe<Scalars['Int']>;
1714+
take?: InputMaybe<Scalars['Int']>;
1715+
where?: InputMaybe<ViewFieldWhereInput>;
1716+
};
1717+
1718+
16791719
export type QueryFindManyWorkspaceMemberArgs = {
16801720
cursor?: InputMaybe<WorkspaceMemberWhereUniqueInput>;
16811721
distinct?: InputMaybe<Array<WorkspaceMemberScalarFieldEnum>>;
@@ -1961,6 +2001,66 @@ export type Verify = {
19612001
user: User;
19622002
};
19632003

2004+
export type ViewField = {
2005+
__typename?: 'ViewField';
2006+
fieldName: Scalars['String'];
2007+
id: Scalars['ID'];
2008+
index: Scalars['Int'];
2009+
isVisible: Scalars['Boolean'];
2010+
objectName: Scalars['String'];
2011+
sizeInPx: Scalars['Int'];
2012+
};
2013+
2014+
export type ViewFieldOrderByWithRelationInput = {
2015+
fieldName?: InputMaybe<SortOrder>;
2016+
id?: InputMaybe<SortOrder>;
2017+
index?: InputMaybe<SortOrder>;
2018+
isVisible?: InputMaybe<SortOrder>;
2019+
objectName?: InputMaybe<SortOrder>;
2020+
sizeInPx?: InputMaybe<SortOrder>;
2021+
};
2022+
2023+
export enum ViewFieldScalarFieldEnum {
2024+
FieldName = 'fieldName',
2025+
Id = 'id',
2026+
Index = 'index',
2027+
IsVisible = 'isVisible',
2028+
ObjectName = 'objectName',
2029+
SizeInPx = 'sizeInPx',
2030+
WorkspaceId = 'workspaceId'
2031+
}
2032+
2033+
export type ViewFieldUpdateInput = {
2034+
fieldName?: InputMaybe<Scalars['String']>;
2035+
id?: InputMaybe<Scalars['String']>;
2036+
index?: InputMaybe<Scalars['Int']>;
2037+
isVisible?: InputMaybe<Scalars['Boolean']>;
2038+
objectName?: InputMaybe<Scalars['String']>;
2039+
sizeInPx?: InputMaybe<Scalars['Int']>;
2040+
};
2041+
2042+
export type ViewFieldUpdateManyWithoutWorkspaceNestedInput = {
2043+
connect?: InputMaybe<Array<ViewFieldWhereUniqueInput>>;
2044+
disconnect?: InputMaybe<Array<ViewFieldWhereUniqueInput>>;
2045+
set?: InputMaybe<Array<ViewFieldWhereUniqueInput>>;
2046+
};
2047+
2048+
export type ViewFieldWhereInput = {
2049+
AND?: InputMaybe<Array<ViewFieldWhereInput>>;
2050+
NOT?: InputMaybe<Array<ViewFieldWhereInput>>;
2051+
OR?: InputMaybe<Array<ViewFieldWhereInput>>;
2052+
fieldName?: InputMaybe<StringFilter>;
2053+
id?: InputMaybe<StringFilter>;
2054+
index?: InputMaybe<IntFilter>;
2055+
isVisible?: InputMaybe<BoolFilter>;
2056+
objectName?: InputMaybe<StringFilter>;
2057+
sizeInPx?: InputMaybe<IntFilter>;
2058+
};
2059+
2060+
export type ViewFieldWhereUniqueInput = {
2061+
id?: InputMaybe<Scalars['String']>;
2062+
};
2063+
19642064
export type Workspace = {
19652065
__typename?: 'Workspace';
19662066
Attachment?: Maybe<Array<Attachment>>;
@@ -1979,6 +2079,7 @@ export type Workspace = {
19792079
pipelineStages?: Maybe<Array<PipelineStage>>;
19802080
pipelines?: Maybe<Array<Pipeline>>;
19812081
updatedAt: Scalars['DateTime'];
2082+
viewFields?: Maybe<Array<ViewField>>;
19822083
workspaceMember?: Maybe<Array<WorkspaceMember>>;
19832084
};
19842085

@@ -2053,6 +2154,7 @@ export type WorkspaceUpdateInput = {
20532154
pipelineStages?: InputMaybe<PipelineStageUpdateManyWithoutWorkspaceNestedInput>;
20542155
pipelines?: InputMaybe<PipelineUpdateManyWithoutWorkspaceNestedInput>;
20552156
updatedAt?: InputMaybe<Scalars['DateTime']>;
2157+
viewFields?: InputMaybe<ViewFieldUpdateManyWithoutWorkspaceNestedInput>;
20562158
workspaceMember?: InputMaybe<WorkspaceMemberUpdateManyWithoutWorkspaceNestedInput>;
20572159
};
20582160

@@ -2448,6 +2550,21 @@ export type RemoveProfilePictureMutationVariables = Exact<{
24482550

24492551
export type RemoveProfilePictureMutation = { __typename?: 'Mutation', updateUser: { __typename?: 'User', id: string, avatarUrl?: string | null } };
24502552

2553+
export type GetViewFieldsQueryVariables = Exact<{
2554+
where?: InputMaybe<ViewFieldWhereInput>;
2555+
}>;
2556+
2557+
2558+
export type GetViewFieldsQuery = { __typename?: 'Query', viewFields: Array<{ __typename?: 'ViewField', id: string, fieldName: string, isVisible: boolean, sizeInPx: number, index: number }> };
2559+
2560+
export type UpdateViewFieldMutationVariables = Exact<{
2561+
data: ViewFieldUpdateInput;
2562+
where: ViewFieldWhereUniqueInput;
2563+
}>;
2564+
2565+
2566+
export type UpdateViewFieldMutation = { __typename?: 'Mutation', updateOneViewField: { __typename?: 'ViewField', id: string, fieldName: string, isVisible: boolean, sizeInPx: number, index: number } };
2567+
24512568
export type GetWorkspaceMembersQueryVariables = Exact<{ [key: string]: never; }>;
24522569

24532570

@@ -4669,6 +4786,83 @@ export function useRemoveProfilePictureMutation(baseOptions?: Apollo.MutationHoo
46694786
export type RemoveProfilePictureMutationHookResult = ReturnType<typeof useRemoveProfilePictureMutation>;
46704787
export type RemoveProfilePictureMutationResult = Apollo.MutationResult<RemoveProfilePictureMutation>;
46714788
export type RemoveProfilePictureMutationOptions = Apollo.BaseMutationOptions<RemoveProfilePictureMutation, RemoveProfilePictureMutationVariables>;
4789+
export const GetViewFieldsDocument = gql`
4790+
query GetViewFields($where: ViewFieldWhereInput) {
4791+
viewFields: findManyViewField(where: $where) {
4792+
id
4793+
fieldName
4794+
isVisible
4795+
sizeInPx
4796+
index
4797+
}
4798+
}
4799+
`;
4800+
4801+
/**
4802+
* __useGetViewFieldsQuery__
4803+
*
4804+
* To run a query within a React component, call `useGetViewFieldsQuery` and pass it any options that fit your needs.
4805+
* When your component renders, `useGetViewFieldsQuery` returns an object from Apollo Client that contains loading, error, and data properties
4806+
* you can use to render your UI.
4807+
*
4808+
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
4809+
*
4810+
* @example
4811+
* const { data, loading, error } = useGetViewFieldsQuery({
4812+
* variables: {
4813+
* where: // value for 'where'
4814+
* },
4815+
* });
4816+
*/
4817+
export function useGetViewFieldsQuery(baseOptions?: Apollo.QueryHookOptions<GetViewFieldsQuery, GetViewFieldsQueryVariables>) {
4818+
const options = {...defaultOptions, ...baseOptions}
4819+
return Apollo.useQuery<GetViewFieldsQuery, GetViewFieldsQueryVariables>(GetViewFieldsDocument, options);
4820+
}
4821+
export function useGetViewFieldsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GetViewFieldsQuery, GetViewFieldsQueryVariables>) {
4822+
const options = {...defaultOptions, ...baseOptions}
4823+
return Apollo.useLazyQuery<GetViewFieldsQuery, GetViewFieldsQueryVariables>(GetViewFieldsDocument, options);
4824+
}
4825+
export type GetViewFieldsQueryHookResult = ReturnType<typeof useGetViewFieldsQuery>;
4826+
export type GetViewFieldsLazyQueryHookResult = ReturnType<typeof useGetViewFieldsLazyQuery>;
4827+
export type GetViewFieldsQueryResult = Apollo.QueryResult<GetViewFieldsQuery, GetViewFieldsQueryVariables>;
4828+
export const UpdateViewFieldDocument = gql`
4829+
mutation UpdateViewField($data: ViewFieldUpdateInput!, $where: ViewFieldWhereUniqueInput!) {
4830+
updateOneViewField(data: $data, where: $where) {
4831+
id
4832+
fieldName
4833+
isVisible
4834+
sizeInPx
4835+
index
4836+
}
4837+
}
4838+
`;
4839+
export type UpdateViewFieldMutationFn = Apollo.MutationFunction<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>;
4840+
4841+
/**
4842+
* __useUpdateViewFieldMutation__
4843+
*
4844+
* To run a mutation, you first call `useUpdateViewFieldMutation` within a React component and pass it any options that fit your needs.
4845+
* When your component renders, `useUpdateViewFieldMutation` returns a tuple that includes:
4846+
* - A mutate function that you can call at any time to execute the mutation
4847+
* - An object with fields that represent the current status of the mutation's execution
4848+
*
4849+
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
4850+
*
4851+
* @example
4852+
* const [updateViewFieldMutation, { data, loading, error }] = useUpdateViewFieldMutation({
4853+
* variables: {
4854+
* data: // value for 'data'
4855+
* where: // value for 'where'
4856+
* },
4857+
* });
4858+
*/
4859+
export function useUpdateViewFieldMutation(baseOptions?: Apollo.MutationHookOptions<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>) {
4860+
const options = {...defaultOptions, ...baseOptions}
4861+
return Apollo.useMutation<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>(UpdateViewFieldDocument, options);
4862+
}
4863+
export type UpdateViewFieldMutationHookResult = ReturnType<typeof useUpdateViewFieldMutation>;
4864+
export type UpdateViewFieldMutationResult = Apollo.MutationResult<UpdateViewFieldMutation>;
4865+
export type UpdateViewFieldMutationOptions = Apollo.BaseMutationOptions<UpdateViewFieldMutation, UpdateViewFieldMutationVariables>;
46724866
export const GetWorkspaceMembersDocument = gql`
46734867
query GetWorkspaceMembers {
46744868
workspaceMembers: findManyWorkspaceMember {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { gql } from '@apollo/client';
2+
3+
export const GET_VIEW_FIELDS = gql`
4+
query GetViewFields($where: ViewFieldWhereInput) {
5+
viewFields: findManyViewField(where: $where) {
6+
id
7+
fieldName
8+
isVisible
9+
sizeInPx
10+
index
11+
}
12+
}
13+
`;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { gql } from '@apollo/client';
2+
3+
export const UPDATE_VIEW_FIELD = gql`
4+
mutation UpdateViewField(
5+
$data: ViewFieldUpdateInput!
6+
$where: ViewFieldWhereUniqueInput!
7+
) {
8+
updateOneViewField(data: $data, where: $where) {
9+
id
10+
fieldName
11+
isVisible
12+
sizeInPx
13+
index
14+
}
15+
}
16+
`;

server/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.10.0
1+
18.16.0

server/src/ability/ability.factory.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
Attachment,
1919
UserSettings,
2020
Favorite,
21+
ViewField,
2122
} from '@prisma/client';
2223

2324
import { AbilityAction } from './ability.action';
@@ -38,6 +39,7 @@ type SubjectsAbility = Subjects<{
3839
Attachment: Attachment;
3940
UserSettings: UserSettings;
4041
Favorite: Favorite;
42+
ViewField: ViewField;
4143
}>;
4244

4345
export type AppAbility = PureAbility<
@@ -136,6 +138,9 @@ export class AbilityFactory {
136138
can(AbilityAction.Delete, 'Favorite', {
137139
workspaceId: workspace.id,
138140
});
141+
// ViewField
142+
can(AbilityAction.Read, 'ViewField', { workspaceId: workspace.id });
143+
can(AbilityAction.Update, 'ViewField', { workspaceId: workspace.id });
139144

140145
return build();
141146
}

server/src/ability/ability.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ import {
9898
CreateFavoriteAbilityHandler,
9999
ReadFavoriteAbilityHandler,
100100
} from './handlers/favorite.ability-handler';
101+
import {
102+
ReadViewFieldAbilityHandler,
103+
UpdateViewFieldAbilityHandler,
104+
} from './handlers/view-field.ability-handler';
101105

102106
@Global()
103107
@Module({
@@ -185,6 +189,9 @@ import {
185189
//Favorite
186190
ReadFavoriteAbilityHandler,
187191
CreateFavoriteAbilityHandler,
192+
// ViewField
193+
ReadViewFieldAbilityHandler,
194+
UpdateViewFieldAbilityHandler,
188195
],
189196
exports: [
190197
AbilityFactory,
@@ -269,6 +276,9 @@ import {
269276
//Favorite
270277
ReadFavoriteAbilityHandler,
271278
CreateFavoriteAbilityHandler,
279+
// ViewField
280+
ReadViewFieldAbilityHandler,
281+
UpdateViewFieldAbilityHandler,
272282
],
273283
})
274284
export class AbilityModule {}

0 commit comments

Comments
 (0)