Skip to content

Commit

Permalink
Merge branch 'develop' into mds-6285-esup-detonator-magazine-missing
Browse files Browse the repository at this point in the history
  • Loading branch information
asinn134 committed Dec 14, 2024
2 parents 106d4ed + 3ba16b8 commit 7497fd4
Show file tree
Hide file tree
Showing 95 changed files with 2,430 additions and 934 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/permit-service.unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
env:
DOCKER_BUILDKIT: 1
run: |
docker compose -f docker-compose.yaml run -e AZURE_API_KEY=testkey haystack coverage run -m pytest
docker compose -f docker-compose.yaml run -e AZURE_API_KEY=testkey haystack coverage xml
docker compose -f docker-compose.yaml run -e AZURE_API_KEY=testkey -e DOCUMENTINTELLIGENCE_API_KEY=testkey haystack coverage run -m pytest
docker compose -f docker-compose.yaml run -e AZURE_API_KEY=testkey -e DOCUMENTINTELLIGENCE_API_KEY=testkey haystack coverage xml
sed -i "s/<source>\/code/<source>\/github\/workspace\/services\/permits/g" services/permits/coverage.xml
- name: Upload test coverage results
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ services:
container_name: core_api_celery
build:
context: services/core-api
entrypoint: ./celery.sh
entrypoint: ./celery_dev.sh
ports:
- 5556:5555
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE permit_conditions ADD COLUMN IF NOT EXISTS meta JSONB NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE mine_report_permit_requirement ADD COLUMN report_name VARCHAR(255) NULL;
26 changes: 26 additions & 0 deletions migrations/sql/V2024.12.10.15.15__create_users_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE TABLE "user"
(
sub VARCHAR PRIMARY KEY,
email VARCHAR NOT NULL,
given_name VARCHAR NOT NULL,
family_name VARCHAR NOT NULL,
display_name VARCHAR NOT NULL,
idir_username VARCHAR NOT NULL,
identity_provider VARCHAR NOT NULL,
idir_user_guid VARCHAR NOT NULL,
last_logged_in TIMESTAMPTZ,
create_user VARCHAR(255) NOT NULL,
create_timestamp timestamp with time zone DEFAULT now() NOT NULL,
update_user VARCHAR(255) NOT NULL,
update_timestamp timestamp with time zone DEFAULT now() NOT NULL,
deleted_ind BOOLEAN DEFAULT false
);

ALTER TABLE "user"
OWNER TO mds;

--
-- Name: TABLE user; Type: COMMENT; Schema: public; Owner: mds
--

COMMENT ON TABLE "user" IS 'User Profile data sourced from keycloak';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE permit_conditions_version ADD COLUMN IF NOT EXISTS meta JSONB NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- This file was generated by the generate_history_table_ddl command
-- The file contains the corresponding history table definition for the {table} table
CREATE TABLE user_version (
create_user VARCHAR(60),
create_timestamp TIMESTAMP WITHOUT TIME ZONE,
update_user VARCHAR(60),
update_timestamp TIMESTAMP WITHOUT TIME ZONE,
deleted_ind BOOLEAN default FALSE,
sub VARCHAR NOT NULL,
email VARCHAR,
given_name VARCHAR,
family_name VARCHAR,
display_name VARCHAR,
idir_username VARCHAR,
identity_provider VARCHAR,
idir_user_guid VARCHAR,
transaction_id BIGINT NOT NULL,
end_transaction_id BIGINT,
operation_type SMALLINT NOT NULL,
PRIMARY KEY (sub, transaction_id)
);
CREATE INDEX ix_user_version_operation_type ON user_version (operation_type);
CREATE INDEX ix_user_version_end_transaction_id ON user_version (end_transaction_id);
CREATE INDEX ix_user_version_transaction_id ON user_version (transaction_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- This file was generated by the generate_history_table_ddl command
-- The file contains the data migration to backfill history records for the {table} table
with transaction AS (insert into transaction(id) values(DEFAULT) RETURNING id)
insert into user_version (transaction_id, operation_type, end_transaction_id, "create_user", "create_timestamp", "update_user", "update_timestamp", "deleted_ind", "sub", "email", "given_name", "family_name", "display_name", "idir_username", "identity_provider", "idir_user_guid")
select t.id, '0', null, "create_user", "create_timestamp", "update_user", "update_timestamp", "deleted_ind", "sub", "email", "given_name", "family_name", "display_name", "idir_username", "identity_provider", "idir_user_guid"
from "user",transaction t;
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ const ProjectDescriptionTab = () => {
<Typography.Title level={2}>Project Description Overview</Typography.Title>
</Col>
<Col>
<Button onClick={handleViewProjectDescriptionClicked} type="primary">
<Button onClick={handleViewProjectDescriptionClicked} type="primary" data-cy="view-project-description-details-button">
View Project Description Details
</Button>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exports[`ProjectDescriptionTab renders properly 1`] = `
>
<button
class="ant-btn ant-btn-primary"
data-cy="view-project-description-details-button"
type="button"
>
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ export const AuthorizationsInvolved: FC<ProjectSummaryFormComponentProps> = ({ f

const systemFlag = useSelector(getSystemFlag);
const isCore = systemFlag === SystemFlagEnum.core;
const envFieldsDisabled = areAuthEnvFieldsDisabled(systemFlag, formValues?.status_code);
const envFieldsDisabled = areAuthEnvFieldsDisabled(systemFlag, formValues?.status_code, formValues?.confirmation_of_submission);

const handleChange = (e, code) => {
if (e.target.checked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,18 @@ export const ProjectManagement: FC = () => {
component={RenderSelect}
data={projectLeadData}
/>
{isProjectLeadAssigned && (
<Paragraph>
<b>Warning:</b> Unassigning the project lead will set the Project Description status to
'Submitted' in MineSpace. Ensure the status is correct before proceeding.
</Paragraph>
)}
{!isNewProject && !isProjectLeadAssigned && (
<Alert
message="This project does not have a Project Lead"
description={<p>Please assign a Project Lead to this project.</p>}
message="Assign a Project Lead"
description={<p>Assigning a Project Lead will set the Project Description status
to 'Assigned' in Core and 'Submitted' in MineSpace. Please ensure the project
is set at the correct status before continuing.</p>}
type="warning"
showIcon
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ export const ProjectSummaryForm: FC<ProjectSummaryFormProps> = ({
getProjectSummaryAuthorizationTypesArray
);
const formValues = useSelector(getFormValues(FORM.ADD_EDIT_PROJECT_SUMMARY)) as IProjectSummaryForm;
const { status_code } = formValues ?? {};
const { status_code, confirmation_of_submission } = formValues ?? {};

const fieldsDisabled = areFieldsDisabled(systemFlag, status_code);
const fieldsDisabled = areFieldsDisabled(systemFlag, status_code, confirmation_of_submission);
const docFieldsDisabled = areDocumentFieldsDisabled(systemFlag, status_code);
const authFieldsDisabled = areAuthFieldsDisabled(systemFlag, status_code);
const authFieldsDisabled = areAuthFieldsDisabled(systemFlag, status_code, confirmation_of_submission);

const handleTransformPayload = (valuesFromForm: any) => {
return formatProjectPayload(valuesFromForm, { projectSummaryAuthorizationTypesArray });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,13 @@ exports[`Project Management renders properly 1`] = `
<div
class="ant-alert-message"
>
This project does not have a Project Lead
Assign a Project Lead
</div>
<div
class="ant-alert-description"
>
<p>
Please assign a Project Lead to this project.
Assigning a Project Lead will set the Project Description status to 'Assigned' in Core and 'Submitted' in MineSpace. Please ensure the project is set at the correct status before continuing.
</p>
</div>
</div>
Expand Down
16 changes: 14 additions & 2 deletions services/common/src/components/projects/projectUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,20 @@ TEST_PARAMETERS.forEach(
expect(result).toBe(true);
});
});

if (label !== "areDocumentFieldsDisabled") {
const noSubmissionMinespaceDisabledStatuses = [...msDisabledStatuses].filter((status) => status !== "ASG");
noSubmissionMinespaceDisabledStatuses.forEach((status) => {
it(`MS status: ${status} Should return true (disabled) when submission has not occured`, () => {
const result = testFunction(SystemFlagEnum.ms, status);
expect(result).toBe(true);
});
})
}

msDisabledStatuses.forEach((status) => {
it(`MS status: ${status} Should return true (disabled)`, () => {
const result = testFunction(SystemFlagEnum.ms, status);
it(`MS status: ${status} Should return true (disabled) when submission has occured`, () => {
const result = testFunction(SystemFlagEnum.ms, status, true);
expect(result).toBe(true);
});
});
Expand All @@ -72,6 +83,7 @@ TEST_PARAMETERS.forEach(
expect(result).toBe(false);
});
});

msEnabledStatuses.forEach((status) => {
it(`MS status: ${status} Should return false (enabled)`, () => {
const result = testFunction(SystemFlagEnum.ms, status);
Expand Down
17 changes: 6 additions & 11 deletions services/common/src/components/projects/projectUtils.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
import { PROJECT_STATUS_CODES, SystemFlagEnum } from "@mds/common/constants/enums";
import { memoize } from "lodash";

export const areFieldsDisabled = memoize((systemFlag: SystemFlagEnum, projectSummaryStatusCode: string) => {
export const areFieldsDisabled = memoize((systemFlag: SystemFlagEnum, projectSummaryStatusCode: string, confirmationOfSubmission?: boolean) => {
// Return false (enabled) if status = "" => "Not Started"
const isStatusInEnum = (<any>Object).values(PROJECT_STATUS_CODES).includes(projectSummaryStatusCode);

if (!isStatusInEnum) return false;
const projectSummaryStatus = projectSummaryStatusCode as PROJECT_STATUS_CODES;

const disabledStatuses = [PROJECT_STATUS_CODES.WDN, PROJECT_STATUS_CODES.COM];

const enabledStatuses = systemFlag === SystemFlagEnum.core
? [PROJECT_STATUS_CODES.DFT, PROJECT_STATUS_CODES.ASG, PROJECT_STATUS_CODES.UNR, PROJECT_STATUS_CODES.CHR, PROJECT_STATUS_CODES.OHD, PROJECT_STATUS_CODES.SUB]
: [PROJECT_STATUS_CODES.DFT, PROJECT_STATUS_CODES.CHR];
: [PROJECT_STATUS_CODES.DFT, PROJECT_STATUS_CODES.CHR, ...(!confirmationOfSubmission ? [PROJECT_STATUS_CODES.ASG] : [])];

if (disabledStatuses.includes(projectSummaryStatus)) return true;
return !enabledStatuses.includes(projectSummaryStatus);

},
(systemFlag: SystemFlagEnum, projectSummaryStatusCode: string) => `${systemFlag}_${projectSummaryStatusCode}`);

export const areAuthFieldsDisabled = memoize((systemFlag: SystemFlagEnum, projectSummaryStatusCode: string) => {
const fieldsDisabled = areFieldsDisabled(systemFlag, projectSummaryStatusCode);
export const areAuthFieldsDisabled = memoize((systemFlag: SystemFlagEnum, projectSummaryStatusCode: string, confirmationOfSubmission?: boolean) => {
const fieldsDisabled = areFieldsDisabled(systemFlag, projectSummaryStatusCode, confirmationOfSubmission);
if (fieldsDisabled) return true;

const extraDisabledStatuses = [PROJECT_STATUS_CODES.CHR, PROJECT_STATUS_CODES.UNR];
const authDisabled = extraDisabledStatuses.includes(projectSummaryStatusCode as PROJECT_STATUS_CODES)
return authDisabled;
}, (systemFlag: SystemFlagEnum, projectSummaryStatusCode: string) => `${systemFlag}_${projectSummaryStatusCode}`);

export const areAuthEnvFieldsDisabled = memoize((systemFlag, projectSummaryStatusCode) => {
const authFieldsDisabled = areAuthFieldsDisabled(systemFlag, projectSummaryStatusCode);
export const areAuthEnvFieldsDisabled = memoize((systemFlag: SystemFlagEnum, projectSummaryStatusCode: string, confirmationOfSubmission?: boolean) => {
const authFieldsDisabled = areAuthFieldsDisabled(systemFlag, projectSummaryStatusCode, confirmationOfSubmission);
if (authFieldsDisabled) return true;

const extraDisabledStatuses = systemFlag === SystemFlagEnum.core
Expand All @@ -56,7 +52,6 @@ export const areDocumentFieldsDisabled = memoize((systemFlag: SystemFlagEnum, pr

if (disabledStatuses.includes(projectSummaryStatus)) return true;
return !enabledStatuses.includes(projectSummaryStatus);

},
(systemFlag: SystemFlagEnum, projectSummaryStatusCode: string) => `${systemFlag}_${projectSummaryStatusCode}`);

Expand Down
3 changes: 3 additions & 0 deletions services/common/src/constants/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,6 @@ export const REGIONS_LIST = "/regions";
// App Help
export const APP_HELP = (helpKey: string, params?: { system?: string; help_guid?: string }) =>
`/help/${helpKey}?${queryString.stringify(params)}`;

// User
export const USER_PROFILE = () => "/users/profile";
3 changes: 0 additions & 3 deletions services/common/src/constants/networkReducerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ export enum NetworkReducerTypes {
CREATE_PROJECT_LINKS = "CREATE_PROJECT_LINKS",
DELETE_PROJECT_LINK = "DELETE_PROJECT_LINK",

// Core Users
GET_CORE_USERS = "GET_CORE_USERS",

// Incidents
CREATE_MINE_INCIDENT = "CREATE_MINE_INCIDENT",
GET_INCIDENTS = "GET_INCIDENTS",
Expand Down
1 change: 1 addition & 0 deletions services/common/src/constants/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,5 +491,6 @@ export const REPORT_FREQUENCY_HASH = {
"Semi-Annually": 6,
"Annually": 12,
"Bi-Annually": 24,
"Every 5 Years": 60,
"Not Specified": 0,
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export interface IMineReportPermitRequirement {
report_name: string;
mine_report_permit_requirement_id: number;
cim_or_cpo: string;
ministry_recipient: string[];
permit_condition_id: number;
due_date_period_months: number;
initial_due_date: Date;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ export interface IProjectSummaryForm extends Omit<IProjectSummary, "authorizatio
legal_land_desc: string;
facility_pid_pin_crown_file_no: string;
zoning: boolean;
confirmation_of_submission?: boolean;
}
1 change: 1 addition & 0 deletions services/common/src/interfaces/user/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./userInfo.interface";
export * from "./user.interface";
8 changes: 8 additions & 0 deletions services/common/src/interfaces/user/user.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface IUser {
sub: string;
display_name: string;
email: string;
family_name: string;
given_name: string;
last_logged_in: string;
}
20 changes: 0 additions & 20 deletions services/common/src/redux/actionCreators/userActionCreator.js

This file was deleted.

8 changes: 0 additions & 8 deletions services/common/src/redux/actions/userActions.js

This file was deleted.

2 changes: 0 additions & 2 deletions services/common/src/redux/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import searchReducerObject from "./reducers/searchReducer";
import securitiesReducerObject from "./reducers/securitiesReducer";
import staticContentReducerObject from "./reducers/staticContentReducer";
import tailingsReducerObject from "./reducers/tailingsReducer";
import userReducerObject from "./reducers/userReducer";
import varianceReducerObject from "./reducers/varianceReducer";
import workInformationReducerObject from "./reducers/workInformationReducer";
import verifiableCredentialReducerObject from "./reducers/verifiableCredentialReducer";
Expand All @@ -40,7 +39,6 @@ export const permitReducer = permitReducerObject;
export const reportReducer = reportReducerObject;
export const searchReducer = searchReducerObject;
export const staticContentReducer = staticContentReducerObject;
export const userReducer = userReducerObject;
export const varianceReducer = varianceReducerObject;
export const securitiesReducer = securitiesReducerObject;
export const orgbookReducer = orgbookReducerObject;
Expand Down
9 changes: 6 additions & 3 deletions services/common/src/redux/reducers/rootReducerShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
securitiesReducer,
staticContentReducer,
tailingsReducer,
userReducer,
varianceReducer,
verifiableCredentialReducer,
workInformationReducer,
Expand All @@ -37,13 +36,17 @@ import regionsReducer from "@mds/common/redux/slices/regionsSlice";
import complianceCodeReducer, { complianceCodeReducerType } from "../slices/complianceCodesSlice";
import spatialDataReducer, { spatialDataReducerType } from "../slices/spatialDataSlice";
import permitServiceReducer, { permitServiceReducerType } from "../slices/permitServiceSlice";
import searchConditionCategoriesReducer, { searchConditionCategoriesType } from "../slices/permitConditionCategorySlice";
import searchConditionCategoriesReducer, {
searchConditionCategoriesType,
} from "../slices/permitConditionCategorySlice";
import helpReducer, { helpReducerType } from "../slices/helpSlice";

const networkReducers = Object.fromEntries(Object.entries(NetworkReducerTypes).map(([key, value]) =>
[NetworkReducerTypes[key], createReducer(networkReducer, value)]
));

import userReducer, { userReducerType } from "@mds/common/redux/slices/userSlice";

export const sharedReducer = {
...activityReducer,
...authenticationReducer,
Expand All @@ -67,7 +70,6 @@ export const sharedReducer = {
...securitiesReducer,
...staticContentReducer,
...tailingsReducer,
...userReducer,
...varianceReducer,
...verifiableCredentialReducer,
...workInformationReducer,
Expand All @@ -81,5 +83,6 @@ export const sharedReducer = {
[permitServiceReducerType]: permitServiceReducer,
[helpReducerType]: helpReducer,
[searchConditionCategoriesType]: searchConditionCategoriesReducer,
[userReducerType]: userReducer,
...networkReducers
};
Loading

0 comments on commit 7497fd4

Please sign in to comment.