diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_file.vue | 25 | ||||
-rw-r--r-- | app/helpers/auth_helper.rb | 18 | ||||
-rw-r--r-- | app/models/project_services/prometheus_service.rb | 4 | ||||
-rw-r--r-- | app/services/projects/create_service.rb | 15 |
4 files changed, 47 insertions, 15 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index 048dc274cf2..8babc05f1ce 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -179,18 +179,19 @@ export default { <div v-if="errorMessage" class="diff-viewer"> <div class="nothing-here-block" v-html="errorMessage"></div> </div> - <div v-else-if="isCollapsed" class="nothing-here-block diff-collapsed"> - {{ __('This diff is collapsed.') }} - <a class="click-to-expand js-click-to-expand" href="#" @click.prevent="handleToggle">{{ - __('Click to expand it.') - }}</a> - </div> - <diff-content - v-else - :class="{ hidden: isCollapsed || isFileTooLarge }" - :diff-file="file" - :help-page-path="helpPagePath" - /> + <template v-else> + <div v-show="isCollapsed" class="nothing-here-block diff-collapsed"> + {{ __('This diff is collapsed.') }} + <a class="click-to-expand js-click-to-expand" href="#" @click.prevent="handleToggle">{{ + __('Click to expand it.') + }}</a> + </div> + <diff-content + v-show="!isCollapsed && !isFileTooLarge" + :diff-file="file" + :help-page-path="helpPagePath" + /> + </template> </div> </template> </div> diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index e8d3d5f62cb..1f15ac42260 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -16,10 +16,18 @@ module AuthHelper Gitlab::Auth.omniauth_enabled? end - def provider_has_icon?(name) + def provider_has_custom_icon?(name) + icon_for_provider(name.to_s) + end + + def provider_has_builtin_icon?(name) PROVIDERS_WITH_ICONS.include?(name.to_s) end + def provider_has_icon?(name) + provider_has_builtin_icon?(name) || provider_has_custom_icon?(name) + end + def qa_class_for_provider(provider) { saml: 'qa-saml-login-button', @@ -35,6 +43,10 @@ module AuthHelper Gitlab::Auth::OAuth::Provider.label_for(name) end + def icon_for_provider(name) + Gitlab::Auth::OAuth::Provider.icon_for(name) + end + def form_based_provider_priority ['crowd', /^ldap/, 'kerberos'] end @@ -109,7 +121,9 @@ module AuthHelper def provider_image_tag(provider, size = 64) label = label_for_provider(provider) - if provider_has_icon?(provider) + if provider_has_custom_icon?(provider) + image_tag(icon_for_provider(provider), alt: label, title: "Sign in with #{label}") + elsif provider_has_builtin_icon?(provider) file_name = "#{provider.to_s.split('_').first}_#{size}.png" image_tag("auth_buttons/#{file_name}", alt: label, title: "Sign in with #{label}") diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb index 00b06ae2595..75dfad4f3df 100644 --- a/app/models/project_services/prometheus_service.rb +++ b/app/models/project_services/prometheus_service.rb @@ -88,7 +88,9 @@ class PrometheusService < MonitoringService return false if template? return false unless project - project.all_clusters.enabled.any? { |cluster| cluster.application_prometheus_available? } + project.all_clusters.enabled.eager_load(:application_prometheus).any? do |cluster| + cluster.application_prometheus&.available? + end end def allow_local_api_url? diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 7bf68e7d315..cef86e9763c 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -98,6 +98,7 @@ module Projects setup_authorizations current_user.invalidate_personal_projects_count + create_prometheus_service create_readme if @initialize_with_readme end @@ -169,6 +170,20 @@ module Projects end # rubocop: enable CodeReuse/ActiveRecord + def create_prometheus_service + service = @project.find_or_initialize_service(::PrometheusService.to_param) + + if service.prometheus_available? + service.save! + else + @project.prometheus_service = nil + end + + rescue ActiveRecord::RecordInvalid => e + Gitlab::ErrorTracking.track_exception(e, extra: { project_id: project.id }) + @project.prometheus_service = nil + end + def set_project_name_from_path # Set project name from path if @project.name.present? && @project.path.present? |