Disable Replace/Delete on default branch when user cannot unlock file
What does this MR do and why?
When a file is locked by another user, the unlock action is not available to other users on both default and non-default branches. The replace and delete actions are still available to users on the default branch, even though file modification is restricted to the user who has permission to unlock the file or Maintainers. Currently, it's possible to go through replacing and deleting flow, which eventually returns an error from the backend when submitting the change.
This MR updates to indicate the user they cannot perform the action earlier by disabling those buttons. This only applies to default branch since user can still perform those actions on non-default branches.
Technically speaking, this MR:
-
Passes down
root-reffrom tree_helper.rb and blob_helper.rb -
Adds a check to disable the button based on
!this.canLock && this.rootRef === this.currentRef -
Moves up the logic for
canLock,isLockedandpathLockedByUsertoblob_overflow_menu.vue(new file under/ee) since it's now being used byblob_button_group.vue(new file under/ee)and
blob_delete_file_group.vue -
Adjusts tests accordingly
-
Adjust the CE/EE split of the logic - essentially no longer fetching for
pathLocksin CE -
Adds tests for new logic
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| On default branch | On non-default branch | |
|---|---|---|
|
when user has permission to unlock the file (user is the author of the lock) |
||
|
when user does not permission to unlock the file (user is not the author of the lock) |
||
|
running app in CE expected: lock button does not show, replace and delete are enabled (basically no change) |
How to set up and validate locally
- Enable
blob_overflow_menuand enableblob_repository_vue_header_appfeature flag
Feature.enable(:blob_overflow_menu)
Feature.enable(:blob_repository_vue_header_app)
- See table above for different scenarios. To set things up:
- Have two users who both have developer+ permission in the same repo
- Place a lock on file A with user A
- Place a lock on file B with user B
Related to #516868 (closed)

