fix: group and user has at least 1 project owner counter respects multirole project groups #8453
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sometimes when a project had an owner and a group that has Owner role together with other roles you couldn't remove the owner access for the group.
The workaround were to remove the other group roles first, then you could remove the owner role when it was the only role left for the group in the project (given that any other group or user had owner role)
The reason was that we were checking an aggregated
roleId
property on the group roles returned object, which is set by a reduce function to be the first row of group ids returned from the db query. If any other role than 'Owner' was set as roleId, that group wasn't counted by the atleastOneOwner verification and if there was only 1 other 'Owner' on the project then the operation wasn't allowed.Fixed this by removing the property altogether and check the roles property instead, which contains all roles the group has