Skip to content
Snippets Groups Projects
Commit 32fd4cd5 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 951616a2
No related branches found
No related tags found
No related merge requests found
Showing
with 158 additions and 110 deletions
Loading
Loading
@@ -237,7 +237,7 @@ gem 'atlassian-jwt', '~> 0.2.0'
gem 'flowdock', '~> 0.7'
 
# Slack integration
gem 'slack-notifier', '~> 1.5.1'
gem 'slack-messenger', '~> 2.3.3'
 
# Hangouts Chat integration
gem 'hangouts-chat', '~> 0.0.5'
Loading
Loading
@@ -301,7 +301,7 @@ gem 'sentry-raven', '~> 2.9'
gem 'premailer-rails', '~> 1.10.3'
 
# LabKit: Tracing and Correlation
gem 'gitlab-labkit', '0.9.1'
gem 'gitlab-labkit', '0.10.0'
 
# I18n
gem 'ruby_parser', '~> 3.8', require: false
Loading
Loading
Loading
Loading
@@ -380,7 +380,7 @@ GEM
github-markup (1.7.0)
gitlab-chronic (0.10.5)
numerizer (~> 0.2)
gitlab-labkit (0.9.1)
gitlab-labkit (0.10.0)
actionpack (>= 5.0.0, < 6.1.0)
activesupport (>= 5.0.0, < 6.1.0)
grpc (~> 1.19)
Loading
Loading
@@ -1021,7 +1021,7 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sixarm_ruby_unaccent (1.2.0)
slack-notifier (1.5.1)
slack-messenger (2.3.3)
snowplow-tracker (0.6.1)
contracts (~> 0.7, <= 0.11)
spring (2.0.2)
Loading
Loading
@@ -1233,7 +1233,7 @@ DEPENDENCIES
gitaly (~> 1.86.0)
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-labkit (= 0.9.1)
gitlab-labkit (= 0.10.0)
gitlab-license (~> 1.0)
gitlab-markup (~> 1.7.0)
gitlab-net-dns (~> 0.9.1)
Loading
Loading
@@ -1376,7 +1376,7 @@ DEPENDENCIES
sidekiq-cron (~> 1.0)
simple_po_parser (~> 1.1.2)
simplecov (~> 0.16.1)
slack-notifier (~> 1.5.1)
slack-messenger (~> 2.3.3)
snowplow-tracker (~> 0.6.1)
spring (~> 2.0.0)
spring-commands-rspec (~> 1.0.4)
Loading
Loading
Loading
Loading
@@ -73,7 +73,7 @@ export default {
v-if="discussion.resolvable && shouldShowJumpToNextDiscussion"
class="btn-group discussion-actions ml-sm-2"
>
<jump-to-next-discussion-button />
<jump-to-next-discussion-button :from-discussion-id="discussion.id" />
</div>
</div>
</template>
Loading
Loading
@@ -39,7 +39,11 @@ export default {
</script>
 
<template>
<div v-if="resolvableDiscussionsCount > 0" class="line-resolve-all-container full-width-mobile">
<div
v-if="resolvableDiscussionsCount > 0"
ref="discussionCounter"
class="line-resolve-all-container full-width-mobile"
>
<div class="full-width-mobile d-flex d-sm-block">
<div :class="{ 'has-next-btn': hasNextButton }" class="line-resolve-all">
<span
Loading
Loading
Loading
Loading
@@ -12,6 +12,12 @@ export default {
GlTooltip: GlTooltipDirective,
},
mixins: [discussionNavigation],
props: {
fromDiscussionId: {
type: String,
required: true,
},
},
};
</script>
 
Loading
Loading
@@ -22,7 +28,7 @@ export default {
v-gl-tooltip
class="btn btn-default discussion-next-btn"
:title="s__('MergeRequests|Jump to next unresolved thread')"
@click="jumpToNextDiscussion"
@click="jumpToNextRelativeDiscussion(fromDiscussionId)"
>
<icon name="comment-next" />
</button>
Loading
Loading
Loading
Loading
@@ -2,6 +2,86 @@ import { mapGetters, mapActions, mapState } from 'vuex';
import { scrollToElement } from '~/lib/utils/common_utils';
import eventHub from '../../notes/event_hub';
 
/**
* @param {string} selector
* @returns {boolean}
*/
function scrollTo(selector) {
const el = document.querySelector(selector);
if (el) {
scrollToElement(el);
return true;
}
return false;
}
/**
* @param {object} self Component instance with mixin applied
* @param {string} id Discussion id we are jumping to
*/
function diffsJump({ expandDiscussion }, id) {
const selector = `ul.notes[data-discussion-id="${id}"]`;
eventHub.$once('scrollToDiscussion', () => scrollTo(selector));
expandDiscussion({ discussionId: id });
}
/**
* @param {object} self Component instance with mixin applied
* @param {string} id Discussion id we are jumping to
* @returns {boolean}
*/
function discussionJump({ expandDiscussion }, id) {
const selector = `div.discussion[data-discussion-id="${id}"]`;
expandDiscussion({ discussionId: id });
return scrollTo(selector);
}
/**
* @param {object} self Component instance with mixin applied
* @param {string} id Discussion id we are jumping to
*/
function switchToDiscussionsTabAndJumpTo(self, id) {
window.mrTabs.eventHub.$once('MergeRequestTabChange', () => {
setTimeout(() => discussionJump(self, id), 0);
});
window.mrTabs.tabShown('show');
}
/**
* @param {object} self Component instance with mixin applied
* @param {object} discussion Discussion we are jumping to
*/
function jumpToDiscussion(self, discussion) {
const { id, diff_discussion: isDiffDiscussion } = discussion;
if (id) {
const activeTab = window.mrTabs.currentAction;
if (activeTab === 'diffs' && isDiffDiscussion) {
diffsJump(self, id);
} else if (activeTab === 'show') {
discussionJump(self, id);
} else {
switchToDiscussionsTabAndJumpTo(self, id);
}
}
}
/**
* @param {object} self Component instance with mixin applied
* @param {function} fn Which function used to get the target discussion's id
* @param {string} [discussionId=this.currentDiscussionId] Current discussion id, will be null if discussions have not been traversed yet
*/
function handleDiscussionJump(self, fn, discussionId = self.currentDiscussionId) {
const isDiffView = window.mrTabs.currentAction === 'diffs';
const targetId = fn(discussionId, isDiffView);
const discussion = self.getDiscussion(targetId);
jumpToDiscussion(self, discussion);
self.setCurrentDiscussionId(targetId);
}
export default {
computed: {
...mapGetters([
Loading
Loading
@@ -16,76 +96,20 @@ export default {
methods: {
...mapActions(['expandDiscussion', 'setCurrentDiscussionId']),
 
diffsJump(id) {
const selector = `ul.notes[data-discussion-id="${id}"]`;
eventHub.$once('scrollToDiscussion', () => {
const el = document.querySelector(selector);
if (el) {
scrollToElement(el);
return true;
}
return false;
});
this.expandDiscussion({ discussionId: id });
},
discussionJump(id) {
const selector = `div.discussion[data-discussion-id="${id}"]`;
const el = document.querySelector(selector);
this.expandDiscussion({ discussionId: id });
if (el) {
scrollToElement(el);
return true;
}
return false;
},
switchToDiscussionsTabAndJumpTo(id) {
window.mrTabs.eventHub.$once('MergeRequestTabChange', () => {
setTimeout(() => this.discussionJump(id), 0);
});
window.mrTabs.tabShown('show');
},
jumpToDiscussion(discussion) {
const { id, diff_discussion: isDiffDiscussion } = discussion;
if (id) {
const activeTab = window.mrTabs.currentAction;
if (activeTab === 'diffs' && isDiffDiscussion) {
this.diffsJump(id);
} else if (activeTab === 'show') {
this.discussionJump(id);
} else {
this.switchToDiscussionsTabAndJumpTo(id);
}
}
},
jumpToNextDiscussion() {
this.handleDiscussionJump(this.nextUnresolvedDiscussionId);
handleDiscussionJump(this, this.nextUnresolvedDiscussionId);
},
 
jumpToPreviousDiscussion() {
this.handleDiscussionJump(this.previousUnresolvedDiscussionId);
handleDiscussionJump(this, this.previousUnresolvedDiscussionId);
},
 
handleDiscussionJump(fn) {
const isDiffView = window.mrTabs.currentAction === 'diffs';
const targetId = fn(this.currentDiscussionId, isDiffView);
const discussion = this.getDiscussion(targetId);
this.jumpToDiscussion(discussion);
this.setCurrentDiscussionId(targetId);
/**
* Go to the next discussion from the given discussionId
* @param {String} discussionId The id we are jumping from
*/
jumpToNextRelativeDiscussion(discussionId) {
handleDiscussionJump(this, this.nextUnresolvedDiscussionId, discussionId);
},
},
};
Loading
Loading
@@ -199,10 +199,7 @@ export default {
</script>
 
<template>
<div
v-gl-resize-observer="handleResize"
class="my-3 position-absolute w-100 slide-enter-to-element"
>
<div v-gl-resize-observer="handleResize" class="my-3 w-100 slide-enter-to-element">
<div class="d-flex my-3 align-items-center">
<h4>
<gl-sprintf :message="s__('ContainerRegistry|%{imageName} tags')">
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ export default {};
</script>
 
<template>
<div class="position-relative">
<div>
<transition name="slide">
<router-view />
</transition>
Loading
Loading
Loading
Loading
@@ -78,7 +78,7 @@ export default {
</script>
 
<template>
<div class="position-absolute w-100 slide-enter-from-element">
<div class="w-100 slide-enter-from-element">
<gl-empty-state
v-if="config.characterError"
:title="s__('ContainerRegistry|Docker connection error')"
Loading
Loading
Loading
Loading
@@ -15,6 +15,7 @@
.slide-enter-from-element {
&.slide-enter,
&.slide-leave-to {
position: absolute;
transform: translateX(-150%);
}
}
Loading
Loading
@@ -22,6 +23,7 @@
.slide-enter-to-element {
&.slide-enter,
&.slide-leave-to {
position: absolute;
transform: translateX(150%);
}
}
Loading
Loading
# frozen_string_literal: true
 
class Explore::SnippetsController < Explore::ApplicationController
include PaginatedCollection
include Gitlab::NoteableMetadata
 
def index
@snippets = SnippetsFinder.new(current_user, explore: true)
.execute
.page(params[:page])
.without_count
.inc_author
 
return if redirect_out_of_range(@snippets)
@noteable_meta_data = noteable_meta_data(@snippets, 'Snippet')
end
end
Loading
Loading
@@ -531,6 +531,7 @@ module Ci
.concat(persisted_variables)
.concat(scoped_variables)
.concat(job_variables)
.concat(environment_changed_page_variables)
.concat(persisted_environment_variables)
.to_runner_variables
end
Loading
Loading
@@ -569,6 +570,15 @@ module Ci
end
end
 
def environment_changed_page_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless environment_status
variables.append(key: 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS', value: environment_status.changed_paths.join(','))
variables.append(key: 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS', value: environment_status.changed_urls.join(','))
end
end
def deploy_token_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless gitlab_deploy_token
Loading
Loading
@@ -970,6 +980,14 @@ module Ci
options&.dig(:environment, :url) || persisted_environment&.external_url
end
 
def environment_status
strong_memoize(:environment_status) do
if has_environment? && merge_request
EnvironmentStatus.new(project, persisted_environment, merge_request, pipeline.sha)
end
end
end
# The format of the retry option changed in GitLab 11.5: Before it was
# integer only, after it is a hash. New builds are created with the new
# format, but builds created before GitLab 11.5 and saved in database still
Loading
Loading
Loading
Loading
@@ -62,9 +62,9 @@ class EnvironmentStatus
end
 
def changes
return [] unless has_route_map?
changed_files.map { |file| build_change(file) }.compact
strong_memoize(:changes) do
has_route_map? ? changed_files.map { |file| build_change(file) }.compact : []
end
end
 
def changed_files
Loading
Loading
@@ -72,6 +72,14 @@ class EnvironmentStatus
.merge_request_diff_files.where(deleted_file: false)
end
 
def changed_paths
changes.map { |change| change[:path] }
end
def changed_urls
changes.map { |change| change[:external_url] }
end
def has_route_map?
project.route_map_for(sha).present?
end
Loading
Loading
Loading
Loading
@@ -68,6 +68,10 @@ class PagesDomain < ApplicationRecord
 
scope :instance_serverless, -> { where(wildcard: true, scope: :instance, usage: :serverless) }
 
def self.find_by_domain_case_insensitive(domain)
find_by("LOWER(domain) = LOWER(?)", domain)
end
def verified?
!!verified_at
end
Loading
Loading
# frozen_string_literal: true
 
require 'slack-notifier'
module ChatMessage
class BaseMessage
RELATIVE_LINK_REGEX = /!\[[^\]]*\]\((\/uploads\/[^\)]*)\)/.freeze
Loading
Loading
@@ -59,7 +57,7 @@ module ChatMessage
end
 
def format(string)
Slack::Notifier::LinkFormatter.format(format_relative_links(string))
Slack::Messenger::Util::LinkFormatter.format(format_relative_links(string))
end
 
def format_relative_links(string)
Loading
Loading
# frozen_string_literal: true
require 'slack-notifier'
 
module ChatMessage
class PipelineMessage < BaseMessage
Loading
Loading
@@ -98,7 +97,7 @@ module ChatMessage
def failed_stages_field
{
title: s_("ChatMessage|Failed stage").pluralize(failed_stages.length),
value: Slack::Notifier::LinkFormatter.format(failed_stages_links),
value: Slack::Messenger::Util::LinkFormatter.format(failed_stages_links),
short: true
}
end
Loading
Loading
@@ -106,7 +105,7 @@ module ChatMessage
def failed_jobs_field
{
title: s_("ChatMessage|Failed job").pluralize(failed_jobs.length),
value: Slack::Notifier::LinkFormatter.format(failed_jobs_links),
value: Slack::Messenger::Util::LinkFormatter.format(failed_jobs_links),
short: true
}
end
Loading
Loading
@@ -123,12 +122,12 @@ module ChatMessage
fields = [
{
title: ref_type == "tag" ? s_("ChatMessage|Tag") : s_("ChatMessage|Branch"),
value: Slack::Notifier::LinkFormatter.format(ref_link),
value: Slack::Messenger::Util::LinkFormatter.format(ref_link),
short: true
},
{
title: s_("ChatMessage|Commit"),
value: Slack::Notifier::LinkFormatter.format(commit_link),
value: Slack::Messenger::Util::LinkFormatter.format(commit_link),
short: true
}
]
Loading
Loading
Loading
Loading
@@ -48,7 +48,7 @@ module ChatMessage
end
 
def format(string)
Slack::Notifier::LinkFormatter.format(string)
Slack::Messenger::Util::LinkFormatter.format(string)
end
 
def commit_messages
Loading
Loading
Loading
Loading
@@ -84,10 +84,10 @@ class ChatNotificationService < Service
 
event_type = data[:event_type] || object_kind
 
channel_name = get_channel_field(event_type).presence || channel
channel_names = get_channel_field(event_type).presence || channel
 
opts = {}
opts[:channel] = channel_name if channel_name
opts[:channel] = channel_names.split(',').map(&:strip) if channel_names
opts[:username] = username if username
 
return false unless notify(message, opts)
Loading
Loading
Loading
Loading
@@ -13,18 +13,8 @@ class SlackService < ChatNotificationService
'slack'
end
 
def help
'This service sends notifications about projects events to Slack channels.<br />
To set up this service:
<ol>
<li><a href="https://slack.com/apps/A0F7XDUAZ-incoming-webhooks">Add an incoming webhook</a> in your Slack team. The default channel can be overridden for each event.</li>
<li>Paste the <strong>Webhook URL</strong> into the field below.</li>
<li>Select events below to enable notifications. The <strong>Channel name</strong> and <strong>Username</strong> fields are optional.</li>
</ol>'
end
def default_channel_placeholder
"Channel name (e.g. general)"
_('Slack channels (e.g. general, development)')
end
 
def webhook_placeholder
Loading
Loading
@@ -35,8 +25,8 @@ class SlackService < ChatNotificationService
private
 
def notify(message, opts)
# See https://github.com/stevenosloan/slack-notifier#custom-http-client
notifier = Slack::Notifier.new(webhook, opts.merge(http_client: HTTPClient))
# See https://gitlab.com/gitlab-org/slack-notifier/#custom-http-client
notifier = Slack::Messenger.new(webhook, opts.merge(http_client: HTTPClient))
 
notifier.ping(
message.pretext,
Loading
Loading
Loading
Loading
@@ -29,6 +29,6 @@ class SlackSlashCommandsService < SlashCommandsService
private
 
def format(text)
Slack::Notifier::LinkFormatter.format(text) if text
Slack::Messenger::Util::LinkFormatter.format(text) if text
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment