Commit fc35570a authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '330846-convert-package-list-page-to-use-apollo-graphql-4' into 'master'

Add can_destroy to GraphQL package type

See merge request gitlab-org/gitlab!71916
parents 806d0477 e4e92b82
...@@ -28,6 +28,7 @@ module Types ...@@ -28,6 +28,7 @@ module Types
description: 'Other versions of the package.', description: 'Other versions of the package.',
deprecated: { reason: 'This field is now only returned in the PackageDetailsType', milestone: '13.11' } 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 :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 def project
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
...@@ -37,6 +38,10 @@ module Types ...@@ -37,6 +38,10 @@ module Types
[] []
end end
def can_destroy
Ability.allowed?(current_user, :destroy_package, object)
end
# NOTE: This method must be kept in sync with the union # NOTE: This method must be kept in sync with the union
# type: `Types::Packages::MetadataType`. # type: `Types::Packages::MetadataType`.
# #
......
...@@ -12145,6 +12145,7 @@ Represents a package in the Package Registry. Note that this type is in beta and ...@@ -12145,6 +12145,7 @@ Represents a package in the Package Registry. Note that this type is in beta and
| Name | Type | Description | | 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="packagecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packageid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. | | <a id="packageid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
| <a id="packagemetadata"></a>`metadata` | [`PackageMetadata`](#packagemetadata) | Package metadata. | | <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 ...@@ -12204,6 +12205,7 @@ Represents a package details in the Package Registry. Note that this type is in
| Name | Type | Description | | 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="packagedetailstypecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packagedetailstypedependencylinks"></a>`dependencyLinks` | [`PackageDependencyLinkConnection`](#packagedependencylinkconnection) | Dependency link. (see [Connections](#connections)) | | <a id="packagedetailstypedependencylinks"></a>`dependencyLinks` | [`PackageDependencyLinkConnection`](#packagedependencylinkconnection) | Dependency link. (see [Connections](#connections)) |
| <a id="packagedetailstypeid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. | | <a id="packagedetailstypeid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
"pipelines", "pipelines",
"versions", "versions",
"metadata", "metadata",
"status" "status",
"canDestroy"
], ],
"properties": { "properties": {
"id": { "id": {
...@@ -31,6 +32,9 @@ ...@@ -31,6 +32,9 @@
"version": { "version": {
"type": ["string", "null"] "type": ["string", "null"]
}, },
"canDestroy": {
"type": ["boolean"]
},
"packageType": { "packageType": {
"type": ["string"], "type": ["string"],
"enum": [ "enum": [
......
...@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Package'] do ...@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Package'] do
created_at updated_at created_at updated_at
project project
tags pipelines metadata versions tags pipelines metadata versions
status status can_destroy
] ]
expect(described_class).to include_graphql_fields(*expected_fields) 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