Hide virtual registry scopes from project deploy tokens UI

Problem to solve

In MR !185059 (merged), we added UI changes to display the new virtual registry scopes (read_virtual_registry and write_virtual_registry) in the UI for creating deploy tokens when the dependency proxy is enabled. However, these scopes should not be visible in the UI for creating project deploy tokens, only for group deploy tokens.

Dependency Proxy and Virtual Registry are resources at the group level, so it does not make sense to grant permissions to them at the project level.

Proposal

We need to modify the deploy token creation UI to hide the virtual registry scopes specifically when creating project deploy tokens, while keeping them visible for group deploy tokens.

Implementation details

  1. Update the new_deploy_token.vue component to check the token type (project vs group) before displaying the virtual registry scopes

  2. Modify the condition that determines when to show the virtual registry scopes:

    {
      id: 'deploy_token_read_virtual_registry',
      isShown: this.$props.dependencyProxyEnabled && this.$props.tokenType !== 'project',
      value: false,
      helpText: this.$options.translations.readVirtualRegistryHelp,
      scopeName: 'read_virtual_registry',
    },
    {
      id: 'deploy_token_write_virtual_registry',
      isShown: this.$props.dependencyProxyEnabled && this.$props.tokenType !== 'project',
      value: false,
      helpText: this.$options.translations.writeVirtualRegistryHelp,
      scopeName: 'write_virtual_registry',
    },
  3. Update the relevant tests to verify that:

    • Virtual registry scopes are not shown for project deploy tokens
    • Virtual registry scopes are shown for group deploy tokens when dependency proxy is enabled

Validation steps

  1. Navigate to a project's settings > Repository > Deploy Tokens
  2. Create a new deploy token
  3. Verify that the "Read virtual registry" and "Write virtual registry" scopes are not visible
  4. Navigate to a group's settings > Repository > Deploy Tokens
  5. Create a new deploy token
  6. Verify that the "Read virtual registry" and "Write virtual registry" scopes are visible (if dependency proxy is enabled)

Related links