Skip to content

Commit

Permalink
Merge branch 'main' into fix/1541-fix-smp-mix-single-tree-submission
Browse files Browse the repository at this point in the history
  • Loading branch information
mgaseta authored Aug 28, 2024
2 parents bff7eea + 6ad06e6 commit b22bd18
Show file tree
Hide file tree
Showing 16 changed files with 5,973 additions and 4,511 deletions.
41 changes: 16 additions & 25 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ jobs:
runs-on: ubuntu-latest
steps:
# Get PR number for squash merges to main
- name: PR Number
id: pr
- id: pr
uses: bcgov-nr/[email protected]

deploys:
name: TEST
deploys-test:
name: TEST Deploys (${{ needs.init.outputs.pr }})
needs: [init]
secrets: inherit
uses: ./.github/workflows/.deploy.yml
Expand All @@ -36,12 +35,19 @@ jobs:
tag: ${{ needs.init.outputs.pr }}
target: test

deploys-prod:
name: PROD Deploys (${{ needs.init.outputs.pr }})
needs: [init, deploys-test]
secrets: inherit
uses: ./.github/workflows/.deploy.yml
with:
environment: prod
tag: ${{ needs.init.outputs.pr }}
target: prod

promote:
name: Promote Images
env:
target: ${{ needs.init.outputs.pr }}
tag: prod
needs: [init, deploys]
needs: [init, deploys-prod]
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -51,20 +57,5 @@ jobs:
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ env.target }}
tags: ${{ env.tag }}

- run: |
# Verify tagging
INSPECT="docker manifest inspect ghcr.io/${{ github.repository }}/${{ matrix.package }}"
TARGET=$(${INSPECT}:${{ env.target }} | jq -r '.manifests[] | select(.platform.architecture=="amd64") | .digest')
TAG=$(${INSPECT}:${{ env.tag }} | jq -r '.manifests[] | select(.platform.architecture=="amd64") | .digest')
echo "TARGET: ${TARGET}"
echo "TAG: ${TAG}"
if [ "${TARGET}" != "${TAG}" ]; then
echo "ERROR: Tagging failed!"
echo "RETRY=true" >> $GITHUB_ENV
else
echo "ERROR: Tagging success!"
echo "RETRY=false" >> $GITHUB_ENV
fi
target: ${{ needs.init.outputs.pr }}
tags: prod
2 changes: 1 addition & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
triggers: ('${{ matrix.package }}/')

deploys:
name: Deploys
name: Deploys (${{ github.event.number }})
needs: [builds]
secrets: inherit
uses: ./.github/workflows/.deploy.yml
Expand Down
10,210 changes: 5,816 additions & 4,394 deletions frontend/package-lock.json

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions frontend/src/contexts/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { env } from '../env';
import FamUser from '../types/FamUser';
import LoginProviders from '../types/LoginProviders';
import AuthContext, { AuthContextData } from './AuthContext';
import { SPAR_REDIRECT_PATH, TSC_ADMIN_ROLE } from '../shared-constants/shared-constants';
import { MINISTRY_OF_FOREST_ID, SPAR_REDIRECT_PATH, TSC_ADMIN_ROLE } from '../shared-constants/shared-constants';
import { TWO_MINUTE } from '../config/TimeUnits';
import ROUTES from '../routes/constants';

Expand Down Expand Up @@ -42,7 +42,6 @@ const findFindAndLastName = (displayName: string, provider: string): Array<strin

const parseRole = (accessToken: { [id: string]: any }): UserClientRolesType[] => {
const separator = '_';
const minitryOfForestId = '00012797';

const cognitoGroups: string[] = accessToken['cognito:groups'];
if (!cognitoGroups) {
Expand All @@ -51,19 +50,19 @@ const parseRole = (accessToken: { [id: string]: any }): UserClientRolesType[] =>

const parsedClientRoles: UserClientRolesType[] = [];

cognitoGroups.forEach((cognaitoRole) => {
if (!cognaitoRole.includes(separator)) {
throw new Error(`Invalid role format with string: ${cognaitoRole}`);
cognitoGroups.forEach((cognitoRole) => {
if (!cognitoRole.includes(separator)) {
throw new Error(`Invalid role format with string: ${cognitoRole}`);
}
const lastUnderscoreIndex = cognaitoRole.lastIndexOf(separator);
let role = cognaitoRole.substring(0, lastUnderscoreIndex);
let clientId = cognaitoRole.substring(lastUnderscoreIndex + 1);
const lastUnderscoreIndex = cognitoRole.lastIndexOf(separator);
let role = cognitoRole.substring(0, lastUnderscoreIndex);
let clientId = cognitoRole.substring(lastUnderscoreIndex + 1);

// If the last substring after an underscore is not a number then it's a concrete role,
// we need to manually assign it a MoF client id for now.
if (Number.isNaN(Number(clientId))) {
clientId = minitryOfForestId;
role = cognaitoRole;
clientId = MINISTRY_OF_FOREST_ID;
role = cognitoRole;
}

// Check if a client id already exist in parsed client role
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/shared-constants/shared-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const LARGE_SCREEN_WIDTH = 1056;
export const TSC_ADMIN_ROLE = 'SPAR_TSC_ADMIN';

export const PLACE_HOLDER = '--';

export const MINISTRY_OF_FOREST_ID = '00012797';
22 changes: 22 additions & 0 deletions frontend/src/utils/BreadcrumbUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ROUTES from '../routes/constants';
import { addParamToPath } from './PathUtils';
import { MINISTRY_OF_FOREST_ID } from '../shared-constants/shared-constants';

export const getSeedlotBreadcrumbs = (
seedlotNumber: string,
seedlotApplicant: string,
isTscAdmin: boolean
) => {
const crumbsList = [];
crumbsList.push({ name: 'Seedlots', path: ROUTES.SEEDLOTS });
if (isTscAdmin && seedlotApplicant !== MINISTRY_OF_FOREST_ID) {
crumbsList.push({ name: 'Review Seedlots', path: ROUTES.TSC_SEEDLOTS_TABLE });
} else {
crumbsList.push({ name: 'My seedlots', path: ROUTES.MY_SEEDLOTS });
}
crumbsList.push({
name: `Seedlot ${seedlotNumber}`,
path: `${addParamToPath(ROUTES.SEEDLOT_DETAILS, seedlotNumber)}`
});
return crumbsList;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { EmptyMultiOptObj } from '../../../shared-constants/shared-constants';
import { EmptyMultiOptObj, MINISTRY_OF_FOREST_ID } from '../../../shared-constants/shared-constants';
import MultiOptionsObj from '../../../types/MultiOptionsObject';
import {
CollectionFormSubmitType, ExtractionFormSubmitType, InterimFormSubmitType, OrchardFormSubmitType,
Expand Down Expand Up @@ -87,8 +87,8 @@ export const stepMap: StepMap = {
};

export const tscAgencyObj: MultiOptionsObj = {
code: '00012797',
label: '00012797 - Tree Seed Centre - MOF',
code: MINISTRY_OF_FOREST_ID,
label: `${MINISTRY_OF_FOREST_ID} - Tree Seed Centre - MOF`,
description: 'Tree Seed Centre'
};

Expand Down
28 changes: 17 additions & 11 deletions frontend/src/views/Seedlot/EditAClassApplication/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useContext, useEffect } from 'react';
import {
ActionableNotification,
FlexGrid,
Expand All @@ -13,26 +13,26 @@ import { AxiosError } from 'axios';
import { toast } from 'react-toastify';
import { useNavigate, useParams } from 'react-router-dom';

import AuthContext from '../../../contexts/AuthContext';
import { getSeedlotById, patchSeedlotApplicationInfo } from '../../../api-service/seedlotAPI';
import { THREE_HALF_HOURS, THREE_HOURS } from '../../../config/TimeUnits';
import getVegCodes from '../../../api-service/vegetationCodeAPI';
import LotApplicantAndInfoForm from '../../../components/LotApplicantAndInfoForm';
import ROUTES from '../../../routes/constants';
import { SeedlotType } from '../../../types/SeedlotType';
import { SeedlotPatchPayloadType, SeedlotRegFormType } from '../../../types/SeedlotRegistrationTypes';
import MultiOptionsObj from '../../../types/MultiOptionsObject';
import PageTitle from '../../../components/PageTitle';
import { THREE_HALF_HOURS, THREE_HOURS } from '../../../config/TimeUnits';
import focusById from '../../../utils/FocusUtils';
import ROUTES from '../../../routes/constants';
import ErrorToast from '../../../components/Toast/ErrorToast';
import Breadcrumbs from '../../../components/Breadcrumbs';
import { ErrToastOption } from '../../../config/ToastifyConfig';
import { getForestClientStringInput } from '../../../utils/ForestClientUtils';
import { getBooleanInputObj, getOptionsInputObj, getStringInputObj } from '../../../utils/FormInputUtils';
import { getSpeciesOptionByCode } from '../../../utils/SeedlotUtils';
import { addParamToPath } from '../../../utils/PathUtils';
import { getMultiOptList } from '../../../utils/MultiOptionsUtils';

import { getBreadcrumbs } from './utils';
import { getSeedlotBreadcrumbs } from '../../../utils/BreadcrumbUtils';
import LotApplicantAndInfoForm from '../../../components/LotApplicantAndInfoForm';
import PageTitle from '../../../components/PageTitle';
import ErrorToast from '../../../components/Toast/ErrorToast';
import Breadcrumbs from '../../../components/Breadcrumbs';
import { ErrToastOption } from '../../../config/ToastifyConfig';

import './styles.scss';

Expand All @@ -47,6 +47,8 @@ const EditAClassApplicationForm = ({ isReview, applicantData, setApplicantData }
const navigate = useNavigate();
const { seedlotNumber } = useParams();

const { isTscAdmin } = useContext(AuthContext);

const vegCodeQuery = useQuery({
queryKey: ['vegetation-codes'],
queryFn: getVegCodes,
Expand Down Expand Up @@ -160,7 +162,11 @@ const EditAClassApplicationForm = ({ isReview, applicantData, setApplicantData }
: (
<>
<Row className="breadcrumb-row">
<Breadcrumbs crumbs={getBreadcrumbs(seedlotNumber!)} />
<Breadcrumbs
crumbs={
getSeedlotBreadcrumbs(seedlotNumber!, applicantClientNumber!, isTscAdmin)
}
/>
</Row>
<Row className="title-row">
<PageTitle
Expand Down
17 changes: 0 additions & 17 deletions frontend/src/views/Seedlot/EditAClassApplication/utils.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ interface ApplicantSeedlotInformationProps {
seedlotNumber?: string;
applicant?: SeedlotApplicantType;
isFetching: boolean;
hideEditButton: boolean;
}

const ApplicantInformation = (
{ seedlotNumber, applicant, isFetching }: ApplicantSeedlotInformationProps
) => {
const ApplicantInformation = ({
seedlotNumber,
applicant,
isFetching,
hideEditButton
}: ApplicantSeedlotInformationProps) => {
const navigate = useNavigate();

return (
Expand Down Expand Up @@ -146,19 +150,25 @@ const ApplicantInformation = (
}
</Column>
</Row>
<Row>
<Column>
<Button
kind="tertiary"
size="md"
className="section-btn"
renderIcon={Edit}
onClick={() => navigate(addParamToPath(ROUTES.SEEDLOT_A_CLASS_EDIT, seedlotNumber ?? ''))}
>
Edit applicant
</Button>
</Column>
</Row>
{
hideEditButton
? null
: (
<Row>
<Column>
<Button
kind="tertiary"
size="md"
className="section-btn"
renderIcon={Edit}
onClick={() => navigate(addParamToPath(ROUTES.SEEDLOT_A_CLASS_EDIT, seedlotNumber ?? ''))}
>
Edit applicant
</Button>
</Column>
</Row>
)
}
</FlexGrid>
);
};
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/views/Seedlot/SeedlotDetails/FormProgress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Edit } from '@carbon/icons-react';

import { getAClassSeedlotProgressStatus } from '../../../../api-service/seedlotAPI';
import { ProgressIndicatorConfig } from '../../ContextContainerClassA/definitions';
import DetailSection from '../../../../components/DetailSection';
import SeedlotRegistrationProgress from '../../../../components/SeedlotRegistrationProgress';
import NetworkError from '../../../../components/NetworkError';
import { completeProgressConfig, initialProgressConfig } from '../../ContextContainerClassA/constants';
Expand All @@ -19,7 +20,6 @@ import { QueryStatusType } from '../../../../types/QueryStatusType';
import { SeedlotStatusCode } from '../../../../types/SeedlotType';

import './styles.scss';
import DetailSection from '../../../../components/DetailSection';

interface FormProgressProps {
seedlotNumber?: string;
Expand Down Expand Up @@ -115,7 +115,14 @@ const FormProgress = (
onClick={() => navigate(addParamToPath(ROUTES.SEEDLOT_A_CLASS_REGISTRATION, seedlotNumber ?? ''))}
disabled={getSeedlotQueryStatus === 'loading'}
>
{seedlotStatusCode === 'SUB' ? 'View your seedlot' : 'Edit seedlot form'}
{
seedlotStatusCode === 'SUB'
|| seedlotStatusCode === 'EXP'
|| seedlotStatusCode === 'COM'
|| seedlotStatusCode === 'APP'
? 'View your seedlot'
: 'Edit seedlot form'
}
</Button>
</Column>
</Row>
Expand Down
Loading

0 comments on commit b22bd18

Please sign in to comment.