Skip to content

feat: sharing dialog prevent users from removing metadata write access [DHIS2-18430]#1694

Merged
tomzemp merged 8 commits intomasterfrom
sharing-prevent-removing-access
Jul 16, 2025
Merged

feat: sharing dialog prevent users from removing metadata write access [DHIS2-18430]#1694
tomzemp merged 8 commits intomasterfrom
sharing-prevent-removing-access

Conversation

@tomzemp
Copy link
Copy Markdown
Member

@tomzemp tomzemp commented Jun 26, 2025

Implements DHIS2-18430


Description

This PR adds a property preventUsersFromRemovingMetadataWriteAccess to SharingDialog component that lets you prevent users from removing their metadata write access. By default, this property is set to false, so that the sharing dialog component will behave as it has previously.

If you pass preventUsersFromRemovingMetadataWriteAccess=true, the sharing dialog will reject and not carry out any action that would leave you without metadata write access after the action is completed. In order to have metadata write access, one or more of the following must be true:

  • you must have ALL authority
  • your user must have metadata:write access
  • a user group of which you are a member must have metadata:write access
  • all users must have metadata:write access

Known issues

This is not much of an issue but the checks rely on user information at the point the sharing dialog is opened, so if the user's group membership or authorities are updated while the sharing dialog is open, the front end check would not necessarily be accurate. I think that's fine (and unlikely)


Checklist

  • API docs are generated
    (there is no documentation for sharing dialog)
  • Tests were added
    I've added a number of unit tests and have added a few e2e tests
  • Storybook demos were added
    the storybook demos don't allow for you to dynamically change fields, do I don't think there's much we could show here except the error message

Screenshots

alinana user tries to set the sharing on their user to "View only" and gets an error message:

image

@tomzemp tomzemp requested a review from a team as a code owner June 26, 2025 12:58
@dhis2-bot
Copy link
Copy Markdown
Contributor

dhis2-bot commented Jun 26, 2025

🚀 Deployed on https://pr-1694--dhis2-ui.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify June 26, 2025 13:03 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify June 26, 2025 13:16 Inactive
Copy link
Copy Markdown
Contributor

@flaminic flaminic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tom! looks great

})
})

describe.only('isMetadataWriteAccessRemoved', () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove .only

dataTest = 'dhis2-uicore-sharingdialog',
dataSharing = false,
cascadeDashboardSharing = true,
preventUsersFromRemovingMetadataWriteAccess = false,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i understand it you default to false to not make this a breaking change, but is there a common scenario - in our apps for example - where we'd want them to be able to remove their metadata write access? If not I'd argue the default should be true, and this was a defect before

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; I defaulted to false, so it wouldn't be a breaking change. When we discussed this internally on platform team we had a bit of a hard time imagining a use case for why you would want to allow users to remove their own access. On the other hand, the backend does allow it, so it's hard to say that the current sharing dialog is defective. I can set this to true by default, but then would want to check beyond the platform team if anyone has a use case for wanting users to be able to remove their own access.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah let's leave it False - better safe...

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jul 4, 2025

@dhis2-bot dhis2-bot temporarily deployed to netlify July 4, 2025 07:49 Inactive
@tomzemp tomzemp merged commit a267689 into master Jul 16, 2025
19 checks passed
@tomzemp tomzemp deleted the sharing-prevent-removing-access branch July 16, 2025 07:10
dhis2-bot added a commit that referenced this pull request Jul 16, 2025
# [10.8.0](v10.7.8...v10.8.0) (2025-07-16)

### Features

* sharing dialog prevent users from removing metadata write access [DHIS2-18430] ([#1694](#1694)) ([a267689](a267689))
@dhis2-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 10.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants