-
Notifications
You must be signed in to change notification settings - Fork 23
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: [DHIS2-16922] Delete Tracked entity from profile Widget #3545
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @simonadomnisoru!
Some quick comments, but otherwise great job on this! 🎉
return i18n.t("You don't have access to delete this {{TETName}}", { | ||
TETName: trackedEntityTypeName, | ||
interpolation: { escapeValue: false }, | ||
}); | ||
} | ||
if (!canCascadeDeleteTei) { | ||
return i18n.t("You can't delete this {{TETName}} when it has associated enrollments and events", { | ||
TETName: trackedEntityTypeName, | ||
interpolation: { escapeValue: false }, | ||
}); | ||
} | ||
return ''; | ||
}; | ||
|
||
export const DeleteMenuItem = ({ | ||
trackedEntityTypeName, | ||
canCascadeDeleteTei, | ||
canWriteData, | ||
setActionsIsOpen, | ||
setDeleteModalIsOpen, | ||
}: Props) => { | ||
const tooltipContent = getTooltipContent(canWriteData, canCascadeDeleteTei, trackedEntityTypeName); | ||
|
||
return ( | ||
<ConditionalTooltip content={tooltipContent} enabled={!canWriteData || !canCascadeDeleteTei}> | ||
<MenuItem | ||
destructive | ||
dense | ||
icon={<IconDelete16 />} | ||
label={i18n.t('Delete {{TETName}}', { | ||
TETName: trackedEntityTypeName, | ||
interpolation: { escapeValue: false }, | ||
})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to use a lowercased trackedEntityTypeName, similar to what we use other places?
<Button onClick={() => setOpenModal(false)} secondary> | ||
{i18n.t('No, cancel')} | ||
</Button> | ||
<Button onClick={() => deleteMutation(trackedEntity)} primary loading={deleteLoading}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this button be destructive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still keep this file after the discussion we had in Changelogs-PR, or should we use the one in Buttons
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I move it into the Buttons
folder in the latest commit. Thanks!
Thanks for the feedback @eirikhaugstulen. I implemented your suggestions. Can you have a look? |
authorities && | ||
authorities.some(authority => authority === auth.ALL || authority === auth.F_TEI_CASCADE_DELETE), | ||
}; | ||
const { data } = useApiMetadataQuery<any>(queryKey, queryFn, queryOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to properly use generics here is probably something we can figure out later @eirikhaugstulen @simonadomnisoru
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is the same as src/core_modules/capture-core/components/Tooltips/ConditionalTooltip/ConditionalTooltip.component.js
. Let's use that one even though we are in a "self-contained" Widget.
if (!canWriteData) { | ||
return i18n.t("You don't have access to delete this {{trackedEntityTypeName}}", { | ||
trackedEntityTypeName, | ||
interpolation: { escapeValue: false }, | ||
}); | ||
} | ||
if (!canCascadeDeleteTei) { | ||
return i18n.t("You can't delete this {{trackedEntityTypeName}} when it has associated enrollments and events", { | ||
trackedEntityTypeName, | ||
interpolation: { escapeValue: false }, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There has been some last minute changes to the design here. Let's use the tooltip content: "You do not have access to delete this $TET" (for both the cases here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
🚀 Deployed on https://deploy-preview-3545--dhis2-capture.netlify.app |
docs/user/using-the-capture-app.md
Outdated
@@ -1029,6 +1029,10 @@ Click the **Edit** button to make changes to the tracked entity instance profile | |||
|
|||
![](resources/images/enrollment-dash-tei-profile-widget-edit.png) | |||
|
|||
Click the **Delete ${tracked entity type}** button to delete the tracked entity. You can confirm the action from the dialog. Once confirmed, tracked entity and all its associated enrollment and events across all programs will be deleted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click the **Delete ${tracked entity type}** button to delete the tracked entity. You can confirm the action from the dialog. Once confirmed, tracked entity and all its associated enrollment and events across all programs will be deleted. | |
Click the **Delete ${tracked entity type}** button to delete the tracked entity. You can confirm the action from the dialog. Once confirmed, tracked entity and all its associated enrollment and events across all programs will be deleted. To delete a ${tracked entity type} that has any enrollments, the user needs the authority **Delete tracked entity instance and associated enrollments and events**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion. It's implemented in the latest commit. Thanks for the feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested successfully on 2.41 ,2.40.4,2.39.6,2.38.7 versions
# [100.63.0](v100.62.0...v100.63.0) (2024-03-05) ### Features * [DHIS2-16922] Delete Tracked entity from profile Widget ([#3545](#3545)) ([fb8171e](fb8171e))
🎉 This PR is included in version 100.63.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
DHIS2-16922
Tech summary
onDeleteSuccess
callback that will be used to navigate to main page by the enrollment pages.