Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:opencrvs/opencrvs-core into metr…
Browse files Browse the repository at this point in the history
…ics-location-changes
  • Loading branch information
rikukissa committed Jun 14, 2024
2 parents d7048c2 + e4e9a1e commit 67f3f36
Show file tree
Hide file tree
Showing 148 changed files with 735 additions and 580 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
- Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341)
- Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893)
- Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481)
- Fix unassign action not appearing in audit history [#7035](https://github.com/opencrvs/opencrvs-core/pull/7072)
- Fix client modal glitches on integrations page [#7002](https://github.com/opencrvs/opencrvs-core/issues/7002)
- Fix "Print and issue to groom|bride" is added to a different variable [#7066](https://github.com/opencrvs/opencrvs-core/pull/7066)
- Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081)
Expand Down
1 change: 0 additions & 1 deletion development-environment/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set -e
DIR=$(cd "$(dirname "$0")"; pwd)

export LANGUAGES="en,fr"
export LOG_LEVEL="error"

if [ -n "$(uname -a | grep Ubuntu)" ]; then
OS="UBUNTU"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MPL-2.0",
"private": true,
"scripts": {
"start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts",
"start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts",
"start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js",
"test": "jest --coverage --silent --noStackTrace && yarn test:compilation",
"test:watch": "jest --watch",
Expand Down
20 changes: 10 additions & 10 deletions packages/auth/src/config/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import { SENTRY_DSN } from '@auth/constants'
import { ServerRegisterPluginObject } from '@hapi/hapi'
import { logger } from '@opencrvs/commons'
import * as Pino from 'hapi-pino'
import * as Sentry from 'hapi-sentry'
import { SENTRY_DSN } from '@auth/constants'
import { logger } from '@auth/logger'

interface IHapiPlugin {
plugin: typeof Sentry | typeof Pino
options: Record<string, unknown>
}
type IHapiPlugin<T = any> = ServerRegisterPluginObject<T>

export default function getPlugins() {
const plugins: IHapiPlugin[] = [
{
const plugins: IHapiPlugin[] = []

if (process.env.NODE_ENV === 'production') {
plugins.push({
plugin: Pino,
options: {
prettyPrint: false,
logPayload: false,
instance: logger
}
}
]
})
}

if (SENTRY_DSN) {
plugins.push({
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as redis from 'redis'
import { REDIS_HOST } from '@auth/constants'
import { promisify } from 'util'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'

let redisClient: redis.RedisClient

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/authenticate/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
sendVerificationCode,
storeVerificationCode
} from '@auth/features/verifyCode/service'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'
import { unauthorized } from '@hapi/boom'
import { chainW, tryCatch } from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/invalidateToken/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as Joi from 'joi'
import { internal } from '@hapi/boom'
import { invalidateToken } from '@auth/features/invalidateToken/service'
import { postUserActionToMetrics } from '@auth/features/authenticate/service'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'

interface IInvalidateTokenPayload {
token: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
storeRetrievalStepInformation,
RetrievalSteps
} from '@auth/features/retrievalSteps/verifyUser/service'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'

const fetch = fetchAny as fetchAny.FetchMock

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
RetrievalSteps,
deleteRetrievalStepInformation
} from '@auth/features/retrievalSteps/verifyUser/service'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'
import { PRODUCTION } from '@auth/constants'
import { postUserActionToMetrics } from '@auth/features/authenticate/service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@auth/features/retrievalSteps/verifyUser/service'
import { checkVerificationCode } from '@auth/features/verifyCode/service'
import { unauthorized } from '@hapi/boom'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'

interface IVerifyNumberPayload {
nonce: string
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/features/verifyCode/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
createToken,
postUserActionToMetrics
} from '@auth/features/authenticate/service'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'
import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from '@auth/constants'
interface IVerifyPayload {
nonce: string
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import sendUserNameHandler, {
requestSchema as reqSendUserNameSchema
} from '@auth/features/retrievalSteps/sendUserName/handler'
import { tokenHandler } from '@auth/features/system/handler'
import { logger } from '@auth/logger'
import { logger } from '@opencrvs/commons'
import { getPublicKey } from '@auth/features/authenticate/service'
import anonymousTokenHandler, {
responseSchema
Expand Down
22 changes: 18 additions & 4 deletions packages/client/src/SubmissionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const INPROGRESS_STATUS = [
SUBMISSION_STATUS.REQUESTING_CORRECTION
] as const

function isSubmissionAction(action: Action): action is SubmissionAction {
export function isSubmissionAction(action: Action): action is SubmissionAction {
return Object.values(SubmissionAction).includes(action as SubmissionAction)
}

Expand Down Expand Up @@ -104,6 +104,7 @@ export class SubmissionController {
/* eslint-disable no-console */

public sync = () => {
const firstSync = this.syncCount === 0
this.syncCount++
console.debug(`[${this.syncCount}] Starting sync...`)
if (!isNavigatorOnline() || this.syncRunning) {
Expand All @@ -116,11 +117,24 @@ export class SubmissionController {
this.syncRunning = true

this.requeueHangingDeclarations()
const declarations = this.getSubmitableDeclarations()
const submitableDeclarations = this.getSubmitableDeclarations()

if (firstSync) {
const failedDeclarations = this.getDeclarations().filter(
(declaration) =>
declaration.submissionStatus === SUBMISSION_STATUS.FAILED
)

submitableDeclarations.push(...failedDeclarations)
console.debug(
`[${this.syncCount}] First sync, adding ${failedDeclarations.length} failed declarations`
)
}

console.debug(
`[${this.syncCount}] Syncing ${declarations.length} declarations`
`[${this.syncCount}] Syncing ${submitableDeclarations.length} declarations`
)
for (const declaration of declarations) {
for (const declaration of submitableDeclarations) {
const action = declaration.action
if (action && isSubmissionAction(action)) {
this.store.dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ describe('download button tests', () => {
let store: AppStore
let history: History<unknown>
let testComponent: ReactWrapper<{}, {}>
let deleteSpy: SpyInstance
let unassignSpy: SpyInstance
let client: ApolloClient<{}>

describe('for download status downloaded', () => {
describe('when assignment object is undefined in props', () => {
beforeEach(async () => {
deleteSpy = vi.spyOn(declarationReducer, 'deleteDeclaration')
const testStore = await createTestStore()
store = testStore.store
history = testStore.history
Expand Down Expand Up @@ -80,11 +78,6 @@ describe('download button tests', () => {
const modal = getAssignmentModal(testComponent)
expect(modal.text()).toContain('Unassign record?')
})

it('clicking on unassign button triggers deleteDeclaration action', () => {
clickOnModalAction(testComponent, '#unassign')
expect(deleteSpy).toBeCalledWith('123', client)
})
})
describe('when assignment object is defined in props', () => {
beforeEach(async () => {
Expand Down
18 changes: 4 additions & 14 deletions packages/client/src/components/interface/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) {
downloadDeclaration,
userRole,
practitionerId,
unassignDeclaration,
deleteDeclaration
unassignDeclaration
} = props
const { assignment, compositionId } = downloadConfigs
const [assignModal, setAssignModal] = useState<AssignModalOptions | null>(
Expand All @@ -238,18 +237,9 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) {
}, [downloadConfigs, client, downloadDeclaration])
const hideModal = useCallback(() => setAssignModal(null), [])
const unassign = useCallback(async () => {
if (assignment) {
unassignDeclaration(compositionId, client)
} else {
deleteDeclaration(compositionId, client)
}
}, [
compositionId,
client,
unassignDeclaration,
assignment,
deleteDeclaration
])
unassignDeclaration(compositionId, client)
}, [compositionId, client, unassignDeclaration])

const isFailed = useMemo(
() =>
status === DOWNLOAD_STATUS.FAILED ||
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/components/interface/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ const NavigationView = (props: IFullProps) => {
(
[
...ALLOWED_STATUS_FOR_RETRY,
...INPROGRESS_STATUS
...INPROGRESS_STATUS,
SUBMISSION_STATUS.FAILED
] as SUBMISSION_STATUS[]
).includes(draft.submissionStatus as SUBMISSION_STATUS)
).length
Expand Down
23 changes: 12 additions & 11 deletions packages/client/src/declarations/submissionMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,8 @@ export const submissionMiddleware: Middleware<{}, IStoreState> =
2000
)
} catch (error) {
if (!(error instanceof ApolloError)) {
updateDeclaration(dispatch, {
...declaration,
submissionStatus: SUBMISSION_STATUS.FAILED
})
captureException(error)
return
}
if (
error instanceof ApolloError &&
error.graphQLErrors.length > 0 &&
error.graphQLErrors[0].extensions.code === 'UNASSIGNED'
) {
Expand All @@ -346,11 +339,19 @@ export const submissionMiddleware: Middleware<{}, IStoreState> =
dispatch(deleteDeclaration(declaration.id, client))
return
}
if (error instanceof ApolloError && error.networkError) {
updateDeclaration(dispatch, {
...declaration,
submissionStatus: SUBMISSION_STATUS.FAILED_NETWORK
})
captureException(error)
return
}

updateDeclaration(dispatch, {
...declaration,
submissionStatus: error.networkError
? SUBMISSION_STATUS.FAILED_NETWORK
: SUBMISSION_STATUS.FAILED
submissionStatus: SUBMISSION_STATUS.FAILED
})
captureException(error)
}
}
11 changes: 11 additions & 0 deletions packages/client/src/i18n/messages/views/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ const messagesToDefine = {
description: 'Label for declaration status waiting for reject',
id: 'regHome.outbox.statusWaitingToSubmit'
},
retry: {
id: 'regHome.outbox.retry',
defaultMessage: 'Retry',
description:
'Copy for "Retry" button in Outbox shown for records that failed to send'
},
userAuditSuccess: {
defaultMessage:
'{name} was {action, select, DEACTIVATE {deactivated} REACTIVATE {reactivated} other {deactivated}}',
Expand Down Expand Up @@ -164,6 +170,11 @@ const messagesToDefine = {
description: 'Label for declaration status waiting for connection',
id: 'regHome.outbox.waitingToRetry'
},
failed: {
defaultMessage: 'Failed to send',
description: 'Label for declaration status failed',
id: 'regHome.outbox.failed'
},
downloadDeclarationFailed: {
defaultMessage: 'Failed to download declaration. Please try again',
description: 'Label for declaration downloading failed',
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,5 @@ vi.mock('@client/views/OIDPVerificationCallback/utils', async () => ({
'@client/views/OIDPVerificationCallback/utils'
)) as any),
useExtractCallBackState: vi.fn(),
useQueryParams: vi.fn(),
useCheckNonce: vi.fn()
useQueryParams: vi.fn()
}))
4 changes: 2 additions & 2 deletions packages/client/src/utils/referenceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ async function loadForms(): Promise<LoadFormsResponse> {
throw err
}

if (res && res.status !== 201) {
throw Error(res.statusText)
if (res && !res.ok) {
throw new Error(res.statusText)
}

const response = await res.json()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { waitFor, waitForElement } from '@client/tests/wait-for-element'
import { vi, Mock } from 'vitest'
import { OIDPVerificationCallback } from './OIDPVerificationCallback'
import { URLSearchParams } from 'url'
import { useQueryParams, useExtractCallBackState, useCheckNonce } from './utils'
import { useQueryParams, useExtractCallBackState } from './utils'
import { GET_OIDP_USER_INFO } from './queries'
import { createDeclaration, storeDeclaration } from '@client/declarations'
import { Event } from '@client/utils/gateway'
Expand Down Expand Up @@ -131,7 +131,6 @@ beforeEach(async () => {
;(useQueryParams as Mock).mockImplementation(
() => new URLSearchParams({ code: '1234' })
)
;(useCheckNonce as Mock).mockImplementation(() => true)

await store.dispatch(checkAuth())
await store.dispatch(storeDeclaration(draft))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { useIntl } from 'react-intl'
import { useDispatch, useSelector } from 'react-redux'
import {
addNidUserInfoToDeclaration,
useCheckNonce,
useExtractCallBackState,
useQueryParams
} from '@client/views/OIDPVerificationCallback/utils'
Expand All @@ -38,7 +37,6 @@ import { OIDP_VERIFICATION_CALLBACK } from '@client/navigation/routes'
// OIDP Verification Callback
// --
// Checks the ?state= query parameter for a JSON string like: { pathname: "/path/somewhere" }
// Checks that the &nonce= parameter matches the one in localStorage, removes it if yes, throws if not
// Redirects to the pathname in state

const Page = styled.div`
Expand All @@ -65,7 +63,6 @@ const UserActionsContainer = styled.div`
export const OIDPVerificationCallback = () => {
const params = useQueryParams()
const { pathname, declarationId, section } = useExtractCallBackState()
const isNonceOk = useCheckNonce()
const code = params.get('code')
const offlineData = useSelector(getOfflineData)
const clientId = offlineData.systems.find((s) => s.type === 'NATIONAL_ID')
Expand All @@ -91,7 +88,7 @@ export const OIDPVerificationCallback = () => {
}
})

if (!pathname || !isNonceOk) {
if (!pathname) {
// Do not redirect and let the hooks throw
return null
}
Expand Down
Loading

0 comments on commit 67f3f36

Please sign in to comment.