# Feature OP-20801 - Add a new permission to manage public, global Work Package Queries

Project: OpenProject
Status: new
URL: https://community.openproject.org/work_packages/OP-20801

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | Wish List |
| Sprint |  |
| Backlog bucket |  |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Administration / Work package administration, Modules and project features / Work packages, Administration / Roles and permissions |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

**As** an administrator  
**I want to** control who can create, edit and delete public work package views outside of projects (global views) through a dedicated global permission  
**so that** a user&#x27;s project memberships don&#x27;t let them change or delete global views that other users created.

**Acceptance criteria**

*   A new global permission &quot;Manage public global work package views&quot; (`manage_global_public_queries`) is available on global roles.
    
*   Administrators always have the permission.
    
*   Only users holding the new permission can, for global public work package views (not attached to a project):
    
    *   mark a view as public / private,
        
    *   edit another user&#x27;s public view,
        
    *   delete another user&#x27;s public view.
        
*   Holding &quot;Manage public views&quot; (`manage_public_queries`) in any project no longer grants any of the above for global views.
    
*   Public views inside a project are unchanged: they still require &quot;Manage public views&quot; in that project.
    
*   Private views are unchanged: users can still manage their own private global views if they have &quot;Save views&quot; in any project.
    
*   The API v3 query schema reports `public` as writable only for users holding the new permission (for global queries), so the &quot;Public&quot; option in the save/settings dialog is shown accordingly.
    
*   On upgrade, the permission is added to all global roles that have &quot;Manage public project lists&quot; (`manage_public_project_queries`). No other roles receive it.
    
*   The changed behaviour is documented in the release notes (users who could manage global public views through a project role lose that ability until an admin grants the new permission).
    

**Technical notes**

*   Define the permission in `config/initializers/permissions.rb` next to `manage_public_project_queries`: `permissible_on: :global`, `require: :loggedin`, `grant_to_admin: true`.
    
*   Switch the &quot;no project&quot; branch to `user.allowed_globally?(:manage_global_public_queries)` in:
    
    *   `QueryPolicy#manage_public_queries_allowed?` (`app/policies/query_policy.rb`),
        
    *   `Queries::BaseContract#may_not_manage_queries?` (`app/contracts/queries/base_contract.rb`),
        
    *   `QuerySchemaRepresenter#allowed_to_manage_public_queries?` (`lib/api/v3/queries/schemas/query_schema_representer.rb`).
        
*   Update the global-context examples in `spec/policies/query_policy_spec.rb` and the query contract specs: a project-level `manage_public_queries` must no longer grant access to global queries.
    
*   Check other consumers of global public queries that check `manage_public_queries` (e.g. the global views contracts in `app/contracts/views/base_contract.rb`, the Gantt contract strategy) and align them.
    

**Permissions and visibility considerations**

*   _To whom is this feature visible?_ Administrators configuring global roles see the new permission in the global role form. Users with the permission see the &quot;Public&quot; option and the edit/delete actions for others&#x27; public views in the global work package list.
    
*   _When is it not visible?_ Users without the permission don&#x27;t get the &quot;Public&quot; option when saving global views and can&#x27;t edit or delete public global views created by others. Project-level views are unaffected.
    

**Translation considerations**

*   _Key terms and phrases in the key languages_ &quot;Manage public global work pacbel, `permission_manage_global_public_queries`). Wording should match the existing &quot;Manage public views&quot; and &quot;Manage public project lists&quot; labels.
    

**Out of scope**

*   Changing the permission model for project-scoped public views.
    
*   Authorization of the query index endpoint (`GET /api/v3/queries`).
    
*   Granting the permission to users who currently manage global views through c creation of global roles or memberships).
    
*   Boards, calendars and team planners beyond aligning their checks for global
    

**To be clarified**

*   Who is granted this permission. As the current permission check is done via project level permission, there&#x27;s no easy way to attach the new global permission to.  
    Ideas that were thrown around:
    
    *   Create a new global role with just the new permission and give it to everybody who currently has the `manage_public_queries` permission in any project
        
    *   Attach it to all global roles that currently grant the `manage_public_project_queries` permission, as it is a bit adjacent
        
    *   Create a new global role with just the new permission and give it to everybody who is the _owner_ of a public, global query object
