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 all 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
8 changes: 8 additions & 0 deletions cypress/e2e/NewPage/NewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
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