summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 15:08:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-24 15:08:44 +0000
commit120f4aaedc8fe830a3f572491d240d8ee6addefb (patch)
treea2138baa55dfa67d292fb1a83ce686ee7f5d10a5 /app
parent729e3765d5feb762df1ccfbc228a8dd4662aa3f9 (diff)
downloadgitlab-ce-120f4aaedc8fe830a3f572491d240d8ee6addefb.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/pages/admin/application_settings/integrations/index.js6
-rw-r--r--app/assets/javascripts/pages/projects/snippets/show/index.js4
-rw-r--r--app/assets/javascripts/pages/snippets/show/index.js4
-rw-r--r--app/assets/javascripts/pipelines/components/pipeline_url.vue6
-rw-r--r--app/assets/javascripts/snippets/components/show.vue (renamed from app/assets/javascripts/snippets/components/app.vue)0
-rw-r--r--app/assets/javascripts/snippets/index.js17
-rw-r--r--app/assets/stylesheets/utilities.scss5
-rw-r--r--app/controllers/admin/application_settings_controller.rb10
-rw-r--r--app/helpers/broadcast_messages_helper.rb2
-rw-r--r--app/helpers/services_helper.rb4
-rw-r--r--app/helpers/user_callouts_helper.rb5
-rw-r--r--app/models/concerns/optionally_search.rb2
-rw-r--r--app/models/label.rb2
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/project_services/discord_service.rb7
-rw-r--r--app/models/user.rb2
-rw-r--r--app/models/user_callout_enums.rb3
-rw-r--r--app/views/admin/application_settings/general.html.haml9
-rw-r--r--app/views/admin/application_settings/integrations.html.haml38
-rw-r--r--app/views/admin/integrations/edit.html.haml2
-rw-r--r--app/views/projects/services/_integrations.html.haml26
-rw-r--r--app/workers/all_queues.yml2
-rw-r--r--app/workers/background_migration_worker.rb2
23 files changed, 128 insertions, 32 deletions
diff --git a/app/assets/javascripts/pages/admin/application_settings/integrations/index.js b/app/assets/javascripts/pages/admin/application_settings/integrations/index.js
new file mode 100644
index 00000000000..2e61eedd185
--- /dev/null
+++ b/app/assets/javascripts/pages/admin/application_settings/integrations/index.js
@@ -0,0 +1,6 @@
+import PersistentUserCallout from '~/persistent_user_callout';
+
+document.addEventListener('DOMContentLoaded', () => {
+ const callout = document.querySelector('.js-admin-integrations-moved');
+ PersistentUserCallout.factory(callout);
+});
diff --git a/app/assets/javascripts/pages/projects/snippets/show/index.js b/app/assets/javascripts/pages/projects/snippets/show/index.js
index d8fbb851ffb..e49d46ea97b 100644
--- a/app/assets/javascripts/pages/projects/snippets/show/index.js
+++ b/app/assets/javascripts/pages/projects/snippets/show/index.js
@@ -3,7 +3,7 @@ import ZenMode from '~/zen_mode';
import LineHighlighter from '~/line_highlighter';
import BlobViewer from '~/blob/viewer';
import snippetEmbed from '~/snippet/snippet_embed';
-import initSnippetsApp from '~/snippets';
+import { SnippetShowInit } from '~/snippets';
document.addEventListener('DOMContentLoaded', () => {
if (!gon.features.snippetsVue) {
@@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', () => {
new ZenMode(); // eslint-disable-line no-new
snippetEmbed();
} else {
- initSnippetsApp();
+ SnippetShowInit();
initNotes();
}
});
diff --git a/app/assets/javascripts/pages/snippets/show/index.js b/app/assets/javascripts/pages/snippets/show/index.js
index 3bc9d4f957f..9a463b4762b 100644
--- a/app/assets/javascripts/pages/snippets/show/index.js
+++ b/app/assets/javascripts/pages/snippets/show/index.js
@@ -3,7 +3,7 @@ import BlobViewer from '~/blob/viewer';
import ZenMode from '~/zen_mode';
import initNotes from '~/init_notes';
import snippetEmbed from '~/snippet/snippet_embed';
-import initSnippetsApp from '~/snippets';
+import { SnippetShowInit } from '~/snippets';
document.addEventListener('DOMContentLoaded', () => {
if (!gon.features.snippetsVue) {
@@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', () => {
new ZenMode(); // eslint-disable-line no-new
snippetEmbed();
} else {
- initSnippetsApp();
+ SnippetShowInit();
initNotes();
}
});
diff --git a/app/assets/javascripts/pipelines/components/pipeline_url.vue b/app/assets/javascripts/pipelines/components/pipeline_url.vue
index 0c9d242f509..6c977b841af 100644
--- a/app/assets/javascripts/pipelines/components/pipeline_url.vue
+++ b/app/assets/javascripts/pipelines/components/pipeline_url.vue
@@ -58,7 +58,11 @@ export default {
</script>
<template>
<div class="table-section section-10 d-none d-sm-none d-md-block pipeline-tags">
- <gl-link :href="pipeline.path" class="js-pipeline-url-link js-onboarding-pipeline-item">
+ <gl-link
+ :href="pipeline.path"
+ class="js-pipeline-url-link js-onboarding-pipeline-item"
+ data-qa-selector="pipeline_url_link"
+ >
<span class="pipeline-id">#{{ pipeline.id }}</span>
</gl-link>
<div class="label-container">
diff --git a/app/assets/javascripts/snippets/components/app.vue b/app/assets/javascripts/snippets/components/show.vue
index e98f56d87f5..e98f56d87f5 100644
--- a/app/assets/javascripts/snippets/components/app.vue
+++ b/app/assets/javascripts/snippets/components/show.vue
diff --git a/app/assets/javascripts/snippets/index.js b/app/assets/javascripts/snippets/index.js
index 654856f8d14..b826110117c 100644
--- a/app/assets/javascripts/snippets/index.js
+++ b/app/assets/javascripts/snippets/index.js
@@ -3,19 +3,16 @@ import Translate from '~/vue_shared/translate';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
-import SnippetsApp from './components/app.vue';
+import SnippetsApp from './components/show.vue';
Vue.use(VueApollo);
Vue.use(Translate);
-export default () => {
- const el = document.getElementById('js-snippet-view');
-
+function appFactory(el, Component) {
if (!el) {
return false;
}
- const { snippetGid } = el.dataset;
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
@@ -24,11 +21,17 @@ export default () => {
el,
apolloProvider,
render(createElement) {
- return createElement(SnippetsApp, {
+ return createElement(Component, {
props: {
- snippetGid,
+ ...el.dataset,
},
});
},
});
+}
+
+export const SnippetShowInit = () => {
+ appFactory(document.getElementById('js-snippet-view'), SnippetsApp);
};
+
+export default () => {};
diff --git a/app/assets/stylesheets/utilities.scss b/app/assets/stylesheets/utilities.scss
index 1eff21401a2..00d738a50be 100644
--- a/app/assets/stylesheets/utilities.scss
+++ b/app/assets/stylesheets/utilities.scss
@@ -81,3 +81,8 @@
.gl-text-green-700 { @include gl-text-green-700; }
.gl-align-items-center { @include gl-align-items-center; }
+.d-sm-table-column {
+ @include media-breakpoint-up(sm) {
+ display: table-column !important;
+ }
+}
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 2192bcc96ee..ef6af01eff6 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -27,6 +27,16 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
define_method(action) { perform_update if submitted? }
end
+ 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 = []
+ end
+
+ perform_update if submitted?
+ end
+
def update
perform_update
end
diff --git a/app/helpers/broadcast_messages_helper.rb b/app/helpers/broadcast_messages_helper.rb
index 73c68dd9e18..0c32b48a85a 100644
--- a/app/helpers/broadcast_messages_helper.rb
+++ b/app/helpers/broadcast_messages_helper.rb
@@ -48,7 +48,7 @@ module BroadcastMessagesHelper
def render_broadcast_message(broadcast_message)
if Feature.enabled?(:broadcast_message_placeholders)
- Banzai.render_and_post_process(broadcast_message.message, {
+ Banzai.render_field_and_post_process(broadcast_message, :message, {
current_user: current_user,
skip_project_check: true,
broadcast_message_placeholders: true
diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb
index caef6dba212..d2336de7193 100644
--- a/app/helpers/services_helper.rb
+++ b/app/helpers/services_helper.rb
@@ -62,6 +62,10 @@ module ServicesHelper
!current_controller?("admin/services") && service.deprecated?
end
+ def edit_integration_path(integration)
+ edit_admin_application_settings_integration_path(integration)
+ end
+
extend self
end
diff --git a/app/helpers/user_callouts_helper.rb b/app/helpers/user_callouts_helper.rb
index 841599abe81..34c8ce51df0 100644
--- a/app/helpers/user_callouts_helper.rb
+++ b/app/helpers/user_callouts_helper.rb
@@ -1,12 +1,17 @@
# frozen_string_literal: true
module UserCalloutsHelper
+ ADMIN_INTEGRATIONS_MOVED = 'admin_integrations_moved'
GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'
GCP_SIGNUP_OFFER = 'gcp_signup_offer'
SUGGEST_POPOVER_DISMISSED = 'suggest_popover_dismissed'
TABS_POSITION_HIGHLIGHT = 'tabs_position_highlight'
WEBHOOKS_MOVED = 'webhooks_moved'
+ def show_admin_integrations_moved?
+ !user_dismissed?(ADMIN_INTEGRATIONS_MOVED)
+ end
+
def show_gke_cluster_integration_callout?(project)
can?(current_user, :create_cluster, project) &&
!user_dismissed?(GKE_CLUSTER_INTEGRATION)
diff --git a/app/models/concerns/optionally_search.rb b/app/models/concerns/optionally_search.rb
index 06f8c3dc1cb..9d43c61eb57 100644
--- a/app/models/concerns/optionally_search.rb
+++ b/app/models/concerns/optionally_search.rb
@@ -4,7 +4,7 @@ module OptionallySearch
extend ActiveSupport::Concern
class_methods do
- def search(*)
+ def search(query, **options)
raise(
NotImplementedError,
'Your model must implement the "search" class method'
diff --git a/app/models/label.rb b/app/models/label.rb
index 106d26685d4..d9c5fe0bb39 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -138,7 +138,7 @@ class Label < ApplicationRecord
# query - The search query as a String.
#
# Returns an ActiveRecord::Relation.
- def self.search(query)
+ def self.search(query, **options)
fuzzy_search(query, [:title, :description])
end
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 2deece8c7cd..260ba9ea4a5 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -274,7 +274,7 @@ class Namespace < ApplicationRecord
end
def has_parent?
- parent_id.present? || parent.present?
+ parent.present?
end
def root_ancestor
diff --git a/app/models/project_services/discord_service.rb b/app/models/project_services/discord_service.rb
index ff1a9552a6c..294b286f073 100644
--- a/app/models/project_services/discord_service.rb
+++ b/app/models/project_services/discord_service.rb
@@ -3,6 +3,8 @@
require "discordrb/webhooks"
class DiscordService < ChatNotificationService
+ ATTACHMENT_REGEX = /: (?<entry>.*?)\n - (?<name>.*)\n*/.freeze
+
def title
s_("DiscordService|Discord Notifications")
end
@@ -52,7 +54,10 @@ class DiscordService < ChatNotificationService
client = Discordrb::Webhooks::Client.new(url: webhook)
client.execute do |builder|
- builder.content = message.pretext
+ builder.add_embed do |embed|
+ embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: message.user_name, icon_url: message.user_avatar)
+ embed.description = (message.pretext + "\n" + Array.wrap(message.attachments).join("\n")).gsub(ATTACHMENT_REGEX, " \\k<entry> - \\k<name>\n")
+ end
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 4f484657f13..090d033f80c 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -511,7 +511,7 @@ class User < ApplicationRecord
# query - The search query as a String
#
# Returns an ActiveRecord::Relation.
- def search(query)
+ def search(query, **options)
query = query&.delete_prefix('@')
return none if query.blank?
diff --git a/app/models/user_callout_enums.rb b/app/models/user_callout_enums.rb
index 625cbb4fe5f..0a3f597ae27 100644
--- a/app/models/user_callout_enums.rb
+++ b/app/models/user_callout_enums.rb
@@ -16,7 +16,8 @@ module UserCalloutEnums
cluster_security_warning: 3,
suggest_popover_dismissed: 9,
tabs_position_highlight: 10,
- webhooks_moved: 13
+ webhooks_moved: 13,
+ admin_integrations_moved: 15
}
end
end
diff --git a/app/views/admin/application_settings/general.html.haml b/app/views/admin/application_settings/general.html.haml
index 94048060767..1a029996aaf 100644
--- a/app/views/admin/application_settings/general.html.haml
+++ b/app/views/admin/application_settings/general.html.haml
@@ -103,3 +103,12 @@
= s_('IDE|Allow live previews of JavaScript projects in the Web IDE using CodeSandbox client side evaluation.')
= f.submit _('Save changes'), class: "btn btn-success"
+
+- if Feature.enabled?(:instance_level_integrations)
+ = render_if_exists 'admin/application_settings/elasticsearch_form'
+ = render 'admin/application_settings/plantuml'
+ = render 'admin/application_settings/sourcegraph'
+ = render_if_exists 'admin/application_settings/slack'
+ = render 'admin/application_settings/third_party_offers'
+ = render 'admin/application_settings/snowplow'
+ = render 'admin/application_settings/eks'
diff --git a/app/views/admin/application_settings/integrations.html.haml b/app/views/admin/application_settings/integrations.html.haml
index c6318c9bb2f..14df0599583 100644
--- a/app/views/admin/application_settings/integrations.html.haml
+++ b/app/views/admin/application_settings/integrations.html.haml
@@ -1,12 +1,30 @@
-- breadcrumb_title _("Integrations")
-- page_title _("Integrations")
-- @content_class = "limit-container-width" unless fluid_layout
+- breadcrumb_title _('Integrations')
+- page_title _('Integrations')
+- @content_class = 'limit-container-width' unless fluid_layout
-= render_if_exists 'admin/application_settings/elasticsearch_form'
-= render 'admin/application_settings/plantuml'
-= render 'admin/application_settings/sourcegraph'
-= render_if_exists 'admin/application_settings/slack'
-= render 'admin/application_settings/third_party_offers'
-= render 'admin/application_settings/snowplow'
-= render 'admin/application_settings/eks'
+- if Feature.enabled?(:instance_level_integrations)
+ - if show_admin_integrations_moved?
+ .gl-alert.gl-alert-info.js-admin-integrations-moved.mt-3{ role: 'alert', data: { feature_id: UserCalloutsHelper::ADMIN_INTEGRATIONS_MOVED, dismiss_endpoint: user_callouts_path } }
+ = sprite_icon('information-o', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
+ %button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label' => _('Dismiss') }
+ = sprite_icon('close', size: 16, css_class: 'gl-icon')
+ .gl-alert-body
+ %h4.gl-alert-title= s_('AdminSettings|Some settings have moved')
+ = s_('AdminSettings|Elasticsearch, PlantUML, Slack application, Third party offers, Snowplow, Amazon EKS have moved to Settings > General.')
+ .gl-alert-actions
+ = link_to s_('AdminSettings|Go to General Settings'), admin_application_settings_path, class: 'btn gl-alert-action btn-info new-gl-button'
+ %h4= s_('AdminSettings|Apply integration settings to all Projects')
+ %p
+ = s_('AdminSettings|Integrations configured here will automatically apply to all projects on this instance.')
+ = link_to _('Learn more'), '#'
+ = render 'projects/services/integrations'
+
+- else
+ = render_if_exists 'admin/application_settings/elasticsearch_form'
+ = render 'admin/application_settings/plantuml'
+ = render 'admin/application_settings/sourcegraph'
+ = render_if_exists 'admin/application_settings/slack'
+ = render 'admin/application_settings/third_party_offers'
+ = render 'admin/application_settings/snowplow'
+ = render 'admin/application_settings/eks'
diff --git a/app/views/admin/integrations/edit.html.haml b/app/views/admin/integrations/edit.html.haml
index dea0f524f03..b19d00d7a16 100644
--- a/app/views/admin/integrations/edit.html.haml
+++ b/app/views/admin/integrations/edit.html.haml
@@ -1,4 +1,4 @@
-- add_to_breadcrumbs _('Integrations'), admin_application_settings_integration_path
+- add_to_breadcrumbs _('Integrations'), integrations_admin_application_settings_path
- breadcrumb_title @service.title
- page_title @service.title, _('Integrations')
diff --git a/app/views/projects/services/_integrations.html.haml b/app/views/projects/services/_integrations.html.haml
new file mode 100644
index 00000000000..e51585e55a4
--- /dev/null
+++ b/app/views/projects/services/_integrations.html.haml
@@ -0,0 +1,26 @@
+%table.table.b-table.gl-table.mt-3{ role: 'table', 'aria-busy': false, 'aria-colcount': 4 }
+ %colgroup
+ %col
+ %col
+ %col.d-none.d-sm-table-column
+ %col{ width: 120 }
+ %thead{ role: 'rowgroup' }
+ %tr{ role: 'row' }
+ %th{ role: 'columnheader', scope: 'col', 'aria-colindex': 1 }
+ %th{ role: 'columnheader', scope: 'col', 'aria-colindex': 2 }= _('Integration')
+ %th.d-none.d-sm-block{ role: 'columnheader', scope: 'col', 'aria-colindex': 3 }= _('Description')
+ %th{ role: 'columnheader', scope: 'col', 'aria-colindex': 4 }= _('Last updated')
+
+ %tbody{ role: 'rowgroup' }
+ - @integrations&.each do |integration|
+ %tr{ role: 'row' }
+ %td{ role: 'cell', 'aria-colindex': 1 }
+ = boolean_to_icon integration.activated?
+ %td{ role: 'cell', 'aria-colindex': 2 }
+ = link_to edit_integration_path(integration) do
+ %strong= integration.title
+ %td.d-none.d-sm-block{ role: 'cell', 'aria-colindex': 3 }
+ = integration.description
+ %td{ role: 'cell', 'aria-colindex': 4 }
+ - if integration.updated_at.present?
+ = time_ago_with_tooltip integration.updated_at
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index cae4bb73e04..c101759ff9b 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -928,7 +928,7 @@
:weight: 2
:idempotent: true
- :name: background_migration
- :feature_category: :not_owned
+ :feature_category: :database
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb
index 231c2bcd83b..f5fd73156b3 100644
--- a/app/workers/background_migration_worker.rb
+++ b/app/workers/background_migration_worker.rb
@@ -3,7 +3,7 @@
class BackgroundMigrationWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
- feature_category_not_owned!
+ feature_category :database
# The minimum amount of time between processing two jobs of the same migration
# class.