From 429d1abad29d379d8bc8f5219eb72384ad485deb Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 14 Oct 2019 15:06:07 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../components/error_tracking_list.vue | 33 +++++++++-------- app/assets/javascripts/labels_select.js | 14 ++++++++ app/assets/javascripts/snippet/snippet_embed.js | 41 ++++++++++++---------- app/assets/stylesheets/framework/common.scss | 2 ++ app/controllers/concerns/uploads_actions.rb | 20 ++++++----- .../groups/settings/ci_cd_controller.rb | 23 ++++++++++++ .../projects/settings/ci_cd_controller.rb | 10 ++++-- app/controllers/uploads_controller.rb | 9 +++-- app/policies/group_policy.rb | 5 ++- app/policies/project_policy.rb | 2 ++ .../admin/application_settings/_ci_cd.html.haml | 2 +- .../admin/application_settings/_pages.html.haml | 2 +- app/views/groups/settings/ci_cd/_form.html.haml | 13 +++++++ app/views/groups/settings/ci_cd/show.html.haml | 15 ++++++++ app/views/projects/settings/ci_cd/_form.html.haml | 9 +++++ app/workers/migrate_external_diffs_worker.rb | 2 +- .../schedule_migrate_external_diffs_worker.rb | 2 +- app/workers/update_project_statistics_worker.rb | 1 - 18 files changed, 151 insertions(+), 54 deletions(-) create mode 100644 app/views/groups/settings/ci_cd/_form.html.haml (limited to 'app') diff --git a/app/assets/javascripts/error_tracking/components/error_tracking_list.vue b/app/assets/javascripts/error_tracking/components/error_tracking_list.vue index 1d54c4a4264..3528f0a9335 100644 --- a/app/assets/javascripts/error_tracking/components/error_tracking_list.vue +++ b/app/assets/javascripts/error_tracking/components/error_tracking_list.vue @@ -7,10 +7,10 @@ import { __ } from '~/locale'; export default { fields: [ - { key: 'error', label: __('Open errors') }, + { key: 'error', label: __('Open errors'), thClass: 'w-70p' }, { key: 'events', label: __('Events') }, { key: 'users', label: __('Users') }, - { key: 'lastSeen', label: __('Last seen') }, + { key: 'lastSeen', label: __('Last seen'), thClass: 'w-15p' }, ], components: { GlEmptyState, @@ -67,40 +67,39 @@ export default {
{{ __('View in Sentry') }} - +
- + + diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js index 22b062563b5..72de3b5d726 100644 --- a/app/assets/javascripts/labels_select.js +++ b/app/assets/javascripts/labels_select.js @@ -32,6 +32,7 @@ export default class LabelsSelect { $selectbox, $sidebarCollapsedValue, $value, + $dropdownMenu, abilityName, defaultLabel, issueUpdateURL, @@ -67,6 +68,7 @@ export default class LabelsSelect { $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span'); $sidebarLabelTooltip = $block.find('.js-sidebar-labels-tooltip'); $value = $block.find('.value'); + $dropdownMenu = $dropdown.parent().find('.dropdown-menu'); $loading = $block.find('.block-loading').fadeOut(); fieldName = $dropdown.data('fieldName'); initialSelected = $selectbox @@ -454,9 +456,21 @@ export default class LabelsSelect { } $loading.fadeIn(); + const oldLabels = boardsStore.detail.issue.labels; boardsStore.detail.issue .update($dropdown.attr('data-issue-update')) + .then(() => { + if (isScopedLabel(label)) { + const prevIds = oldLabels.map(label => label.id); + const newIds = boardsStore.detail.issue.labels.map(label => label.id); + const differentIds = _.difference(prevIds, newIds); + $dropdown.data('marked', newIds); + $dropdownMenu + .find(differentIds.map(id => `[data-label-id="${id}"]`).join(',')) + .removeClass('is-active'); + } + }) .then(fadeOutLoader) .catch(fadeOutLoader); } else if (handleClick) { diff --git a/app/assets/javascripts/snippet/snippet_embed.js b/app/assets/javascripts/snippet/snippet_embed.js index fe08d2c7ebb..6606271c4fa 100644 --- a/app/assets/javascripts/snippet/snippet_embed.js +++ b/app/assets/javascripts/snippet/snippet_embed.js @@ -1,25 +1,30 @@ import { __ } from '~/locale'; export default () => { - const { protocol, host, pathname } = window.location; const shareBtn = document.querySelector('.js-share-btn'); - const embedBtn = document.querySelector('.js-embed-btn'); - const snippetUrlArea = document.querySelector('.js-snippet-url-area'); - const embedAction = document.querySelector('.js-embed-action'); - const url = `${protocol}//${host + pathname}`; - shareBtn.addEventListener('click', () => { - shareBtn.classList.add('is-active'); - embedBtn.classList.remove('is-active'); - snippetUrlArea.value = url; - embedAction.innerText = __('Share'); - }); + if (shareBtn) { + const { protocol, host, pathname } = window.location; - embedBtn.addEventListener('click', () => { - embedBtn.classList.add('is-active'); - shareBtn.classList.remove('is-active'); - const scriptTag = ``; - snippetUrlArea.value = scriptTag; - embedAction.innerText = __('Embed'); - }); + const embedBtn = document.querySelector('.js-embed-btn'); + + const snippetUrlArea = document.querySelector('.js-snippet-url-area'); + const embedAction = document.querySelector('.js-embed-action'); + const url = `${protocol}//${host + pathname}`; + + shareBtn.addEventListener('click', () => { + shareBtn.classList.add('is-active'); + embedBtn.classList.remove('is-active'); + snippetUrlArea.value = url; + embedAction.innerText = __('Share'); + }); + + embedBtn.addEventListener('click', () => { + embedBtn.classList.add('is-active'); + shareBtn.classList.remove('is-active'); + const scriptTag = ``; + snippetUrlArea.value = scriptTag; + embedAction.innerText = __('Embed'); + }); + } }; diff --git a/app/assets/stylesheets/framework/common.scss b/app/assets/stylesheets/framework/common.scss index 922051ab0e9..16cb63fc0df 100644 --- a/app/assets/stylesheets/framework/common.scss +++ b/app/assets/stylesheets/framework/common.scss @@ -452,6 +452,8 @@ img.emoji { .w-0 { width: 0; } .w-8em { width: 8em; } .w-3rem { width: 3rem; } +.w-15p { width: 15%; } +.w-70p { width: 70%; } .h-12em { height: 12em; } .h-32-px { height: 32px;} diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index 77afffc4b27..6d9ee39f841 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -29,13 +29,15 @@ module UploadsActions def show return render_404 unless uploader&.exists? - if cache_publicly? - # We need to reset caching from the applications controller to get rid of the no-store value - headers['Cache-Control'] = '' - expires_in 5.minutes, public: true, must_revalidate: false - else - expires_in 0.seconds, must_revalidate: true, private: true - end + # We need to reset caching from the applications controller to get rid of the no-store value + headers['Cache-Control'] = '' + headers['Pragma'] = '' + + ttl, directives = *cache_settings + ttl ||= 6.months + directives ||= { private: true, must_revalidate: true } + + expires_in ttl, directives disposition = uploader.embeddable? ? 'inline' : 'attachment' @@ -120,8 +122,8 @@ module UploadsActions nil end - def cache_publicly? - false + def cache_settings + [] end def model diff --git a/app/controllers/groups/settings/ci_cd_controller.rb b/app/controllers/groups/settings/ci_cd_controller.rb index c465e622de0..0e83d057484 100644 --- a/app/controllers/groups/settings/ci_cd_controller.rb +++ b/app/controllers/groups/settings/ci_cd_controller.rb @@ -5,11 +5,22 @@ module Groups class CiCdController < Groups::ApplicationController skip_cross_project_access_check :show before_action :authorize_admin_group! + before_action :authorize_update_max_artifacts_size!, only: [:update] def show define_ci_variables end + def update + if update_group_service.execute + flash[:notice] = s_('GroupSettings|Pipeline settings was updated for the group') + else + flash[:alert] = s_("GroupSettings|There was a problem updating the pipeline settings: %{error_messages}." % { error_messages: group.errors.full_messages }) + end + + redirect_to group_settings_ci_cd_path + end + def reset_registration_token @group.reset_runners_token! @@ -40,6 +51,10 @@ module Groups return render_404 unless can?(current_user, :admin_group, group) end + def authorize_update_max_artifacts_size! + return render_404 unless can?(current_user, :update_max_artifacts_size, group) + end + def auto_devops_params params.require(:group).permit(:auto_devops_enabled) end @@ -47,6 +62,14 @@ module Groups def auto_devops_service Groups::AutoDevopsService.new(group, current_user, auto_devops_params) end + + def update_group_service + Groups::UpdateService.new(group, current_user, update_group_params) + end + + def update_group_params + params.require(:group).permit(:max_artifacts_size) + end end end end diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 0d61c3cc031..cfed8727450 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -46,13 +46,19 @@ module Projects private def update_params - params.require(:project).permit( + params.require(:project).permit(*permitted_project_params) + end + + def permitted_project_params + [ :runners_token, :builds_enabled, :build_allow_git_fetch, :build_timeout_human_readable, :build_coverage_regex, :public_builds, :auto_cancel_pending_pipelines, :ci_config_path, auto_devops_attributes: [:id, :domain, :enabled, :deploy_strategy], ci_cd_settings_attributes: [:default_git_depth] - ) + ].tap do |list| + list << :max_artifacts_size if can?(current_user, :update_max_artifacts_size, project) + end end def run_autodevops_pipeline(service) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 2adfeab182e..635db386792 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -81,8 +81,13 @@ class UploadsController < ApplicationController end end - def cache_publicly? - User === model || Appearance === model + def cache_settings + case model + when User, Appearance + [5.minutes, { public: true, must_revalidate: false }] + when Project, Group + [5.minutes, { private: true, must_revalidate: true }] + end end def secret? diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index 951a104122d..9e8ee3acf00 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -53,7 +53,10 @@ class GroupPolicy < BasePolicy enable :upload_file end - rule { admin }.enable :read_group + rule { admin }.policy do + enable :read_group + enable :update_max_artifacts_size + end rule { has_projects }.policy do enable :read_group diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index e6f8d1052ed..a3540f31077 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -137,6 +137,8 @@ class ProjectPolicy < BasePolicy # not. rule { guest | admin }.enable :read_project_for_iids + rule { admin }.enable :update_max_artifacts_size + rule { guest }.enable :guest_access rule { reporter }.enable :reporter_access rule { developer }.enable :developer_access diff --git a/app/views/admin/application_settings/_ci_cd.html.haml b/app/views/admin/application_settings/_ci_cd.html.haml index d1de4286ee7..1f5bce19bc6 100644 --- a/app/views/admin/application_settings/_ci_cd.html.haml +++ b/app/views/admin/application_settings/_ci_cd.html.haml @@ -34,7 +34,7 @@ = f.number_field :max_artifacts_size, class: 'form-control' .form-text.text-muted = _("Set the maximum file size for each job's artifacts") - = link_to icon('question-circle'), help_page_path('user/admin_area/settings/continuous_integration', anchor: 'maximum-artifacts-size') + = link_to icon('question-circle'), help_page_path('user/admin_area/settings/continuous_integration', anchor: 'maximum-artifacts-size-core-only') .form-group = f.label :default_artifacts_expire_in, _('Default artifacts expiration'), class: 'label-bold' = f.text_field :default_artifacts_expire_in, class: 'form-control' diff --git a/app/views/admin/application_settings/_pages.html.haml b/app/views/admin/application_settings/_pages.html.haml index 1282a032f52..b15afb3b806 100644 --- a/app/views/admin/application_settings/_pages.html.haml +++ b/app/views/admin/application_settings/_pages.html.haml @@ -30,6 +30,6 @@ = f.check_box :lets_encrypt_terms_of_service_accepted, class: 'form-check-input' = f.label :lets_encrypt_terms_of_service_accepted, class: 'form-check-label' do - terms_of_service_link_start = ''.html_safe % { url: lets_encrypt_terms_of_service_admin_application_settings_path } - = _("I have read and agree to the Let's Encrypt %{link_start}Terms of Service%{link_end}").html_safe % { link_start: terms_of_service_link_start, link_end: ''.html_safe } + = _("I have read and agree to the Let's Encrypt %{link_start}Terms of Service%{link_end} (PDF)").html_safe % { link_start: terms_of_service_link_start, link_end: ''.html_safe } = f.submit _('Save changes'), class: "btn btn-success" diff --git a/app/views/groups/settings/ci_cd/_form.html.haml b/app/views/groups/settings/ci_cd/_form.html.haml new file mode 100644 index 00000000000..54e88d11827 --- /dev/null +++ b/app/views/groups/settings/ci_cd/_form.html.haml @@ -0,0 +1,13 @@ +.row.prepend-top-default + .col-lg-12 + = form_for group, url: group_settings_ci_cd_path(group, anchor: 'js-general-pipeline-settings') do |f| + = form_errors(group) + %fieldset.builds-feature + .form-group + = f.label :max_artifacts_size, _('Maximum artifacts size (MB)'), class: 'label-bold' + = f.number_field :max_artifacts_size, class: 'form-control' + %p.form-text.text-muted + = _("Set the maximum file size for each job's artifacts") + = link_to icon('question-circle'), help_page_path('user/admin_area/settings/continuous_integration', anchor: 'maximum-artifacts-size-core-only'), target: '_blank' + + = f.submit _('Save changes'), class: "btn btn-success" diff --git a/app/views/groups/settings/ci_cd/show.html.haml b/app/views/groups/settings/ci_cd/show.html.haml index d21496ee0aa..a3f35b72cc6 100644 --- a/app/views/groups/settings/ci_cd/show.html.haml +++ b/app/views/groups/settings/ci_cd/show.html.haml @@ -2,6 +2,21 @@ - page_title "CI / CD" - expanded = expanded_by_default? +- general_expanded = @group.errors.empty? ? expanded : true + +-# Given we only have one field in this form which is also admin-only, +-# we don't want to show an empty section to non-admin users, +- if can?(current_user, :update_max_artifacts_size, @group) + %section.settings#js-general-pipeline-settings.no-animate{ class: ('expanded' if general_expanded) } + .settings-header + %h4 + = _("General pipelines") + %button.btn.js-settings-toggle{ type: 'button' } + = expanded ? _('Collapse') : _('Expand') + %p + = _("Customize your pipeline configuration.") + .settings-content + = render 'groups/settings/ci_cd/form', group: @group %section.settings#ci-variables.no-animate{ class: ('expanded' if expanded) } .settings-header diff --git a/app/views/projects/settings/ci_cd/_form.html.haml b/app/views/projects/settings/ci_cd/_form.html.haml index 430d6071468..a674136e791 100644 --- a/app/views/projects/settings/ci_cd/_form.html.haml +++ b/app/views/projects/settings/ci_cd/_form.html.haml @@ -40,6 +40,15 @@ = _('If any job surpasses this timeout threshold, it will be marked as failed. Human readable time input language is accepted like "1 hour". Values without specification represent seconds.') = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'timeout'), target: '_blank' + - if can?(current_user, :update_max_artifacts_size, @project) + %hr + .form-group + = f.label :max_artifacts_size, _('Maximum artifacts size (MB)'), class: 'label-bold' + = f.number_field :max_artifacts_size, class: 'form-control' + %p.form-text.text-muted + = _("Set the maximum file size for each job's artifacts") + = link_to icon('question-circle'), help_page_path('user/admin_area/settings/continuous_integration', anchor: 'maximum-artifacts-size-core-only'), target: '_blank' + %hr .form-group = f.label :ci_config_path, _('Custom CI config path'), class: 'label-bold' diff --git a/app/workers/migrate_external_diffs_worker.rb b/app/workers/migrate_external_diffs_worker.rb index debac97af2c..fe757968d49 100644 --- a/app/workers/migrate_external_diffs_worker.rb +++ b/app/workers/migrate_external_diffs_worker.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true class MigrateExternalDiffsWorker include ApplicationWorker diff --git a/app/workers/schedule_migrate_external_diffs_worker.rb b/app/workers/schedule_migrate_external_diffs_worker.rb index 70910f7ca04..04a370f01af 100644 --- a/app/workers/schedule_migrate_external_diffs_worker.rb +++ b/app/workers/schedule_migrate_external_diffs_worker.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true class ScheduleMigrateExternalDiffsWorker include ApplicationWorker diff --git a/app/workers/update_project_statistics_worker.rb b/app/workers/update_project_statistics_worker.rb index 9a29cc12707..3abb7e34a9d 100644 --- a/app/workers/update_project_statistics_worker.rb +++ b/app/workers/update_project_statistics_worker.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true # Worker for updating project statistics. -- cgit v1.2.3