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

fix: [DHIS2-18668] remove delete button in enrollment event pages #3941

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React, { useState } from 'react';
import { FlyoutMenu, IconMore16, MenuItem, MenuDivider } from '@dhis2/ui';
import { FlyoutMenu, IconMore16, MenuItem } from '@dhis2/ui';
import i18n from '@dhis2/d2-i18n';
import type { PlainProps } from './OverflowMenu.types';
import { DeleteMenuItem, DeleteModal } from './Delete';
Expand All @@ -17,11 +17,16 @@ export const OverflowMenuComponent = ({
displayChangelog,
teiId,
programAPI,
readOnlyMode,
}: PlainProps) => {
const [actionsIsOpen, setActionsIsOpen] = useState(false);
const [deleteModalIsOpen, setDeleteModalIsOpen] = useState(false);
const [changelogIsOpen, setChangelogIsOpen] = useState(false);

if (readOnlyMode && !displayChangelog) {
return null;
}

return (
<>
<OverflowButton
Expand All @@ -34,24 +39,23 @@ export const OverflowMenuComponent = ({
component={
<FlyoutMenu dense>
{displayChangelog && (
<>
<MenuItem
label={i18n.t('View changelog')}
onClick={() => {
setChangelogIsOpen(true);
setActionsIsOpen(false);
}}
/>
<MenuDivider dense />
</>
<MenuItem
label={i18n.t('View changelog')}
onClick={() => {
setChangelogIsOpen(true);
setActionsIsOpen(false);
}}
/>
)}
{!readOnlyMode && (
<DeleteMenuItem
trackedEntityTypeName={trackedEntityTypeName}
canWriteData={canWriteData}
canCascadeDeleteTei={canCascadeDeleteTei}
setActionsIsOpen={setActionsIsOpen}
setDeleteModalIsOpen={setDeleteModalIsOpen}
/>
)}
<DeleteMenuItem
trackedEntityTypeName={trackedEntityTypeName}
canWriteData={canWriteData}
canCascadeDeleteTei={canCascadeDeleteTei}
setActionsIsOpen={setActionsIsOpen}
setDeleteModalIsOpen={setDeleteModalIsOpen}
/>
</FlyoutMenu>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const OverflowMenu = ({
displayChangelog,
teiId,
programAPI,
readOnlyMode,
}: Props) => {
const { hasAuthority } = useAuthorities({ authorities: ['F_TEI_CASCADE_DELETE'] });

Expand All @@ -27,6 +28,7 @@ export const OverflowMenu = ({
displayChangelog={displayChangelog}
teiId={teiId}
programAPI={programAPI}
readOnlyMode={readOnlyMode}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Props = {|
displayChangelog: boolean,
teiId: string,
programAPI: any,
readOnlyMode: boolean,
|};

export type PlainProps = {|
Expand All @@ -21,4 +22,5 @@ export type PlainProps = {|
displayChangelog: boolean,
teiId: string,
programAPI: any,
readOnlyMode: boolean,
|};
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const WidgetProfilePlain = ({
trackedEntityData={clientAttributesWithSubvalues}
teiId={teiId}
programAPI={program}
readOnlyMode={readOnlyMode || false}
/>
</div>
</div>
Expand Down
Loading