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