Skip to content

Commit

Permalink
Merge branch 'main' into NDT-731-Enable-multiple-Global-Search-options
Browse files Browse the repository at this point in the history
  • Loading branch information
RRanath authored Feb 6, 2025
2 parents c291fe8 + 92e6fb2 commit e5d9858
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 47 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# [1.238.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.237.2...v1.238.0) (2025-02-06)

### Features

- update and group history filters ([c327776](https://github.com/bcgov/CONN-CCBC-portal/commit/c327776ac556ac35cf4f11ff41a542ebdcb20125))

## [1.237.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.237.1...v1.237.2) (2025-02-06)

### Bug Fixes

- email sender wrongly set to dev in prod ([c6adea4](https://github.com/bcgov/CONN-CCBC-portal/commit/c6adea4f7d49a5618539262738e87876d6ca8994))

## [1.237.1](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.237.0...v1.237.1) (2025-02-06)

### Bug Fixes

- distorted conditional approval history ([15403e0](https://github.com/bcgov/CONN-CCBC-portal/commit/15403e0088cefea6964df1c22c702056077fed94))

# [1.237.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.235.1...v1.237.0) (2025-02-05)

### Bug Fixes
Expand Down
8 changes: 4 additions & 4 deletions app/backend/lib/ches/sendEmail.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as Sentry from '@sentry/nextjs';
import getConfig from 'next/config';
import toTitleCase from '../../../utils/formatString';
import config from '../../../config';
import toTitleCase from '../../../utils/formatString';

const CHES_API_URL = config.get('CHES_API_URL');
const namespace = getConfig()?.publicRuntimeConfig?.OPENSHIFT_APP_NAMESPACE;

const sendEmail = async (
token: string,
Expand All @@ -14,15 +13,16 @@ const sendEmail = async (
tag: string,
emailCC: string[] = []
) => {
const environment = toTitleCase(namespace?.split('-')[1] || 'Dev');
const namespace = getConfig()?.publicRuntimeConfig?.OPENSHIFT_APP_NAMESPACE;
const environment = toTitleCase(namespace?.split('-')[1] || '');
try {
const request = {
bodyType: 'html',
body,
cc: emailCC,
delayTs: 0,
encoding: 'utf-8',
from: `CCBC Portal ${environment !== 'Prod' && environment} <[email protected]>`,
from: `CCBC Portal ${environment} <[email protected]>`,
priority: 'normal',
subject,
to: emailTo,
Expand Down
6 changes: 3 additions & 3 deletions app/backend/lib/ches/sendEmailMerge.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as Sentry from '@sentry/nextjs';
import getConfig from 'next/config';
import toTitleCase from '../../../utils/formatString';
import config from '../../../config';
import toTitleCase from '../../../utils/formatString';

const CHES_API_URL = config.get('CHES_API_URL');
const namespace = getConfig()?.publicRuntimeConfig?.OPENSHIFT_APP_NAMESPACE;

export interface Context {
to: string[];
Expand All @@ -22,14 +21,15 @@ const sendEmailMerge = async (
subject: string,
contexts: Contexts
) => {
const namespace = getConfig()?.publicRuntimeConfig?.OPENSHIFT_APP_NAMESPACE;
const environment = toTitleCase(namespace?.split('-')[1] || 'Dev');
try {
const request = {
bodyType: 'html',
body,
contexts,
encoding: 'utf-8',
from: `CCBC Portal ${environment !== 'Prod' && environment} <[email protected]>`,
from: `CCBC Portal ${environment} <[email protected]>`,
priority: 'normal',
subject,
attachments: [],
Expand Down
1 change: 1 addition & 0 deletions app/components/Analyst/History/HistoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ const HistoryContent = ({
'name',
'uuid',
'type',
'letterOfApprovalUpload',
]}
diffSchema={conditionalApprovalSchema}
overrideParent="conditionalApproval"
Expand Down
58 changes: 42 additions & 16 deletions app/components/Analyst/History/HistoryFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,47 @@ interface HistoryFilterProps {
onFilterChange: (newFilters: any) => void;
}

export const filterByType = (historyItem: any, filters: any) =>
!filters?.types?.length || filters?.types?.includes(historyItem.tableName);
const typeLabelMappings: Record<string, string> = {
application_community_progress_report_data: 'Community progress report',
application_dependencies: 'Assessment',
assessment_data: 'Assessment',
application_announced: 'Announcement',
application_announcement: 'Announcement',
project_information_data: 'Funding agreement, SOW & map',
application_sow_data: 'Funding agreement, SOW & map',
application_project_type: 'Project type',
application_status: 'Status',
conditional_approval_data: 'Conditional approval',
application_gis_data: 'Assessment',
form_data: 'Application',
rfi_data: 'RFI',
application_package: 'Package',
application_analyst_lead: 'Lead',
application_milestone_data: 'Milestone report',
change_request_data: 'Amendment',
application_claims_data: 'Claims & Progress Report',
application_gis_assessment_hh: 'Assessment',
};

const getLabelForType = (type: string) =>
typeLabelMappings[type] || toTitleCase(type, '_');

export const filterByType = (historyItem: any, filters: any) => {
const typeLabel = getLabelForType(historyItem.tableName);
return !filters?.types?.length || filters?.types?.includes(typeLabel);
};

export const filterByUser = (historyItem: any, filters: any) =>
!filters?.users?.length || filters?.users?.includes(historyItem.user);

export const getTypeOptions = (historyItems: any[], filters: any) => {
return [
...new Set(
historyItems
.filter(
(item) =>
!filters?.users?.length || filters?.users?.includes(item.user)
)
.map((item) => item.tableName)
),
];
const typeLabels = historyItems
.filter(
(item) => !filters?.users?.length || filters?.users?.includes(item.user)
)
.map((item) => getLabelForType(item.tableName));

return [...new Set(typeLabels)];
};

export const getUserOptions = (historyItems: any[], filters: any) => {
Expand All @@ -35,7 +59,8 @@ export const getUserOptions = (historyItems: any[], filters: any) => {
historyItems
.filter(
(item) =>
!filters?.types?.length || filters?.types?.includes(item.tableName)
!filters?.types?.length ||
filters?.types?.includes(getLabelForType(item.tableName))
)
.map((item) => item.user)
),
Expand All @@ -50,11 +75,12 @@ const HistoryFilter: React.FC<HistoryFilterProps> = ({
const { typeOptions, userOptions } = filterOptions;

const formattedTypeOptions = typeOptions
.filter((type) => type !== 'attachment')
.filter((type) => type !== 'Attachment')
.map((type) => ({
value: type,
label: toTitleCase(type, '_'),
}));
label: getLabelForType(type),
}))
.sort((a, b) => a.label.localeCompare(b.label));

const filterSchema = historyFilter(formattedTypeOptions, userOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3566,29 +3566,24 @@ describe('The filter', () => {
const dropdown = document.querySelector('[role="listbox"]') as HTMLElement;
const options = within(dropdown!).getAllByRole('option');
const optionNames = options.map((option) => option.textContent?.trim());

expect(options.length).toEqual(19);
expect(options.length).toEqual(15);

const expectedOptionNames = [
'Application Dependencies',
'Application Announced',
'Application Sow Data',
'Application Gis Assessment Hh',
'Application Project Type',
'Conditional Approval Data',
'Application Milestone Data',
'Application Claims Data',
'Application Community Progress Report Data',
'Change Request Data',
'Project Information Data',
'Application Package',
'Application Analyst Lead',
'Assessment Data',
'Application Status',
'Application Gis Data',
'Form Data',
'Rfi Data',
'Application Communities',
'Amendment',
'Announcement',
'Application',
'Application communities',
'Assessment',
'Claims & progress report',
'Community progress report',
'Conditional approval',
'Funding agreement, sow & map',
'Lead',
'Milestone report',
'Package',
'Project type',
'Rfi',
'Status',
];

expect(optionNames).toEqual(expect.arrayContaining(expectedOptionNames));
Expand Down Expand Up @@ -3636,12 +3631,12 @@ describe('The filter', () => {
fireEvent.mouseDown(typeFilter);

const applicationOption = await screen.findByRole('option', {
name: /Application Status/i,
name: /Status/i,
});

fireEvent.click(applicationOption);

expect(screen.getByText(/Application Status/)).toBeInTheDocument();
expect(screen.getAllByText(/Status/)[0]).toBeInTheDocument();

expect(screen.queryAllByTestId('history-content-status')).toHaveLength(7);
expect(screen.queryAllByTestId('history-content-package')).toHaveLength(0);
Expand Down
3 changes: 3 additions & 0 deletions db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -802,3 +802,6 @@ tables/application_map_data 2025-01-28T17:53:59Z Rafael Solorzano <61289255+rafa
@1.235.1 2025-02-03T22:52:39Z CCBC Service Account <[email protected]> # release v1.235.1
@1.236.0 2025-02-04T16:28:48Z CCBC Service Account <[email protected]> # release v1.236.0
@1.237.0 2025-02-05T16:25:22Z CCBC Service Account <[email protected]> # release v1.237.0
@1.237.1 2025-02-06T04:18:26Z CCBC Service Account <[email protected]> # release v1.237.1
@1.237.2 2025-02-06T16:41:46Z CCBC Service Account <[email protected]> # release v1.237.2
@1.238.0 2025-02-06T17:33:57Z CCBC Service Account <[email protected]> # release v1.238.0
2 changes: 2 additions & 0 deletions helm/app/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ db:
crunchy-postgres:
pgBackRest:
retention: '1'
volume:
storage: 20Gi
instances:
dataVolumeClaimSpec:
storage: 20Gi
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CONN-CCBC-portal",
"version": "1.237.0",
"version": "1.238.0",
"main": "index.js",
"repository": "https://github.com/bcgov/CONN-CCBC-portal.git",
"author": "Romer, Meherzad CITZ:EX <[email protected]>",
Expand Down

0 comments on commit e5d9858

Please sign in to comment.