Skip to content

Enable pages feature for read-only Namespaces

Vijay Hawoldar requested to merge vij-pages-policies into master

What does this MR do and why?

In https://gitlab.com/gitlab-org/gitlab/-/issues/363473 we are adjusting which features/abilities are restricted when a Namespace is made read-only.

This MR handles Pages from that list and allows the feature to be available

Please note: Read-only mode is not yet in use because it relates to unreleased work described in the linked issue above

How to set up and validate locally

As noted in this comment, the create_pages ability is not one that is ever explicitly allowed/enabled, so it's not really possible to validate this change for it, but for the others (update_pages, admin_pages) we can validate with:

  1. Checkout master branch
  2. Adjust the read_only? method to return true
      def read_only?
        true
      end
  3. In a rails console:
      u = User.first # or some other user of yours
      p = Project.first # or some other project the user has access to
    
      u.can?(:admin_pages, p)
      => false
    
      u.can?(:update_pages, p)
      => false
  4. Checkout this branch (vij-pages-policies)
  5. In a rails console:
      u.can?(:admin_pages, p)
      => true
    
      u.can?(:update_pages, p)
      => true

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vijay Hawoldar

Merge request reports

Loading