Skip to content

Commit

Permalink
fix: [DHIS2-18668] remove delete tei button in enrollment event pages (
Browse files Browse the repository at this point in the history
…#3941)

* fix: implement logic

* fix: remove divider

* fix: remove breaking tests

* fix: change test

* fix: change test
eirikhaugstulen authored Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
marmarek Marek Marczykowski-Górecki
1 parent a5be53a commit aef3400
Showing 7 changed files with 38 additions and 37 deletions.
8 changes: 8 additions & 0 deletions cypress/e2e/NewPage/NewPage.js
Original file line number Diff line number Diff line change
@@ -649,6 +649,14 @@ And('you delete the recently added tracked entity', () => {
});

And('you delete the recently added malaria entity', () => {
// deselect the program stage from the context selector
cy.get('[data-test="stage-selector-container-clear-icon"]')
.click();

cy.get('[data-test="dhis2-uicore-button"]')
.contains('Yes, discard changes')
.click();

cy.get('[data-test="profile-widget"]')
.contains('Malaria Entity profile')
.should('exist');
Original file line number Diff line number Diff line change
@@ -38,15 +38,6 @@ Feature: The user interacts with the widgets on the enrollment add event page
And the user sees the owner organisation unit
And the user sees the last update date

Scenario: You can delete a tracked entity from the profile widget
Given you add a new tracked entity in the Malaria focus investigation program
When the user clicks the "Back to all stages and events" button
When the user clicks the "New Event" button
When you open the overflow menu and click the "Delete Focus area" button
Then you see the delete tracked entity confirmation modal
When you confirm by clicking the "Yes, delete Focus area" button
Then you are redirected to the home page

Scenario: User can open the delete modal
Given you land on the enrollment add event page by having typed #/enrollmentEventNew?programId=IpHINAT79UW&orgUnitId=DiszpKrYNg8&teiId=EaOyKGOIGRp&enrollmentId=wBU0RAsYjKE&stageId=A03MvHHogjR
Then the enrollment widget should be opened
Original file line number Diff line number Diff line change
@@ -38,13 +38,6 @@ Feature: The user interacts with the widgets on the enrollment edit event
And the user sees the owner organisation unit
And the user sees the last update date

Scenario: You can delete a tracked entity from the profile widget
Given you add a new tracked entity in the Malaria focus investigation program
When you open the overflow menu and click the "Delete Focus area" button
Then you see the delete tracked entity confirmation modal
When you confirm by clicking the "Yes, delete Focus area" button
Then you are redirected to the home page

Scenario: User can open the delete modal
Given you land on the enrollment edit event page by having typed /#/enrollmentEventEdit?eventId=XGLkLlOXgmE&orgUnitId=DiszpKrYNg8
Then the enrollment widget should be opened
@@ -76,7 +69,7 @@ Feature: The user interacts with the widgets on the enrollment edit event
Then the event has the user Tracker demo User assigned
When you remove the assigned user
Then the event has no assignd user

@v>=41
Scenario: The user can view an event changelog on the enrollment edit event
Given you land on the enrollment edit event page by having typed /#/enrollmentEventEdit?eventId=QsAhMiZtnl2&orgUnitId=DiszpKrYNg8
@@ -85,7 +78,7 @@ Feature: The user interacts with the widgets on the enrollment edit event
And the changelog modal should contain data
# One row is filtered out as the metadata is no longer there
And the number of changelog table rows should be 9

@v>=41
Scenario: The user can change changelog page size
Given you land on the enrollment edit event page by having typed /#/enrollmentEventEdit?eventId=QsAhMiZtnl2&orgUnitId=DiszpKrYNg8
@@ -96,7 +89,7 @@ Feature: The user interacts with the widgets on the enrollment edit event
And you change the page size to 100
Then the number of changelog table rows should be 37
Then the table footer should display page 1

@v>=41
Scenario: The user can move to the next page in the changelog
Given you land on the enrollment edit event page by having typed /#/enrollmentEventEdit?eventId=QsAhMiZtnl2&orgUnitId=DiszpKrYNg8
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';
@@ -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
@@ -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>
}
/>
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ export const OverflowMenu = ({
displayChangelog,
teiId,
programAPI,
readOnlyMode,
}: Props) => {
const { hasAuthority } = useAuthorities({ authorities: ['F_TEI_CASCADE_DELETE'] });

@@ -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
@@ -9,6 +9,7 @@ export type Props = {|
displayChangelog: boolean,
teiId: string,
programAPI: any,
readOnlyMode: boolean,
|};

export type PlainProps = {|
@@ -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
@@ -171,6 +171,7 @@ const WidgetProfilePlain = ({
trackedEntityData={clientAttributesWithSubvalues}
teiId={teiId}
programAPI={program}
readOnlyMode={readOnlyMode || false}
/>
</div>
</div>

0 comments on commit aef3400

Please sign in to comment.