Set default project scope based on user permissions
Background
Discovered while fixing #408364 (closed) , !118358 (merged) was implemented as a frontend only fix but was reverted. The original exposed some other edge cases and we chose to fix them in one MR
The additional edge cases caused a few UI bugs:
- no search tabs in project scoped search results page
- no tab being selected some tabs were shown
- tabs being shown that the user does not have permission to view for project scoped searches
This was due to the backend defaulting project scoped searches to blobs
if no scope is chosen and allowing scopes to be selected when the user does not have permissions for the scope.
What does this MR do and why?
This MR has frontend and backend changes split into two commits, they can be reviewed by commit.
frontend changes
- fix for edge case where no search term is showing search tabs in the old navigation
backend changes
- the ~default scope is now set by looking at allowed scopes & taking into account permissions for the user
- fixed a few of the tabs condition checks for project scoped searches
- added/updated specs
Screenshots or screen recordings
before | after |
---|---|
frontend | |
backend |
How to set up and validate locally
- Check the new navigation and old navigation
- Visit the search page with no search term
http://gdk.test:3000/search?scope=issues&search=
- The search page should not show any search tabs
- Create a public project
- Disable Repository and Issues for the project in Project Settings - General
- Login as a user who does not have access to the project
- Run a project scoped search with NO scope: http://gdk.test:3000/search?project_id=8&search=* (use project id from step 1)
- Verify the Code tab doesn't show up and that a tab is selected
- Run a project scoped search with the issues scope: http://gdk.test:3000/search?project_id=8&search=*&scope=issues (use project id from step 1)
- Verify the Issues tab doesn't show up and that a tab is selected
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Terri Chu