From 38fe437b8bf1a6d9391cf9441ee4bf64a3a113c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:27:03 +0000 Subject: [PATCH 1/9] chore(deps): bump webpack-dev-middleware from 5.3.3 to 5.3.4 (#14248) Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4. - [Release notes](https://github.com/webpack/webpack-dev-middleware/releases) - [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4) --- updated-dependencies: - dependency-name: webpack-dev-middleware dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 56a916758c04..772817908b22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54300,8 +54300,8 @@ __metadata: linkType: hard "webpack-dev-middleware@npm:^5.3.1": - version: 5.3.3 - resolution: "webpack-dev-middleware@npm:5.3.3" + version: 5.3.4 + resolution: "webpack-dev-middleware@npm:5.3.4" dependencies: colorette: ^2.0.10 memfs: ^3.4.3 @@ -54310,7 +54310,7 @@ __metadata: schema-utils: ^4.0.0 peerDependencies: webpack: ^4.0.0 || ^5.0.0 - checksum: dd332cc6da61222c43d25e5a2155e23147b777ff32fdf1f1a0a8777020c072fbcef7756360ce2a13939c3f534c06b4992a4d659318c4a7fe2c0530b52a8a6621 + checksum: 90cf3e27d0714c1a745454a1794f491b7076434939340605b9ee8718ba2b85385b120939754e9fdbd6569811e749dee53eec319e0d600e70e0b0baffd8e3fb13 languageName: node linkType: hard From dc2ec0aa5371a36a83d0eda18ba7eafc43aa1bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0j=C3=B3n=20Gu=C3=B0j=C3=B3nsson?= Date: Wed, 3 Jul 2024 21:09:28 +0000 Subject: [PATCH 2/9] fix(j-s): Roles Rules (#15416) * Fixes and improves roles rules logic * Fixes typo --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/app/modules/case/case.controller.ts | 30 +-------- .../src/app/modules/case/guards/rolesRules.ts | 64 +++++++++++++++---- .../getRulingSignatureConfirmation.spec.ts | 21 ------ ...ingSignatureConfirmationRolesRules.spec.ts | 4 +- .../requestRulingSignature.spec.ts | 22 +------ .../requestRulingSignatureRolesRules.spec.ts | 4 +- 6 files changed, 59 insertions(+), 86 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/case/case.controller.ts b/apps/judicial-system/backend/src/app/modules/case/case.controller.ts index 213d399f4209..e73b47b71811 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.controller.ts @@ -84,6 +84,7 @@ import { courtOfAppealsRegistrarUpdateRule, districtCourtAssistantTransitionRule, districtCourtAssistantUpdateRule, + districtCourtJudgeSignRulingRule, districtCourtJudgeTransitionRule, districtCourtJudgeUpdateRule, districtCourtRegistrarTransitionRule, @@ -297,12 +298,6 @@ export class CaseController { break case CaseTransition.SUBMIT: if (isIndictmentCase(theCase.type)) { - if (!user.canConfirmIndictment) { - throw new ForbiddenException( - `User ${user.id} does not have permission to confirm indictments`, - ) - } - update.indictmentDeniedExplanation = null } break @@ -387,13 +382,6 @@ export class CaseController { update.appealRulingDecision = CaseAppealRulingDecision.DISCONTINUED } break - case CaseTransition.DENY_INDICTMENT: - if (!user.canConfirmIndictment) { - throw new ForbiddenException( - `User ${user.id} does not have permission to reject indictments`, - ) - } - break case CaseTransition.ASK_FOR_CONFIRMATION: update.indictmentReturnedExplanation = null break @@ -777,7 +765,7 @@ export class CaseController { new CaseTypeGuard([...restrictionCases, ...investigationCases]), CaseWriteGuard, ) - @RolesRules(districtCourtJudgeRule) + @RolesRules(districtCourtJudgeSignRulingRule) @Post('case/:caseId/ruling/signature') @ApiCreatedResponse({ type: SigningServiceResponse, @@ -790,12 +778,6 @@ export class CaseController { ): Promise { this.logger.debug(`Requesting a signature for the ruling of case ${caseId}`) - if (user.id !== theCase.judgeId) { - throw new ForbiddenException( - 'A ruling must be signed by the assigned judge', - ) - } - return this.caseService.requestRulingSignature(theCase).catch((error) => { if (error instanceof DokobitError) { throw new HttpException( @@ -820,7 +802,7 @@ export class CaseController { new CaseTypeGuard([...restrictionCases, ...investigationCases]), CaseWriteGuard, ) - @RolesRules(districtCourtJudgeRule) + @RolesRules(districtCourtJudgeSignRulingRule) @Get('case/:caseId/ruling/signature') @ApiOkResponse({ type: SignatureConfirmationResponse, @@ -835,12 +817,6 @@ export class CaseController { ): Promise { this.logger.debug(`Confirming a signature for the ruling of case ${caseId}`) - if (user.id !== theCase.judgeId) { - throw new ForbiddenException( - 'A ruling must be signed by the assigned judge', - ) - } - return this.caseService.getRulingSignatureConfirmation( theCase, user, diff --git a/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts b/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts index 5857b0fa556e..ca71abf169c6 100644 --- a/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts +++ b/apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts @@ -1,6 +1,12 @@ import { RolesRule, RulesType } from '@island.is/judicial-system/auth' -import { CaseTransition, UserRole } from '@island.is/judicial-system/types' +import { + CaseTransition, + CaseType, + User, + UserRole, +} from '@island.is/judicial-system/types' +import { TransitionCaseDto } from '../dto/transitionCase.dto' import { UpdateCaseDto } from '../dto/updateCase.dto' import { Case } from '../models/case.model' @@ -189,29 +195,39 @@ export const prosecutorTransitionRule: RolesRule = { dtoFieldValues: [ CaseTransition.OPEN, CaseTransition.ASK_FOR_CONFIRMATION, + CaseTransition.DENY_INDICTMENT, CaseTransition.SUBMIT, CaseTransition.ASK_FOR_CANCELLATION, CaseTransition.DELETE, CaseTransition.APPEAL, CaseTransition.WITHDRAW_APPEAL, - CaseTransition.DENY_INDICTMENT, ], canActivate: (request) => { + const user: User = request.user + const dto: TransitionCaseDto = request.body const theCase: Case = request.case - // Deny if the case is missing - shuould never happen - if (!theCase) { + // Deny if something is missing - shuould never happen + if (!user || !dto || !theCase) { return false } // Deny transition if prosecutor did not appeal the case if ( - request.body.transition === CaseTransition.WITHDRAW_APPEAL && + dto.transition === CaseTransition.WITHDRAW_APPEAL && !theCase.prosecutorPostponedAppealDate ) { return false } + if ( + (dto.transition === CaseTransition.SUBMIT && + theCase.type === CaseType.INDICTMENT) || + dto.transition === CaseTransition.DENY_INDICTMENT + ) { + return user.canConfirmIndictment + } + return true }, } @@ -221,7 +237,11 @@ export const prosecutorRepresentativeTransitionRule: RolesRule = { role: UserRole.PROSECUTOR_REPRESENTATIVE, type: RulesType.FIELD_VALUES, dtoField: 'transition', - dtoFieldValues: [CaseTransition.ASK_FOR_CONFIRMATION, CaseTransition.DELETE], + dtoFieldValues: [ + CaseTransition.ASK_FOR_CONFIRMATION, + CaseTransition.ASK_FOR_CANCELLATION, + CaseTransition.DELETE, + ], } // Allows defenders to transition cases @@ -231,16 +251,17 @@ export const defenderTransitionRule: RolesRule = { dtoField: 'transition', dtoFieldValues: [CaseTransition.APPEAL, CaseTransition.WITHDRAW_APPEAL], canActivate: (request) => { + const dto: TransitionCaseDto = request.body const theCase: Case = request.case - // Deny if the case is missing - should never happen - if (!theCase) { + // Deny if something is missing - shuould never happen + if (!dto || !theCase) { return false } // Deny withdrawal if defender did not appeal the case if ( - request.body.transition === CaseTransition.WITHDRAW_APPEAL && + dto.transition === CaseTransition.WITHDRAW_APPEAL && !theCase.accusedPostponedAppealDate ) { return false @@ -283,7 +304,7 @@ export const districtCourtRegistrarTransitionRule: RolesRule = { ], } -// Allows district court assistants to transition cases. +// Allows district court assistants to transition cases export const districtCourtAssistantTransitionRule: RolesRule = { role: UserRole.DISTRICT_COURT_ASSISTANT, type: RulesType.FIELD_VALUES, @@ -291,7 +312,7 @@ export const districtCourtAssistantTransitionRule: RolesRule = { dtoFieldValues: [CaseTransition.RECEIVE, CaseTransition.COMPLETE], } -// Allows court of appeals judges to transition cases. +// Allows court of appeals judges to transition cases export const courtOfAppealsJudgeTransitionRule: RolesRule = { role: UserRole.COURT_OF_APPEALS_JUDGE, type: RulesType.FIELD_VALUES, @@ -302,7 +323,7 @@ export const courtOfAppealsJudgeTransitionRule: RolesRule = { ], } -// Allows court of appeals registrars to transition cases. +// Allows court of appeals registrars to transition cases export const courtOfAppealsRegistrarTransitionRule: RolesRule = { role: UserRole.COURT_OF_APPEALS_REGISTRAR, type: RulesType.FIELD_VALUES, @@ -313,7 +334,7 @@ export const courtOfAppealsRegistrarTransitionRule: RolesRule = { ], } -// Allows court of appeals assistants to transition cases. +// Allows court of appeals assistants to transition cases export const courtOfAppealsAssistantTransitionRule: RolesRule = { role: UserRole.COURT_OF_APPEALS_ASSISTANT, type: RulesType.FIELD_VALUES, @@ -323,3 +344,20 @@ export const courtOfAppealsAssistantTransitionRule: RolesRule = { CaseTransition.REOPEN_APPEAL, ], } + +// Allows district court judges to sign a ruling +export const districtCourtJudgeSignRulingRule: RolesRule = { + role: UserRole.DISTRICT_COURT_JUDGE, + type: RulesType.BASIC, + canActivate: (request) => { + const user: User = request.user + const theCase: Case = request.case + + // Deny if something is missing - shuould never happen + if (!user || !theCase) { + return false + } + + return user.id === theCase.judgeId + }, +} diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmation.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmation.spec.ts index 14298526ae74..25a9fa28deeb 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmation.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmation.spec.ts @@ -1,8 +1,6 @@ import { Transaction } from 'sequelize/types' import { uuid } from 'uuidv4' -import { ForbiddenException } from '@nestjs/common' - import { MessageService, MessageType } from '@island.is/judicial-system/message' import { CaseFileState, @@ -212,25 +210,6 @@ describe('CaseController - Get ruling signature confirmation', () => { ]) }) }) - - describe('user is not the assigned judge', () => { - const caseId = uuid() - const theCase = { id: caseId, judgeId: uuid() } as Case - const documentToken = uuid() - let then: Then - - beforeEach(async () => { - then = await givenWhenThen(caseId, user, theCase, documentToken) - }) - - it('should throw ForbiddenException', () => { - expect(then.error).toBeInstanceOf(ForbiddenException) - expect(then.error.message).toBe( - 'A ruling must be signed by the assigned judge', - ) - }) - }) - describe('database update fails', () => { const caseId = uuid() const theCase = { diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts index 9f9be3fe40c6..e41962b38178 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts @@ -1,5 +1,5 @@ -import { districtCourtJudgeRule } from '../../../../guards' import { CaseController } from '../../case.controller' +import { districtCourtJudgeSignRulingRule } from '../../guards/rolesRules' describe('CaseController - Get ruling signature confirmation rules', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -14,6 +14,6 @@ describe('CaseController - Get ruling signature confirmation rules', () => { it('should give permission to one roles', () => { expect(rules).toHaveLength(1) - expect(rules).toContain(districtCourtJudgeRule) + expect(rules).toContain(districtCourtJudgeSignRulingRule) }) }) diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignature.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignature.spec.ts index b3cf564df832..73dd58a8cd0e 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignature.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignature.spec.ts @@ -1,7 +1,5 @@ import { uuid } from 'uuidv4' -import { ForbiddenException } from '@nestjs/common' - import { SigningServiceResponse } from '@island.is/dokobit-signing' import { User } from '@island.is/judicial-system/types' @@ -44,7 +42,7 @@ describe('CaseController - Request ruling signature', () => { } }) - describe('the user is the assigned judge', () => { + describe('signature requested', () => { const userId = uuid() const user = { id: userId } as User const caseId = uuid() @@ -62,22 +60,4 @@ describe('CaseController - Request ruling signature', () => { }) }) }) - - describe('the user is not the assigned judge', () => { - const user = { id: uuid() } as User - const caseId = uuid() - const theCase = { id: caseId, judgeId: uuid() } as Case - let then: Then - - beforeEach(async () => { - then = await givenWhenThen(caseId, user, theCase) - }) - - it('should throw ForbiddenException', () => { - expect(then.error).toBeInstanceOf(ForbiddenException) - expect(then.error.message).toBe( - 'A ruling must be signed by the assigned judge', - ) - }) - }) }) diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts index 35c739008c99..81f956445bfd 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts @@ -1,5 +1,5 @@ -import { districtCourtJudgeRule } from '../../../../guards' import { CaseController } from '../../case.controller' +import { districtCourtJudgeSignRulingRule } from '../../guards/rolesRules' describe('CaseController - Request ruling signature rules', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -14,6 +14,6 @@ describe('CaseController - Request ruling signature rules', () => { it('should give permission to one roles', () => { expect(rules).toHaveLength(1) - expect(rules).toContain(districtCourtJudgeRule) + expect(rules).toContain(districtCourtJudgeSignRulingRule) }) }) From dfa9ccb257f4f0ea2b59146e6def6d74992a2f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0j=C3=B3n=20Gu=C3=B0j=C3=B3nsson?= Date: Wed, 3 Jul 2024 21:46:34 +0000 Subject: [PATCH 3/9] fix(j-s): Court Client Error Handling (#15423) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/lib/courtClient.service.ts | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/libs/judicial-system/court-client/src/lib/courtClient.service.ts b/libs/judicial-system/court-client/src/lib/courtClient.service.ts index 23bbb8920683..cfa5a8d5a223 100644 --- a/libs/judicial-system/court-client/src/lib/courtClient.service.ts +++ b/libs/judicial-system/court-client/src/lib/courtClient.service.ts @@ -59,7 +59,7 @@ export type UpdateCaseWithDefendantArgs = Omit< 'authenticationToken' > -function injectAgentMiddleware(agent: Agent) { +const injectAgentMiddleware = (agent: Agent) => { return async (context: RequestContext): Promise => { const { url, init } = context @@ -67,7 +67,7 @@ function injectAgentMiddleware(agent: Agent) { } } -function stripResult(str: string): string { +const stripResult = (str: string): string => { if (str[0] !== '"') { return str } @@ -291,7 +291,7 @@ export class CourtClientServiceImplementation implements CourtClientService { private handleUnknownError( courtId: string, - reason: { status: string; message: string }, + reason: { status: string; message: unknown }, ) { // Get the connection state const connectionState = this.getConnectionState(courtId) @@ -308,10 +308,13 @@ export class CourtClientServiceImplementation implements CourtClientService { private handleCaseError( courtId: string, - reason: { status: string; message: string }, + reason: { status: string; message: unknown }, ): Error { // Check for known errors - if (reason.message?.startsWith('Case Not Found')) { + if ( + typeof reason.message === 'string' && + reason.message.startsWith('Case Not Found') + ) { return new NotFoundException(reason) } @@ -320,10 +323,13 @@ export class CourtClientServiceImplementation implements CourtClientService { private handleParticipantError( courtId: string, - reason: { status: string; message: string }, + reason: { status: string; message: unknown }, ): Error { // Check for known errors - if (reason.message?.startsWith("Incorrect 'CaseId/Number'")) { + if ( + typeof reason.message === 'string' && + reason.message.startsWith("Incorrect 'CaseId/Number'") + ) { return new NotFoundException({ ...reason, message: 'Case not found', @@ -362,7 +368,7 @@ export class CourtClientServiceImplementation implements CourtClientService { this.createDocumentApi.createDocument({ createDocumentData: { ...args, authenticationToken }, }), - ).catch((reason: { status: string; message: string }) => { + ).catch((reason: { status: string; message: unknown }) => { this.logger.warn('Court client error - createDocument', { courtId, reason, @@ -478,13 +484,16 @@ export class CourtClientServiceImplementation implements CourtClientService { this.updateCaseWithDefendantApi.updateCaseWithDefendant({ updateCaseWithDefendantData: { ...args, authenticationToken }, }), - ).catch((reason: { status: string; message: string }) => { + ).catch((reason: { status: string; message: unknown }) => { this.logger.warn('Court client error - updateCaseWithDefendant', { courtId, reason, }) - if (reason.message.startsWith("Can't find defendant with IdNumber")) { + if ( + typeof reason.message === 'string' && + reason.message.startsWith("Can't find defendant with IdNumber") + ) { throw new NotFoundException(reason) } From 3b5aa3417813b38c85178d4d03c470d99bdecd59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0j=C3=B3n=20Gu=C3=B0j=C3=B3nsson?= Date: Wed, 3 Jul 2024 22:09:30 +0000 Subject: [PATCH 4/9] fix(j-s): Indictment Filter Option (#15410) * Remoes indictment filter option from roles that only see indictment cases * Updates unit test --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../web/src/routes/Shared/Cases/useFilter.spec.tsx | 4 ++-- .../judicial-system/web/src/routes/Shared/Cases/useFilter.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.spec.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.spec.tsx index 17a2f0fcae9f..2b1f8b3d554a 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.spec.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.spec.tsx @@ -38,8 +38,8 @@ describe('useFilter - filterOptionsForUser', () => { { value: 'INVESTIGATION', label: 'INVESTIGATION' }, ]), ) - expect(result.length).toBe(3) - expect(result).toEqual( + expect(result.length).toBe(2) + expect(result).not.toEqual( expect.arrayContaining([{ value: 'INDICTMENT', label: 'INDICTMENT' }]), ) }) diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx index c62e9c41ef3d..fca58a3fee8c 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx @@ -83,7 +83,7 @@ export const filterOptionsForUser = ( user?.role === UserRole.PROSECUTOR_REPRESENTATIVE || user?.role === UserRole.DISTRICT_COURT_ASSISTANT ) { - return option.value !== 'INVESTIGATION' + return option.value !== 'INVESTIGATION' && option.value !== 'INDICTMENT' } return true From eec2f4d010ac537b4815698517798230ada7ab13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0j=C3=B3n=20Gu=C3=B0j=C3=B3nsson?= Date: Wed, 3 Jul 2024 22:33:26 +0000 Subject: [PATCH 5/9] chore(j-s): Web Environment Cleanup (#15425) Co-authored-by: unakb Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/judicial-system/web/src/environments/environment.ts | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 apps/judicial-system/web/src/environments/environment.ts diff --git a/apps/judicial-system/web/src/environments/environment.ts b/apps/judicial-system/web/src/environments/environment.ts deleted file mode 100644 index 53f69e76d4c9..000000000000 --- a/apps/judicial-system/web/src/environments/environment.ts +++ /dev/null @@ -1,9 +0,0 @@ -const devConfig = { - production: false, -} - -const prodConfig = { - production: true, -} - -export default process.env.NODE_ENV === 'production' ? prodConfig : devConfig From b15b54f1b6de5a552d431d854be46b1bfe59534a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0j=C3=B3n=20Gu=C3=B0j=C3=B3nsson?= Date: Wed, 3 Jul 2024 23:08:32 +0000 Subject: [PATCH 6/9] chore(j-s): Court Autofill (#15421) * Delays indictment case court autofill until court selection screen * Updates tests --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/app/modules/case/case.service.ts | 17 ++++++---- .../app/modules/case/internalCase.service.ts | 11 ++++--- .../case/test/caseController/create.spec.ts | 1 - .../internalCaseController/create.spec.ts | 1 - .../UserProvider/currentUser.graphql | 6 ++-- .../Indictments/Processing/Processing.tsx | 32 +++++++++++++++++-- 6 files changed, 48 insertions(+), 20 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/case/case.service.ts b/apps/judicial-system/backend/src/app/modules/case/case.service.ts index df104307e28b..9bbcf11f0d57 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.service.ts @@ -41,6 +41,7 @@ import { EventType, isCompletedCase, isIndictmentCase, + isRequestCase, isRestrictionCase, isTrafficViolationCase, NotificationType, @@ -448,9 +449,9 @@ export class CaseService { const theCase = await this.caseModel.create( { ...caseToCreate, - state: isIndictmentCase(caseToCreate.type) - ? CaseState.DRAFT - : CaseState.NEW, + state: isRequestCase(caseToCreate.type) + ? CaseState.NEW + : CaseState.DRAFT, }, { transaction }, ) @@ -1207,7 +1208,7 @@ export class CaseService { if (updatedCase.courtCaseNumber) { if (updatedCase.courtCaseNumber !== theCase.courtCaseNumber) { // New court case number - if (isIndictmentCase(updatedCase.type)) { + if (isIndictment) { await this.addMessagesForIndictmentCourtCaseConnectionToQueue( updatedCase, user, @@ -1222,7 +1223,7 @@ export class CaseService { } if ( - !isIndictmentCase(updatedCase.type) && + !isIndictment && updatedCase.defenderEmail !== theCase.defenderEmail ) { // New defender email @@ -1232,7 +1233,7 @@ export class CaseService { } if ( - isIndictmentCase(updatedCase.type) && + isIndictment && ![ CaseState.DRAFT, CaseState.SUBMITTED, @@ -1326,7 +1327,9 @@ export class CaseService { creatingProsecutorId: user.id, prosecutorId: user.role === UserRole.PROSECUTOR ? user.id : undefined, - courtId: user.institution?.defaultCourtId, + courtId: isRequestCase(caseToCreate.type) + ? user.institution?.defaultCourtId + : undefined, prosecutorsOfficeId: user.institution?.id, } as CreateCaseDto, transaction, diff --git a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts index 31eaa40e382e..eed487be849c 100644 --- a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts @@ -30,6 +30,7 @@ import { EventType, isIndictmentCase, isProsecutionUser, + isRequestCase, isRestrictionCase, isTrafficViolationCase, NotificationType, @@ -353,14 +354,16 @@ export class InternalCaseService { .create( { ...caseToCreate, - state: isIndictmentCase(caseToCreate.type) - ? CaseState.DRAFT - : CaseState.NEW, + state: isRequestCase(caseToCreate.type) + ? CaseState.NEW + : CaseState.DRAFT, origin: CaseOrigin.LOKE, creatingProsecutorId: creator.id, prosecutorId: creator.role === UserRole.PROSECUTOR ? creator.id : undefined, - courtId: creator.institution?.defaultCourtId, + courtId: isRequestCase(caseToCreate.type) + ? creator.institution?.defaultCourtId + : undefined, prosecutorsOfficeId: creator.institution?.id, }, { transaction }, diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/create.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/create.spec.ts index 6dd00c817668..5f58bc59323f 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/create.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/create.spec.ts @@ -138,7 +138,6 @@ describe('CaseController - Create', () => { origin: CaseOrigin.RVG, creatingProsecutorId: userId, prosecutorId: userId, - courtId, prosecutorsOfficeId, }, { transaction }, diff --git a/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/create.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/create.spec.ts index b70702fd26dd..1203feeb9d73 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/create.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/create.spec.ts @@ -260,7 +260,6 @@ describe('InternalCaseController - Create', () => { origin: CaseOrigin.LOKE, state: CaseState.DRAFT, creatingProsecutorId: userId, - courtId, prosecutorsOfficeId, }, { diff --git a/apps/judicial-system/web/src/components/UserProvider/currentUser.graphql b/apps/judicial-system/web/src/components/UserProvider/currentUser.graphql index f373ac43d623..ec9a54b1ef48 100644 --- a/apps/judicial-system/web/src/components/UserProvider/currentUser.graphql +++ b/apps/judicial-system/web/src/components/UserProvider/currentUser.graphql @@ -13,12 +13,10 @@ query CurrentUser { canConfirmIndictment institution { id - created - modified - name type + name + defaultCourtId policeCaseNumberPrefix - active } } } diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx index 9e247a8b2417..d28259f0399a 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx @@ -16,6 +16,7 @@ import { PageLayout, ProsecutorCaseInfo, SectionHeading, + UserContext, } from '@island.is/judicial-system-web/src/components' import RequiredStar from '@island.is/judicial-system-web/src/components/RequiredStar/RequiredStar' import { @@ -27,6 +28,7 @@ import { import { useCase, useDefendants, + useOnceOn, } from '@island.is/judicial-system-web/src/utils/hooks' import { isProcessingStepValidIndictments } from '@island.is/judicial-system-web/src/utils/validate' @@ -35,14 +37,38 @@ import { strings } from './processing.strings' import * as styles from './Processing.css' const Processing: FC = () => { - const { workingCase, setWorkingCase, isLoadingWorkingCase, caseNotFound } = - useContext(FormContext) - const { transitionCase } = useCase() + const { user } = useContext(UserContext) + const { + workingCase, + setWorkingCase, + isLoadingWorkingCase, + caseNotFound, + isCaseUpToDate, + refreshCase, + } = useContext(FormContext) + const { updateCase, transitionCase } = useCase() const { formatMessage } = useIntl() const { updateDefendant, updateDefendantState } = useDefendants() const router = useRouter() const isTrafficViolationCaseCheck = isTrafficViolationCase(workingCase) + const initialize = useCallback(async () => { + if (!workingCase.court) { + await updateCase(workingCase.id, { + courtId: user?.institution?.defaultCourtId, + }) + refreshCase() + } + }, [ + refreshCase, + updateCase, + user?.institution?.defaultCourtId, + workingCase.court, + workingCase.id, + ]) + + useOnceOn(isCaseUpToDate, initialize) + const handleNavigationTo = useCallback( async (destination: string) => { if (workingCase.state === CaseState.NEW) { From bbdf329ade723732b027c8947048070916285484 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:13:40 +0000 Subject: [PATCH 7/9] chore(deps): bump actions/github-script from 6 to 7 (#12742) Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c66827514abb..73d242737016 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -614,7 +614,7 @@ jobs: - name: Comment on PR if: needs.pre-checks.outputs.PRE_CHECK == 'feature-deploy' && !(needs.pre-checks.outputs.PRE_RELEASE == 'true') - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | From 477dbce2f2453f935eabadaad23b317e1c0a2c9e Mon Sep 17 00:00:00 2001 From: lommi Date: Thu, 4 Jul 2024 08:16:34 +0000 Subject: [PATCH 8/9] chore: add dependabot to scripts (#15440) --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0832e3c5e458..ee0a25eac426 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,3 +24,11 @@ updates: labels: - automerge - dependencies + + - package-ecosystem: npm + directory: /scripts/ci/cache + schedule: + interval: daily + labels: + - automerge + - dependencies From b18ac60652a40e1d2359bc2f7b289ab5cdef96b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:26:52 +0000 Subject: [PATCH 9/9] chore(deps): bump glob from 10.4.1 to 10.4.2 in /scripts/ci/cache (#15441) * chore(deps): bump glob from 10.4.1 to 10.4.2 in /scripts/ci/cache Bumps [glob](https://github.com/isaacs/node-glob) from 10.4.1 to 10.4.2. - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](https://github.com/isaacs/node-glob/compare/v10.4.1...v10.4.2) --- updated-dependencies: - dependency-name: glob dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: nx format:write update dirty files --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: andes-it --- .github/dependabot.yml | 2 +- scripts/ci/cache/package.json | 2 +- scripts/ci/cache/yarn.lock | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ee0a25eac426..eec91d5b6123 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,7 +24,7 @@ updates: labels: - automerge - dependencies - + - package-ecosystem: npm directory: /scripts/ci/cache schedule: diff --git a/scripts/ci/cache/package.json b/scripts/ci/cache/package.json index 56e72c7bd5ae..d590ae1e2a27 100644 --- a/scripts/ci/cache/package.json +++ b/scripts/ci/cache/package.json @@ -1,7 +1,7 @@ { "dependencies": { "@actions/cache": "3.2.4", - "glob": "10.4.1" + "glob": "10.4.2" }, "resolutions": { "@actions/cache@3.2.4": "patch:@actions/cache@npm%3A3.2.4#./.yarn/patches/@actions-cache-npm-3.2.4-c57b047f14.patch" diff --git a/scripts/ci/cache/yarn.lock b/scripts/ci/cache/yarn.lock index fae81660e280..be32bd4ca1cf 100644 --- a/scripts/ci/cache/yarn.lock +++ b/scripts/ci/cache/yarn.lock @@ -492,18 +492,19 @@ __metadata: languageName: node linkType: hard -"glob@npm:10.4.1": - version: 10.4.1 - resolution: "glob@npm:10.4.1" +"glob@npm:10.4.2": + version: 10.4.2 + resolution: "glob@npm:10.4.2" dependencies: foreground-child: ^3.1.0 jackspeak: ^3.1.2 minimatch: ^9.0.4 minipass: ^7.1.2 + package-json-from-dist: ^1.0.0 path-scurry: ^1.11.1 bin: glob: dist/esm/bin.mjs - checksum: 5d33c686c80bf6877f4284adf99a8c3cbb2a6eccbc92342943fe5d4b42c01d78c1881f2223d950c92a938d0f857e12e37b86a8e5483ab2141822e053b67d0dde + checksum: bd7c0e30701136e936f414e5f6f82c7f04503f01df77408f177aa584927412f0bde0338e6ec541618cd21eacc57dde33e7b3c6c0a779cc1c6e6a0e14f3d15d9b languageName: node linkType: hard @@ -623,6 +624,13 @@ __metadata: languageName: node linkType: hard +"package-json-from-dist@npm:^1.0.0": + version: 1.0.0 + resolution: "package-json-from-dist@npm:1.0.0" + checksum: ac706ec856a5a03f5261e4e48fa974f24feb044d51f84f8332e2af0af04fbdbdd5bbbfb9cbbe354190409bc8307c83a9e38c6672c3c8855f709afb0006a009ea + languageName: node + linkType: hard + "path-key@npm:^3.1.0": version: 3.1.1 resolution: "path-key@npm:3.1.1" @@ -645,7 +653,7 @@ __metadata: resolution: "root-workspace-0b6124@workspace:." dependencies: "@actions/cache": 3.2.4 - glob: 10.4.1 + glob: 10.4.2 languageName: unknown linkType: soft