Skip to content

Commit

Permalink
fix: pr-review
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Oct 28, 2024
1 parent 295b866 commit 611fbb1
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
10 changes: 8 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-10-22T14:40:35.028Z\n"
"PO-Revision-Date: 2024-10-22T14:40:35.028Z\n"
"POT-Creation-Date: 2024-10-28T13:13:50.133Z\n"
"PO-Revision-Date: 2024-10-28T13:13:50.133Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1690,6 +1690,9 @@ msgstr[1] "{{count}} enrollments already marked as completed will not be changed
msgid "Mark all events within enrollments as complete"
msgstr "Mark all events within enrollments as complete"

msgid "You do not have access to bulk complete enrollments"
msgstr "You do not have access to bulk complete enrollments"

msgid "Complete enrollments"
msgstr "Complete enrollments"

Expand All @@ -1710,6 +1713,9 @@ msgstr "An error occurred when completing the enrollments"
msgid "An unknown error occurred when completing enrollments"
msgstr "An unknown error occurred when completing enrollments"

msgid "You do not have access to delete enrollments"
msgstr "You do not have access to delete enrollments"

msgid "Delete enrollments"
msgstr "Delete enrollments"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = {
selectedRows: { [id: string]: any },
programId: string,
stages: Map<string, ProgramStage>,
programDataWriteAccess: boolean,
onUpdateList: (disableClearSelections?: boolean) => void,
removeRowsFromSelection: (rows: Array<string>) => void,
};
Expand Down Expand Up @@ -50,6 +51,7 @@ const CompleteActionPlain = ({
selectedRows,
programId,
stages,
programDataWriteAccess,
onUpdateList,
removeRowsFromSelection,
classes,
Expand Down Expand Up @@ -170,12 +172,18 @@ const CompleteActionPlain = ({

return (
<>
<Button
small
onClick={() => setModalIsOpen(true)}
<ConditionalTooltip
enabled={!programDataWriteAccess}
content={i18n.t('You do not have access to bulk complete enrollments')}
>
{i18n.t('Complete enrollments')}
</Button>
<Button
small
disabled={!programDataWriteAccess}
onClick={() => setModalIsOpen(true)}
>
{i18n.t('Complete enrollments')}
</Button>
</ConditionalTooltip>

{modalIsOpen && (
<Modal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// @flow
import React, { useState } from 'react';
import i18n from '@dhis2/d2-i18n';
import {
Button,
} from '@dhis2/ui';
import { Button } from '@dhis2/ui';
import { useAuthority } from '../../../../../../utils/userInfo/useAuthority';
import { EnrollmentDeleteModal } from './EnrollmentDeleteModal';
import { ConditionalTooltip } from '../../../../../Tooltips/ConditionalTooltip';

type Props = {
selectedRows: { [id: string]: boolean },
programDataWriteAccess: boolean,
programId: string,
onUpdateList: () => void,
}
Expand All @@ -17,6 +17,7 @@ const CASCADE_DELETE_TEI_AUTHORITY = 'F_ENROLLMENT_CASCADE_DELETE';

export const DeleteEnrollmentsAction = ({
selectedRows,
programDataWriteAccess,
programId,
onUpdateList,
}: Props) => {
Expand All @@ -29,12 +30,18 @@ export const DeleteEnrollmentsAction = ({

return (
<>
<Button
small
onClick={() => setIsDeleteDialogOpen(true)}
<ConditionalTooltip
enabled={!programDataWriteAccess}
content={i18n.t('You do not have access to delete enrollments')}
>
{i18n.t('Delete enrollments')}
</Button>
<Button
small
disabled={!programDataWriteAccess}
onClick={() => setIsDeleteDialogOpen(true)}
>
{i18n.t('Delete enrollments')}
</Button>
</ConditionalTooltip>

{isDeleteDialogOpen && (
<EnrollmentDeleteModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type Props = {

const CASCADE_DELETE_TEI_AUTHORITY = 'F_TEI_CASCADE_DELETE';


// TODO - Add program and TEType access checks before adding action to prod
export const DeleteTeiAction = ({
selectedRows,
selectedRowsCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const TrackedEntityBulkActionsComponent = ({
selectedRows,
programId,
stages,
programDataWriteAccess,
onClearSelection,
onUpdateList,
removeRowsFromSelection,
Expand All @@ -26,6 +27,7 @@ export const TrackedEntityBulkActionsComponent = ({
>
<CompleteAction
programId={programId}
programDataWriteAccess={programDataWriteAccess}
selectedRows={selectedRows}
stages={stages}
onUpdateList={onUpdateList}
Expand All @@ -34,6 +36,7 @@ export const TrackedEntityBulkActionsComponent = ({

<DeleteEnrollmentsAction
selectedRows={selectedRows}
programDataWriteAccess={programDataWriteAccess}
programId={programId}
onUpdateList={onUpdateList}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { TrackedEntityBulkActionsComponent } from './TrackedEntityBulkActions.co
import type { ContainerProps } from './TrackedEntityBulkActions.types';
import { errorCreator } from '../../../../../capture-core-utils';

export const TrackedEntityBulkActions = ({ programStageId, stages, programId, ...passOnProps }: ContainerProps) => {
export const TrackedEntityBulkActions = ({
programStageId,
stages,
programDataWriteAccess,
programId,
...passOnProps
}: ContainerProps) => {
if (programStageId) {
const stage = stages.get(programStageId);

Expand All @@ -27,6 +33,7 @@ export const TrackedEntityBulkActions = ({ programStageId, stages, programId, ..
<TrackedEntityBulkActionsComponent
programId={programId}
stages={stages}
programDataWriteAccess={programDataWriteAccess}
{...passOnProps}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type Props = {|
programId: string,
stages: Map<string, ProgramStage>,
onClearSelection: () => void,
programDataWriteAccess: boolean,
onUpdateList: () => void,
removeRowsFromSelection: (rows: Array<string>) => void,
|}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const TrackerWorkingListsViewMenuSetup = ({
const TrackedEntityBulkActionsComponent = useMemo(() => (
<TrackedEntityBulkActions
programId={program.id}
programDataWriteAccess={program.access.data.write}
programStageId={programStageId}
stages={program.stages}
selectedRows={selectedRows}
Expand Down

0 comments on commit 611fbb1

Please sign in to comment.