diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 12:09:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 12:09:42 +0000 |
commit | 403678e00406edc8094f087ec70e00aa29e49bef (patch) | |
tree | 447d6d4967e9a11895683b27e637a50bd9fc0602 /app | |
parent | f5050253469fc0961c02deec0e698ad62bdd9de5 (diff) | |
download | gitlab-ce-403678e00406edc8094f087ec70e00aa29e49bef.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
18 files changed, 105 insertions, 44 deletions
diff --git a/app/assets/javascripts/static_site_editor/components/static_site_editor.vue b/app/assets/javascripts/static_site_editor/components/static_site_editor.vue index 4a0e153eb33..f06d48ee4f5 100644 --- a/app/assets/javascripts/static_site_editor/components/static_site_editor.vue +++ b/app/assets/javascripts/static_site_editor/components/static_site_editor.vue @@ -1,5 +1,5 @@ <script> -import { mapState, mapActions } from 'vuex'; +import { mapState, mapGetters, mapActions } from 'vuex'; import { GlSkeletonLoader } from '@gitlab/ui'; import EditArea from './edit_area.vue'; @@ -10,7 +10,8 @@ export default { GlSkeletonLoader, }, computed: { - ...mapState(['content', 'isContentLoaded', 'isLoadingContent']), + ...mapState(['content', 'isLoadingContent']), + ...mapGetters(['isContentLoaded']), }, mounted() { this.loadContent(); diff --git a/app/assets/javascripts/static_site_editor/index.js b/app/assets/javascripts/static_site_editor/index.js index 4290cb9a9ba..22f96a60df0 100644 --- a/app/assets/javascripts/static_site_editor/index.js +++ b/app/assets/javascripts/static_site_editor/index.js @@ -3,7 +3,11 @@ import StaticSiteEditor from './components/static_site_editor.vue'; import createStore from './store'; const initStaticSiteEditor = el => { - const store = createStore(); + const { projectId, path: sourcePath } = el.dataset; + + const store = createStore({ + initialState: { projectId, sourcePath }, + }); return new Vue({ el, diff --git a/app/assets/javascripts/static_site_editor/store/actions.js b/app/assets/javascripts/static_site_editor/store/actions.js new file mode 100644 index 00000000000..192345f3749 --- /dev/null +++ b/app/assets/javascripts/static_site_editor/store/actions.js @@ -0,0 +1,18 @@ +import createFlash from '~/flash'; +import { __ } from '~/locale'; + +import * as mutationTypes from './mutation_types'; +import loadSourceContent from '~/static_site_editor/services/load_source_content'; + +export const loadContent = ({ commit, state: { sourcePath, projectId } }) => { + commit(mutationTypes.LOAD_CONTENT); + + return loadSourceContent({ sourcePath, projectId }) + .then(data => commit(mutationTypes.RECEIVE_CONTENT_SUCCESS, data)) + .catch(() => { + commit(mutationTypes.RECEIVE_CONTENT_ERROR); + createFlash(__('An error ocurred while loading your content. Please try again.')); + }); +}; + +export default () => {}; diff --git a/app/assets/javascripts/static_site_editor/store/getters.js b/app/assets/javascripts/static_site_editor/store/getters.js new file mode 100644 index 00000000000..8baa2941594 --- /dev/null +++ b/app/assets/javascripts/static_site_editor/store/getters.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line import/prefer-default-export +export const isContentLoaded = ({ content }) => Boolean(content); diff --git a/app/assets/javascripts/static_site_editor/store/index.js b/app/assets/javascripts/static_site_editor/store/index.js index 653c2532ee6..43256979ddd 100644 --- a/app/assets/javascripts/static_site_editor/store/index.js +++ b/app/assets/javascripts/static_site_editor/store/index.js @@ -1,12 +1,18 @@ import Vuex from 'vuex'; import Vue from 'vue'; import createState from './state'; +import * as getters from './getters'; +import * as actions from './actions'; +import mutations from './mutations'; Vue.use(Vuex); const createStore = ({ initialState } = {}) => { return new Vuex.Store({ state: createState(initialState), + getters, + actions, + mutations, }); }; diff --git a/app/assets/javascripts/static_site_editor/store/mutation_types.js b/app/assets/javascripts/static_site_editor/store/mutation_types.js new file mode 100644 index 00000000000..cbe51180541 --- /dev/null +++ b/app/assets/javascripts/static_site_editor/store/mutation_types.js @@ -0,0 +1,3 @@ +export const LOAD_CONTENT = 'loadContent'; +export const RECEIVE_CONTENT_SUCCESS = 'receiveContentSuccess'; +export const RECEIVE_CONTENT_ERROR = 'receiveContentError'; diff --git a/app/assets/javascripts/static_site_editor/store/mutations.js b/app/assets/javascripts/static_site_editor/store/mutations.js new file mode 100644 index 00000000000..88cb74d2b11 --- /dev/null +++ b/app/assets/javascripts/static_site_editor/store/mutations.js @@ -0,0 +1,15 @@ +import * as types from './mutation_types'; + +export default { + [types.LOAD_CONTENT](state) { + state.isLoadingContent = true; + }, + [types.RECEIVE_CONTENT_SUCCESS](state, { title, content }) { + state.isLoadingContent = false; + state.title = title; + state.content = content; + }, + [types.RECEIVE_CONTENT_ERROR](state) { + state.isLoadingContent = false; + }, +}; diff --git a/app/assets/javascripts/static_site_editor/store/state.js b/app/assets/javascripts/static_site_editor/store/state.js index 68a7f95760c..b68e73f06f5 100644 --- a/app/assets/javascripts/static_site_editor/store/state.js +++ b/app/assets/javascripts/static_site_editor/store/state.js @@ -1,8 +1,12 @@ const createState = (initialState = {}) => ({ + projectId: null, + sourcePath: null, + isLoadingContent: false, - isContentLoaded: false, content: '', + title: '', + ...initialState, }); diff --git a/app/models/ci/group.rb b/app/models/ci/group.rb index 0e05318b253..15dc1ca8954 100644 --- a/app/models/ci/group.rb +++ b/app/models/ci/group.rb @@ -11,11 +11,12 @@ module Ci include StaticModel include Gitlab::Utils::StrongMemoize - attr_reader :stage, :name, :jobs + attr_reader :project, :stage, :name, :jobs delegate :size, to: :jobs - def initialize(stage, name:, jobs:) + def initialize(project, stage, name:, jobs:) + @project = project @stage = stage @name = name @jobs = jobs @@ -23,7 +24,7 @@ module Ci def status strong_memoize(:status) do - if Feature.enabled?(:ci_composite_status, default_enabled: false) + if Feature.enabled?(:ci_composite_status, project, default_enabled: false) Gitlab::Ci::Status::Composite .new(@jobs) .status @@ -44,11 +45,11 @@ module Ci end end - def self.fabricate(stage) + def self.fabricate(project, stage) stage.statuses.ordered.latest .sort_by(&:sortable_name).group_by(&:group_name) .map do |group_name, grouped_statuses| - self.new(stage, name: group_name, jobs: grouped_statuses) + self.new(project, stage, name: group_name, jobs: grouped_statuses) end end end diff --git a/app/models/ci/legacy_stage.rb b/app/models/ci/legacy_stage.rb index 9ca5cf13907..f156219ea81 100644 --- a/app/models/ci/legacy_stage.rb +++ b/app/models/ci/legacy_stage.rb @@ -20,7 +20,7 @@ module Ci end def groups - @groups ||= Ci::Group.fabricate(self) + @groups ||= Ci::Group.fabricate(project, self) end def to_param diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index e6c34f3df03..93bd42f8734 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -109,7 +109,7 @@ module Ci end def groups - @groups ||= Ci::Group.fabricate(self) + @groups ||= Ci::Group.fabricate(project, self) end def has_warnings? diff --git a/app/models/concerns/ci/maskable.rb b/app/models/concerns/ci/maskable.rb index 15bc48bf964..4e0ee72f18f 100644 --- a/app/models/concerns/ci/maskable.rb +++ b/app/models/concerns/ci/maskable.rb @@ -9,9 +9,9 @@ module Ci # * No variables # * No spaces # * Minimal length of 8 characters - # * Characters must be from the Base64 alphabet (RFC4648) with the addition of @ and : + # * Characters must be from the Base64 alphabet (RFC4648) with the addition of '@', ':' and '.' # * Absolutely no fun is allowed - REGEX = /\A[a-zA-Z0-9_+=\/@:-]{8,}\z/.freeze + REGEX = /\A[a-zA-Z0-9_+=\/@:.-]{8,}\z/.freeze included do validates :masked, inclusion: { in: [true, false] } diff --git a/app/serializers/analytics_summary_entity.rb b/app/serializers/analytics_summary_entity.rb index 39c6b4b06b2..b9797bfb021 100644 --- a/app/serializers/analytics_summary_entity.rb +++ b/app/serializers/analytics_summary_entity.rb @@ -3,4 +3,5 @@ class AnalyticsSummaryEntity < Grape::Entity expose :value, safe: true expose :title + expose :unit, if: { with_unit: true } end diff --git a/app/services/ci/external_pull_requests/create_pipeline_service.rb b/app/services/ci/external_pull_requests/create_pipeline_service.rb new file mode 100644 index 00000000000..78be94bfb41 --- /dev/null +++ b/app/services/ci/external_pull_requests/create_pipeline_service.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# This service is responsible for creating a pipeline for a given +# ExternalPullRequest coming from other providers such as GitHub. + +module Ci + module ExternalPullRequests + class CreatePipelineService < BaseService + def execute(pull_request) + return unless pull_request.open? && pull_request.actual_branch_head? + + create_pipeline_for(pull_request) + end + + private + + def create_pipeline_for(pull_request) + Ci::CreatePipelineService.new(project, current_user, create_params(pull_request)) + .execute(:external_pull_request_event, external_pull_request: pull_request) + end + + def create_params(pull_request) + { + ref: pull_request.source_ref, + source_sha: pull_request.source_sha, + target_sha: pull_request.target_sha + } + end + end + end +end diff --git a/app/services/external_pull_requests/create_pipeline_service.rb b/app/services/external_pull_requests/create_pipeline_service.rb deleted file mode 100644 index 36411465ff1..00000000000 --- a/app/services/external_pull_requests/create_pipeline_service.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# This service is responsible for creating a pipeline for a given -# ExternalPullRequest coming from other providers such as GitHub. - -module ExternalPullRequests - class CreatePipelineService < BaseService - def execute(pull_request) - return unless pull_request.open? && pull_request.actual_branch_head? - - create_pipeline_for(pull_request) - end - - private - - def create_pipeline_for(pull_request) - Ci::CreatePipelineService.new(project, current_user, create_params(pull_request)) - .execute(:external_pull_request_event, external_pull_request: pull_request) - end - - def create_params(pull_request) - { - ref: pull_request.source_ref, - source_sha: pull_request.source_sha, - target_sha: pull_request.target_sha - } - end - end -end diff --git a/app/views/groups/_activities.html.haml b/app/views/groups/_activities.html.haml index 44554cab1e9..47e7e27de48 100644 --- a/app/views/groups/_activities.html.haml +++ b/app/views/groups/_activities.html.haml @@ -5,4 +5,6 @@ %i.fa.fa-rss .content_list -= spinner +.loading + .spinner.spinner-md + diff --git a/app/views/projects/settings/_general.html.haml b/app/views/projects/settings/_general.html.haml index 520f342f567..0f60fc18026 100644 --- a/app/views/projects/settings/_general.html.haml +++ b/app/views/projects/settings/_general.html.haml @@ -20,6 +20,8 @@ = f.text_field :tag_list, value: @project.tag_list.join(', '), maxlength: 2000, class: "form-control" %p.form-text.text-muted= _('Separate topics with commas.') + = render_if_exists 'compliance_management/compliance_framework/project_settings', f: f + .row .form-group.col-md-9 = f.label :description, _('Project description (optional)'), class: 'label-bold' diff --git a/app/workers/update_external_pull_requests_worker.rb b/app/workers/update_external_pull_requests_worker.rb index b459d26e487..0d48877e1b0 100644 --- a/app/workers/update_external_pull_requests_worker.rb +++ b/app/workers/update_external_pull_requests_worker.rb @@ -21,7 +21,7 @@ class UpdateExternalPullRequestsWorker # rubocop:disable Scalability/IdempotentW .by_source_branch(branch) external_pull_requests.find_each do |pull_request| - ExternalPullRequests::CreatePipelineService.new(project, user) + Ci::ExternalPullRequests::CreatePipelineService.new(project, user) .execute(pull_request) end end |