diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-15 15:42:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-15 15:42:17 +0000 |
commit | 44fdf983bd35328dd577d3d3650d14163ef3e2b6 (patch) | |
tree | 84ff300d056cfbabb5a0fe2a9cbaa80aaeab1cc5 /app | |
parent | bc9fa07b26184b5c94808f704db6ea1ac81bf4de (diff) | |
download | gitlab-ce-44fdf983bd35328dd577d3d3650d14163ef3e2b6.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app')
23 files changed, 107 insertions, 50 deletions
diff --git a/app/assets/javascripts/registry/settings/components/registry_settings_app.vue b/app/assets/javascripts/registry/settings/components/registry_settings_app.vue index 4d767f1a578..b4a59fd0178 100644 --- a/app/assets/javascripts/registry/settings/components/registry_settings_app.vue +++ b/app/assets/javascripts/registry/settings/components/registry_settings_app.vue @@ -1,5 +1,5 @@ <script> -import { mapActions, mapState } from 'vuex'; +import { mapActions, mapGetters, mapState } from 'vuex'; import { GlAlert, GlSprintf, GlLink } from '@gitlab/ui'; import { s__ } from '~/locale'; @@ -15,8 +15,15 @@ export default { GlLink, }, i18n: { - unavailableFeatureText: s__( - 'ContainerRegistry|Currently, the Container Registry tag expiration feature is not available for projects created before GitLab version 12.8. For updates and more information, visit Issue %{linkStart}#196124%{linkEnd}', + unavailableFeatureTitle: s__( + `ContainerRegistry|Container Registry tag expiration and retention policy is disabled`, + ), + unavailableFeatureIntroText: s__( + `ContainerRegistry|The Container Registry tag expiration and retention policies for this project have not been enabled.`, + ), + unavailableUserFeatureText: s__(`ContainerRegistry|Please contact your administrator.`), + unavailableAdminFeatureText: s__( + `ContainerRegistry| Please visit the %{linkStart}administration settings%{linkEnd} to enable this feature.`, ), fetchSettingsErrorText: FETCH_SETTINGS_ERROR_MESSAGE, }, @@ -26,10 +33,19 @@ export default { }; }, computed: { - ...mapState(['isDisabled']), + ...mapState(['isAdmin', 'adminSettingsPath']), + ...mapGetters({ isDisabled: 'getIsDisabled' }), showSettingForm() { return !this.isDisabled && !this.fetchSettingsError; }, + showDisabledFormMessage() { + return this.isDisabled && !this.fetchSettingsError; + }, + unavailableFeatureMessage() { + return this.isAdmin + ? this.$options.i18n.unavailableAdminFeatureText + : this.$options.i18n.unavailableUserFeatureText; + }, }, mounted() { this.fetchSettings().catch(() => { @@ -59,16 +75,21 @@ export default { </ul> <settings-form v-if="showSettingForm" /> <template v-else> - <gl-alert v-if="isDisabled" :dismissible="false"> - <p> - <gl-sprintf :message="$options.i18n.unavailableFeatureText"> - <template #link="{content}"> - <gl-link href="https://gitlab.com/gitlab-org/gitlab/issues/196124" target="_blank"> - {{ content }} - </gl-link> - </template> - </gl-sprintf> - </p> + <gl-alert + v-if="showDisabledFormMessage" + :dismissible="false" + :title="$options.i18n.unavailableFeatureTitle" + variant="tip" + > + {{ $options.i18n.unavailableFeatureIntroText }} + + <gl-sprintf :message="unavailableFeatureMessage"> + <template #link="{ content }"> + <gl-link :href="adminSettingsPath" target="_blank"> + {{ content }} + </gl-link> + </template> + </gl-sprintf> </gl-alert> <gl-alert v-else-if="fetchSettingsError" variant="warning" :dismissible="false"> <gl-sprintf :message="$options.i18n.fetchSettingsErrorText" /> diff --git a/app/assets/javascripts/registry/settings/store/actions.js b/app/assets/javascripts/registry/settings/store/actions.js index d0379d05164..be1f62334fa 100644 --- a/app/assets/javascripts/registry/settings/store/actions.js +++ b/app/assets/javascripts/registry/settings/store/actions.js @@ -5,11 +5,7 @@ export const setInitialState = ({ commit }, data) => commit(types.SET_INITIAL_ST export const updateSettings = ({ commit }, data) => commit(types.UPDATE_SETTINGS, data); export const toggleLoading = ({ commit }) => commit(types.TOGGLE_LOADING); export const receiveSettingsSuccess = ({ commit }, data) => { - if (data) { - commit(types.SET_SETTINGS, data); - } else { - commit(types.SET_IS_DISABLED, true); - } + commit(types.SET_SETTINGS, data); }; export const resetSettings = ({ commit }) => commit(types.RESET_SETTINGS); diff --git a/app/assets/javascripts/registry/settings/store/getters.js b/app/assets/javascripts/registry/settings/store/getters.js index 639becebeec..ef4b4f0ba02 100644 --- a/app/assets/javascripts/registry/settings/store/getters.js +++ b/app/assets/javascripts/registry/settings/store/getters.js @@ -19,3 +19,7 @@ export const getSettings = (state, getters) => ({ }); export const getIsEdited = state => !isEqual(state.original, state.settings); + +export const getIsDisabled = state => { + return !(state.original || state.enableHistoricEntries); +}; diff --git a/app/assets/javascripts/registry/settings/store/mutation_types.js b/app/assets/javascripts/registry/settings/store/mutation_types.js index 2d071567c1f..db499ffa761 100644 --- a/app/assets/javascripts/registry/settings/store/mutation_types.js +++ b/app/assets/javascripts/registry/settings/store/mutation_types.js @@ -3,4 +3,3 @@ export const UPDATE_SETTINGS = 'UPDATE_SETTINGS'; export const TOGGLE_LOADING = 'TOGGLE_LOADING'; export const SET_SETTINGS = 'SET_SETTINGS'; export const RESET_SETTINGS = 'RESET_SETTINGS'; -export const SET_IS_DISABLED = 'SET_IS_DISABLED'; diff --git a/app/assets/javascripts/registry/settings/store/mutations.js b/app/assets/javascripts/registry/settings/store/mutations.js index f562137db1a..bb7071b020b 100644 --- a/app/assets/javascripts/registry/settings/store/mutations.js +++ b/app/assets/javascripts/registry/settings/store/mutations.js @@ -1,3 +1,4 @@ +import { parseBoolean } from '~/lib/utils/common_utils'; import * as types from './mutation_types'; export default { @@ -8,19 +9,19 @@ export default { keepN: JSON.parse(initialState.keepNOptions), olderThan: JSON.parse(initialState.olderThanOptions), }; + state.enableHistoricEntries = parseBoolean(initialState.enableHistoricEntries); + state.isAdmin = parseBoolean(initialState.isAdmin); + state.adminSettingsPath = initialState.adminSettingsPath; }, [types.UPDATE_SETTINGS](state, data) { state.settings = { ...state.settings, ...data.settings }; }, [types.SET_SETTINGS](state, settings) { - state.settings = settings; + state.settings = settings ?? state.settings; state.original = Object.freeze(settings); }, - [types.SET_IS_DISABLED](state, isDisabled) { - state.isDisabled = isDisabled; - }, [types.RESET_SETTINGS](state) { - state.settings = { ...state.original }; + state.settings = Object.assign({}, state.original); }, [types.TOGGLE_LOADING](state) { state.isLoading = !state.isLoading; diff --git a/app/assets/javascripts/registry/settings/store/state.js b/app/assets/javascripts/registry/settings/store/state.js index 582e18e5465..fccc0991c1c 100644 --- a/app/assets/javascripts/registry/settings/store/state.js +++ b/app/assets/javascripts/registry/settings/store/state.js @@ -8,9 +8,17 @@ export default () => ({ */ isLoading: false, /* - * Boolean to determine if the user is allowed to interact with the form + * Boolean to determine if the user is an admin */ - isDisabled: false, + isAdmin: false, + /* + * String containing the full path to the admin config page for CI/CD + */ + adminSettingsPath: '', + /* + * Boolean to determine if project created before 12.8 can use this feature + */ + enableHistoricEntries: false, /* * This contains the data shown and manipulated in the UI * Has the following structure: @@ -24,9 +32,9 @@ export default () => ({ */ settings: {}, /* - * Same structure as settings, above but Frozen object and used only in case the user clicks 'cancel' + * Same structure as settings, above but Frozen object and used only in case the user clicks 'cancel', initialized to null */ - original: {}, + original: null, /* * Contains the options used to populate the form selects */ diff --git a/app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js b/app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js index bffaa096210..2f6640232dd 100644 --- a/app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js +++ b/app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js @@ -202,7 +202,7 @@ const fileExtensionIcons = { flv: 'movie', vob: 'movie', ogv: 'movie', - ogg: 'movie', + ogg: 'music', gifv: 'movie', avi: 'movie', mov: 'movie', diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c5c586ea489..b2496427924 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -496,6 +496,10 @@ class ApplicationController < ActionController::Base html_request? && !devise_controller? end + def public_visibility_restricted? + Gitlab::CurrentSettings.restricted_visibility_levels.include? Gitlab::VisibilityLevel::PUBLIC + end + def set_usage_stats_consent_flag return unless current_user return if sessionless_user? diff --git a/app/controllers/explore/application_controller.rb b/app/controllers/explore/application_controller.rb index 8eee3742d89..9d33135d4c1 100644 --- a/app/controllers/explore/application_controller.rb +++ b/app/controllers/explore/application_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Explore::ApplicationController < ApplicationController - skip_before_action :authenticate_user! + skip_before_action :authenticate_user!, unless: :public_visibility_restricted? layout 'explore' end diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 97895d6461c..91bba1eb617 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class HelpController < ApplicationController - skip_before_action :authenticate_user! + skip_before_action :authenticate_user!, unless: :public_visibility_restricted? layout 'help' diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb index 1b36f60c316..b341cc795a0 100644 --- a/app/helpers/explore_helper.rb +++ b/app/helpers/explore_helper.rb @@ -51,6 +51,10 @@ module ExploreHelper links.any? { |link| explore_nav_link?(link) } end + def public_visibility_restricted? + Gitlab::CurrentSettings.restricted_visibility_levels.include? Gitlab::VisibilityLevel::PUBLIC + end + private def get_explore_nav_links diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index a4b6e613100..f3f4cdc857f 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -74,7 +74,7 @@ module ServicesHelper def scoped_integration_path(integration) if @project.present? - project_settings_integration_path(@project, integration) + project_service_path(@project, integration) elsif @group.present? group_settings_integration_path(@group, integration) else diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index c1e44748304..0aa0216558f 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -14,6 +14,7 @@ class ApplicationSetting < ApplicationRecord add_authentication_token_field :static_objects_external_storage_auth_token belongs_to :self_monitoring_project, class_name: "Project", foreign_key: 'instance_administration_project_id' + belongs_to :push_rule alias_attribute :self_monitoring_project_id, :instance_administration_project_id belongs_to :instance_administrators_group, class_name: "Group" diff --git a/app/models/project_services/alerts_service.rb b/app/models/project_services/alerts_service.rb index 2f7902d9617..16bf37fd189 100644 --- a/app/models/project_services/alerts_service.rb +++ b/app/models/project_services/alerts_service.rb @@ -15,6 +15,8 @@ class AlertsService < Service before_validation :ensure_token, if: :activated? def url + return if instance? || template? + url_helpers.project_alerts_notify_url(project, format: :json) end diff --git a/app/models/project_setting.rb b/app/models/project_setting.rb index 37e4a7be770..7c93faf3928 100644 --- a/app/models/project_setting.rb +++ b/app/models/project_setting.rb @@ -9,3 +9,5 @@ class ProjectSetting < ApplicationRecord where(primary_key => safe_find_or_create_by(attrs)) end end + +ProjectSetting.prepend_if_ee('EE::ProjectSetting') diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb index 86e2eeda21f..f8715b57d6e 100644 --- a/app/services/groups/import_export/export_service.rb +++ b/app/services/groups/import_export/export_service.rb @@ -56,7 +56,12 @@ module Groups end def tree_exporter - Gitlab::ImportExport::Group::TreeSaver.new(group: @group, current_user: @current_user, shared: @shared, params: @params) + Gitlab::ImportExport::Group::LegacyTreeSaver.new( + group: @group, + current_user: @current_user, + shared: @shared, + params: @params + ) end def file_saver diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index d36e08f44a4..6a261bbbc46 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -38,7 +38,9 @@ %hr.footer-fixed .container.footer-container .footer-links - = link_to _("Explore"), explore_root_path - = link_to _("Help"), help_path + - if !public_visibility_restricted? + = link_to _("Explore"), explore_root_path + = link_to _("Help"), help_path = link_to _("About GitLab"), "https://about.gitlab.com/" + = footer_message diff --git a/app/views/layouts/devise_empty.html.haml b/app/views/layouts/devise_empty.html.haml index ff2b00ea376..6ac80a5aba3 100644 --- a/app/views/layouts/devise_empty.html.haml +++ b/app/views/layouts/devise_empty.html.haml @@ -14,7 +14,8 @@ %hr .container .footer-links - = link_to _("Explore"), explore_root_path - = link_to _("Help"), help_path + - if !public_visibility_restricted? + = link_to _("Explore"), explore_root_path + = link_to _("Help"), help_path = link_to _("About GitLab"), "https://about.gitlab.com/" = footer_message diff --git a/app/views/projects/registry/settings/_index.haml b/app/views/projects/registry/settings/_index.haml index 0e0341a9923..c0cef8503e0 100644 --- a/app/views/projects/registry/settings/_index.haml +++ b/app/views/projects/registry/settings/_index.haml @@ -1,4 +1,7 @@ #js-registry-settings{ data: { project_id: @project.id, cadence_options: cadence_options.to_json, keep_n_options: keep_n_options.to_json, - older_than_options: older_than_options.to_json} } + older_than_options: older_than_options.to_json, + is_admin: current_user&.admin.to_s, + admin_settings_path: ci_cd_admin_application_settings_path(anchor: 'js-registry-settings'), + enable_historic_entries: Gitlab::CurrentSettings.try(:container_expiration_policies_enable_historic_entries).to_s} } diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml index a0d9d29a7ae..bd9defe5f74 100644 --- a/app/views/projects/services/_form.html.haml +++ b/app/views/projects/services/_form.html.haml @@ -10,7 +10,7 @@ - if @service.respond_to?(:detailed_description) %p= @service.detailed_description .col-lg-9 - = form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form| + = form_for(@service, as: :service, url: scoped_integration_path(@service), method: :put, html: { class: 'gl-show-field-errors integration-settings-form js-integration-settings-form', data: { 'can-test' => @service.can_test?, 'test-url' => test_project_service_path(@project, @service) } }) do |form| = render 'shared/service_settings', form: form, service: @service - if @service.editable? .footer-block.row-content-block diff --git a/app/views/projects/services/alerts/_help.html.haml b/app/views/projects/services/alerts/_help.html.haml index be910203125..ef3ab8d8d04 100644 --- a/app/views/projects/services/alerts/_help.html.haml +++ b/app/views/projects/services/alerts/_help.html.haml @@ -1,3 +1,3 @@ .js-alerts-service-settings{ data: { activated: @service.activated?.to_s, - form_path: project_service_path(@project, @service.to_param), - authorization_key: @service.token, url: @service.url, learn_more_url: 'https://docs.gitlab.com/ee/user/project/integrations/generic_alerts.html' } } + form_path: scoped_integration_path(@service), + authorization_key: @service.token, url: @service.url || _('<namespace / project>'), learn_more_url: 'https://docs.gitlab.com/ee/user/project/integrations/generic_alerts.html' } } diff --git a/app/views/projects/services/mattermost_slash_commands/_detailed_help.html.haml b/app/views/projects/services/mattermost_slash_commands/_detailed_help.html.haml index 395df502ddb..cf73a7055c6 100644 --- a/app/views/projects/services/mattermost_slash_commands/_detailed_help.html.haml +++ b/app/views/projects/services/mattermost_slash_commands/_detailed_help.html.haml @@ -1,4 +1,5 @@ -- run_actions_text = s_("ProjectService|Perform common operations on GitLab project: %{project_name}") % { project_name: @project.full_name } +- pretty_name = @project&.full_name || _('<project name>') +- run_actions_text = s_("ProjectService|Perform common operations on GitLab project: %{project_name}") % { project_name: pretty_name } %p= s_("ProjectService|To set up this service:") %ul.list-unstyled.indent-list @@ -20,7 +21,7 @@ .form-group = label_tag :display_name, _('Display name'), class: 'col-12 col-form-label label-bold' .col-12.input-group - = text_field_tag :display_name, "GitLab / #{@project.full_name}", class: 'form-control form-control-sm', readonly: 'readonly' + = text_field_tag :display_name, "GitLab / #{pretty_name}", class: 'form-control form-control-sm', readonly: 'readonly' .input-group-append = clipboard_button(target: '#display_name', class: 'input-group-text') @@ -38,8 +39,9 @@ %p = s_('MattermostService|Suggestions:') %code= 'gitlab' - %code= @project.path # Path contains no spaces, but dashes - %code= @project.full_path + - if @project + %code= @project.path # Path contains no spaces, but dashes + %code= @project.full_path .form-group = label_tag :request_url, s_('MattermostService|Request URL'), class: 'col-12 col-form-label label-bold' diff --git a/app/views/projects/services/slack_slash_commands/_help.html.haml b/app/views/projects/services/slack_slash_commands/_help.html.haml index 7f6717e298c..93ea17a3a3d 100644 --- a/app/views/projects/services/slack_slash_commands/_help.html.haml +++ b/app/views/projects/services/slack_slash_commands/_help.html.haml @@ -1,5 +1,5 @@ -- pretty_name = defined?(@project) ? @project.full_name : 'namespace / path' -- run_actions_text = "Perform common operations on GitLab project: #{pretty_name}" +- pretty_name = @project&.full_name || _('<project name>') +- run_actions_text = s_("ProjectService|Perform common operations on GitLab project: %{project_name}") % { project_name: pretty_name } .info-well .well-segment @@ -31,8 +31,10 @@ %p = _("Suggestions:") %code= 'gitlab' - %code= @project.path # Path contains no spaces, but dashes - %code= @project.full_path + %code= 'project' + - if @project + %code= @project.path # Path contains no spaces, but dashes + %code= @project.full_path .form-group = label_tag :url, 'URL', class: 'col-12 col-form-label label-bold' |