Skip to content

Commit

Permalink
Merge branch 'develop' into fix-advanced-search-pills
Browse files Browse the repository at this point in the history
  • Loading branch information
jamil314 authored Nov 25, 2024
2 parents 66b37c7 + b07a6c1 commit 3c041e1
Show file tree
Hide file tree
Showing 42 changed files with 1,408 additions and 129 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build-images-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
name: Publish images to Dockerhub from any branch

on:
workflow_dispatch:
workflow_call:
inputs:
branch_name:
description: Branch to build from
required: true
type: string
workflow_dispatch:
inputs:
branch_name:
default: develop
required: true
pull_request:
branches-ignore:
- 'dependabot/**'
- 'renovate/**'
description: Branch to build from
push:
branches:
- develop
Expand Down Expand Up @@ -48,6 +50,11 @@ jobs:
export VERSION=`git log -1 --pretty=format:%h`
echo "Pushing version $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
# the event_name is the event that triggered the caller workflow
# and not "workflow_call" like how it was supposed to be when
# another workflow is calling this one
if [ "${{ github.event_name }}" == 'push' ]; then
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
elif [ "${{ github.event_name }}" == 'pull_request' ]; then
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/deploy-to-feature-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ jobs:
}
core.setOutput('stack', slugify('${{ env.BRANCH_NAME }}'));
trigger-build:
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.actor, 'bot') && github.event.pull_request.head.repo.fork == false) }}
needs: generate_stack_name_and_branch
uses: ./.github/workflows/build-images-from-branch.yml
with:
branch_name: ${{ needs.generate_stack_name_and_branch.outputs.branch_name }}
secrets: inherit

trigger-e2e:
if: ${{ (github.event_name == 'workflow_dispatch') || (!contains(github.actor, 'bot') && github.event.pull_request.head.repo.fork == false) }}
runs-on: ubuntu-22.04
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,36 @@ jobs:
with:
node-version-file: .nvmrc

- name: Extract dependencies for ${{ matrix.package }}
if: steps.check-scripts.outputs.skip != 'true'
id: extract-dependencies
run: |
DEPENDENCIES=$(node -e "
const { execSync } = require('child_process');
const output = execSync('yarn --silent workspaces info', { encoding: 'utf-8' });
const json = JSON.parse(output.replaceAll('@opencrvs', 'packages'));
const getDependencies = (pkg) =>
json[pkg].workspaceDependencies.concat(
json[pkg].workspaceDependencies.flatMap(getDependencies)
);
console.log(
getDependencies('${{ matrix.package }}').join(' ')
);
")
echo "DEPENDENCIES=${DEPENDENCIES}" >> $GITHUB_ENV
echo "Found dependencies: $DEPENDENCIES"
- name: Remove other package directories
if: steps.check-scripts.outputs.skip != 'true'
run: |
for dir in packages/*; do
if [ "$dir" != "${{ matrix.package }}" ] && [ "$dir" != "packages/commons" ] && [ "$dir" != "packages/components" ]; then
if [ "${{ matrix.package }}" == "packages/client" ] && [ "$dir" == "packages/gateway" ] ; then
echo "Skipping $dir"
else
echo "Removing $dir"
rm -rf "$dir"
fi
if echo "${{ matrix.package }} $DEPENDENCIES" | grep -q -w "$dir"; then
echo "Skipping $dir"
else
echo "Removing $dir"
rm -rf "$dir"
fi
done
Expand All @@ -119,15 +138,13 @@ jobs:

# TODO: Move out of the matrix to be built once and shared
- name: Build common package
if: steps.check-scripts.outputs.skip != 'true'
if: steps.check-scripts.outputs.skip != 'true' && contains(env.DEPENDENCIES, 'packages/commons')
run: cd packages/commons && yarn build

- name: Build components client and login
if: steps.check-scripts.outputs.skip != 'true'
if: steps.check-scripts.outputs.skip != 'true' && contains(env.DEPENDENCIES, 'packages/components')
run: |
if [[ "${{ matrix.package }}" == "packages/client" || "${{ matrix.package }}" == "packages/login" ]]; then
cd packages/components && yarn build
fi
cd packages/components && yarn build
# TODO: should run parallel to unit tests as can take as much as unit tests
- name: Run linting
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Breaking changes

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

## Improvements

Expand All @@ -26,6 +26,7 @@
- Deploy UI-Kit Storybook to [opencrvs.pages.dev](https://opencrvs.pages.dev) to allow extending OpenCRVS using the component library
- Record audit action buttons are moved into action menu [#7390](https://github.com/opencrvs/opencrvs-core/issues/7390)
- Reoder the sytem user add/edit field for surname to be first, also change labels from `Last name` to `User's surname` and lastly remove the NID question from the form [#6830](https://github.com/opencrvs/opencrvs-core/issues/6830)
- Corrected the total amount displayed for _certification_ and _correction_ fees on the Performance Page, ensuring accurate fee tracking across certification and correction sequences. [#7793](https://github.com/opencrvs/opencrvs-core/issues/7793)
- Auth now allows registrar's token to be exchanged for a new token that strictly allows confirming or rejecting a specific record. Core now passes this token to country configuration instead of the registrar's token [#7728](https://github.com/opencrvs/opencrvs-core/issues/7728) [#7849](https://github.com/opencrvs/opencrvs-core/issues/7849)

## Bug fixes
Expand All @@ -36,6 +37,13 @@
- Only render units/postfix when field has a value [#7055](https://github.com/opencrvs/opencrvs-core/issues/7055)
- Only show items with values in review [#5192](https://github.com/opencrvs/opencrvs-core/pull/5192)
- Fix prefix text overlap issue in form text inputs
- Fix the event name displayed in email templates for death correction requests [#7703](https://github.com/opencrvs/opencrvs-core/issues/7703)

## 1.6.1 Release candidate

### New features

- Add an optional configurable field in section `canContinue` which takes an expression. Falsy value of this expression will disable the continue button in forms. This can be used to work with fetch field which has a loading state and prevent the user to get past the section while the request is still in progress.

## 1.6.0 Release candidate

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ services:
- CONFIG_SMS_CODE_EXPIRY_SECONDS=600
- CONFIG_TOKEN_EXPIRY_SECONDS=604800
- NODE_ENV=development
- EVENTS_URL=http://events:5555/
- FHIR_URL=http://hearth:3447/fhir
- USER_MANAGEMENT_URL=http://user-mgnt:3030/
- SEARCH_URL=http://search:9090/
Expand All @@ -86,6 +87,18 @@ services:
- CHECK_INVALID_TOKEN=true
- MINIO_BUCKET=ocrvs
- DOCUMENTS_URL=http://documents:9050
events:
image: opencrvs/ocrvs-events:${VERSION}
#platform: linux/amd64
build:
context: .
dockerfile: ./packages/events/Dockerfile
restart: unless-stopped
depends_on:
- base
environment:
- MONGO_URL=mongodb://mongo1/events

# User facing services
workflow:
image: opencrvs/ocrvs-workflow:${VERSION}
Expand Down
4 changes: 4 additions & 0 deletions packages/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ FROM opencrvs/ocrvs-base:${BRANCH}

USER node

COPY --chown=node:node packages/gateway /app/packages/gateway
COPY --chown=node:node packages/events /app/packages/events

WORKDIR /app/packages/components
COPY --chown=node:node packages/components /app/packages/components

RUN yarn install --frozen-lockfile && yarn build
ENV CONTENT_SECURITY_POLICY_WILDCARD "{{CONTENT_SECURITY_POLICY_WILDCARD}}"
ENV COUNTRY_CONFIG_URL_INTERNAL "{{COUNTRY_CONFIG_URL_INTERNAL}}"
Expand Down
3 changes: 2 additions & 1 deletion packages/client/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ packages/*
!packages/commons
!packages/components
!packages/client
!packages/gateway
!packages/gateway
!packages/events
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"xregexp": "^4.2.0"
},
"devDependencies": {
"@opencrvs/gateway": "^1.5.0",
"@graphql-codegen/add": "^5.0.0",
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/introspection": "^3.0.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/forms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,14 @@ export interface IFormSection {
optional?: boolean
notice?: MessageDescriptor
mapping?: IFormSectionMapping
/**
* used for disabling continue button conditionally on a loading value
* of a FETCH field
* example: canContinue: '!$form.fetch?.loading'
* above example blocks user when fetch is on loading state, preventing implications
* caused by the unresolved pending requests
*/
canContinue?: string
}

export type ISerializedFormSectionGroup = Omit<IFormSectionGroup, 'fields'> & {
Expand Down
21 changes: 18 additions & 3 deletions packages/client/src/views/RegisterForm/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ import {
getSectionFields,
getNextSectionIds,
VIEW_TYPE,
handleInitialValue
handleInitialValue,
evalExpressionInFieldDefinition
} from '@client/forms/utils'
import { messages } from '@client/i18n/messages/views/register'
import { duplicateMessages } from '@client/i18n/messages/views/duplicates'
Expand Down Expand Up @@ -1002,7 +1003,8 @@ class RegisterFormView extends React.Component<FullProps, State> {
activeSection,
activeSectionGroup,
reviewSummaryHeader,
userDetails
userDetails,
config
} = this.props

const nextSectionGroup = getNextSectionIds(
Expand All @@ -1018,6 +1020,17 @@ class RegisterFormView extends React.Component<FullProps, State> {
const isDocumentUploadPage = this.props.match.params.pageId === 'documents'
const introSection =
findFirstVisibleSection(registerForm.sections).id === activeSection.id
const canContinue =
'canContinue' in activeSection
? evalExpressionInFieldDefinition(
activeSection.canContinue!,
declaration.data[activeSection.id],
config,
declaration.data,
userDetails
)
: true

return (
<>
<TimeMounted
Expand Down Expand Up @@ -1137,7 +1150,9 @@ class RegisterFormView extends React.Component<FullProps, State> {
declaration.event.toLowerCase()
)
}}
disabled={this.state.isFileUploading}
disabled={
!canContinue || this.state.isFileUploading
}
>
{intl.formatMessage(
buttonMessages.continueButton
Expand Down
5 changes: 5 additions & 0 deletions packages/commons/src/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ export const getTokenPayload = (token: string): ITokenPayload => {
}
return decoded
}

export const getUserId = (token: string): string => {
const tokenPayload = getTokenPayload(token.split(' ')[1])
return tokenPayload.sub
}
33 changes: 21 additions & 12 deletions packages/commons/src/events/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const ActionConfig = z.object({
})

export const ActionInputBase = z.object({
type: z.enum(actionTypes as NonEmptyArray<ActionType>),
fields: z.array(
z.object({
id: z.string(),
Expand All @@ -62,18 +61,28 @@ export const ActionInputBase = z.object({
)
})

export const ActionInput = z.union([
ActionInputBase.extend({
type: z.enum([ActionType.CREATE])
}),
ActionInputBase.extend({
type: z.enum([ActionType.REGISTER]),
identifiers: z.object({
trackingId: z.string(),
registrationNumber: z.string()
})
export const CreateActionInput = ActionInputBase.extend({})
export const NotifyActionInput = ActionInputBase.extend({})
export const DeclareActionInput = ActionInputBase.extend({})
export const RegisterActionInput = ActionInputBase.extend({
identifiers: z.object({
trackingId: z.string(),
registrationNumber: z.string()
})
])
})

export const ActionInput = z
.union([
CreateActionInput.extend({ type: z.enum([ActionType.CREATE]) }),
NotifyActionInput.extend({ type: z.enum([ActionType.NOTIFY]) }),
DeclareActionInput.extend({ type: z.enum([ActionType.DECLARE]) }),
RegisterActionInput.extend({ type: z.enum([ActionType.REGISTER]) })
])
.and(
z.object({
createdBy: z.string()
})
)

export type ActionInput = z.infer<typeof ActionInput>

Expand Down
20 changes: 1 addition & 19 deletions packages/commons/src/events/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,7 @@ import { Label, Summary } from './utils'
* A subset of an event. Describes fields that can be sent to the system with the intention of either creating or mutating a an event
*/
export const EventInput = z.object({
type: z.string(),
fields: z.array(
z.object({
id: z.string(),
value: z.union([
z.string(),
z.number(),
z.array(
// @TODO: Check if we could make this stricter
z.object({
optionValues: z.array(z.string()),
type: z.string(),
data: z.string(),
fileSize: z.number()
})
)
])
})
)
type: z.string()
})
export type EventInput = z.infer<typeof EventInput>

Expand Down
Loading

0 comments on commit 3c041e1

Please sign in to comment.