Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CE-882 test1 #634

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f9f3cd0
feat: CE-202-Complaint-Type-doesnt-automatically-reclassify-as-an-Enf…
dmitri-korin-bcps Aug 26, 2024
b05a0ca
fix: CE-1008 - WebEOC complaints with very long Suspect and Witness D…
marqueone-ps Aug 26, 2024
96b8c51
feat: CE 981 hide zone and tabs for CEEB users (#597)
gregorylavery Aug 26, 2024
e3dd991
fix: CE-1023 Few layout fixes to actions taken. (#603)
gregorylavery Aug 26, 2024
b2cf910
feat: CE-1004 outcome attachments for CEEB (#606)
Scarlett-Truong Aug 30, 2024
e2a12f0
feat: CE-1013 - Update to Logic that Displays Agency Icon (#600)
marqueone-ps Aug 30, 2024
bd20923
fix: CE-1004 add plus icon to button (#608)
barrfalk Aug 30, 2024
1cac931
fix: CE-1004-fix-attachment-text-casing (#609)
barrfalk Aug 30, 2024
b072e01
feat: CE-976 Admin screen for CEEB (#605)
Scarlett-Truong Aug 30, 2024
8a4bd67
feat: CE-1029 - UI Updates to Complaints Tables (#614)
jeznorth Sep 5, 2024
aff15a7
chore(deps): update jest monorepo (#611)
renovate[bot] Sep 5, 2024
9c17f3f
fix: CE-1036-revert-hwcr-tab-rename (#617)
afwilcox Sep 6, 2024
18f3ebc
fix: Makes the naming in the list consistent. (#618)
gregorylavery Sep 6, 2024
d011ecb
feat: CE-977 create ceeb decison (#607)
marqueone-ps Sep 6, 2024
ba0cfb9
fix: CE-1049 Remove GIR Officer Initials (#622)
afwilcox Sep 9, 2024
beb8193
feat: CE-776 - Keyboard Navigation Improvements - Complaints List Pag…
jeznorth Sep 9, 2024
927ccb6
feat: CE-1003 Add notes to CEEB complaint outcome (#621)
Scarlett-Truong Sep 9, 2024
2c562aa
chore(deps): update postgis/postgis:15-master docker digest to 9e03ed…
renovate[bot] Sep 10, 2024
ccbb38c
feat: CE-1028 - Add Close Button to Desktop Filters (#615)
jeznorth Sep 10, 2024
d891013
fix: CE 1052 Reapply the button styling for Species (#624)
gregorylavery Sep 10, 2024
cb1e766
fix: CE 1017 (#619)
gregorylavery Sep 11, 2024
b28a168
fix: Modifies how the contstraint is added to the feature_agency_xref…
gregorylavery Sep 11, 2024
49d8048
fix: CE-1055 Remove Margins from decision HR (#625)
afwilcox Sep 11, 2024
a937a6d
feat: CE-996-Add Method complaint was received field to Complaint (#626)
barrfalk Sep 12, 2024
4a59540
feat: CE-1002 Allow CEEB users to capture authorization number (#620)
marqueone-ps Sep 13, 2024
dfbff2d
Added github actions for tags
barrfalk Sep 13, 2024
42da105
Update merge-main.yml
barrfalk Sep 13, 2024
ecb1d54
Restructured PR workflows
barrfalk Sep 16, 2024
32e2170
Update pr-version-bump.yml
barrfalk Sep 16, 2024
ecc5138
Update pr-version-bump.yml
barrfalk Sep 16, 2024
2209262
Update pr-version-bump.yml
barrfalk Sep 16, 2024
7972736
Update pr-version-bump.yml
barrfalk Sep 16, 2024
1bc5dbe
Update pr-version-bump.yml
barrfalk Sep 16, 2024
8d2937a
Update pr-version-bump.yml
barrfalk Sep 16, 2024
aae2ba8
Update pr-version-bump.yml
barrfalk Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ jobs:
- name: Set PR Output
run: echo "pr=${{ steps.pr.outputs.pr }}" >> $GITHUB_OUTPUT

create_release:
name: Create GitHub Release (Keep Version)
runs-on: ubuntu-22.04
strategy:
matrix:
package: [backend, frontend, webeoc]
steps:
- uses: actions/checkout@v4

# Retrieve the latest tag (from the release branch)
- name: Get Latest Tag
id: tag
run: |
git fetch --tags
latest_tag=$(git describe --tags --abbrev=0 --match "v*.*.*")
echo "::set-output name=latest_tag::$latest_tag"
echo "Latest tag: $latest_tag"

# Create GitHub Release using the last tag
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag.outputs.latest_tag }}
name: Release ${{ steps.tag.outputs.latest_tag }}
body: |
## Changes in this release:
- New features and bug fixes.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/bcgov/quickstart-openshift-helpers
deploy-prod:
name: Deploy (prod)
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: PR

on:
pull_request:

workflow_run:
workflows: ["PR Bump Version Workflow"]
types:
- completed
branches:
- release/**
concurrency:
# Cancel in progress for PR open and close
group: ${{ github.event.number }}
Expand All @@ -20,7 +24,6 @@ jobs:
steps:
- uses: bcgov-nr/action-builder-ghcr@v2.0.2
with:
keep_versions: 50
package: ${{ matrix.package }}
tag: ${{ github.event.number }}
tag_fallback: latest
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/pr-version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: PR Bump Version Workflow

on:
pull_request:
types: [opened]
branches:
- release/**

concurrency:
# Cancel in progress for PR open and close
group: ${{ github.event.number }}
cancel-in-progress: true

jobs:
bump_version:
name: Bump Version for Release Branch
runs-on: ubuntu-22.04
strategy:
matrix:
package: [backend, frontend, webeoc]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Install jq (JSON parser)
run: sudo apt-get install -y jq

# Check if it's the first PR into the release branch (no existing tags)
- name: Check for existing tags
id: check_tag
run: |
git fetch --tags
latest_tag=$(git describe --tags --abbrev=0 --match "v*.*.*" || echo "none")
echo "::set-output name=latest_tag::$latest_tag"

# Bump minor version and reset patch for first PR
- name: Bump minor version and reset patch for first PR
if: ${{ steps.check_tag.outputs.latest_tag == 'none' }}
run: |
cd ${{ matrix.package }}
current_version=$(jq -r '.version' package.json)
new_version=$(echo $current_version | awk -F. '{$2+=1; $3=0; print $1"."$2"."$3}')
jq --arg v "$new_version" '.version = $v' package.json > package.json.tmp && mv package.json.tmp package.json
echo "First PR: Resetting patch and bumping minor. New version: $new_version"

# Bump patch version for subsequent PRs
- name: Bump patch version for subsequent PRs
if: ${{ steps.check_tag.outputs.latest_tag != 'none' }}
run: |
cd ${{ matrix.package }}
current_version=$(jq -r '.version' package.json)
new_version=$(echo $current_version | awk -F. '{$3+=1; print $1"."$2"."$3}')
jq --arg v "$new_version" '.version = $v' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Subsequent PR: Bumping patch. New version: $new_version"

- name: Set Git Identity
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

# Commit and push version bump
- name: Commit and push version bump
run: |
git add ${{ matrix.package }}/package.json
git commit -m "chore(${{ matrix.package }}): bump version."
git push origin HEAD:refs/heads/${{ github.head_ref }} # Push to the branch associated with the PR
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nr-compliance-enforcement",
"version": "0.0.1",
"version": "0.26.0",
"description": "BCGov devops quickstart. For reference, testing and new projects.",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ import { GirTypeCodeModule } from "./v1/gir_type_code/gir_type_code.module";
import { GeneralIncidentComplaintModule } from "./v1/gir_complaint/gir_complaint.module";
import { FeatureFlagModule } from "./v1/feature_flag/feature_flag.module";
import { FeatureCodeModule } from "./v1/feature_code/feature_code.module";
import { TeamModule } from "./v1/team/team.module";
import { TeamCodeModule } from "./v1/team_code/team_code.module";
import { OfficerTeamXrefModule } from "./v1/officer_team_xref/officer_team_xref.module";
import { ComplaintMethodReceivedCodeModule } from "./v1/complaint_method_received_code/complaint_method_received_code.module";
import { CompMthdRecvCdAgcyCdXrefModule } from "./v1/comp_mthd_recv_cd_agcy_cd_xref/comp_mthd_recv_cd_agcy_cd_xref.module";

console.log("Var check - POSTGRESQL_HOST", process.env.POSTGRESQL_HOST);
console.log("Var check - POSTGRESQL_DATABASE", process.env.POSTGRESQL_DATABASE);
Expand Down Expand Up @@ -118,6 +123,11 @@ if (process.env.POSTGRESQL_PASSWORD != null) {
GeneralIncidentComplaintModule,
FeatureFlagModule,
FeatureCodeModule,
TeamModule,
TeamCodeModule,
OfficerTeamXrefModule,
ComplaintMethodReceivedCodeModule,
CompMthdRecvCdAgcyCdXrefModule,
],
controllers: [AppController],
providers: [AppService, ComplaintSequenceResetScheduler],
Expand Down
5 changes: 5 additions & 0 deletions backend/src/common/has-role.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const hasRole = (req, role: string) => {
const userroles = req.user.client_roles;
const hasRole = userroles?.includes(role);
return hasRole;
};
4 changes: 3 additions & 1 deletion backend/src/enum/role.enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export enum Role {
COS_OFFICER = "COS Officer",
COS_ADMIN = "COS Admin",
COS_ADMINISTRATOR = "COS Administrator",
CEEB = "CEEB",
CEEB_COMPLIANCE_COORDINATOR = "CEEB Compliance Coordinator",
CEEB_SECTION_HEAD = "CEEB Section Head",
TEMPORARY_TEST_ADMIN = "TEMPORARY_TEST_ADMIN",
}
10 changes: 10 additions & 0 deletions backend/src/external_api/css/css.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from "@nestjs/common";
import { CssService } from "./css.service";
import { ConfigurationModule } from "../../v1/configuration/configuration.module";

@Module({
imports: [ConfigurationModule],
providers: [CssService],
exports: [CssService],
})
export class CssModule {}
28 changes: 28 additions & 0 deletions backend/src/external_api/css/css.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Test, TestingModule } from "@nestjs/testing";
import { getRepositoryToken } from "@nestjs/typeorm";
import { ConfigurationService } from "../../v1/configuration/configuration.service";
import { Configuration } from "../../v1/configuration/entities/configuration.entity";
import { CssService } from "./css.service";

describe("CssService", () => {
let service: CssService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
CssService,
ConfigurationService,
{
provide: getRepositoryToken(Configuration),
useValue: {},
},
],
}).compile();

service = module.get<CssService>(CssService);
});

it("should be defined", () => {
expect(service).toBeDefined();
});
});
118 changes: 118 additions & 0 deletions backend/src/external_api/css/css.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { Inject, Injectable, Logger } from "@nestjs/common";
import { ExternalApiService } from "../external-api-service";
import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
import { get } from "../../helpers/axios-api";
import { ConfigurationService } from "../../v1/configuration/configuration.service";

@Injectable()
export class CssService implements ExternalApiService {
private readonly logger = new Logger(CssService.name);

readonly authApi: string;
readonly baseUri: string;
readonly clientId: string;
readonly clientSecret: string;
readonly grantType: string;
readonly env: string;

@Inject(ConfigurationService)
readonly configService: ConfigurationService;

constructor() {
this.authApi = process.env.CSS_TOKEN_URL;
this.baseUri = process.env.CSS_URL;
this.clientId = process.env.CSS_CLIENT_ID;
this.clientSecret = process.env.CSS_CLIENT_SECRET;
this.grantType = "client_credentials";
this.env = process.env.ENVIRONMENT;
}

authenticate = async (): Promise<string> => {
const response: AxiosResponse = await axios.post(
this.authApi,
{
client_id: this.clientId,
client_secret: this.clientSecret,
grant_type: this.grantType,
},
{
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
},
);
return response?.data?.access_token;
};

getUserIdirByName = async (firstName, lastName): Promise<AxiosResponse> => {
try {
const apiToken = await this.authenticate();
const url = `${this.baseUri}/api/v1/${this.env}/idir/users?firstName=${firstName}&lastName=${lastName}`;
const config: AxiosRequestConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiToken}`,
},
};
const response = await get(apiToken, url, config);
return response?.data.data;
} catch (error) {
this.logger.error(`exception: unable to get user: ${firstName} ${lastName} - error: ${error}`);
throw new Error(`exception: unable to get user: ${firstName} ${lastName} - error: ${error}`);
}
};

getUserRoles = async (userIdir): Promise<{ name: string; composite: string }[]> => {
try {
const apiToken = await this.authenticate();
const url = `${this.baseUri}/api/v1/integrations/4794/${this.env}/users/${userIdir}/roles`;
const config: AxiosRequestConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiToken}`,
},
};
const response = await get(apiToken, url, config);
return response?.data.data;
} catch (error) {
this.logger.error(`exception: unable to get user's roles ${userIdir} - error: ${error}`);
throw new Error(`exception: unable to get user's roles ${userIdir} - error: ${error}`);
}
};

updateUserRole = async (userIdir, userRoles): Promise<{ name: string; composite: string }[]> => {
try {
const apiToken = await this.authenticate();
const url = `${this.baseUri}/api/v1/integrations/4794/${this.env}/users/${userIdir}/roles`;
const config: AxiosRequestConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiToken}`,
},
};
const response = await axios.post(url, userRoles, config);
return response?.data.data;
} catch (error) {
this.logger.error(`exception: unable to update user's roles ${userIdir} - error: ${error}`);
throw new Error(`exception: unable to update user's roles ${userIdir} - error: ${error}`);
}
};

deleteUserRole = async (userIdir, roleName): Promise<AxiosResponse> => {
try {
const apiToken = await this.authenticate();
const url = `${this.baseUri}/api/v1/integrations/4794/${this.env}/users/${userIdir}/roles/${roleName}`;
const config: AxiosRequestConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiToken}`,
},
};
const response = await axios.delete(url, config);
return response?.data.data;
} catch (error) {
this.logger.error(`exception: unable to delete user's role ${userIdir} - error: ${error}`);
throw new Error(`exception: unable to delete user's role ${userIdir} - error: ${error}`);
}
};
}
7 changes: 7 additions & 0 deletions backend/src/middleware/maps/automapper-dto-to-entity-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ export const mapComplaintDtoToComplaint = (mapper: Mapper) => {
return { complaint_status_code: status };
}),
),
forMember(
(dest) => dest.comp_mthd_recv_cd_agcy_cd_xref,
mapFrom((src) => {
// This will be looked up from the service using the received complaintMethodReceivedCode
return null; // This will be handled in the service
}),
),
);
};

Expand Down
Loading
Loading