Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-7584
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa authored Nov 14, 2024
2 parents 9838169 + da4a0b5 commit 48ff7f4
Show file tree
Hide file tree
Showing 14 changed files with 466 additions and 709 deletions.
16 changes: 0 additions & 16 deletions .trivyignore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ vulnerabilities:
statement: Dashboards vulns (java libs)
- id: CVE-2022-1471
statement: Dashboards vulns (java libs)
- id: CVE-2024-25710
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49
- id: CVE-2024-26308
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49
- id: CVE-2024-22201
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49
- id: CVE-2023-36478
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49
- id: CVE-2024-21634
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49
- id: CVE-2024-4068
statement: Transitive dependency of jest and msw. Not running in production. Likely fixed by upgrading.
- id: CVE-2024-37890
Expand All @@ -57,9 +47,3 @@ vulnerabilities:
statement: Transitive dependency of react-router 5.3.4. Only affects client-side code ocrvs-7682
- id: CVE-2024-47068
statement: Transitive dependency of Vite. Not run in production and there is currently no fix.
- id: CVE-2024-7254
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.50 ocrvs-6607
- id: CVE-2024-41909
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.50 ocrvs-6607
- id: CVE-2024-22871
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.50 ocrvs-6607
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Breaking changes

- **Title** Description
- **Dashboard:** Changes made to the dashboard configuration will reset after upgrading OpenCRVS.

## Improvements

Expand Down
1 change: 1 addition & 0 deletions packages/client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'no-restricted-imports': [
'error',
{
Expand Down
2 changes: 2 additions & 0 deletions packages/client/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const config: CodegenConfig = {
/*
* DO NOT EDIT! This file is auto-generated by yarn generate-gateway-types - see 'codegen.yml'
*/
/* eslint-disable */
import { PlainDate } from '@client/utils/date-formatting'
`
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"open:cov": "yarn test && opener coverage/index.html",
"lint": "yarn lint:css && yarn lint:ts",
"lint:css": "stylelint 'src/**/*.{ts,tsx}'",
"lint:ts": "eslint --fix './src/**/*.{ts,tsx}' --max-warnings=0",
"lint:ts": "eslint --fix './src/**/*.{ts,tsx}' --max-warnings=349",
"test:compilation": "tsc --noEmit",
"extract:translations": "bash extract-translations.sh",
"generate-gateway-types": "NODE_OPTIONS=--dns-result-order=ipv4first graphql-codegen --config codegen.ts && prettier --write src/utils/gateway.ts",
Expand Down Expand Up @@ -111,6 +111,7 @@
"@graphql-codegen/introspection": "^3.0.0",
"@graphql-codegen/typescript": "^3.0.0",
"@graphql-codegen/typescript-operations": "^3.0.0",
"@types/browser-image-compression": "^1.0.13",
"@types/csv2json": "^1.4.5",
"@types/enzyme": "^3.1.13",
"@types/fetch-mock": "^7.3.0",
Expand Down Expand Up @@ -161,7 +162,6 @@
"traverse": "^0.6.6",
"ts-node": "^7.0.1",
"typescript": "4.9.5",
"vite-plugin-babel-macros": "^1.0.6",
"vite-plugin-pwa": "^0.20.0",
"vitest": "0.25.5",
"vitest-fetch-mock": "^0.2.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ type DocumentFields = {
documentData: string
}

export const getBase64String = (file: File) => {
return new Promise<string | ArrayBuffer>((resolve, reject) => {
const getBase64String = (file: File) => {
return new Promise<string>((resolve, reject) => {
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => {
if (reader.result) {
return resolve(reader.result)
return resolve(reader.result.toString())
}
}
reader.onerror = (error) => reject(error)
Expand Down Expand Up @@ -152,26 +152,26 @@ export const DocumentUploaderWithOption = (props: IFullProps) => {
if (props.compressImagesToSizeMB !== undefined) {
options.maxSizeMB = props.compressImagesToSizeMB
}
// disable compression with a falsy value
const resized =
Boolean(options.maxSizeMB) &&
bytesToMB(uploadedImage.size) > options.maxSizeMB &&
(await imageCompression(uploadedImage, options))
if (
!Boolean(options.maxSizeMB) ||
bytesToMB(uploadedImage.size) <= options.maxSizeMB
) {
return uploadedImage
}

const fileAsBase64 = await getBase64String(resized || uploadedImage)
const resized = await imageCompression(uploadedImage, options)

return fileAsBase64.toString()
return resized
}

const handleFileChange = async (uploadedImage: File) => {
if (!uploadedImage) {
return
}

// If there is only one option available then it would stay selected
const documentType = fields.documentType || dropdownOptions[0].value

let fileAsBase64: string
let processedFile: File
const optionValues: [IFormFieldValue, string] = [
props.extraValue,
documentType
Expand All @@ -194,7 +194,7 @@ export const DocumentUploaderWithOption = (props: IFullProps) => {

try {
// Start processing
;[fileAsBase64] = await Promise.all([
;[processedFile] = await Promise.all([
processImage(uploadedImage),
minimumProcessingTime
])
Expand Down Expand Up @@ -223,9 +223,9 @@ export const DocumentUploaderWithOption = (props: IFullProps) => {

const newDocument: IFileValue = {
optionValues,
type: uploadedImage.type,
data: fileAsBase64.toString(),
fileSize: uploadedImage.size
type: processedFile.type,
data: await getBase64String(processedFile),
fileSize: processedFile.size
}

props.onComplete([...props.files, newDocument])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import styled from 'styled-components'
import { DocumentListPreview } from './DocumentListPreview'
import { buttonMessages, formMessages as messages } from '@client/i18n/messages'
import { getBase64String } from './DocumentUploaderWithOption'
import { getBase64String } from '@client/utils/imageUtils'

const DocumentUploader = styled(ImageUploader)`
color: ${({ theme }) => theme.colors.primary};
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/utils/gateway-deprecated-do-not-use.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

/* eslint-disable @typescript-eslint/no-explicit-any */

import { GraphQLResolveInfo, GraphQLScalarType } from 'graphql'
/**
* This file is auto-generated by graphql-schema-typescript
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/*
* DO NOT EDIT! This file is auto-generated by yarn generate-gateway-types - see 'codegen.yml'
*/

/* eslint-disable */
import { PlainDate } from '@client/utils/date-formatting'

export type Maybe<T> = T | null
Expand Down
11 changes: 0 additions & 11 deletions packages/client/typings/browser-image-compression.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/dashboards/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM metabase/metabase:v0.46.6.4
FROM metabase/metabase:v0.50.30.1

ADD packages/dashboards/run.sh /
ADD packages/dashboards/initialize-database.sh /
Expand Down
Loading

0 comments on commit 48ff7f4

Please sign in to comment.