Align lock file button permission logic to the directory one
What does this MR do and why?
Currently, the permission logic for lock file and lock directory buttons are inconsistent. This issue aims to align them by using the GraphQL fields added in Project graphql query is returning incorrect pa... (#512677 - closed)
AI code change summary
This change refines the file locking functionality in the repository interface by splitting a single "canLock" permission into two more specific permissions: "canCreateLock" and "canDestroyLock". This allows for more granular control over who can create new locks on files versus who can remove existing locks. The code now properly distinguishes between these two actions, making the permission system more precise. Additionally, the implementation now relies on permissions from the API rather than calculating them client-side, and removes the dependency on the global username variable. The changes also improve how locked files are detected and how the UI responds to different permission combinations, ensuring buttons are properly enabled or disabled based on the user's actual permissions.
References
- this implementation copies the logic for lock directory button Refactor to use pathLocks ability fields from g... (!185342 - merged)
- this change should not impact the logic to disable replace/delete logic added in Disable Replace/Delete on default branch when u... (!183594 - merged)
- documentation
⚠️ existing bug that's out of the scope for this MR Directory/file page locking: Address UX issues ... (#536530)
Screenshots or screen recordings
| after | |
|---|---|
| user can create lock | ![]() |
| user cannot create lock | ![]() |
| On default branch | On non-default branch | |
|---|---|---|
|
user can destroy lock (user is the author of the lock) |
|
|
|
user cannot destroy lock (user is not the author of the lock) |
How to set up and validate locally
- Go to Project overview or Code / Repository
- Enable
blob_repository_vue_header_appflag - Log in as a user who has developer permission to a project
- User should be able to lock and unlock a file (e.g. button should not be disabled)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #526589 (closed)




