Commit cbe89827 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'fj-228828-rename-graphql-files-to-blob-actions' into 'master'

Rename snippet GraphQL files field to blob_actions

See merge request gitlab-org/gitlab!36852
parents 95b259d7 8fddd456
......@@ -84,7 +84,7 @@ export default {
title: this.snippet.title,
description: this.snippet.description,
visibilityLevel: this.snippet.visibilityLevel,
files: this.getActionsEntries.filter(entry => entry.action !== ''),
blobActions: this.getActionsEntries.filter(entry => entry.action !== ''),
};
},
saveButtonLabel() {
......
......@@ -40,8 +40,8 @@ module Mutations
required: false,
description: 'The paths to files uploaded in the snippet description'
argument :files, [Types::Snippets::FileInputType],
description: "The snippet files to create",
argument :blob_actions, [Types::Snippets::BlobActionInputType],
description: 'Actions to perform over the snippet repository and blobs',
required: false
def resolve(args)
......@@ -85,9 +85,9 @@ module Mutations
def create_params(args)
args.tap do |create_args|
# We need to rename `files` into `snippet_actions` because
# We need to rename `blob_actions` into `snippet_actions` because
# it's the expected key param
create_args[:snippet_actions] = create_args.delete(:files)&.map(&:to_h)
create_args[:snippet_actions] = create_args.delete(:blob_actions)&.map(&:to_h)
# We need to rename `uploaded_files` into `files` because
# it's the expected key param
......
......@@ -30,8 +30,8 @@ module Mutations
description: 'The visibility level of the snippet',
required: false
argument :files, [Types::Snippets::FileInputType],
description: 'The snippet files to update',
argument :blob_actions, [Types::Snippets::BlobActionInputType],
description: 'Actions to perform over the snippet repository and blobs',
required: false
def resolve(args)
......@@ -56,9 +56,9 @@ module Mutations
def update_params(args)
args.tap do |update_args|
# We need to rename `files` into `snippet_actions` because
# We need to rename `blob_actions` into `snippet_actions` because
# it's the expected key param
update_args[:snippet_actions] = update_args.delete(:files)&.map(&:to_h)
update_args[:snippet_actions] = update_args.delete(:blob_actions)&.map(&:to_h)
end
end
end
......
......@@ -2,9 +2,9 @@
module Types
module Snippets
class FileInputActionEnum < BaseEnum
graphql_name 'SnippetFileInputActionEnum'
description 'Type of a snippet file input action'
class BlobActionEnum < BaseEnum
graphql_name 'SnippetBlobActionEnum'
description 'Type of a snippet blob input action'
value 'create', value: :create
value 'update', value: :update
......
......@@ -2,11 +2,11 @@
module Types
module Snippets
class FileInputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes
graphql_name 'SnippetFileInputType'
class BlobActionInputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes
graphql_name 'SnippetBlobActionInputType'
description 'Represents an action to perform over a snippet file'
argument :action, Types::Snippets::FileInputActionEnum,
argument :action, Types::Snippets::BlobActionEnum,
description: 'Type of input action',
required: true
......
---
title: Rename snippet GraphQL files field to blob_actions
merge_request: 36852
author:
type: changed
......@@ -2071,6 +2071,11 @@ type CreateRequirementPayload {
Autogenerated input type of CreateSnippet
"""
input CreateSnippetInput {
"""
Actions to perform over the snippet repository and blobs
"""
blobActions: [SnippetBlobActionInputType!]
"""
A unique identifier for the client performing the mutation.
"""
......@@ -2091,11 +2096,6 @@ input CreateSnippetInput {
"""
fileName: String
"""
The snippet files to create
"""
files: [SnippetFileInputType!]
"""
The project full path the snippet is associated with
"""
......@@ -12831,6 +12831,41 @@ type SnippetBlob {
size: Int!
}
"""
Type of a snippet blob input action
"""
enum SnippetBlobActionEnum {
create
delete
move
update
}
"""
Represents an action to perform over a snippet file
"""
input SnippetBlobActionInputType {
"""
Type of input action
"""
action: SnippetBlobActionEnum!
"""
Snippet file content
"""
content: String
"""
Path of the snippet file
"""
filePath: String!
"""
Previous path of the snippet file
"""
previousPath: String
}
"""
Represents how the blob content should be displayed
"""
......@@ -12906,41 +12941,6 @@ type SnippetEdge {
node: Snippet
}
"""
Type of a snippet file input action
"""
enum SnippetFileInputActionEnum {
create
delete
move
update
}
"""
Represents an action to perform over a snippet file
"""
input SnippetFileInputType {
"""
Type of input action
"""
action: SnippetFileInputActionEnum!
"""
Snippet file content
"""
content: String
"""
Path of the snippet file
"""
filePath: String!
"""
Previous path of the snippet file
"""
previousPath: String
}
type SnippetPermissions {
"""
Indicates the user can perform `admin_snippet` on this resource
......@@ -14210,6 +14210,11 @@ type UpdateRequirementPayload {
Autogenerated input type of UpdateSnippet
"""
input UpdateSnippetInput {
"""
Actions to perform over the snippet repository and blobs
"""
blobActions: [SnippetBlobActionInputType!]
"""
A unique identifier for the client performing the mutation.
"""
......@@ -14230,11 +14235,6 @@ input UpdateSnippetInput {
"""
fileName: String
"""
The snippet files to update
"""
files: [SnippetFileInputType!]
"""
The global id of the snippet to update
"""
......
......@@ -5623,8 +5623,8 @@
"defaultValue": null
},
{
"name": "files",
"description": "The snippet files to create",
"name": "blobActions",
"description": "Actions to perform over the snippet repository and blobs",
"type": {
"kind": "LIST",
"name": null,
......@@ -5633,7 +5633,7 @@
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "SnippetFileInputType",
"name": "SnippetBlobActionInputType",
"ofType": null
}
}
......@@ -37840,6 +37840,100 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "SnippetBlobActionEnum",
"description": "Type of a snippet blob input action",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "create",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "update",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "delete",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "move",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "SnippetBlobActionInputType",
"description": "Represents an action to perform over a snippet file",
"fields": null,
"inputFields": [
{
"name": "action",
"description": "Type of input action",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "SnippetBlobActionEnum",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "previousPath",
"description": "Previous path of the snippet file",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "filePath",
"description": "Path of the snippet file",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "content",
"description": "Snippet file content",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "SnippetBlobViewer",
......@@ -38087,100 +38181,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "SnippetFileInputActionEnum",
"description": "Type of a snippet file input action",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "create",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "update",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "delete",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "move",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "SnippetFileInputType",
"description": "Represents an action to perform over a snippet file",
"fields": null,
"inputFields": [
{
"name": "action",
"description": "Type of input action",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "SnippetFileInputActionEnum",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "previousPath",
"description": "Previous path of the snippet file",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "filePath",
"description": "Path of the snippet file",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "content",
"description": "Snippet file content",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "SnippetPermissions",
......@@ -41968,8 +41968,8 @@
"defaultValue": null
},
{
"name": "files",
"description": "The snippet files to update",
"name": "blobActions",
"description": "Actions to perform over the snippet repository and blobs",
"type": {
"kind": "LIST",
"name": null,
......@@ -41978,7 +41978,7 @@
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "SnippetFileInputType",
"name": "SnippetBlobActionInputType",
"ofType": null
}
}
......@@ -218,7 +218,7 @@ describe('Snippet Edit app', () => {
return waitForPromises().then(() => {
expect(resolveMutate).toHaveBeenCalledWith(
expect.objectContaining({ variables: { input: { files: [bar] } } }),
expect.objectContaining({ variables: { input: { blobActions: [bar] } } }),
);
});
});
......
......@@ -2,8 +2,8 @@
require 'spec_helper'
RSpec.describe Types::Snippets::FileInputActionEnum do
specify { expect(described_class.graphql_name).to eq('SnippetFileInputActionEnum') }
RSpec.describe Types::Snippets::BlobActionEnum do
specify { expect(described_class.graphql_name).to eq('SnippetBlobActionEnum') }
it 'exposes all file input action types' do
expect(described_class.values.keys).to eq(%w[create update delete move])
......
......@@ -2,14 +2,14 @@
require 'spec_helper'
RSpec.describe Types::Snippets::FileInputType do
specify { expect(described_class.graphql_name).to eq('SnippetFileInputType') }
RSpec.describe Types::Snippets::BlobActionInputType do
specify { expect(described_class.graphql_name).to eq('SnippetBlobActionInputType') }
it 'has the correct arguments' do
expect(described_class.arguments.keys).to match_array(%w[filePath action previousPath content])
end
it 'sets the type of action argument to FileInputActionEnum' do
expect(described_class.arguments['action'].type.of_type).to eq(Types::Snippets::FileInputActionEnum)
it 'sets the type of action argument to BlobActionEnum' do
expect(described_class.arguments['action'].type.of_type).to eq(Types::Snippets::BlobActionEnum)
end
end
......@@ -149,7 +149,7 @@ RSpec.describe 'Creating a Snippet' do
visibility_level: visibility_level,
project_path: project_path,
title: title,
files: actions
blob_actions: actions
}
end
......
......@@ -157,7 +157,7 @@ RSpec.describe 'Updating a Snippet' do
let(:mutation_vars) do
{
id: snippet_gid,
files: [
blob_actions: [
{ action: :update, filePath: updated_file, content: updated_content },
{ action: :delete, filePath: deleted_file }
]
......
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