diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-27 21:07:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-27 21:07:48 +0300 |
commit | e20baee820ea2c76ee16980a98e8080f255d9035 (patch) | |
tree | 6e13a73bee42b7ef310850d03982faebea17a0b1 /app | |
parent | 71c5863d7b1ca9836a7d7703f35750cd726a9846 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/clusters/clusters_bundle.js | 13 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/serverless/index.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/serverless/survey_banner.js | 36 | ||||
-rw-r--r-- | app/assets/javascripts/serverless/survey_banner.vue | 52 | ||||
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/admin/projects_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/admin/services_controller.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/environment_type.rb | 3 | ||||
-rw-r--r-- | app/models/concerns/bulk_insert_safe.rb | 4 | ||||
-rw-r--r-- | app/models/service.rb | 20 | ||||
-rw-r--r-- | app/views/admin/services/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/clusters/clusters/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/serverless/functions/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/services/_integrations.html.haml | 2 |
14 files changed, 140 insertions, 16 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index cb9c44bc36d..da34c5030f9 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -8,13 +8,20 @@ import Flash from '../flash'; import Poll from '../lib/utils/poll'; import initSettingsPanels from '../settings_panels'; import eventHub from './event_hub'; -import { APPLICATION_STATUS, INGRESS, INGRESS_DOMAIN_SUFFIX, CROSSPLANE } from './constants'; +import { + APPLICATION_STATUS, + INGRESS, + INGRESS_DOMAIN_SUFFIX, + CROSSPLANE, + KNATIVE, +} from './constants'; import ClustersService from './services/clusters_service'; import ClustersStore from './stores/clusters_store'; import Applications from './components/applications.vue'; import RemoveClusterConfirmation from './components/remove_cluster_confirmation.vue'; import setupToggleButtons from '../toggle_buttons'; import initProjectSelectDropdown from '~/project_select'; +import initServerlessSurveyBanner from '~/serverless/survey_banner'; const Environments = () => import('ee_component/clusters/components/environments.vue'); @@ -326,6 +333,10 @@ export default class Clusters { this.store.state.applications[INGRESS], ); } + + if (this.store.state.applications[KNATIVE]?.status === APPLICATION_STATUS.INSTALLED) { + initServerlessSurveyBanner(); + } } showToken() { diff --git a/app/assets/javascripts/pages/projects/serverless/index.js b/app/assets/javascripts/pages/projects/serverless/index.js index 7b08620773c..a883737ac9b 100644 --- a/app/assets/javascripts/pages/projects/serverless/index.js +++ b/app/assets/javascripts/pages/projects/serverless/index.js @@ -1,5 +1,7 @@ import ServerlessBundle from '~/serverless/serverless_bundle'; +import initServerlessSurveyBanner from '~/serverless/survey_banner'; document.addEventListener('DOMContentLoaded', () => { + initServerlessSurveyBanner(); new ServerlessBundle(); // eslint-disable-line no-new }); diff --git a/app/assets/javascripts/serverless/survey_banner.js b/app/assets/javascripts/serverless/survey_banner.js new file mode 100644 index 00000000000..070e8f4c661 --- /dev/null +++ b/app/assets/javascripts/serverless/survey_banner.js @@ -0,0 +1,36 @@ +import Vue from 'vue'; +import { setUrlParams } from '~/lib/utils/url_utility'; +import SurveyBanner from './survey_banner.vue'; + +let bannerInstance; +const SURVEY_URL_BASE = 'https://gitlab.fra1.qualtrics.com/jfe/form/SV_00PfofFfY9s8Shf'; + +export default function initServerlessSurveyBanner() { + const el = document.querySelector('.js-serverless-survey-banner'); + if (el && !bannerInstance) { + const { userName, userEmail } = el.dataset; + + // pre-populate survey fields + const surveyUrl = setUrlParams( + { + Q_PopulateResponse: JSON.stringify({ + QID1: userEmail, + QID2: userName, + QID16: '1', // selects "yes" to "do you currently use GitLab?" + }), + }, + SURVEY_URL_BASE, + ); + + bannerInstance = new Vue({ + el, + render(createElement) { + return createElement(SurveyBanner, { + props: { + surveyUrl, + }, + }); + }, + }); + } +} diff --git a/app/assets/javascripts/serverless/survey_banner.vue b/app/assets/javascripts/serverless/survey_banner.vue new file mode 100644 index 00000000000..a0a90fa5e80 --- /dev/null +++ b/app/assets/javascripts/serverless/survey_banner.vue @@ -0,0 +1,52 @@ +<script> +import Cookies from 'js-cookie'; +import { parseBoolean } from '~/lib/utils/common_utils'; +import { GlBanner } from '@gitlab/ui'; + +export default { + components: { + GlBanner, + }, + props: { + surveyUrl: { + type: String, + required: true, + }, + }, + data() { + return { + visible: true, + }; + }, + created() { + if (parseBoolean(Cookies.get('hide_serverless_survey'))) { + this.visible = false; + } + }, + methods: { + handleClose() { + Cookies.set('hide_serverless_survey', 'true', { expires: 365 * 10 }); + this.visible = false; + }, + }, +}; +</script> + +<template> + <gl-banner + v-if="visible" + class="mt-4" + :title="s__('Serverless|Help shape the future of Serverless at GitLab')" + :button-text="s__('Serverless|Sign up for First Look')" + :button-link="surveyUrl" + @close="handleClose" + > + <p> + {{ + s__( + 'Serverless|We are continually striving to improve our Serverless functionality. As a Knative user, we would love to hear how we can make this experience better for you. Sign up for GitLab First Look today and we will be in touch shortly.', + ) + }} + </p> + </gl-banner> +</template> diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index ef6af01eff6..ce71730cef1 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -8,7 +8,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController # ApplicationSetting model uses Gitlab::ThreadMemoryCache for caching and the # cache might be stale immediately after an update. # https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/30233 - before_action :set_application_setting + before_action :set_application_setting, except: :integrations before_action :whitelist_query_limiting, only: [:usage_data] @@ -29,12 +29,11 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController def integrations if Feature.enabled?(:instance_level_integrations) - # TODO: Update this with actual integrations - # To be fixed with https://gitlab.com/gitlab-org/gitlab/-/issues/199388 - @integrations = [] + @integrations = Service.find_or_initialize_instances.sort_by(&:title) + else + set_application_setting + perform_update if submitted? end - - perform_update if submitted? end def update diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 7015da8bd50..9fe1f22c342 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -9,6 +9,11 @@ class Admin::ProjectsController < Admin::ApplicationController def index params[:sort] ||= 'latest_activity_desc' @sort = params[:sort] + + if params[:last_repository_check_failed].present? && params[:archived].nil? + params[:archived] = true + end + @projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute respond_to do |format| diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb index 55817550b4b..08ef992e604 100644 --- a/app/controllers/admin/services_controller.rb +++ b/app/controllers/admin/services_controller.rb @@ -6,7 +6,7 @@ class Admin::ServicesController < Admin::ApplicationController before_action :service, only: [:edit, :update] def index - @services = Service.find_or_create_templates + @services = Service.find_or_create_templates.sort_by(&:title) end def edit diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index ad65caa24a6..c165c0ddc61 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -12,5 +12,8 @@ module Types field :id, GraphQL::ID_TYPE, null: false, description: 'ID of the environment' + + field :state, GraphQL::STRING_TYPE, null: false, + description: 'State of the environment, for example: available/stopped' end end diff --git a/app/models/concerns/bulk_insert_safe.rb b/app/models/concerns/bulk_insert_safe.rb index f1a2d566e97..e09f44e68dc 100644 --- a/app/models/concerns/bulk_insert_safe.rb +++ b/app/models/concerns/bulk_insert_safe.rb @@ -160,9 +160,7 @@ module BulkInsertSafe attributes = {} column_names.each do |name| - value = item.read_attribute(name) - value = item.type_for_attribute(name).serialize(value) # rubocop:disable Cop/ActiveRecordSerialize - attributes[name] = value + attributes[name] = item.read_attribute(name) end _bulk_insert_reject_primary_key!(attributes, item.class.primary_key) diff --git a/app/models/service.rb b/app/models/service.rb index 138da0c546e..e4ae68cdaa7 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -47,6 +47,7 @@ class Service < ApplicationRecord scope :without_defaults, -> { where(default: false) } scope :by_type, -> (type) { where(type: type) } scope :templates, -> { where(template: true, type: available_services_types) } + scope :instances, -> { where(instance: true, type: available_services_types) } scope :push_hooks, -> { where(push_events: true, active: true) } scope :tag_push_hooks, -> { where(tag_push_events: true, active: true) } @@ -260,17 +261,16 @@ class Service < ApplicationRecord self.category == :issue_tracker end - # Find all service templates; if some of them do not exist, create them - # within a transaction to perform the lowest possible SQL queries. def self.find_or_create_templates create_nonexistent_templates templates end private_class_method def self.create_nonexistent_templates - nonexistent_services = available_services_types - templates.map(&:type) + nonexistent_services = list_nonexistent_services_for(templates) return if nonexistent_services.empty? + # Create within a transaction to perform the lowest possible SQL queries. transaction do nonexistent_services.each do |service_type| service_type.constantize.create(template: true) @@ -278,6 +278,20 @@ class Service < ApplicationRecord end end + def self.find_or_initialize_instances + instances + build_nonexistent_instances + end + + private_class_method def self.build_nonexistent_instances + list_nonexistent_services_for(instances).map do |service_type| + service_type.constantize.new + end + end + + private_class_method def self.list_nonexistent_services_for(scope) + available_services_types - scope.map(&:type) + end + def self.available_services_names service_names = %w[ alerts diff --git a/app/views/admin/services/index.html.haml b/app/views/admin/services/index.html.haml index 89872c1b91a..48f31bd0c6e 100644 --- a/app/views/admin/services/index.html.haml +++ b/app/views/admin/services/index.html.haml @@ -10,7 +10,7 @@ %th Service %th Description %th Last edit - - @services.sort_by(&:title).each do |service| + - @services.each do |service| %tr %td = boolean_to_icon service.activated? diff --git a/app/views/clusters/clusters/show.html.haml b/app/views/clusters/clusters/show.html.haml index 4aa5b6af636..8797178f920 100644 --- a/app/views/clusters/clusters/show.html.haml +++ b/app/views/clusters/clusters/show.html.haml @@ -39,6 +39,8 @@ .js-cluster-application-notice .flash-container + .js-serverless-survey-banner{ data: { user_name: current_user.name, user_email: current_user.email } } + %h4= @cluster.name = render 'banner' diff --git a/app/views/projects/serverless/functions/index.html.haml b/app/views/projects/serverless/functions/index.html.haml index 09f4e556949..2f1da453c0a 100644 --- a/app/views/projects/serverless/functions/index.html.haml +++ b/app/views/projects/serverless/functions/index.html.haml @@ -10,6 +10,8 @@ help_path: help_page_path('user/project/clusters/serverless/index') } } %div{ class: [('limit-container-width' unless fluid_layout)] } + .js-serverless-survey-banner{ data: { user_name: current_user.name, user_email: current_user.email } } + .js-serverless-functions-notice .flash-container diff --git a/app/views/projects/services/_integrations.html.haml b/app/views/projects/services/_integrations.html.haml index e51585e55a4..24aeb598d7b 100644 --- a/app/views/projects/services/_integrations.html.haml +++ b/app/views/projects/services/_integrations.html.haml @@ -12,7 +12,7 @@ %th{ role: 'columnheader', scope: 'col', 'aria-colindex': 4 }= _('Last updated') %tbody{ role: 'rowgroup' } - - @integrations&.each do |integration| + - @integrations.each do |integration| %tr{ role: 'row' } %td{ role: 'cell', 'aria-colindex': 1 } = boolean_to_icon integration.activated? |