Add currentUser query to LockDirectoryButton
What does this MR do and why?
This MR is a part of a bigger effort that aims to consolidate various tiny Vue apps in the header area of tree and blob view into one common Vue application.
Note: There's a potential for refactor, but that part will be handled in the following issues within &13018. The MRs for #497051 (closed) goal is to move everything as is.
This is just a fraction of the functionality for the Lock button
I started work in !173576 (closed), but the changes were extensive. I want to have a little piece merged first to make sure the other MR is easier to review and there's less potential for errors (which I have already made re-implementing logic that was in Ruby
This MR adds:
- currentUser query
- projectInfo query with the user permissions
- rendering an alert if any of the queries fails
- a loading and a disabled state
- all changes are behind a
common_repository_blob_header_app=trueURL param - elements are being moved in batches, what you're reviewing may not yet look like the old version
- breaking the work into smaller parts means that feature tests won't pass, due to missing UI elements. We will take care of the feature tests in the last step, after all other MRs are merged
- please make sure you give it a go and thoroughly test all the buttons
The breakdown of #497051 (closed) MRs:
| step | status |
|---|---|
| introduce ff & move first batch of controls, move web ide button for tree header, recreate projects/tree/lock_link in Vue | |
| move code buttons (desktop & mobile) for tree header | |
| move contents of app/views/projects/blob/_breadcrumb.html.haml | |
| recreate projects/tree/lock_link in Vue | |
turn on feature tests for when the ff is true
|
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.
- Prepare common Vue app for Repository and Blob header area
- MR that introduced the UI
- Previous Ruby version of the button
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.
| Before | After |
|---|---|
![]() |
![]() |
| n/a | ![]() |
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
To emulate an error on CurrentUser query:
diff --git a/app/assets/javascripts/graphql_shared/queries/current_user.query.graphql b/app/assets/javascripts/graphql_shared/queries/current_user.query.graphql
index 93335c93c1dd..517b7be5510e 100644
--- a/app/assets/javascripts/graphql_shared/queries/current_user.query.graphql
+++ b/app/assets/javascripts/graphql_shared/queries/current_user.query.graphql
@@ -2,6 +2,6 @@
query currentUser {
currentUser {
- ...User
+ someUser
}
}
- Impersonate a user with a reporter role in the project to test disabled button.
- Go to Project overview or Code / Repository and go into one of the folders of your project. The namespace of the projects needs an active Premium or Ultimate subscription.
- Add
common_repository_blob_header_app=trueparam to the URL - Make sure
Lockbutton is disabled. - Change the query to throw an error (see a snippet above) and make sure the alert is visible.
- Remove
common_repository_blob_header_app=trueparam from the URL. Make sure the HAML version looks the same for an unlock directory seen by user withoutpushCodepermissions
Related to #497051 (closed)


