Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions packages/client/src/graphql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export type Mutation = {
deleteStudy: Scalars['Boolean']['output'];
forgotPassword: Scalars['Boolean']['output'];
grantOwner: Scalars['Boolean']['output'];
grantProjectPermissions: Scalars['Boolean']['output'];
lexiconAddEntry: LexiconEntry;
/** Remove all entries from a given lexicon */
lexiconClearEntries: Scalars['Boolean']['output'];
Expand Down Expand Up @@ -316,6 +317,13 @@ export type MutationGrantOwnerArgs = {
};


export type MutationGrantProjectPermissionsArgs = {
isAdmin: Scalars['Boolean']['input'];
project: Scalars['ID']['input'];
user: Scalars['ID']['input'];
};


export type MutationLexiconAddEntryArgs = {
entry: LexiconAddEntry;
};
Expand Down Expand Up @@ -409,6 +417,14 @@ export type OrganizationCreate = {
projectId: Scalars['String']['input'];
};

export type Permission = {
__typename?: 'Permission';
editable: Scalars['Boolean']['output'];
hasRole: Scalars['Boolean']['output'];
role: Roles;
user: UserModel;
};

export type Project = {
__typename?: 'Project';
_id: Scalars['ID']['output'];
Expand Down Expand Up @@ -485,6 +501,7 @@ export type Query = {
getEntryUploadURL: Scalars['String']['output'];
getOrganizations: Array<Organization>;
getProject: ProjectModel;
getProjectPermissions: Array<Permission>;
getProjects: Array<Project>;
getUser: UserModel;
invite: InviteModel;
Expand Down Expand Up @@ -535,6 +552,11 @@ export type QueryGetProjectArgs = {
};


export type QueryGetProjectPermissionsArgs = {
project: Scalars['ID']['input'];
};


export type QueryGetUserArgs = {
id: Scalars['ID']['input'];
};
Expand Down Expand Up @@ -589,6 +611,13 @@ export type ResetDto = {
projectId: Scalars['String']['input'];
};

export enum Roles {
Contributor = 'CONTRIBUTOR',
Owner = 'OWNER',
ProjectAdmin = 'PROJECT_ADMIN',
StudyAdmin = 'STUDY_ADMIN'
}

export type Study = {
__typename?: 'Study';
_id: Scalars['ID']['output'];
Expand Down
22 changes: 22 additions & 0 deletions packages/client/src/graphql/permission/permission.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
query getProjectPermissions($project: ID!) {
getProjectPermissions(project: $project) {
user {
id,
projectId,
fullname,
username,
email,
role,
createdAt,
updatedAt,
deletedAt
},
hasRole,
editable,
role
}
}

mutation grantProjectPermissions($project: ID!, $user: ID!, $isAdmin: Boolean!) {
grantProjectPermissions(project: $project, user: $user, isAdmin: $isAdmin)
}
105 changes: 105 additions & 0 deletions packages/client/src/graphql/permission/permission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* Generated File DO NOT EDIT. */
/* tslint:disable */
import * as Types from '../graphql';

import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type GetProjectPermissionsQueryVariables = Types.Exact<{
project: Types.Scalars['ID']['input'];
}>;


export type GetProjectPermissionsQuery = { __typename?: 'Query', getProjectPermissions: Array<{ __typename?: 'Permission', hasRole: boolean, editable: boolean, role: Types.Roles, user: { __typename?: 'UserModel', id: string, projectId: string, fullname?: string | null, username?: string | null, email?: string | null, role: number, createdAt: any, updatedAt: any, deletedAt?: any | null } }> };

export type GrantProjectPermissionsMutationVariables = Types.Exact<{
project: Types.Scalars['ID']['input'];
user: Types.Scalars['ID']['input'];
isAdmin: Types.Scalars['Boolean']['input'];
}>;


export type GrantProjectPermissionsMutation = { __typename?: 'Mutation', grantProjectPermissions: boolean };


export const GetProjectPermissionsDocument = gql`
query getProjectPermissions($project: ID!) {
getProjectPermissions(project: $project) {
user {
id
projectId
fullname
username
email
role
createdAt
updatedAt
deletedAt
}
hasRole
editable
role
}
}
`;

/**
* __useGetProjectPermissionsQuery__
*
* To run a query within a React component, call `useGetProjectPermissionsQuery` and pass it any options that fit your needs.
* When your component renders, `useGetProjectPermissionsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @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;
*
* @example
* const { data, loading, error } = useGetProjectPermissionsQuery({
* variables: {
* project: // value for 'project'
* },
* });
*/
export function useGetProjectPermissionsQuery(baseOptions: Apollo.QueryHookOptions<GetProjectPermissionsQuery, GetProjectPermissionsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<GetProjectPermissionsQuery, GetProjectPermissionsQueryVariables>(GetProjectPermissionsDocument, options);
}
export function useGetProjectPermissionsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GetProjectPermissionsQuery, GetProjectPermissionsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<GetProjectPermissionsQuery, GetProjectPermissionsQueryVariables>(GetProjectPermissionsDocument, options);
}
export type GetProjectPermissionsQueryHookResult = ReturnType<typeof useGetProjectPermissionsQuery>;
export type GetProjectPermissionsLazyQueryHookResult = ReturnType<typeof useGetProjectPermissionsLazyQuery>;
export type GetProjectPermissionsQueryResult = Apollo.QueryResult<GetProjectPermissionsQuery, GetProjectPermissionsQueryVariables>;
export const GrantProjectPermissionsDocument = gql`
mutation grantProjectPermissions($project: ID!, $user: ID!, $isAdmin: Boolean!) {
grantProjectPermissions(project: $project, user: $user, isAdmin: $isAdmin)
}
`;
export type GrantProjectPermissionsMutationFn = Apollo.MutationFunction<GrantProjectPermissionsMutation, GrantProjectPermissionsMutationVariables>;

/**
* __useGrantProjectPermissionsMutation__
*
* To run a mutation, you first call `useGrantProjectPermissionsMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useGrantProjectPermissionsMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @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;
*
* @example
* const [grantProjectPermissionsMutation, { data, loading, error }] = useGrantProjectPermissionsMutation({
* variables: {
* project: // value for 'project'
* user: // value for 'user'
* isAdmin: // value for 'isAdmin'
* },
* });
*/
export function useGrantProjectPermissionsMutation(baseOptions?: Apollo.MutationHookOptions<GrantProjectPermissionsMutation, GrantProjectPermissionsMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<GrantProjectPermissionsMutation, GrantProjectPermissionsMutationVariables>(GrantProjectPermissionsDocument, options);
}
export type GrantProjectPermissionsMutationHookResult = ReturnType<typeof useGrantProjectPermissionsMutation>;
export type GrantProjectPermissionsMutationResult = Apollo.MutationResult<GrantProjectPermissionsMutation>;
export type GrantProjectPermissionsMutationOptions = Apollo.BaseMutationOptions<GrantProjectPermissionsMutation, GrantProjectPermissionsMutationVariables>;
Loading