Skip to content

Add GitLab Pages link to sidebar

Ben King requested to merge benjaminking-pages-url into master

What does this MR do and why?

This MR seeks to be an iteration to address #18027 (closed), by providing a shortcut link in the new sidebar to the GitLab Pages site, if one has been configured. As there was some discussion in the issue on 'level of access' required to view this information, it currently relies on two criteria:

  • Is GitLab Pages deployed (not just enabled) on the project? (project.pages_deployed?)
  • Does the user viewing the project page have permissions to view the pages content? (:read_pages_content)

For this latter rule, based on the project policy, all guest-level users and above receive read_pages_content, but many are stopped by this line:

rule { pages_disabled }.prevent :read_pages_content

This seems to take into consideration if the user has access to pages content outside of being a guest member, which will prevent non-members of the project from seeing this change. If Access Control is enabled (shown below), then it becomes more accessible to non-members. Examples of different states are shown below:

Public Project

With Access Control (Everyone with Access) - Public Project

  • Unauthenticated users
  • Logged-in users (but not a member of the project)
  • Project Members (at any access level, including Guest)

With Access Control (Only Project Members) - Public Project

  • Unauthenticated users
  • Logged-in users (but not a member of the project)
  • Project Members (at any access level, including Guest)

Without Access Control - Public Project

  • Unauthenticated users
  • Logged-in users (but not a member of the project)
  • Project Members (at any access level, including Guest)

Private Projects

With Access Control (Everyone) - Private Project

  • Unauthenticated users - Directed to sign-in before viewing project.
  • Logged-in users (but not a member of the project) - User cannot access project (404).
  • Project Members (at any access level, including Guest)

Note: Even though project access is restricted on a private project, with Everyone set, if someone has access to the Pages URL, it can be accessed as expected which is normal behaviour. We just won't show a sidebar as they can't see the project.

With Access Control (Only Project Members) - Private Project

  • Unauthenticated users - Directed to sign-in before viewing project.
  • Logged-in users (but not a member of the project) - User cannot access project (404).
  • Project Members (at any access level, including Guest)

Without Access Control - Private Project

  • Unauthenticated users - Directed to sign-in before viewing project.
  • Logged-in users (but not a member of the project) - User cannot access project (404).
  • Project Members (at any access level, including Guest)

Custom Domains?

In this first iteration, only the generated domain (tied to the Pages External URL) is provided. When a custom domain is included and verified, it is not used as the link. This could be improved in a later iteration.

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

Example of the UI update with the Tanuki logo being used:

image

How to set up and validate locally

  1. Follow this process to prepare your GDK environment to use GitLab Pages.
  2. Enable the new sidebar with the feature flag: Feature.enable(:project_overview_reorg). This uses the new 'sidebar' on the right side of the UI.
  3. Create a project using a template involving Pages, such as the Plain HTML example template.
  4. Use GitLab Runner to run a pipeline in this project, and confirm via Deploy > Pages that GitLab Pages has been deployed and reachable.
  5. Navigate back to the main repository view. The sidebar should show GitLab Pages with a direct link to the GitLab Pages URL.
Edited by Ben King

Merge request reports