diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-05-22 15:21:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-05-22 15:21:27 +0000 |
commit | 7a9963c6a645d24506611ecdf0c86362e8756f04 (patch) | |
tree | 73d25c6128633f2d3c4fdb1109cfd831f40b485e | |
parent | f579deabfa4c330196c4834f87da88a57f6d6b87 (diff) | |
parent | 47bfa0a00a4d345274234bfa5391ac0ecd7d9754 (diff) | |
download | gitlab-ce-7a9963c6a645d24506611ecdf0c86362e8756f04.tar.gz |
Automatic merge of gitlab-org/gitlab-ce master
23 files changed, 346 insertions, 22 deletions
diff --git a/app/assets/stylesheets/framework/mixins.scss b/app/assets/stylesheets/framework/mixins.scss index 18eb10c1f23..97de0c98325 100644 --- a/app/assets/stylesheets/framework/mixins.scss +++ b/app/assets/stylesheets/framework/mixins.scss @@ -325,8 +325,8 @@ line-height: 1; padding: 0; min-width: 16px; - color: $gray-darkest; - fill: $gray-darkest; + color: $gray-600; + fill: $gray-600; .fa { position: relative; diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss index fcb57db590a..50c87e55f56 100644 --- a/app/assets/stylesheets/pages/notes.scss +++ b/app/assets/stylesheets/pages/notes.scss @@ -645,7 +645,7 @@ $note-form-margin-left: 72px; display: inline-flex; align-items: center; margin-left: 10px; - color: $gray-darkest; + color: $gray-600; @include notes-media('max', map-get($grid-breakpoints, sm) - 1) { float: none; diff --git a/app/graphql/resolvers/tree_resolver.rb b/app/graphql/resolvers/tree_resolver.rb new file mode 100644 index 00000000000..5aad1c71b40 --- /dev/null +++ b/app/graphql/resolvers/tree_resolver.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Resolvers + class TreeResolver < BaseResolver + argument :path, GraphQL::STRING_TYPE, + required: false, + default_value: '', + description: 'The path to get the tree for. Default value is the root of the repository' + argument :ref, GraphQL::STRING_TYPE, + required: false, + default_value: :head, + description: 'The commit ref to get the tree for. Default value is HEAD' + argument :recursive, GraphQL::BOOLEAN_TYPE, + required: false, + default_value: false, + description: 'Used to get a recursive tree. Default is false' + + alias_method :repository, :object + + def resolve(**args) + return unless repository.exists? + + repository.tree(args[:ref], args[:path], recursive: args[:recursive]) + end + end +end diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index baea6658e05..06a1aab09f6 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -69,6 +69,8 @@ module Types field :namespace, Types::NamespaceType, null: false field :group, Types::GroupType, null: true + field :repository, Types::RepositoryType, null: false + field :merge_requests, Types::MergeRequestType.connection_type, null: true, diff --git a/app/graphql/types/repository_type.rb b/app/graphql/types/repository_type.rb new file mode 100644 index 00000000000..5987467e1ea --- /dev/null +++ b/app/graphql/types/repository_type.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Types + class RepositoryType < BaseObject + graphql_name 'Repository' + + authorize :download_code + + field :root_ref, GraphQL::STRING_TYPE, null: true + field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty? + field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists? + field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver + end +end diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb new file mode 100644 index 00000000000..230624201b0 --- /dev/null +++ b/app/graphql/types/tree/blob_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +module Types + module Tree + class BlobType < BaseObject + implements Types::Tree::EntryType + + graphql_name 'Blob' + end + end +end diff --git a/app/graphql/types/tree/entry_type.rb b/app/graphql/types/tree/entry_type.rb new file mode 100644 index 00000000000..d8e8642ddb8 --- /dev/null +++ b/app/graphql/types/tree/entry_type.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true +module Types + module Tree + module EntryType + include Types::BaseInterface + + field :id, GraphQL::ID_TYPE, null: false + field :name, GraphQL::STRING_TYPE, null: false + field :type, Tree::TypeEnum, null: false + field :path, GraphQL::STRING_TYPE, null: false + field :flat_path, GraphQL::STRING_TYPE, null: false + end + end +end diff --git a/app/graphql/types/tree/submodule_type.rb b/app/graphql/types/tree/submodule_type.rb new file mode 100644 index 00000000000..cea76dbfd2a --- /dev/null +++ b/app/graphql/types/tree/submodule_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +module Types + module Tree + class SubmoduleType < BaseObject + implements Types::Tree::EntryType + + graphql_name 'Submodule' + end + end +end diff --git a/app/graphql/types/tree/tree_entry_type.rb b/app/graphql/types/tree/tree_entry_type.rb new file mode 100644 index 00000000000..d5cfb898aea --- /dev/null +++ b/app/graphql/types/tree/tree_entry_type.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true +module Types + module Tree + class TreeEntryType < BaseObject + implements Types::Tree::EntryType + + graphql_name 'TreeEntry' + description 'Represents a directory' + end + end +end diff --git a/app/graphql/types/tree/tree_type.rb b/app/graphql/types/tree/tree_type.rb new file mode 100644 index 00000000000..1eb6c43972e --- /dev/null +++ b/app/graphql/types/tree/tree_type.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +module Types + module Tree + class TreeType < BaseObject + graphql_name 'Tree' + + field :trees, Types::Tree::TreeEntryType.connection_type, null: false + field :submodules, Types::Tree::SubmoduleType.connection_type, null: false + field :blobs, Types::Tree::BlobType.connection_type, null: false + end + end +end diff --git a/app/graphql/types/tree/type_enum.rb b/app/graphql/types/tree/type_enum.rb new file mode 100644 index 00000000000..6560d91e9e5 --- /dev/null +++ b/app/graphql/types/tree/type_enum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Types + module Tree + class TypeEnum < BaseEnum + graphql_name 'EntryType' + description 'Type of a tree entry' + + value 'tree', value: :tree + value 'blob', value: :blob + value 'commit', value: :commit + end + end +end diff --git a/changelogs/unreleased/62061-note-icon-color.yml b/changelogs/unreleased/62061-note-icon-color.yml new file mode 100644 index 00000000000..5bfea1a9ed3 --- /dev/null +++ b/changelogs/unreleased/62061-note-icon-color.yml @@ -0,0 +1,5 @@ +--- +title: Update icon color to match design system, pass accessibility +merge_request: 28498 +author: Jarek Ostrowski @jareko +type: fixed diff --git a/doc/user/project/web_ide/index.md b/doc/user/project/web_ide/index.md index 2a2507d98a3..a634a8b2f54 100644 --- a/doc/user/project/web_ide/index.md +++ b/doc/user/project/web_ide/index.md @@ -8,7 +8,7 @@ projects by providing an advanced editor with commit staging. ## Open the Web IDE -The Web IDE can be opened when viewing a file, from the repository file list, +You can open the Web IDE when viewing a file, from the repository file list, and from merge requests. ![Open Web IDE](img/open_web_ide.png) @@ -45,7 +45,7 @@ Single file editing is based on the [Ace Editor](https://ace.c9.io). ## Stage and commit changes -After making your changes, click the Commit button in the bottom left to +After making your changes, click the **Commit** button in the bottom left to review the list of changed files. Click on each file to review the changes and click the tick icon to stage the file. @@ -67,10 +67,11 @@ shows you a preview of the merge request diff if you commit your changes. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19279) in [GitLab Core][ce] 11.0. -The Web IDE can be used to quickly fix failing tests by opening the branch or -merge request in the Web IDE and opening the logs of the failed job. The status -of all jobs for the most recent pipeline and job traces for the current commit -can be accessed by clicking the **Pipelines** button in the top right. +You can use the Web IDE to quickly fix failing tests by opening +the branch or merge request in the Web IDE and opening the logs of the failed +job. You can access the status of all jobs for the most recent pipeline and job +traces for the current commit by clicking the **Pipelines** button in the top +right. The pipeline status is also shown at all times in the status bar in the bottom left. @@ -79,31 +80,31 @@ left. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19318) in [GitLab Core][ce] 11.0. -Switching between your authored and assigned merge requests can be done without -leaving the Web IDE. Click the dropdown in the top of the sidebar to open a list -of merge requests. You will need to commit or discard all your changes before -switching to a different merge request. +To switch between your authored and assigned merge requests, click the +dropdown in the top of the sidebar to open a list of merge requests. You will +need to commit or discard all your changes before switching to a different merge +request. ## Switching branches > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20850) in [GitLab Core][ce] 11.2. -Switching between branches of the current project repository can be done without -leaving the Web IDE. Click the dropdown in the top of the sidebar to open a list -of branches. You will need to commit or discard all your changes before -switching to a different branch. +To switch between branches of the current project repository, click the dropdown +in the top of the sidebar to open a list of branches. +You will need to commit or discard all your changes before switching to a +different branch. ## Client Side Evaluation > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19764) in [GitLab Core][ce] 11.2. -The Web IDE can be used to preview JavaScript projects right in the browser. +You can use the Web IDE to preview JavaScript projects right in the browser. This feature uses CodeSandbox to compile and bundle the JavaScript used to preview the web application. ![Web IDE Client Side Evaluation](img/clientside_evaluation.png) -Additionally, for public projects an `Open in CodeSandbox` button is available +Additionally, for public projects an **Open in CodeSandbox** button is available to transfer the contents of the project into a public CodeSandbox project to quickly share your project with others. @@ -115,9 +116,9 @@ GitLab.com ![Admin Client Side Evaluation setting](img/admin_clientside_evaluation.png) -Once it has been enabled in application settings, projects with a -`package.json` file and a `main` entry point can be previewed inside of the Web -IDE. An example `package.json` is below. +Once you have done that, you can preview projects with a `package.json` file and +a `main` entry point inside the Web IDE. An example `package.json` is shown +below. ```json { diff --git a/spec/graphql/resolvers/tree_resolver_spec.rb b/spec/graphql/resolvers/tree_resolver_spec.rb new file mode 100644 index 00000000000..9f95b740ab1 --- /dev/null +++ b/spec/graphql/resolvers/tree_resolver_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Resolvers::TreeResolver do + include GraphqlHelpers + + let(:repository) { create(:project, :repository).repository } + + describe '#resolve' do + it 'resolves to a tree' do + result = resolve_repository({ ref: "master" }) + + expect(result).to be_an_instance_of(Tree) + end + + it 'resolve to a recursive tree' do + result = resolve_repository({ ref: "master", recursive: true }) + + expect(result.trees[4].path).to eq('files/html') + end + + context 'when repository does not exist' do + it 'returns nil' do + allow(repository).to receive(:exists?).and_return(false) + + result = resolve_repository({ ref: "master" }) + + expect(result).to be(nil) + end + end + end + + def resolve_repository(args) + resolve(described_class, obj: repository, args: args) + end +end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index e0ad09bdf22..075fa7c7e43 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -17,4 +17,6 @@ describe GitlabSchema.types['Project'] do end it { is_expected.to have_graphql_field(:pipelines) } + + it { is_expected.to have_graphql_field(:repository) } end diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb new file mode 100644 index 00000000000..8a8238f2a2a --- /dev/null +++ b/spec/graphql/types/repository_type_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe GitlabSchema.types['Repository'] do + it { expect(described_class.graphql_name).to eq('Repository') } + + it { expect(described_class).to require_graphql_authorizations(:download_code) } + + it { is_expected.to have_graphql_field(:root_ref) } + + it { is_expected.to have_graphql_field(:tree) } +end diff --git a/spec/graphql/types/tree/blob_type_spec.rb b/spec/graphql/types/tree/blob_type_spec.rb new file mode 100644 index 00000000000..fa29bb5fff7 --- /dev/null +++ b/spec/graphql/types/tree/blob_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Types::Tree::BlobType do + it { expect(described_class.graphql_name).to eq('Blob') } + + it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path) } +end diff --git a/spec/graphql/types/tree/submodule_type_spec.rb b/spec/graphql/types/tree/submodule_type_spec.rb new file mode 100644 index 00000000000..bdb3149b41c --- /dev/null +++ b/spec/graphql/types/tree/submodule_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Types::Tree::SubmoduleType do + it { expect(described_class.graphql_name).to eq('Submodule') } + + it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path) } +end diff --git a/spec/graphql/types/tree/tree_entry_type_spec.rb b/spec/graphql/types/tree/tree_entry_type_spec.rb new file mode 100644 index 00000000000..397cabde8e5 --- /dev/null +++ b/spec/graphql/types/tree/tree_entry_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Types::Tree::TreeEntryType do + it { expect(described_class.graphql_name).to eq('TreeEntry') } + + it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path) } +end diff --git a/spec/graphql/types/tree/tree_type_spec.rb b/spec/graphql/types/tree/tree_type_spec.rb new file mode 100644 index 00000000000..b9c5570115e --- /dev/null +++ b/spec/graphql/types/tree/tree_type_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Types::Tree::TreeType do + it { expect(described_class.graphql_name).to eq('Tree') } + + it { expect(described_class).to have_graphql_fields(:trees, :submodules, :blobs) } +end diff --git a/spec/graphql/types/tree/type_enum_spec.rb b/spec/graphql/types/tree/type_enum_spec.rb new file mode 100644 index 00000000000..4caf9e1c457 --- /dev/null +++ b/spec/graphql/types/tree/type_enum_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Types::Tree::TypeEnum do + it { expect(described_class.graphql_name).to eq('EntryType') } + + it 'exposes all tree entry types' do + expect(described_class.values.keys).to include(*%w[tree blob commit]) + end +end diff --git a/spec/requests/api/graphql/project/repository_spec.rb b/spec/requests/api/graphql/project/repository_spec.rb new file mode 100644 index 00000000000..67af612a4a0 --- /dev/null +++ b/spec/requests/api/graphql/project/repository_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe 'getting a repository in a project' do + include GraphqlHelpers + + let(:project) { create(:project, :repository) } + let(:current_user) { project.owner } + let(:fields) do + <<~QUERY + #{all_graphql_fields_for('repository'.classify)} + QUERY + end + let(:query) do + graphql_query_for( + 'project', + { 'fullPath' => project.full_path }, + query_graphql_field('repository', {}, fields) + ) + end + + it 'returns repository' do + post_graphql(query, current_user: current_user) + + expect(graphql_data['project']['repository']).to be_present + end + + context 'as a non-authorized user' do + let(:current_user) { create(:user) } + + it 'returns nil' do + post_graphql(query, current_user: current_user) + + expect(graphql_data['project']).to be(nil) + end + end +end diff --git a/spec/requests/api/graphql/project/tree/tree_spec.rb b/spec/requests/api/graphql/project/tree/tree_spec.rb new file mode 100644 index 00000000000..b07aa1e12d3 --- /dev/null +++ b/spec/requests/api/graphql/project/tree/tree_spec.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe 'getting a tree in a project' do + include GraphqlHelpers + + let(:project) { create(:project, :repository) } + let(:current_user) { project.owner } + let(:path) { "" } + let(:ref) { "master" } + let(:fields) do + <<~QUERY + tree(path:"#{path}", ref:"#{ref}") { + #{all_graphql_fields_for('tree'.classify)} + } + QUERY + end + let(:query) do + graphql_query_for( + 'project', + { 'fullPath' => project.full_path }, + query_graphql_field('repository', {}, fields) + ) + end + + context 'when path does not exist' do + let(:path) { "testing123" } + + it 'returns empty tree' do + post_graphql(query, current_user: current_user) + + expect(graphql_data['project']['repository']['tree']['trees']['edges']).to eq([]) + expect(graphql_data['project']['repository']['tree']['submodules']['edges']).to eq([]) + expect(graphql_data['project']['repository']['tree']['blobs']['edges']).to eq([]) + end + end + + context 'when ref does not exist' do + let(:ref) { "testing123" } + + it 'returns empty tree' do + post_graphql(query, current_user: current_user) + + expect(graphql_data['project']['repository']['tree']['trees']['edges']).to eq([]) + expect(graphql_data['project']['repository']['tree']['submodules']['edges']).to eq([]) + expect(graphql_data['project']['repository']['tree']['blobs']['edges']).to eq([]) + end + end + + context 'when ref and path exist' do + it 'returns tree' do + post_graphql(query, current_user: current_user) + + expect(graphql_data['project']['repository']['tree']).to be_present + end + + it 'returns blobs, subtrees and submodules inside tree' do + post_graphql(query, current_user: current_user) + + expect(graphql_data['project']['repository']['tree']['trees']['edges'].size).to be > 0 + expect(graphql_data['project']['repository']['tree']['blobs']['edges'].size).to be > 0 + expect(graphql_data['project']['repository']['tree']['submodules']['edges'].size).to be > 0 + end + end + + context 'when current user is nil' do + it 'returns empty project' do + post_graphql(query, current_user: nil) + + expect(graphql_data['project']).to be(nil) + end + end +end |