Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⌨️ #1098 Add Data Center fields #2754

Merged
merged 12 commits into from
Feb 21, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const createProgramSummaryData = (programSummaryQuery: ProgramSummaryQuer
''
),
Institutions: programSummaryQuery?.institutions?.join(', ') || '',
'Data Center': programSummaryQuery?.dataCenter?.name || '',
'Cancer Types': programSummaryQuery?.cancerTypes?.join(', ') || '',
};
};
Expand Down
5 changes: 5 additions & 0 deletions components/pages/program-entity/gql/PROGRAM_SUMMARY_QUERY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const PROGRAM_SUMMARY_QUERY = gql`
website
institutions
countries
dataCenter {
id
shortName
name
}
cancerTypes
primarySites
}
Expand Down
3 changes: 3 additions & 0 deletions components/pages/program-entity/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import { DataCenter } from 'generated/gql_types';

export type ProgramSummaryQuery = {
shortName: string;
description: string;
name: string;
website: string;
institutions: string[];
countries: string[];
dataCenter: DataCenter;
cancerTypes: string[];
primarySites: string[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const createProgramInput = (formData) => ({
website: formData.website,
institutions: formData.institutions,
countries: formData.countries,
dataCenter: formData.dataCenter,
membershipType: formData.membershipType,
admins: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ const PROGRAM_VALUES_QUERY = gql`
primarySites
institutions
countries
dataCenters {
shortName
name
id
}
}
}
`;
Expand Down
36 changes: 36 additions & 0 deletions components/pages/submission-system/program-form/ProgramForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Typography,
css,
} from '@icgc-argo/uikit';
import { DataCenter } from 'generated/gql_types';
import { PROGRAM_MEMBERSHIP_TYPES } from 'global/constants';
import useFormHook from 'global/hooks/useFormHook';
import get from 'lodash/get';
Expand Down Expand Up @@ -78,6 +79,7 @@ export default function CreateProgramForm({
primarySites?: string[];
commitmentDonors?: number;
institutions?: string[];
dataCenter?: DataCenter;
membershipType?: string;
website?: string;
description?: string;
Expand All @@ -92,6 +94,7 @@ export default function CreateProgramForm({
primarySites: string[];
commitmentLevel: number;
institutions: string[];
dataCenter: string;
membershipType: string;
website: string;
description: string;
Expand All @@ -106,6 +109,7 @@ export default function CreateProgramForm({
primarySites: program.primarySites || [],
commitmentLevel: program.commitmentDonors,
institutions: program.institutions || [],
dataCenter: program.dataCenter?.shortName || '',
membershipType: program.membershipType || '',
website: program.website || '',
description: program.description || '',
Expand Down Expand Up @@ -398,6 +402,38 @@ export default function CreateProgramForm({
</Row>
</FormControl>

<Row>
<Col>
<SectionTitle>Processing Data Center</SectionTitle>
</Col>
</Row>

<FormControl error={validationErrors.dataCenter} required={true}>
<Row>
<Col>
<InputLabel htmlFor="Data Center">
Please indicate the data center where data can be processed.
</InputLabel>
<Select
aria-label="Data Center"
id="checkbox-group-data-center"
options={get(programOptions, 'dataCenters', []).map(({ name, id }) => ({
content: name,
value: id,
}))}
onChange={(val) => setData({ key: 'dataCenter', val: val || '' })}
onBlur={handleInputBlur('dataCenter')}
value={form.dataCenter || ''}
size="lg"
/>
<ErrorText error={validationErrors.dataCenter} />
</Col>
</Row>
<Row>
<Col />
</Row>
</FormControl>

{!isEditing && (
<>
<Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const baseValidations: yup.ObjectSchema<any> = yup.object({
.required(),
website: yup.string().label('Website').trim().url(),
description: yup.string().label('Description').trim(),
dataCenter: yup.string().label('Data Center').required(),
});

const adminValidations = yup.object().shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const createUpdateProgramInput = (formData) => ({
website: formData.website,
institutions: formData.institutions,
countries: formData.countries,
dataCenter: formData.dataCenter,
membershipType: formData.membershipType,
cancerTypes: formData.cancerTypes,
primarySites: formData.primarySites,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const PROGRAM_QUERY = gql`
inviteAcceptedAt
inviteStatus
}
dataCenter {
id
shortName
name
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can be removed too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry, removed

}
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const PROGRAMS_LIST_QUERY = gql`
genomicDonors
submittedDonors
commitmentDonors
dataCenter {
id
shortName
name
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels off. Why are we sending all these urls to the frontend when our architecture is using gateways?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question, I agree however this is just the UI requesting all Data Center related fields
The URLs will have to be removed upstream @ the API GQL type and I will have to ask if this can be changed
Worth investigating before merging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these fields are required so they can be removed from FE query, just going to confirm their intent on Slack

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed based on Slack discussion, not needed for UI

}
}
`;
Expand Down
18 changes: 17 additions & 1 deletion generated/gql_types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ export type Program = {
cancerTypes?: Maybe<Array<Maybe<Scalars['String']>>>;
commitmentDonors?: Maybe<Scalars['Int']>;
countries?: Maybe<Array<Maybe<Scalars['String']>>>;
dataCenter?: Maybe<DataCenter>;
description?: Maybe<Scalars['String']>;
genomicDonors?: Maybe<Scalars['Int']>;
institutions?: Maybe<Array<Maybe<Scalars['String']>>>;
Expand Down Expand Up @@ -1050,11 +1051,19 @@ export type ProgramDonorSummaryStats = {
sangerStatusCount: WorkflowStatusCount;
};

/**
* ProgramInput will throw a bad user input error in the following cases:
* if using name that is already in the database,
* if using a shortName format that is not "NAME-AREA", a working example is "BOB-CA"
* using cancerTypes or countries that doesn't exist or is not in the same format as the database ex. a working example of cancerTypes is "Lung cancer". Bad example are "lung", "lung cancer"
* admin's email must be in an email format ex. use @
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you added this comment to the file directly , it will be deleted when types re-generate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment lives in the API and Daniel wrote it while he was here
I did not add it myself, gql_types has already been generated by running gql:codegen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent! I didn't know it kept comments, that's great to know.

export type ProgramInput = {
admins: Array<ProgramUserInput>;
cancerTypes: Array<InputMaybe<Scalars['String']>>;
commitmentDonors: Scalars['Int'];
countries: Array<Scalars['String']>;
dataCenter?: InputMaybe<Scalars['String']>;
description?: InputMaybe<Scalars['String']>;
institutions: Array<Scalars['String']>;
membershipType: MembershipType;
Expand All @@ -1068,6 +1077,7 @@ export type ProgramOptions = {
__typename?: 'ProgramOptions';
cancerTypes: Array<Maybe<Scalars['String']>>;
countries: Array<Maybe<Scalars['String']>>;
dataCenters: Array<Maybe<DataCenter>>;
institutions: Array<Maybe<Scalars['String']>>;
primarySites: Array<Maybe<Scalars['String']>>;
};
Expand All @@ -1080,7 +1090,7 @@ export type ProgramUser = {
inviteStatus?: Maybe<InviteStatus>;
isDacoApproved?: Maybe<Scalars['Boolean']>;
lastName: Scalars['String'];
role: UserRole;
role?: Maybe<UserRole>;
};

export type ProgramUserInput = {
Expand Down Expand Up @@ -1203,6 +1213,11 @@ export type QueryProgramDonorSummaryArgs = {
};


export type QueryProgramsArgs = {
dataCenter?: InputMaybe<Scalars['String']>;
};


export type QueryQueryArgs = {
query?: InputMaybe<Scalars['String']>;
types?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
Expand Down Expand Up @@ -1312,6 +1327,7 @@ export type UpdateProgramInput = {
cancerTypes?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
commitmentDonors?: InputMaybe<Scalars['Int']>;
countries?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
dataCenter?: InputMaybe<Scalars['String']>;
description?: InputMaybe<Scalars['String']>;
institutions?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
membershipType?: InputMaybe<MembershipType>;
Expand Down