Commit e4e92b82 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Tetiana Chupryna

Add can_destroy to GraphQL package type

parent 9266531e
......@@ -28,6 +28,7 @@ module Types
description: 'Other versions of the package.',
deprecated: { reason: 'This field is now only returned in the PackageDetailsType', milestone: '13.11' }
field :status, Types::Packages::PackageStatusEnum, null: false, description: 'Package status.'
field :can_destroy, GraphQL::Types::Boolean, null: false, description: 'Whether the user can destroy the package.'
def project
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
......@@ -37,6 +38,10 @@ module Types
[]
end
def can_destroy
Ability.allowed?(current_user, :destroy_package, object)
end
# NOTE: This method must be kept in sync with the union
# type: `Types::Packages::MetadataType`.
#
......
......@@ -12145,6 +12145,7 @@ Represents a package in the Package Registry. Note that this type is in beta and
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. |
| <a id="packagecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packageid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
| <a id="packagemetadata"></a>`metadata` | [`PackageMetadata`](#packagemetadata) | Package metadata. |
......@@ -12204,6 +12205,7 @@ Represents a package details in the Package Registry. Note that this type is in
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagedetailstypecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. |
| <a id="packagedetailstypecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packagedetailstypedependencylinks"></a>`dependencyLinks` | [`PackageDependencyLinkConnection`](#packagedependencylinkconnection) | Dependency link. (see [Connections](#connections)) |
| <a id="packagedetailstypeid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
......
......@@ -13,7 +13,8 @@
"pipelines",
"versions",
"metadata",
"status"
"status",
"canDestroy"
],
"properties": {
"id": {
......@@ -31,6 +32,9 @@
"version": {
"type": ["string", "null"]
},
"canDestroy": {
"type": ["boolean"]
},
"packageType": {
"type": ["string"],
"enum": [
......
......@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Package'] do
created_at updated_at
project
tags pipelines metadata versions
status
status can_destroy
]
expect(described_class).to include_graphql_fields(*expected_fields)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment