Editorial workflow: Developers on a protected branch are offered actions they cannot perform
Describe the bug
With publish_mode: editorial_workflow and a protected base branch, a Developer can push other branches and open merge requests, but cannot push or merge into the base branch. With #8012 (for #8010), they can log in, save entries and move them through the workflow. Several actions still write to the base branch, are offered to them anyway, and GitLab refuses them:
- Publish merges the merge request of the entry.
- Uploading or deleting a file from the media library (Media tab) is committed straight to the base branch. Files uploaded from an entry go on the entry's branch, as expected.
- Deleting a published entry is committed straight to the base branch (#5650, #7741).
To Reproduce
- Create a GitLab project whose
mainbranch is protected (Maintainers allowed to push and merge). - Give a user the Developer role.
- Configure Decap with the GitLab backend and
publish_mode: editorial_workflow, with #8012. - As that user, save an entry: its branch and merge request are created.
- Publish it: the merge fails. Upload an image from the Media tab: the commit fails. Delete a published entry: the commit fails.
Expected behavior
Publish is only shown to users who can merge the merge request of the entry. On GitLab, GET /projects/:id/merge_requests/:iid returns user.can_merge, computed for the current user with the branch protection rules.
For the media library and for deleting a published entry, either of these would work:
- Same workflow as entries. Uploading or deleting a file from the media library, and deleting a published entry, create their own branch and merge request, published by someone who can merge. For deletions, this is what #5650 and #7741 ask for.
- Read-only for users who cannot push to the base branch. They can browse the media library and pick existing files, and still upload files from an entry, which go on the entry's branch. The upload and delete actions of the Media tab and the delete action of published entries are hidden for them. On GitLab,
GET /projects/:id/repository/branches/:branchreturnscan_pushfor the current user.
Applicable Versions:
- Decap CMS version:
mainwith #8012 - Git provider: GitLab (self-managed). Other backends with protected branches may behave the same, not tested.
Additional context
Follow-up of #8010 and #8012. Related: #2 (roles).
Source: decaporg/decap-cms