Skip to content

Commit

Permalink
NON-248: Non-Associations Link (#298)
Browse files Browse the repository at this point in the history
* NON-248: Config and helm values for non associations service url

* NON-248: helm values for non associations link feature flag

* NON-248: config and utils update for enabling non associations

* NON-248: Show link to non associations in alerts partial overview page

* NON-248: Unit test for checking non association link

* NON-248: Update to readme and feature.env

* NON-248: Removed unnecessary variable in non-associations util

---------

Co-authored-by: Aldo "xoen" Giambelluca <aldo.giambelluca@digital.justice.gov.uk>
  • Loading branch information
ashleygyngell and xoen authored Sep 29, 2023
1 parent 3409bb3 commit 4bf7280
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 3 deletions.
6 changes: 5 additions & 1 deletion feature.env
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ CASE_NOTES_API_URL=http://localhost:9091/casenotes
INCENTIVES_API_URL=http://localhost:9091/incentives
PATHFINDER_API_URL=http://localhost:9091/pathfinder
MANAGE_SOC_CASES_API_URL=http://localhost:9091/soc
HMPPS_NON_ASSOCIATIONS_API_URL=http://localhost:9091/nonassociations

OFFENDER_CATEGORISATION_UI_URL=http://localhost:9091/offendercategory
USE_OF_FORCE_UI_URL=http://localhost:9091/useofforce
MANAGE_A_WARRANT_FOLDER_UI_URL=http://localhost:9091/manageawarrant
PATHFINDER_UI_URL=http://localhost:9091/pathfinderui
MANAGE_SOC_CASES_UI_URL=http://localhost:9091/managesoccasesui
NON_ASSOCIATIONS_UI_URL=http://localhost:9091/nonassociationsui
NON_ASSOCIATIONS_PRISONS=MDI,LGI,FNI,ISI,RSI
WELCOME_PEOPLE_INTO_PRISON_UI_URL=https://welcome-dev.prison.service.justice.gov.uk
MANAGE_ADJUDICATIONS_API_URL=http://localhost:9091/adjudications
CALCULATE_RELEASE_DATES_UI_URL=https://localhost:9091/calculateRelease
FEEDBACK_DISABLED_PRISONS=LEI
SYSTEM_PHASE=DEV
NEURODIVERSITY_ENABLED_PRISONS=MDI
HMPPS_NON_ASSOCIATIONS_API_URL=http://localhost:9091/nonassociations


2 changes: 2 additions & 0 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ generic-service:
CREATE_AND_VARY_A_LICENCE_UI_URL: "https://create-and-vary-a-licence-dev.hmpps.service.justice.gov.uk"
MANAGE_ADJUDICATIONS_API_URL: "https://manage-adjudications-api-dev.hmpps.service.justice.gov.uk"
CALCULATE_RELEASE_DATES_UI_URL: "https://calculate-release-dates-dev.hmpps.service.justice.gov.uk"
NON_ASSOCIATIONS_UI_URL: "https://non-associations-dev.hmpps.service.justice.gov.uk"
FEEDBACK_DISABLED_PRISONS: "LEI,FNI,RSI,HMI,NHI"
ENVIRONMENT_NAME: "DEV"
NEURODIVERSITY_ENABLED_PRISONS: "BLI,NHI,LII,SLI"
NON_ASSOCIATIONS_PRISONS: "LGI,FNI,ISI,RSI"
HMPPS_NON_ASSOCIATIONS_API_URL: "https://non-associations-api-dev.hmpps.service.justice.gov.uk"
ACTIVITIES_URL: "https://activities-dev.prison.service.justice.gov.uk/activities"
ACTIVITIES_ENABLED_PRISONS: "LEI,RSI"
Expand Down
2 changes: 2 additions & 0 deletions helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ generic-service:
CREATE_AND_VARY_A_LICENCE_UI_URL: "https://create-and-vary-a-licence-preprod.hmpps.service.justice.gov.uk"
MANAGE_ADJUDICATIONS_API_URL: "https://manage-adjudications-api-preprod.hmpps.service.justice.gov.uk"
CALCULATE_RELEASE_DATES_UI_URL: "https://calculate-release-dates-preprod.hmpps.service.justice.gov.uk"
NON_ASSOCIATIONS_UI_URL: "https://non-associations-preprod.hmpps.service.justice.gov.uk"
FEEDBACK_DISABLED_PRISONS: "LEI,FNI,RSI,HMI,NHI"
ENVIRONMENT_NAME: "PRE-PRODUCTION"
NEURODIVERSITY_ENABLED_PRISONS: "BLI,NHI,LII,SLI"
NON_ASSOCIATIONS_PRISONS: "LGI,FNI,ISI,RSI"
HMPPS_NON_ASSOCIATIONS_API_URL: "https://non-associations-api-preprod.hmpps.service.justice.gov.uk"
ACTIVITIES_URL: "https://activities-preprod.prison.service.justice.gov.uk/activities"
ACTIVITIES_ENABLED_PRISONS: ""
Expand Down
2 changes: 2 additions & 0 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ generic-service:
CREATE_AND_VARY_A_LICENCE_UI_URL: "https://create-and-vary-a-licence.hmpps.service.justice.gov.uk"
MANAGE_ADJUDICATIONS_API_URL: "https://manage-adjudications-api.hmpps.service.justice.gov.uk"
CALCULATE_RELEASE_DATES_UI_URL: "https://calculate-release-dates.hmpps.service.justice.gov.uk"
NON_ASSOCIATIONS_UI_URL: "https://non-associations.hmpps.service.justice.gov.uk"
FEEDBACK_DISABLED_PRISONS: "LEI,FNI,RSI,HMI,NHI"
NEURODIVERSITY_ENABLED_PRISONS: "BLI,NHI,LII,SLI"
NON_ASSOCIATIONS_PRISONS: ""
HMPPS_NON_ASSOCIATIONS_API_URL: "https://non-associations-api.hmpps.service.justice.gov.uk"
ACTIVITIES_URL: "https://activities.prison.service.justice.gov.uk/activities"
ACTIVITIES_ENABLED_PRISONS: ""
Expand Down
1 change: 1 addition & 0 deletions readme/building_and_running.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ USE_OF_FORCE_UI_URL=https://dev.use-of-force.service.justice.gov.uk
MANAGE_A_WARRANT_FOLDER_UI_URL=https://manage-a-warrant-folder-dev.hmpps.service.justice.gov.uk
PATHFINDER_UI_URL=https://dev.pathfinder.service.justice.gov.uk
MANAGE_SOC_CASES_UI_URL=https://manage-soc-cases-dev.hmpps.service.justice.gov.uk
NON_ASSOCIATIONS_UI_URL: "https://non-associations-dev.hmpps.service.justice.gov.uk"
```
</details>

Expand Down
2 changes: 2 additions & 0 deletions server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default {
calculateReleaseDates: get('CALCULATE_RELEASE_DATES_UI_URL', 'http://localhost:3001', requiredInProduction),
activities: get('ACTIVITIES_URL', 'http://localhost:3001', requiredInProduction),
appointments: get('APPOINTMENTS_URL', 'http://localhost:3001', requiredInProduction),
nonAssociations: get('NON_ASSOCIATIONS_UI_URL', 'http://localhost:3001', requiredInProduction),
},
analytics: {
tagManagerContainerId: get('TAG_MANAGER_CONTAINER_ID', ''),
Expand All @@ -194,6 +195,7 @@ export default {
feedbackDisabledPrisons: get('FEEDBACK_DISABLED_PRISONS', [], requiredInProduction),
environmentName: get('ENVIRONMENT_NAME', ''),
neurodiversityEnabledPrisons: process.env.NEURODIVERSITY_ENABLED_PRISONS || [],
nonAssociationsPrisons: process.env.NON_ASSOCIATIONS_PRISONS?.split(',') || [],
activitiesEnabledPrisons: get('ACTIVITIES_ENABLED_PRISONS', [], requiredInProduction),
appointmentsEnabledPrisons: get('APPOINTMENTS_ENABLED_PRISONS', [], requiredInProduction),
}
2 changes: 2 additions & 0 deletions server/interfaces/overviewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface OverviewNonAssociation {
export interface AlertsSummary {
activeAlertCount: number
nonAssociationsCount: number
showNonAssociationsLink: boolean
nonAssociationsUrl: string
}

export interface OverviewPage {
Expand Down
41 changes: 41 additions & 0 deletions server/services/overviewPageService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { LearnerLatestAssessmentsMock } from '../data/localMockData/learnerLates
import { LearnerGoalsMock } from '../data/localMockData/learnerGoalsMock'
import { NonAssociationsApiClient } from '../data/interfaces/nonAssociationsApiClient'
import movementsMock from '../data/localMockData/movementsData'
import config from '../config'

describe('OverviewPageService', () => {
let prisonApiClient: PrisonApiClient
Expand Down Expand Up @@ -738,6 +739,8 @@ describe('OverviewPageService', () => {
expect(res.alertsSummary).toEqual({
activeAlertCount: 1,
nonAssociationsCount: 2,
nonAssociationsUrl: `${config.serviceUrls.nonAssociations}/prisoner/G6123VU/non-associations`,
showNonAssociationsLink: false,
})
})

Expand All @@ -747,6 +750,44 @@ describe('OverviewPageService', () => {
expect(res.alertsSummary).toEqual({
activeAlertCount: 1,
nonAssociationsCount: 0,
nonAssociationsUrl: `${config.serviceUrls.nonAssociations}/prisoner/G6123VU/non-associations`,
showNonAssociationsLink: false,
})
})

describe('Link to non-associations', () => {
describe('When non-associations is enabled for private beta', () => {
beforeEach(() => {
config.nonAssociationsPrisons = ['BAI', 'MDI']
})

it('should show non-associations link', async () => {
const overviewPageService = overviewPageServiceConstruct()
const res = await overviewPageService.get('token', PrisonerMockDataA, 1, CaseLoadsDummyDataB, [])
expect(res.alertsSummary).toEqual({
activeAlertCount: 1,
nonAssociationsCount: 0,
nonAssociationsUrl: `${config.serviceUrls.nonAssociations}/prisoner/G6123VU/non-associations`,
showNonAssociationsLink: true,
})
})
})

describe('When non-associations is disabled for private beta', () => {
beforeEach(() => {
config.nonAssociationsPrisons = ['MDI']
})

it('should show non-associations link', async () => {
const overviewPageService = overviewPageServiceConstruct()
const res = await overviewPageService.get('token', PrisonerMockDataA, 1, CaseLoadsDummyDataB, [])
expect(res.alertsSummary).toEqual({
activeAlertCount: 1,
nonAssociationsCount: 0,
nonAssociationsUrl: `${config.serviceUrls.nonAssociations}/prisoner/G6123VU/non-associations`,
showNonAssociationsLink: false,
})
})
})
})
})
Expand Down
7 changes: 5 additions & 2 deletions server/services/overviewPageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
formatMoney,
formatPrivilegedVisitsSummary,
getNamesFromString,
nonAssociationsEnabled,
prisonerBelongsToUsersCaseLoad,
userHasRoles,
} from '../utils/utils'
Expand Down Expand Up @@ -535,16 +536,18 @@ export default class OverviewPageService {
}

private getAlertsSummary(
{ activeAlertCount }: InmateDetail,
{ activeAlertCount, offenderNo }: InmateDetail,
nonAssociations: OverviewNonAssociation[],
userCaseloads: CaseLoad[],
): AlertsSummary {
const activeCaseload = userCaseloads.find(caseload => caseload.currentlyActive)
const nonAssociationsCount = nonAssociations.filter(
nonAssociation => nonAssociation.agencyId === activeCaseload?.caseLoadId,
).length
const showNonAssociationsLink = nonAssociationsEnabled(activeCaseload?.caseLoadId)
const nonAssociationsUrl = `${config.serviceUrls.nonAssociations}/prisoner/${offenderNo}/non-associations`

return { activeAlertCount, nonAssociationsCount }
return { activeAlertCount, nonAssociationsCount, showNonAssociationsLink, nonAssociationsUrl }
}

private async getSchedule(prisonerData: Prisoner): Promise<OverviewSchedule> {
Expand Down
4 changes: 4 additions & 0 deletions server/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ export const neurodiversityEnabled = (agencyId: string): boolean => {
return isEnabled
}

export const nonAssociationsEnabled = (agencyId: string): boolean => {
return config.nonAssociationsPrisons?.includes(agencyId)
}

export const stripAgencyPrefix = (location: string, agency: string): string => {
const parts = location && location.split('-')
if (parts && parts.length > 0) {
Expand Down
3 changes: 3 additions & 0 deletions server/views/partials/overviewPage/alerts/alerts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<div class="govuk-!-padding-top-3">
<dt class="govuk-!-font-weight-bold govuk-!-margin-bottom-1">Non-associations in {{ user.activeCaseLoad.description }}</dt>
<dd class="govuk-!-margin-left-0" data-qa="overview-non-association-count">{{ alertsSummary.nonAssociationsCount }}</dd>
{% if alertsSummary.showNonAssociationsLink %}
<dd class="govuk-!-margin-left-0"><a href="{{ alertsSummary.nonAssociationsUrl }}" class="govuk-link govuk-link--no-visited-state">Non-associations</a></dd>
{% endif %}
</div>
</div>
</dl>
Expand Down

0 comments on commit 4bf7280

Please sign in to comment.