From 97f0ae7454597105a27df65ffb772949d9d4f3cb Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 14 Apr 2020 09:09:34 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- app/assets/javascripts/api.js | 9 ++ .../snippets/components/snippet_blob_view.vue | 40 ++---- .../fragments/snippetBase.fragment.graphql | 15 ++ .../queries/snippet.blob.query.graphql | 24 ---- .../static_site_editor/constants.js | 12 ++ .../services/generate_branch_name.js | 8 ++ .../services/submit_content_changes.js | 76 +++++++++- .../static_site_editor/store/state.js | 2 + .../resolvers/merge_requests_resolver.rb | 13 +- .../212561-saving-changes-rest-service.yml | 5 + ...ity_by_stage-create-protected_branches.yml | 5 + ...ix-graphql-endpoint-for-merge-requests.yml | 5 + config/routes/project.rb | 4 + config/routes/repository.rb | 4 - ...ator_id_created_at_id_to_projects_table.rb | 17 +++ db/structure.sql | 3 + doc/administration/gitaly/praefect.md | 30 ++-- lib/api/entities/project_import_status.rb | 2 +- lib/gitlab/path_regex.rb | 1 - locale/gitlab.pot | 15 +- spec/frontend/api_spec.js | 34 ++++- .../components/snippet_blob_view_spec.js | 39 +----- spec/frontend/static_site_editor/mock_data.js | 8 ++ .../services/generate_branch_name_spec.js | 22 +++ .../services/submit_content_changes_spec.js | 131 ++++++++++++++++++ .../project/merge_request/diff_notes_spec.rb | 2 +- .../api/graphql/project/merge_request_spec.rb | 37 +++++ 27 files changed, 449 insertions(+), 114 deletions(-) delete mode 100644 app/assets/javascripts/snippets/queries/snippet.blob.query.graphql create mode 100644 app/assets/javascripts/static_site_editor/constants.js create mode 100644 app/assets/javascripts/static_site_editor/services/generate_branch_name.js create mode 100644 changelogs/unreleased/212561-saving-changes-rest-service.yml create mode 100644 changelogs/unreleased/213800-optimize-usage_activity_by_stage-create-protected_branches.yml create mode 100644 changelogs/unreleased/34527-fix-graphql-endpoint-for-merge-requests.yml create mode 100644 db/migrate/20200408175424_add_index_on_creator_id_created_at_id_to_projects_table.rb create mode 100644 spec/frontend/static_site_editor/services/generate_branch_name_spec.js create mode 100644 spec/frontend/static_site_editor/services/submit_content_changes_spec.js diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 75f7fe62a7e..6301f6a3910 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -188,6 +188,15 @@ const Api = { return axios.get(url, { params }); }, + createProjectMergeRequest(projectPath, options) { + const url = Api.buildUrl(Api.projectMergeRequestsPath).replace( + ':id', + encodeURIComponent(projectPath), + ); + + return axios.post(url, options); + }, + // Return Merge Request for project projectMergeRequest(projectPath, mergeRequestId, params = {}) { const url = Api.buildUrl(Api.projectMergeRequestPath) diff --git a/app/assets/javascripts/snippets/components/snippet_blob_view.vue b/app/assets/javascripts/snippets/components/snippet_blob_view.vue index 3e3dcab70c0..02a0fc7686d 100644 --- a/app/assets/javascripts/snippets/components/snippet_blob_view.vue +++ b/app/assets/javascripts/snippets/components/snippet_blob_view.vue @@ -3,10 +3,8 @@ import BlobEmbeddable from '~/blob/components/blob_embeddable.vue'; import { SNIPPET_VISIBILITY_PUBLIC } from '../constants'; import BlobHeader from '~/blob/components/blob_header.vue'; import BlobContent from '~/blob/components/blob_content.vue'; -import { GlLoadingIcon } from '@gitlab/ui'; import CloneDropdownButton from '~/vue_shared/components/clone_dropdown.vue'; -import GetSnippetBlobQuery from '../queries/snippet.blob.query.graphql'; import GetBlobContent from '../queries/snippet.blob.content.query.graphql'; import { SIMPLE_BLOB_VIEWER, RICH_BLOB_VIEWER } from '~/blob/components/constants'; @@ -16,25 +14,9 @@ export default { BlobEmbeddable, BlobHeader, BlobContent, - GlLoadingIcon, CloneDropdownButton, }, apollo: { - blob: { - query: GetSnippetBlobQuery, - variables() { - return { - ids: this.snippet.id, - }; - }, - update: data => data.snippets.edges[0].node.blob, - result(res) { - const viewer = res.data.snippets.edges[0].node.blob.richViewer - ? RICH_BLOB_VIEWER - : SIMPLE_BLOB_VIEWER; - this.switchViewer(viewer, true); - }, - }, blobContent: { query: GetBlobContent, variables() { @@ -55,18 +37,18 @@ export default { }, data() { return { - blob: {}, + blob: this.snippet.blob, blobContent: '', - activeViewerType: window.location.hash ? SIMPLE_BLOB_VIEWER : '', + activeViewerType: + this.snippet.blob?.richViewer && !window.location.hash + ? RICH_BLOB_VIEWER + : SIMPLE_BLOB_VIEWER, }; }, computed: { embeddable() { return this.snippet.visibilityLevel === SNIPPET_VISIBILITY_PUBLIC; }, - isBlobLoading() { - return this.$apollo.queries.blob.loading; - }, isContentLoading() { return this.$apollo.queries.blobContent.loading; }, @@ -79,8 +61,8 @@ export default { }, }, methods: { - switchViewer(newViewer, respectHash = false) { - this.activeViewerType = respectHash && window.location.hash ? SIMPLE_BLOB_VIEWER : newViewer; + switchViewer(newViewer) { + this.activeViewerType = newViewer; }, }, }; @@ -88,13 +70,7 @@ export default {