-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
[ TASK-1027 ] Conditional label for 'Delete Project and Data' button #5104
Conversation
@@ -873,6 +873,10 @@ class ProjectSettings extends React.Component { | |||
const isSelfOwned = assetUtils.isSelfOwned(this.state.formAsset); | |||
const descriptionField = envStore.data.getProjectMetadataField('description'); | |||
|
|||
const deleteButtonLabel = this.state.formAsset.deployment__submission_count > 0 ? |
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 wanted to check this real quick, since it's possible for deployment__submission_count
to be null when viewed by users with row-level submission view permissions (see kpi#4739). But
thanks to the magic of JS, null > 0
is false, so no problem here, it's safe to run. Those users would lack 'manage this form' permission, so it's hard for them to get to this settings page anyway. 👍
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.
Thanks. I changed it in 5f22d64 and moved the condition to the element. Since it may not be rendered it does make more sense to leave the conditional label inside it as well. 🙇🏻
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 and it works!
TASK-1027
Checklist
Description
The "Delete Project" button label now can be either "Delete Project" and "Delete Project and Data" to reflect whether the project has submissions to be deleted along with the project or not.
Notes
This PR adds a conditional label for the 'Delete Project and Data' button, where it will only show 'Delete Project' when there's no submissions to the project.
No data:
With data:
I opted to isolate the label in a separated variable instead of adding the conditional logic into the button for better readability.Decided to go back in this decision and leave the condition in the element itself, since there are other conditions for the element rendering.