Skip to content

Commit

Permalink
Merge branch 'main' into feat/app-disable-dark-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jul 11, 2024
2 parents 16469cd + 2914148 commit cb5d322
Show file tree
Hide file tree
Showing 108 changed files with 1,329 additions and 442 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@
{
"selector": "enumMember",
"format": ["camelCase", "UPPER_CASE", "PascalCase"]
},
{
"selector": "import",
"leadingUnderscore": "allow",
"format": ["camelCase", "PascalCase"]
}
],
"@typescript-eslint/no-empty-interface": [
Expand Down
9 changes: 6 additions & 3 deletions .github/actions/get-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ runs:
ENABLE_CACHE: ${{ inputs.enable-cache }}
NODE_OPTIONS: --max-old-space-size=8192
run: |
echo $_CACHE_KEYS
# This is because of a weird bug where Github would write as root to .cache
export COREPACK_HOME=/github/home/.corepack-cache
export CYPRESS_CACHE_FOLDER=/github/home/.cypress-cache
echo "COREPACK_HOME=$COREPACK_HOME" >> $GITHUB_ENV
echo "CYPRESS_CACHE_FOLDER=$CYPRESS_CACHE_FOLDER" >> $GITHUB_ENV
cd scripts/ci/cache
yarn install --immutable
npx yarn install --immutable
node cache-action.mjs
echo $_CACHE_KEYS
4 changes: 2 additions & 2 deletions .github/workflows/config-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
uses: ./.github/actions/cache
with:
path: infra/node_modules
key: ${{ runner.os }}-${{ hashFiles('infra/yarn.lock') }}-infra
key: ${{ runner.os }}-${{ hashFiles('infra/yarn.lock') }}-infra-2

- name: Check cache success
run: '[[ "${{ steps.node-modules.outputs.success }}" != "false" ]] || exit 1'
Expand All @@ -94,7 +94,7 @@ jobs:
- name: Commit any changes to charts
if: ${{ github.event_name == 'pull_request' }}
run: |
yarn --cwd infra charts
(cd infra && yarn charts)
./infra/scripts/ci/git-check-dirty.sh "charts/" "charts" "dirtybot"
check-secrets:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/datadog-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Datadog Static Analysis
on:
push:
branches:
- 'main'
- 'release/**'
- 'pre-release/**'
paths-ignore:
- '**/*.md'
workflow_dispatch:
create:
pull_request:
types:
- opened
- synchronize

jobs:
static-analysis:
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
name: Datadog Static Analyzer
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check code meets quality and security standards
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@v1
with:
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_app_key: ${{ secrets.DD_APP_KEY }}
dd_service: islandis
dd_env: ci
dd_site: datadoghq.eu
cpu_count: 2
- name: Check imported libraries are secure and compliant
id: datadog-software-composition-analysis
uses: DataDog/datadog-sca-github-action@main
with:
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_app_key: ${{ secrets.DD_APP_KEY }}
dd_service: islandis
dd_env: ci
dd_site: datadoghq.eu
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ jobs:
echo "SHA='$SHA', retrived from action environment"
fi
echo "Using SHA='$SHA' as docker tag sha"
export DOCKER_TAG=${DOCKER_BRANCH_TAG}_${SHA:0:7}_${GITHUB_RUN_NUMBER}
export DOCKER_TAG=${DOCKER_BRANCH_TAG}_${SHA}_${GITHUB_RUN_NUMBER}
echo "Docker tag will be ${DOCKER_TAG}"
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_OUTPUT
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,10 @@ export class Case {

@Field(() => String, { nullable: true })
readonly indictmentCompletedDate?: string

@Field(() => Case, { nullable: true })
readonly mergeCase?: Case

@Field(() => [Case], { nullable: true })
readonly mergedCases?: Case[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ export class Defendant {
@Field(() => DefenderChoice, { nullable: true })
readonly defenderChoice?: DefenderChoice

@Field(() => Boolean, { nullable: true })
readonly acceptCompensationClaim?: boolean

@Field(() => SubpoenaType, { nullable: true })
readonly subpoenaType?: SubpoenaType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) =>
queryInterface.addColumn(
'case',
'merge_case_id',
{
type: Sequelize.UUID,
references: {
model: 'case',
key: 'id',
},
allowNull: true,
},
{ transaction: t },
),
)
},

down: (queryInterface) => {
return queryInterface.sequelize.transaction((t) =>
queryInterface.removeColumn('case', 'merge_case_id', {
transaction: t,
}),
)
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
up: (queryInterface) => {
return queryInterface.sequelize.transaction((t) =>
queryInterface.removeColumn('defendant', 'accept_compensation_claim', {
transaction: t,
}),
)
},
down: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) =>
queryInterface.addColumn(
'defendant',
'accept_compensation_claim',
{
type: Sequelize.BOOLEAN,
allowNull: true,
},
{ transaction: t },
),
)
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ describe('formatCourtEndDate', () => {
onError: jest.fn,
}).formatMessage

function fn(startDate?: Date, endDate?: Date) {
return formatCourtEndDate(formatMessage, startDate, endDate)
}
const fn = (startDate?: Date, endDate?: Date) =>
formatCourtEndDate(formatMessage, startDate, endDate)

test('should return court still in progress', () => {
const startDate = undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ import {
courtOfAppealsRegistrarUpdateRule,
districtCourtAssistantTransitionRule,
districtCourtAssistantUpdateRule,
districtCourtJudgeSignRulingRule,
districtCourtJudgeTransitionRule,
districtCourtJudgeUpdateRule,
districtCourtRegistrarTransitionRule,
Expand Down Expand Up @@ -765,7 +764,7 @@ export class CaseController {
new CaseTypeGuard([...restrictionCases, ...investigationCases]),
CaseWriteGuard,
)
@RolesRules(districtCourtJudgeSignRulingRule)
@RolesRules(districtCourtJudgeRule)
@Post('case/:caseId/ruling/signature')
@ApiCreatedResponse({
type: SigningServiceResponse,
Expand All @@ -778,6 +777,12 @@ export class CaseController {
): Promise<SigningServiceResponse> {
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(
Expand All @@ -802,7 +807,7 @@ export class CaseController {
new CaseTypeGuard([...restrictionCases, ...investigationCases]),
CaseWriteGuard,
)
@RolesRules(districtCourtJudgeSignRulingRule)
@RolesRules(districtCourtJudgeRule)
@Get('case/:caseId/ruling/signature')
@ApiOkResponse({
type: SignatureConfirmationResponse,
Expand All @@ -817,6 +822,12 @@ export class CaseController {
): Promise<SignatureConfirmationResponse> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ export const include: Includeable[] = [
where: { commentType: { [Op.in]: commentTypes } },
},
{ model: Notification, as: 'notifications' },
{ model: Case, as: 'mergeCase' },
{ model: Case, as: 'mergedCases', separate: true },
]

export const order: OrderItem[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,12 @@ export class InternalCaseService {
theCase.judge?.nationalId === nationalId
? {
name: theCase.judge?.name,
role: UserRole.DISTRICT_COURT_JUDGE,
role: theCase.judge?.role,
}
: theCase.registrar?.nationalId === nationalId
? {
name: theCase.registrar?.name,
role: UserRole.DISTRICT_COURT_REGISTRAR,
role: theCase.registrar?.role,
}
: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,4 +1045,26 @@ export class Case extends Model {
})
@ApiPropertyOptional({ enum: CourtSessionType })
courtSessionType?: CourtSessionType

/**********
* The surrogate key of the case an indictment was merged in to - only used if the has been merged
**********/
@ForeignKey(() => Case)
@Column({ type: DataType.UUID, allowNull: true })
@ApiPropertyOptional({ type: String })
mergeCaseId?: string

/**********
* The case this was merged in to - only used if the case was merged
**********/
@BelongsTo(() => Case, 'mergeCaseId')
@ApiPropertyOptional({ type: () => Case })
mergeCase?: Case

// /**********
// * The cases that have been merged in to the current case - only used if the case was merged
// **********/
@HasMany(() => Case, 'mergeCaseId')
@ApiPropertyOptional({ type: () => Case })
mergedCases?: Case[]
}
Original file line number Diff line number Diff line change
@@ -1,6 +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
let rules: any[]
Expand All @@ -14,6 +13,6 @@ describe('CaseController - Get ruling signature confirmation rules', () => {

it('should give permission to one roles', () => {
expect(rules).toHaveLength(1)
expect(rules).toContain(districtCourtJudgeSignRulingRule)
expect(rules).toContain(districtCourtJudgeRule)
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +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
let rules: any[]
Expand All @@ -14,6 +13,6 @@ describe('CaseController - Request ruling signature rules', () => {

it('should give permission to one roles', () => {
expect(rules).toHaveLength(1)
expect(rules).toContain(districtCourtJudgeSignRulingRule)
expect(rules).toContain(districtCourtJudgeRule)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ describe('InternalCaseController - Deliver assigned roles for indictment case to
type: CaseType.INDICTMENT,
court: { name: courtName },
courtCaseNumber,
judge: { name: 'Test Dómari', nationalId: '0101010101' },
judge: {
name: 'Test Dómari',
nationalId: '0101010101',
role: UserRole.DISTRICT_COURT_JUDGE,
},
registrar: { name: 'Test Ritari', nationalId: '0202020202' },
} as Case

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ export class UpdateDefendantDto {
@ApiPropertyOptional({ type: Date })
readonly verdictViewDate?: Date

@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean })
readonly acceptCompensationClaim?: boolean

@IsOptional()
@IsEnum(SubpoenaType)
@ApiPropertyOptional({ enum: SubpoenaType })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export class InternalDefendantController {
@Patch('defense/:defendantNationalId')
@ApiOkResponse({
type: Defendant,
description:
'Assigns defense choice and compensation claim decision to defendant',
description: 'Assigns defense choice to defendant',
})
async assignDefender(
@Param('caseId') caseId: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ export class Defendant extends Model {
@ApiPropertyOptional({ type: Date })
verdictViewDate?: Date

@Column({ type: DataType.BOOLEAN, allowNull: true })
@ApiPropertyOptional({ type: Boolean })
acceptCompensationClaim?: boolean

@Column({
type: DataType.ENUM,
allowNull: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@ export class UpdateSubpoenaDto {
@IsString()
@ApiProperty({ type: String, required: false })
defenderNationalId?: string

@IsOptional()
@IsBoolean()
@ApiProperty({ type: Boolean, required: false })
acceptCompensationClaim?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface Defendant {
defenderEmail?: string
defenderPhoneNumber?: string
defenderChoice?: DefenderChoice
acceptCompensationClaim?: boolean
}

interface DateLog {
Expand Down
Loading

0 comments on commit cb5d322

Please sign in to comment.