Skip to content

Commit

Permalink
Merge pull request #1019 from bcgov/dev
Browse files Browse the repository at this point in the history
BugFix: Release Dev to Test
  • Loading branch information
NickPhura authored Apr 28, 2023
2 parents 790d16d + 586a61a commit 8f9e869
Show file tree
Hide file tree
Showing 28 changed files with 472 additions and 2,734 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PROJECT_ROLE, SYSTEM_ROLE } from '../../../../../constants/roles';
import { getDBConnection } from '../../../../../database/db';
import { authorizeRequestHandler } from '../../../../../request-handlers/security/authorization';
import { AttachmentService } from '../../../../../services/attachment-service';
import { HistoryPublishService } from '../../../../../services/history-publish-service';
import { deleteFileFromS3 } from '../../../../../utils/file-utils';
import { getLogger } from '../../../../../utils/logger';
import { attachmentApiDocObject } from '../../../../../utils/shared-api-docs';
Expand Down Expand Up @@ -103,13 +104,16 @@ export function deleteAttachment(): RequestHandler {
await connection.open();

const attachmentService = new AttachmentService(connection);
const historyPublishService = new HistoryPublishService(connection);

let deleteResult: { key: string };
if (req.body.attachmentType === ATTACHMENT_TYPE.REPORT) {
await historyPublishService.deleteProjectReportAttachmentPublishRecord(Number(req.params.attachmentId));
await attachmentService.deleteProjectReportAttachmentAuthors(Number(req.params.attachmentId));

deleteResult = await attachmentService.deleteProjectReportAttachment(Number(req.params.attachmentId));
} else {
await historyPublishService.deleteProjectAttachmentPublishRecord(Number(req.params.attachmentId));
deleteResult = await attachmentService.deleteProjectAttachment(Number(req.params.attachmentId));
}

Expand Down
38 changes: 38 additions & 0 deletions api/src/repositories/history-publish-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,44 @@ export class HistoryPublishRepository extends BaseRepository {
await this.connection.sql(sqlStatement);
}

/**
* Deletes a record from `project_attachment_publish` for a given attachment id.
*
* @param {number} projectAttachmentId
* @return {*} {Promise<void>}
* @memberof HistoryPublishRepository
*/
async deleteProjectAttachmentPublishRecord(projectAttachmentId: number): Promise<void> {
const sqlStatement = SQL`
delete
from
project_attachment_publish
where
project_attachment_id = ${projectAttachmentId};
`;

await this.connection.sql(sqlStatement);
}

/**
* Deletes a record from `project_report_publish` for a given attachment id.
*
* @param {number} projectAttachmentId
* @return {*} {Promise<void>}
* @memberof HistoryPublishRepository
*/
async deleteProjectReportAttachmentPublishRecord(projectAttachmentId: number): Promise<void> {
const sqlStatement = SQL`
delete
from
project_report_publish
where
project_report_attachment_id = ${projectAttachmentId};
`;

await this.connection.sql(sqlStatement);
}

/**
* Gets the count of unpublished survey attachments
*
Expand Down
6 changes: 3 additions & 3 deletions api/src/repositories/user-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ export class UserRepository extends BaseRepository {
ON
uis.user_identity_source_id = su.user_identity_source_id
WHERE
su.user_identifier = ${userIdentifier}
su.user_identifier = ${userIdentifier.toLowerCase()}
AND
uis.name = ${identitySource}
uis.name = ${identitySource.toUpperCase()}
GROUP BY
su.system_user_id,
su.record_end_date,
Expand Down Expand Up @@ -229,7 +229,7 @@ export class UserRepository extends BaseRepository {
WHERE
name = ${identitySource.toUpperCase()}
),
${userIdentifier},
${userIdentifier.toLowerCase()},
now()
)
RETURNING
Expand Down
22 changes: 22 additions & 0 deletions api/src/services/history-publish-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,28 @@ export class HistoryPublishService extends DBService {
return this.historyRepository.deleteSurveyReportAttachmentPublishRecord(surveyReportAttachmentId);
}

/**
* Deletes a record from `project_attachment_publish` for a given attachment id.
*
* @param {number} surveyAttachmentId
* @return {*} {Promise<void>}
* @memberof HistoryPublishService
*/
async deleteProjectAttachmentPublishRecord(surveyAttachmentId: number): Promise<void> {
return this.historyRepository.deleteProjectAttachmentPublishRecord(surveyAttachmentId);
}

/**
* Deletes a record from `project_report_publish` for a given attachment id.
*
* @param {number} surveyReportAttachmentId
* @return {*} {Promise<void>}
* @memberof HistoryPublishService
*/
async deleteProjectReportAttachmentPublishRecord(surveyReportAttachmentId: number): Promise<void> {
return this.historyRepository.deleteProjectReportAttachmentPublishRecord(surveyReportAttachmentId);
}

/**
* Returns true if a given survey has any unpublished attachments and false if no unpublished attachments are found
*
Expand Down
2 changes: 0 additions & 2 deletions app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Ionic App" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script type="text/javascript" src="https://quartech.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-T/sb53l8/b/24/a44af77267a987a660377e5c46e0fb64/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js?locale=en-US&collectorId=d8488794"></script>
</head>

<body>
<div id="root"></div>
</body>

</html>
15 changes: 9 additions & 6 deletions app/src/components/attachments/list/AttachmentsList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Paper } from '@material-ui/core';
import Box from '@material-ui/core/Box';
import { grey } from '@material-ui/core/colors';
import Link from '@material-ui/core/Link';
Expand Down Expand Up @@ -158,11 +157,15 @@ function AttachmentsTableRow<T extends IGetProjectAttachment | IGetSurveyAttachm
function NoAttachments() {
const classes = useStyles();
return (
<Paper variant="outlined" className={classes.importFile}>
<Box display="flex" flex="1 1 auto" alignItems="center" justifyContent="center" p={2}>
<span data-testid="observations-nodata">No Documents</span>
</Box>
</Paper>
<Box
display="flex"
flex="1 1 auto"
alignItems="center"
justifyContent="center"
p={2}
className={classes.importFile}>
<span data-testid="observations-nodata">No Documents</span>
</Box>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ exports[`EditDialog matches snapshot when open, with error message 1`] = `
<form>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="testField"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled Mui-required Mui-required"
Expand All @@ -76,6 +75,7 @@ exports[`EditDialog matches snapshot when open, with error message 1`] = `
<textarea
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputMultiline MuiOutlinedInput-inputMultiline"
data-testid="testField"
id="testField"
name="testField"
required=""
Expand Down Expand Up @@ -221,7 +221,6 @@ exports[`EditDialog matches the snapshot when open, with no error message 1`] =
<form>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="testField"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled Mui-required Mui-required"
Expand All @@ -244,6 +243,7 @@ exports[`EditDialog matches the snapshot when open, with no error message 1`] =
<textarea
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputMultiline MuiOutlinedInput-inputMultiline"
data-testid="testField"
id="testField"
name="testField"
required=""
Expand Down
4 changes: 3 additions & 1 deletion app/src/components/fields/CustomTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const CustomTextField: React.FC<ICustomTextField> = (props) => {
name={name}
label={label}
id={name}
data-testid={name}
onChange={handleChange}
variant="outlined"
value={get(values, name)}
fullWidth={true}
error={get(touched, name) && Boolean(get(errors, name))}
helperText={get(touched, name) && get(errors, name)}
inputProps={{
'data-testid': name
}}
{...other}
/>
);
Expand Down
16 changes: 10 additions & 6 deletions app/src/components/surveys/SurveysList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Paper } from '@material-ui/core';
import Box from '@material-ui/core/Box';
import Link from '@material-ui/core/Link';
import makeStyles from '@material-ui/core/styles/makeStyles';
import Table from '@material-ui/core/Table';
Expand Down Expand Up @@ -125,11 +125,15 @@ const SurveysList: React.FC = () => {
function NoSurveys() {
const classes = useStyles();
return (
<Paper variant="outlined" className={classes.importFile}>
<Box display="flex" flex="1 1 auto" alignItems="center" justifyContent="center" p={2}>
<span data-testid="observations-nodata">No Surveys</span>
</Box>
</Paper>
<Box
display="flex"
flex="1 1 auto"
alignItems="center"
justifyContent="center"
p={2}
className={classes.importFile}>
<span data-testid="observations-nodata">No Surveys</span>
</Box>
);
}

Expand Down
30 changes: 24 additions & 6 deletions app/src/features/projects/components/ProjectFundingForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { act, fireEvent, render, waitFor } from '@testing-library/react';
import { IMultiAutocompleteFieldOption } from 'components/fields/MultiAutocompleteFieldVariableSize';
import { Formik } from 'formik';
import React from 'react';
import { codes } from 'test-helpers/code-helpers';
import ProjectStepComponents from 'utils/ProjectStepComponents';
import ProjectFundingForm, {
IInvestmentActionCategoryOption,
IProjectFundingForm,
Expand Down Expand Up @@ -93,7 +91,12 @@ describe('ProjectFundingForm', () => {
validateOnBlur={true}
validateOnChange={false}
onSubmit={async () => {}}>
{() => <ProjectStepComponents component="ProjectFunding" codes={codes} />}
{() => (
<ProjectFundingForm
funding_sources={funding_sources}
investment_action_category={investment_action_category}
/>
)}
</Formik>
);

Expand Down Expand Up @@ -140,7 +143,12 @@ describe('ProjectFundingForm', () => {
validateOnBlur={true}
validateOnChange={false}
onSubmit={async () => {}}>
{() => <ProjectStepComponents component="ProjectFunding" codes={codes} />}
{() => (
<ProjectFundingForm
funding_sources={funding_sources}
investment_action_category={investment_action_category}
/>
)}
</Formik>
);

Expand Down Expand Up @@ -182,7 +190,12 @@ describe('ProjectFundingForm', () => {
validateOnBlur={true}
validateOnChange={false}
onSubmit={async () => {}}>
{() => <ProjectStepComponents component="ProjectFunding" codes={codes} />}
{() => (
<ProjectFundingForm
funding_sources={funding_sources}
investment_action_category={investment_action_category}
/>
)}
</Formik>
);

Expand Down Expand Up @@ -232,7 +245,12 @@ describe('ProjectFundingForm', () => {
validateOnBlur={true}
validateOnChange={false}
onSubmit={async () => {}}>
{() => <ProjectStepComponents component="ProjectFunding" codes={codes} />}
{() => (
<ProjectFundingForm
funding_sources={funding_sources}
investment_action_category={investment_action_category}
/>
)}
</Formik>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ exports[`ProjectFundingItemForm auto selection of investment action category wor
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="agency_project_id"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined"
Expand All @@ -109,6 +108,7 @@ exports[`ProjectFundingItemForm auto selection of investment action category wor
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="agency_project_id"
id="agency_project_id"
name="agency_project_id"
type="text"
Expand Down Expand Up @@ -401,7 +401,6 @@ exports[`ProjectFundingItemForm auto selection of investment action category wor
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="agency_project_id"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined"
Expand All @@ -417,6 +416,7 @@ exports[`ProjectFundingItemForm auto selection of investment action category wor
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="agency_project_id"
id="agency_project_id"
name="agency_project_id"
type="text"
Expand Down Expand Up @@ -780,7 +780,6 @@ exports[`ProjectFundingItemForm renders correctly with agency 1 1`] = `
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="agency_project_id"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
Expand All @@ -796,6 +795,7 @@ exports[`ProjectFundingItemForm renders correctly with agency 1 1`] = `
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="agency_project_id"
id="agency_project_id"
name="agency_project_id"
type="text"
Expand Down Expand Up @@ -1159,7 +1159,6 @@ exports[`ProjectFundingItemForm renders correctly with agency 2 1`] = `
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="agency_project_id"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
Expand All @@ -1175,6 +1174,7 @@ exports[`ProjectFundingItemForm renders correctly with agency 2 1`] = `
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="agency_project_id"
id="agency_project_id"
name="agency_project_id"
type="text"
Expand Down Expand Up @@ -1467,7 +1467,6 @@ exports[`ProjectFundingItemForm renders correctly with any agency other than 1 o
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="agency_project_id"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
Expand All @@ -1483,6 +1482,7 @@ exports[`ProjectFundingItemForm renders correctly with any agency other than 1 o
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="agency_project_id"
id="agency_project_id"
name="agency_project_id"
type="text"
Expand Down Expand Up @@ -1777,7 +1777,6 @@ exports[`ProjectFundingItemForm renders correctly with default empty values 1`]
>
<div
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
data-testid="agency_project_id"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined"
Expand All @@ -1793,6 +1792,7 @@ exports[`ProjectFundingItemForm renders correctly with default empty values 1`]
<input
aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input"
data-testid="agency_project_id"
id="agency_project_id"
name="agency_project_id"
type="text"
Expand Down
Loading

0 comments on commit 8f9e869

Please sign in to comment.