Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Action Menu #7633

Open
wants to merge 71 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
97cc9d9
feat: implement action menu
jamil314 Sep 19, 2024
6853f29
chore: export `IProps`
jamil314 Sep 19, 2024
6e39150
feat: enable keyboard navigation
jamil314 Sep 20, 2024
29b3a8d
Merge branch 'develop' into action-menu
jamil314 Sep 20, 2024
d7cc771
feat: implement `Dropdown` component
jamil314 Sep 23, 2024
6dea8e3
feat: make dropdownMenu keyboard accessible
jamil314 Sep 24, 2024
bd37024
feat: make dropdownMenu close on click outside and esc
jamil314 Sep 24, 2024
3bd63c2
fix: make some props optional
jamil314 Sep 24, 2024
95e9b10
fix: close menu on ouside click
jamil314 Sep 24, 2024
60e3bfe
feat: create actionMenu
jamil314 Sep 24, 2024
e46dc94
feat: add `Update`, `Print`, `Issue`, `Delete` items
jamil314 Sep 25, 2024
48a0c3b
feat: implement delete declaration
jamil314 Sep 25, 2024
b326939
Merge branch 'develop' into action-menu
jamil314 Sep 25, 2024
c872344
feat: redirect to home after deleting draft
jamil314 Sep 25, 2024
a6ff234
feat: add label for assigned to someone else
jamil314 Sep 25, 2024
0071b8f
refactor: move actionItems
jamil314 Sep 25, 2024
be12ad6
Merge branch 'develop' into action-menu
jamil314 Sep 26, 2024
1820f6f
amend: add missing props
jamil314 Sep 26, 2024
92f2b28
feat: add scope and other checks for: correct record
jamil314 Sep 26, 2024
40f3d6e
Merge branch 'develop' into action-menu
jamil314 Sep 26, 2024
07ecc4e
feat: add scope and other checks for: archive declaration
jamil314 Sep 26, 2024
e1730ff
Merge branch 'action-menu' of https:/opencrvs/opencrvs-co…
jamil314 Sep 26, 2024
ec229b0
feat: add scope and other checks for: reinstate declaration
jamil314 Sep 26, 2024
bca7d50
refactor: restructure types
jamil314 Sep 26, 2024
371b26b
feat: add scope and other checks for: review
jamil314 Sep 26, 2024
aeb2c98
chore: add todo
jamil314 Sep 26, 2024
e774d62
feat: add scope and other checks for: update declaration
jamil314 Sep 26, 2024
6f60039
feat: add scope and other checks for: print declaration
jamil314 Sep 26, 2024
7a81c01
chore: remove console.log
jamil314 Sep 26, 2024
0cb3f3f
feat: add scope and other checks for: issue certificate
jamil314 Sep 26, 2024
8cdc58a
feat: add scope and other checks for: delete declaration
jamil314 Sep 26, 2024
fd6de09
refactor: change order of items
jamil314 Sep 26, 2024
b25bfa1
wip
jamil314 Sep 27, 2024
5377129
Revert "wip"
jamil314 Sep 27, 2024
79915be
feat: implement unassign button
jamil314 Sep 27, 2024
70fafcd
fix: font and color
jamil314 Sep 27, 2024
fc9dd17
fix: keyDown behaviour
jamil314 Sep 27, 2024
6349d18
chore: remove record audit buttons
jamil314 Sep 27, 2024
1ccc233
refactor: use dropdownMenu to refactor toggleMenu
jamil314 Sep 27, 2024
12a0b2e
chore: remove action from component
jamil314 Sep 27, 2024
916febb
chore: deprecate toggleMenu
jamil314 Sep 27, 2024
3d953f7
Merge branch 'develop' into action-menu
jamil314 Sep 27, 2024
2fb782e
feat: move self unassign to actionMenu
jamil314 Sep 27, 2024
d5a37c6
chore: dont unassign from download button
jamil314 Sep 27, 2024
aa1b022
chore: remove unused imports
jamil314 Sep 27, 2024
ee1cc11
chore: update changelog
jamil314 Sep 27, 2024
610a702
fix: RA will see "correct record" button
jamil314 Sep 30, 2024
3046577
fix: add id in dropdown menu
jamil314 Sep 30, 2024
9db81b2
Merge branch 'develop' into action-menu
rikukissa Sep 30, 2024
3fb579c
refactor: `isDownloadable` logic
jamil314 Oct 8, 2024
fe52196
refactor: remove types from actionMessages
jamil314 Oct 8, 2024
2bb9fe4
refactor: use `useIntl` and `useDispatch` hooks instead of props dril…
jamil314 Oct 8, 2024
08f1213
refactor: dont pass assignment to unassign comp
jamil314 Oct 8, 2024
3d700d3
refactor: use `offsetX` and `offsetY` instead of `offset_x` and `offs…
jamil314 Oct 8, 2024
4dccf00
Merge branch 'develop' into action-menu
jamil314 Oct 8, 2024
33ef0bf
refactor: use `<Button>` instead of `<PrimaryButton>`
jamil314 Oct 8, 2024
539318c
Merge branch 'action-menu' of https:/opencrvs/opencrvs-co…
jamil314 Oct 8, 2024
62836f6
refactor: remove unnecessary `<div>`s
jamil314 Oct 8, 2024
80671a0
feat: use `anchor` and `popover` api to toggle the dropdown visivility
jamil314 Oct 11, 2024
8773dc8
fix: focus
jamil314 Oct 11, 2024
c5453f6
chore: remove as string
jamil314 Oct 11, 2024
ce74d44
refactor: early return if condition fails
jamil314 Oct 11, 2024
fbff2c4
refactor: move declaration status logic into declarations/utils
jamil314 Oct 11, 2024
ab244ae
refactor: change type of status to `SUBMISSION_STATUS`
jamil314 Oct 11, 2024
f393b16
fix: handle multiple dropdown
jamil314 Oct 11, 2024
916eb6d
fix: styles
jamil314 Oct 11, 2024
f308a59
fix: position options and story
jamil314 Oct 11, 2024
8ee686b
Merge branch 'develop' into action-menu
jamil314 Oct 11, 2024
42b38df
fix: close dropdown on action click
jamil314 Oct 14, 2024
5049e56
Merge branch 'develop' into action-menu
jamil314 Oct 14, 2024
0b77313
refactor: align EVENT in common with Event in client
jamil314 Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Two new statuses of record are added: `Validated` and `Correction Requested` for advanced search parameters [#6365](https:/opencrvs/opencrvs-core/issues/6365)
- A new field: `Time Period` is added to advanced search [#6365](https:/opencrvs/opencrvs-core/issues/6365)
- 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:/opencrvs/opencrvs-core/issues/7390)

## Bug fixes

Expand Down
8 changes: 6 additions & 2 deletions packages/client/src/components/interface/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) {
// field agents can only retrieve declarations
const isNotFieldAgent = !FIELD_AGENT_ROLES.includes(String(userRole))

const onClickDownload = useCallback(
const isDownloadable =
status !== DOWNLOAD_STATUS.DOWNLOADED &&
(!assignment || assignment.practitionerId === practitionerId)

const onDownloadClick = useCallback(
(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
if (
(assignment?.practitionerId !== practitionerId ||
Expand Down Expand Up @@ -337,7 +341,7 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) {
<DownloadAction
type="icon"
id={`${id}-icon${isFailed ? `-failed` : ``}`}
onClick={onClickDownload}
onClick={isDownloadable ? onDownloadClick : undefined}
className={className}
aria-label={intl.formatMessage(constantsMessages.assignRecord)}
>
Expand Down
65 changes: 65 additions & 0 deletions packages/client/src/declarations/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https:/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

import { EVENT_STATUS } from '@client/workqueue'
import { SUBMISSION_STATUS } from '.'

export const isPendingCorrection = (status?: SUBMISSION_STATUS) =>
status === EVENT_STATUS.CORRECTION_REQUESTED

export const isReviewableDeclaration = (status?: SUBMISSION_STATUS) =>
status && [EVENT_STATUS.DECLARED, EVENT_STATUS.VALIDATED].includes(status)

export const isUpdatableDeclaration = (status?: SUBMISSION_STATUS) =>
status &&
[
SUBMISSION_STATUS.DRAFT,
EVENT_STATUS.IN_PROGRESS,
EVENT_STATUS.REJECTED
].includes(status)

export const isPrintable = (status?: SUBMISSION_STATUS) =>
status &&
[SUBMISSION_STATUS.REGISTERED, SUBMISSION_STATUS.ISSUED].includes(status)

export const isCertified = (status?: SUBMISSION_STATUS) =>
status === SUBMISSION_STATUS.CERTIFIED

export const isRecordOrDeclaration = (status?: SUBMISSION_STATUS) =>
status
? [
SUBMISSION_STATUS.REGISTERED,
SUBMISSION_STATUS.CORRECTION_REQUESTED,
SUBMISSION_STATUS.CERTIFIED
].includes(status)
? 'record'
: 'declaration'
: ''

export const canBeCorrected = (status?: SUBMISSION_STATUS) =>
status &&
[
SUBMISSION_STATUS.REGISTERED,
SUBMISSION_STATUS.CERTIFIED,
SUBMISSION_STATUS.ISSUED
].includes(status)

export const isArchivable = (status?: SUBMISSION_STATUS) =>
status &&
[
SUBMISSION_STATUS.IN_PROGRESS,
SUBMISSION_STATUS.DECLARED,
SUBMISSION_STATUS.VALIDATED,
SUBMISSION_STATUS.REJECTED
].includes(status)

export const isArchived = (status?: SUBMISSION_STATUS) =>
status === SUBMISSION_STATUS.ARCHIVED
2 changes: 1 addition & 1 deletion packages/client/src/i18n/messages/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface IButtonsMessages
const messagesToDefine: IButtonsMessages = {
archive: {
id: 'buttons.archive',
defaultMessage: 'Archive',
defaultMessage: 'Archive declaration',
description: 'Archive button text'
},
approve: {
Expand Down
71 changes: 71 additions & 0 deletions packages/client/src/i18n/messages/views/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https:/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import { defineMessages } from 'react-intl'

const messagesToDefine = {
action: {
defaultMessage: 'Action',
description: 'Label for action button in dropdown menu',
id: 'action.action'
},
assignedTo: {
defaultMessage: 'Assigned to {name} at {officeName}',
description: 'Label for assignee',
id: 'action.assignee'
},
view: {
defaultMessage: 'View {recordOrDeclaration}',
description: 'Label for view button in dropdown menu',
id: 'action.view'
},
correctRecord: {
defaultMessage: 'Correct Record',
description: 'Label for correct record button in dropdown menu',
id: 'action.correct'
},
archiveRecord: {
defaultMessage: 'Archive Record',
description: 'Label for archive record button in dropdown menu',
id: 'action.archive'
},
reinstateRecord: {
defaultMessage: 'Reinstate Record',
description: 'Label for reinstate record button in dropdown menu',
id: 'action.reinstate'
},
reviewCorrection: {
defaultMessage: 'Review correction request',
description: 'Label for review correction request button in dropdown menu',
id: 'action.review.correction'
},
reviewDeclaration: {
defaultMessage:
'Review {isDuplicate, select, true{potential duplicate} other{declaration}}',
description: 'Label for review record button in dropdown menu',
id: 'action.review.declaration'
},
updateDeclaration: {
defaultMessage: 'Update declaration',
description: 'Label for update record button in dropdown menu',
id: 'action.update'
},
printDeclaration: {
defaultMessage: 'Print certified copy',
description: 'Label for print certified copy in dropdown menu',
id: 'action.print'
},
issueCertificate: {
defaultMessage: 'Issue certificate',
description: 'Label for issue certificate in dropdown menu',
id: 'action.issue'
}
}
export const messages = defineMessages(messagesToDefine)
9 changes: 5 additions & 4 deletions packages/client/src/search/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@ import { formatLongDate } from '@client/utils/date-formatting'
import {
HumanName,
EventSearchSet,
SearchEventsQuery
SearchEventsQuery,
Event
} from '@client/utils/gateway'
import { EMPTY_STRING, LANG_EN } from '@client/utils/constants'
import { ITaskHistory } from '@client/declarations'

export const isBirthEvent = (
req: EventSearchSet
): req is GQLBirthEventSearchSet => {
return req.type === 'Birth'
return req.type === Event.Birth
}

export const isDeathEvent = (
req: EventSearchSet
): req is GQLDeathEventSearchSet => {
return req.type === 'Death'
return req.type === Event.Death
}

export const isMarriageEvent = (
reg: EventSearchSet
): reg is GQLMarriageEventSearchSet => {
return reg.type === 'Marriage'
return reg.type === Event.Marriage
}

export const transformData = (
Expand Down
Loading
Loading