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
2 changes: 2 additions & 0 deletions packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { setContext } from '@apollo/client/link/context';
import { StudyProvider } from './context/Study.context';
import { ConfirmationProvider } from './context/Confirmation.context';
import { DatasetProvider } from './context/Dataset.context';
import { EntryControls } from './pages/studies/EntryControls';

const drawerWidth = 256;
const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })<{
Expand Down Expand Up @@ -127,6 +128,7 @@ const MyRoutes: FC = () => {
<Route path={'/study/new'} element={<NewStudy />} />
<Route path={'/study/controls'} element={<StudyControl />} />
<Route path={'/study/permissions'} element={<StudyUserPermissions />} />
<Route path={'/study/entries'} element={<EntryControls />} />
<Route path={'/study/tags'} element={<DownloadTags />} />
<Route path={'/successpage'} element={<SuccessPage />} />
<Route path={'/dataset/controls'} element={<DatasetControls />} />
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/components/SideBar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const SideBar: FC<SideBarProps> = ({ open, drawerWidth }) => {
{ name: 'Study Control', action: () => navigate('/study/controls'), visible: (p) => p!.projectAdmin },
{ name: 'User Permissions', action: () => navigate('/study/permissions'), visible: (p) => p!.studyAdmin },
{ name: 'Entry Controls', action: () => navigate('/study/controls'), visible: (p) => p!.studyAdmin },
{ name: 'Entry Controls', action: () => navigate('/study/entries'), visible: (p) => p!.studyAdmin },
{ name: 'Download Tags', action: () => navigate('/study/tags'), visible: (p) => p!.studyAdmin }
]
},
Expand Down
65 changes: 65 additions & 0 deletions packages/client/src/components/ToggleEntryEnabled.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Switch } from '@mui/material';
import { useEffect } from 'react';
import { useIsEntryEnabledLazyQuery, useSetEntryEnabledMutation } from '../graphql/tag/tag';
import { useStudy } from '../context/Study.context';
import { useConfirmation } from '../context/Confirmation.context';

export default function ToggleEntryEnabled(props: { entryId: string }) {
const [isEntryEnabled, isEntryEnabledResults] = useIsEntryEnabledLazyQuery();
const [setEntryEnabledMutation, setEntryEnabledResults] = useSetEntryEnabledMutation();

const { study } = useStudy();
const confirmation = useConfirmation();

useEffect(() => {
if (study) {
isEntryEnabled({
variables: {
study: study._id,
entry: props.entryId
},
fetchPolicy: 'network-only'
});
}
}, [study, setEntryEnabledResults.data]);

useEffect(() => {
if (setEntryEnabledResults.called) {
if (setEntryEnabledResults.error) {
//show error message
console.error('error toggling entry', setEntryEnabledResults.error);
}
}
}, [setEntryEnabledResults.error]);

const handleToggleEnabled = async (entryId: string, checked: boolean) => {
if (study) {
if (!checked) {
confirmation.pushConfirmationRequest({
title: 'Disable Entry',
message:
'Are you sure you want to disable this entry? Doing so will exclude this entry from the current study.',
onConfirm: () => {
setEntryEnabledMutation({
variables: { study: study._id, entry: entryId, enabled: checked }
});
},
onCancel: () => {}
});
} else {
setEntryEnabledMutation({
variables: { study: study._id, entry: entryId, enabled: checked }
});
}
}
};

return (
<Switch
disabled={setEntryEnabledResults.loading || !isEntryEnabledResults.data}
checked={isEntryEnabledResults.data ? isEntryEnabledResults.data.isEntryEnabled : false}
onChange={(event) => handleToggleEnabled(props.entryId, event.target.checked)}
inputProps={{ 'aria-label': 'controlled' }}
/>
);
}
12 changes: 10 additions & 2 deletions packages/client/src/graphql/dataset/dataset.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
query getDatasets {
getDatasets {
_id,
name,
_id
name
description
}
}

query getDatasetsByProject($project: ID!) {
getDatasetsByProject(project: $project) {
_id
name
description
}
}
46 changes: 45 additions & 1 deletion packages/client/src/graphql/dataset/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ export type GetDatasetsQueryVariables = Types.Exact<{ [key: string]: never; }>;

export type GetDatasetsQuery = { __typename?: 'Query', getDatasets: Array<{ __typename?: 'Dataset', _id: string, name: string, description: string }> };

export type GetDatasetsByProjectQueryVariables = Types.Exact<{
project: Types.Scalars['ID']['input'];
}>;


export type GetDatasetsByProjectQuery = { __typename?: 'Query', getDatasetsByProject: Array<{ __typename?: 'Dataset', _id: string, name: string, description: string }> };


export const GetDatasetsDocument = gql`
query getDatasets {
Expand Down Expand Up @@ -46,4 +53,41 @@ export function useGetDatasetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOption
}
export type GetDatasetsQueryHookResult = ReturnType<typeof useGetDatasetsQuery>;
export type GetDatasetsLazyQueryHookResult = ReturnType<typeof useGetDatasetsLazyQuery>;
export type GetDatasetsQueryResult = Apollo.QueryResult<GetDatasetsQuery, GetDatasetsQueryVariables>;
export type GetDatasetsQueryResult = Apollo.QueryResult<GetDatasetsQuery, GetDatasetsQueryVariables>;
export const GetDatasetsByProjectDocument = gql`
query getDatasetsByProject($project: ID!) {
getDatasetsByProject(project: $project) {
_id
name
description
}
}
`;

/**
* __useGetDatasetsByProjectQuery__
*
* To run a query within a React component, call `useGetDatasetsByProjectQuery` and pass it any options that fit your needs.
* When your component renders, `useGetDatasetsByProjectQuery` 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 } = useGetDatasetsByProjectQuery({
* variables: {
* project: // value for 'project'
* },
* });
*/
export function useGetDatasetsByProjectQuery(baseOptions: Apollo.QueryHookOptions<GetDatasetsByProjectQuery, GetDatasetsByProjectQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<GetDatasetsByProjectQuery, GetDatasetsByProjectQueryVariables>(GetDatasetsByProjectDocument, options);
}
export function useGetDatasetsByProjectLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GetDatasetsByProjectQuery, GetDatasetsByProjectQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<GetDatasetsByProjectQuery, GetDatasetsByProjectQueryVariables>(GetDatasetsByProjectDocument, options);
}
export type GetDatasetsByProjectQueryHookResult = ReturnType<typeof useGetDatasetsByProjectQuery>;
export type GetDatasetsByProjectLazyQueryHookResult = ReturnType<typeof useGetDatasetsByProjectLazyQuery>;
export type GetDatasetsByProjectQueryResult = Apollo.QueryResult<GetDatasetsByProjectQuery, GetDatasetsByProjectQueryVariables>;
15 changes: 15 additions & 0 deletions packages/client/src/graphql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export type Mutation = {
refresh: AccessToken;
resendInvite: InviteModel;
resetPassword: Scalars['Boolean']['output'];
setEntryEnabled: Scalars['Boolean']['output'];
signLabCreateProject: Project;
signup: AccessToken;
updateProject: ProjectModel;
Expand Down Expand Up @@ -413,6 +414,13 @@ export type MutationResetPasswordArgs = {
};


export type MutationSetEntryEnabledArgs = {
enabled: Scalars['Boolean']['input'];
entry: Scalars['ID']['input'];
study: Scalars['ID']['input'];
};


export type MutationSignLabCreateProjectArgs = {
project: ProjectCreate;
};
Expand Down Expand Up @@ -562,6 +570,7 @@ export type Query = {
getUser: UserModel;
invite: InviteModel;
invites: Array<InviteModel>;
isEntryEnabled: Scalars['Boolean']['output'];
lexFindAll: Array<Lexicon>;
lexiconByKey: LexiconEntry;
lexiconSearch: Array<LexiconEntry>;
Expand Down Expand Up @@ -649,6 +658,12 @@ export type QueryInvitesArgs = {
};


export type QueryIsEntryEnabledArgs = {
entry: Scalars['ID']['input'];
study: Scalars['ID']['input'];
};


export type QueryLexiconByKeyArgs = {
key: Scalars['String']['input'];
lexicon: Scalars['String']['input'];
Expand Down
28 changes: 14 additions & 14 deletions packages/client/src/graphql/study/study.graphql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
query findStudies($project: ID!) {
findStudies(project: $project) {
_id,
name,
description,
instructions,
project,
tagsPerEntry,
_id
name
description
instructions
project
tagsPerEntry
tagSchema {
dataSchema,
dataSchema
uiSchema
}
}
Expand All @@ -19,14 +19,14 @@ mutation deleteStudy($study: ID!) {

mutation createStudy($study: StudyCreate!) {
createStudy(study: $study) {
_id,
name,
description,
instructions,
project,
tagsPerEntry,
_id
name
description
instructions
project
tagsPerEntry
tagSchema {
dataSchema,
dataSchema
uiSchema
}
}
Expand Down
28 changes: 18 additions & 10 deletions packages/client/src/graphql/tag/tag.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ mutation createTags($study: ID!, $entries: [ID!]!) {
}
}

mutation setEntryEnabled($study: ID!, $entry: ID!, $enabled: Boolean!) {
setEntryEnabled(study: $study, entry: $entry, enabled: $enabled)
}

query isEntryEnabled($study: ID!, $entry: ID!) {
isEntryEnabled(study: $study, entry: $entry)
}

mutation assignTag($study: ID!) {
assignTag(study: $study) {
_id,
_id
entry {
_id,
organization,
entryID,
contentType,
dataset,
creator,
dateCreated,
meta,
signedUrl,
_id
organization
entryID
contentType
dataset
creator
dateCreated
meta
signedUrl
signedUrlExpiration
}
}
Expand Down
84 changes: 84 additions & 0 deletions packages/client/src/graphql/tag/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ export type CreateTagsMutationVariables = Types.Exact<{

export type CreateTagsMutation = { __typename?: 'Mutation', createTags: Array<{ __typename?: 'Tag', _id: string }> };

export type SetEntryEnabledMutationVariables = Types.Exact<{
study: Types.Scalars['ID']['input'];
entry: Types.Scalars['ID']['input'];
enabled: Types.Scalars['Boolean']['input'];
}>;


export type SetEntryEnabledMutation = { __typename?: 'Mutation', setEntryEnabled: boolean };

export type IsEntryEnabledQueryVariables = Types.Exact<{
study: Types.Scalars['ID']['input'];
entry: Types.Scalars['ID']['input'];
}>;


export type IsEntryEnabledQuery = { __typename?: 'Query', isEntryEnabled: boolean };

export type AssignTagMutationVariables = Types.Exact<{
study: Types.Scalars['ID']['input'];
}>;
Expand Down Expand Up @@ -63,6 +80,73 @@ export function useCreateTagsMutation(baseOptions?: Apollo.MutationHookOptions<C
export type CreateTagsMutationHookResult = ReturnType<typeof useCreateTagsMutation>;
export type CreateTagsMutationResult = Apollo.MutationResult<CreateTagsMutation>;
export type CreateTagsMutationOptions = Apollo.BaseMutationOptions<CreateTagsMutation, CreateTagsMutationVariables>;
export const SetEntryEnabledDocument = gql`
mutation setEntryEnabled($study: ID!, $entry: ID!, $enabled: Boolean!) {
setEntryEnabled(study: $study, entry: $entry, enabled: $enabled)
}
`;
export type SetEntryEnabledMutationFn = Apollo.MutationFunction<SetEntryEnabledMutation, SetEntryEnabledMutationVariables>;

/**
* __useSetEntryEnabledMutation__
*
* To run a mutation, you first call `useSetEntryEnabledMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useSetEntryEnabledMutation` 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 [setEntryEnabledMutation, { data, loading, error }] = useSetEntryEnabledMutation({
* variables: {
* study: // value for 'study'
* entry: // value for 'entry'
* enabled: // value for 'enabled'
* },
* });
*/
export function useSetEntryEnabledMutation(baseOptions?: Apollo.MutationHookOptions<SetEntryEnabledMutation, SetEntryEnabledMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<SetEntryEnabledMutation, SetEntryEnabledMutationVariables>(SetEntryEnabledDocument, options);
}
export type SetEntryEnabledMutationHookResult = ReturnType<typeof useSetEntryEnabledMutation>;
export type SetEntryEnabledMutationResult = Apollo.MutationResult<SetEntryEnabledMutation>;
export type SetEntryEnabledMutationOptions = Apollo.BaseMutationOptions<SetEntryEnabledMutation, SetEntryEnabledMutationVariables>;
export const IsEntryEnabledDocument = gql`
query isEntryEnabled($study: ID!, $entry: ID!) {
isEntryEnabled(study: $study, entry: $entry)
}
`;

/**
* __useIsEntryEnabledQuery__
*
* To run a query within a React component, call `useIsEntryEnabledQuery` and pass it any options that fit your needs.
* When your component renders, `useIsEntryEnabledQuery` 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 } = useIsEntryEnabledQuery({
* variables: {
* study: // value for 'study'
* entry: // value for 'entry'
* },
* });
*/
export function useIsEntryEnabledQuery(baseOptions: Apollo.QueryHookOptions<IsEntryEnabledQuery, IsEntryEnabledQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<IsEntryEnabledQuery, IsEntryEnabledQueryVariables>(IsEntryEnabledDocument, options);
}
export function useIsEntryEnabledLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<IsEntryEnabledQuery, IsEntryEnabledQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<IsEntryEnabledQuery, IsEntryEnabledQueryVariables>(IsEntryEnabledDocument, options);
}
export type IsEntryEnabledQueryHookResult = ReturnType<typeof useIsEntryEnabledQuery>;
export type IsEntryEnabledLazyQueryHookResult = ReturnType<typeof useIsEntryEnabledLazyQuery>;
export type IsEntryEnabledQueryResult = Apollo.QueryResult<IsEntryEnabledQuery, IsEntryEnabledQueryVariables>;
export const AssignTagDocument = gql`
mutation assignTag($study: ID!) {
assignTag(study: $study) {
Expand Down
Loading