Skip to content

Commit

Permalink
Merge branch 'main' into feat-env-increase-db-pre-memory
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasdc committed Jul 19, 2024
2 parents 211ca18 + 2560e1d commit 6aa40ea
Show file tree
Hide file tree
Showing 37 changed files with 1,389 additions and 818 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.173.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.173.1...v1.173.2) (2024-07-19)

### Bug Fixes

- sow upload error ([38aab1c](https://github.com/bcgov/CONN-CCBC-portal/commit/38aab1cddfcad77759a4da84335a9f7a7cf2788a))

## [1.173.1](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.173.0...v1.173.1) (2024-07-19)

# [1.173.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.172.0...v1.173.0) (2024-07-18)

### Features

- show change in project title and org name ([3573ff8](https://github.com/bcgov/CONN-CCBC-portal/commit/3573ff8d9ae2696123f2236568c9e7520b6eac0f))

# [1.172.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.171.2...v1.172.0) (2024-07-17)

### Bug Fixes
Expand Down
6 changes: 4 additions & 2 deletions app/backend/lib/sow-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const sowUpload = Router();
const processSow: ExpressMiddleware = async (req, res) => {
const authRole = getAuthRole(req);
const isRoleAuthorized =
authRole?.pgRole === 'ccbc_admin' || authRole?.pgRole === 'ccbc_analyst';
authRole?.pgRole === 'ccbc_admin' ||
authRole?.pgRole === 'ccbc_analyst' ||
authRole?.pgRole === 'cbc_admin';

if (!isRoleAuthorized) {
return res.status(404).end();
Expand Down Expand Up @@ -91,7 +93,7 @@ const processSow: ExpressMiddleware = async (req, res) => {
const tab7 = await LoadTab7Data(sowId, wb, '7', req);
exportError = (tab7 as any)?.error;
if (exportError) {
errorList.push({ level: 'tab8', error: exportError });
errorList.push({ level: 'tab7', error: exportError });
}
const tab8 = await LoadTab8Data(sowId, wb, '8', req);
exportError = (tab8 as any)?.error;
Expand Down
8 changes: 2 additions & 6 deletions app/components/Analyst/CBC/AssignField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useFeature } from '@growthbook/growthbook-react';
import { useState } from 'react';
import { graphql, useFragment } from 'react-relay';
import { useUpdateCbcDataByRowIdMutation } from 'schema/mutations/cbc/updateCbcData';
Expand All @@ -19,7 +18,7 @@ const AssignField = ({
fieldOptions,
fieldType,
cbc,
isFormEditMode,
isHeaderEditable,
}) => {
const queryFragment = useFragment(
graphql`
Expand Down Expand Up @@ -49,9 +48,6 @@ const AssignField = ({
: jsonData[fieldName] || null
);

const allowEdit =
(useFeature('show_cbc_edit').value ?? false) && !isFormEditMode;

const handleChange = (e) => {
const { rowId } = queryFragment.cbcDataByCbcId.edges[0].node;
updateField({
Expand Down Expand Up @@ -88,7 +84,7 @@ const AssignField = ({
key={option}
value={option}
selected={fieldValue === option}
disabled={!allowEdit}
disabled={!isHeaderEditable}
>
{option}
</option>
Expand Down
2 changes: 1 addition & 1 deletion app/components/Analyst/CBC/CbcAnalystLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Props {
const CbcAnalystLayout: React.FC<Props> = ({
children,
query,
isFormEditMode = false,
isFormEditMode = true,
}) => {
const queryFragment = useFragment(
graphql`
Expand Down
99 changes: 99 additions & 0 deletions app/components/Analyst/CBC/CbcAssignProjectType.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { useState } from 'react';
import { graphql, useFragment } from 'react-relay';
import { useUpdateCbcDataByRowIdMutation } from 'schema/mutations/cbc/updateCbcData';
import styled from 'styled-components';

interface Props {
cbc: any;
isHeaderEditable: boolean;
}

const StyledDropdown = styled.select`
text-overflow: ellipsis;
color: ${(props) => props.theme.color.links};
background-color: ${(props) => props.theme.color.white};
border: 1px solid ${(props) => props.theme.color.borderGrey};
padding: 0 8px;
max-width: 100%;
border-radius: 4px;
`;

const CbcAssignProjectType: React.FC<Props> = ({ cbc, isHeaderEditable }) => {
const queryFragment = useFragment(
graphql`
fragment CbcAssignProjectType_query on Cbc {
cbcDataByCbcId(first: 500) @connection(key: "CbcData__cbcDataByCbcId") {
__id
edges {
node {
id
jsonData
sharepointTimestamp
rowId
projectNumber
updatedAt
updatedBy
}
}
}
}
`,
cbc
);
const { rowId, jsonData } =
queryFragment?.cbcDataByCbcId?.edges[0].node || {};
const [projectType, setProjectType] = useState(jsonData?.projectType);
const [updateStatus] = useUpdateCbcDataByRowIdMutation();

const handleAssignProjectType = (e: any) => {
const newProjectType = e.target.value || null;
const cbcDataId = rowId;
updateStatus({
variables: {
input: {
rowId: cbcDataId,
cbcDataPatch: {
jsonData: {
...jsonData,
projectType: newProjectType,
},
},
},
},
onCompleted: () => {
setProjectType(newProjectType);
},
debounceKey: 'cbc_change_status',
});
};
const options = [
'Transport',
'Plan',
'Last-Mile',
'Last-Mile & Transport',
'Last-Mile & Cellular',
'Cellular',
];
return (
<StyledDropdown
id="assign-project-type"
onChange={handleAssignProjectType}
data-testid="assign-cbc-project_type"
>
{options.map((option) => {
return (
<option
key={option}
value={option}
selected={projectType === option}
disabled={!isHeaderEditable}
>
{option}
</option>
);
})}
</StyledDropdown>
);
};

export default CbcAssignProjectType;
9 changes: 3 additions & 6 deletions app/components/Analyst/CBC/CbcChangeStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import styled from 'styled-components';
import statusStyles from 'data/statusStyles';
import { useUpdateCbcDataByRowIdMutation } from 'schema/mutations/cbc/updateCbcData';
import { useState } from 'react';
import { useFeature } from '@growthbook/growthbook-react';

interface DropdownProps {
statusStyles: {
Expand Down Expand Up @@ -70,14 +69,14 @@ interface Props {
cbc: any;
status: string;
statusList: any;
isFormEditMode: boolean;
isHeaderEditable: boolean;
}

const CbcChangeStatus: React.FC<Props> = ({
cbc,
status,
statusList,
isFormEditMode,
isHeaderEditable,
}) => {
const queryFragment = useFragment(
graphql`
Expand All @@ -102,8 +101,6 @@ const CbcChangeStatus: React.FC<Props> = ({
);
const [updateStatus] = useUpdateCbcDataByRowIdMutation();
const [currentStatus, setCurrentStatus] = useState(getStatus(status));
const allowEdit =
(useFeature('show_cbc_edit').value ?? false) && !isFormEditMode;

const handleChange = (e) => {
const newStatus = e.target.value;
Expand Down Expand Up @@ -142,7 +139,7 @@ const CbcChangeStatus: React.FC<Props> = ({
const { description, name, id } = statusType;

return (
<StyledOption value={name} key={id} disabled={!allowEdit}>
<StyledOption value={name} key={id} disabled={!isHeaderEditable}>
{description}
</StyledOption>
);
Expand Down
79 changes: 79 additions & 0 deletions app/components/Analyst/CBC/CbcEditProjectDescription.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { useState } from 'react';
import { graphql, useFragment } from 'react-relay';
import InlineTextArea from 'components/InlineTextArea';
import { useUpdateCbcDataByRowIdMutation } from 'schema/mutations/cbc/updateCbcData';

interface Props {
cbc: any;
isHeaderEditable: boolean;
}

const CbcEditProjectDescription: React.FC<Props> = ({
cbc,
isHeaderEditable,
}) => {
const queryFragment = useFragment(
graphql`
fragment CbcEditProjectDescription_query on Cbc {
cbcDataByCbcId(first: 500) @connection(key: "CbcData__cbcDataByCbcId") {
__id
edges {
node {
id
jsonData
sharepointTimestamp
rowId
projectNumber
updatedAt
updatedBy
}
}
}
}
`,
cbc
);
const { rowId, jsonData } =
queryFragment?.cbcDataByCbcId?.edges[0].node || {};
const [description, setDescription] = useState(jsonData?.projectDescription);
const [isEditing, setIsEditing] = useState(false);
const [updateStatus] = useUpdateCbcDataByRowIdMutation();

const handleSubmit = (value: string) => {
if (value !== description) {
const newDescription = value;
const cbcDataId = rowId;
updateStatus({
variables: {
input: {
rowId: cbcDataId,
cbcDataPatch: {
jsonData: {
...jsonData,
projectDescription: newDescription,
},
},
},
},
onCompleted: () => {
setDescription(newDescription);
setIsEditing(false);
},
debounceKey: 'cbc_change_status',
});
} else {
setIsEditing(false);
}
};
return (
<InlineTextArea
isEditing={isEditing && isHeaderEditable}
placeholder="Click to add project description"
value={description}
onSubmit={(value) => handleSubmit(value)}
setIsEditing={setIsEditing}
/>
);
};

export default CbcEditProjectDescription;
Loading

0 comments on commit 6aa40ea

Please sign in to comment.