Commit 04179aae authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 53cdf86cf16a
---
# Syncs any changes pushed to a stable branch to the corresponding CE stable
# branch. We run this prior to any tests so that random failures don't prevent a
# sync.
sync-stable-branch:
# Syncs any changes pushed to a stable branch to the corresponding
# gitlab-foss/CE stable branch. We run this prior to any tests so that random
# failures don't prevent a sync.
.merge-train-sync:
# We don't need/want any global before/after commands, so we overwrite these
# settings.
image: alpine:edge
stage: sync
# This job should only run on EE stable branches on the canonical GitLab.com
# repository.
only:
variables:
- $CI_SERVER_HOST == "gitlab.com"
refs:
- /^[\d-]+-stable-ee$/@gitlab-org/gitlab
before_script:
- apk add --no-cache --update curl bash
after_script: []
script:
- bash scripts/sync-stable-branch.sh
only:
variables:
- $CI_SERVER_HOST == "gitlab.com"
sync-stable-branch:
extends: .merge-train-sync
variables:
SOURCE_PROJECT: gitlab-org/gitlab
TARGET_PROJECT: gitlab-org/gitlab-foss
only:
refs:
- /^[\d-]+-stable-ee$/@gitlab-org/gitlab
sync-security-branch:
extends: .merge-train-sync
variables:
SOURCE_PROJECT: gitlab-org/security/gitlab
TARGET_PROJECT: gitlab-org/security/gitlab-foss
only:
refs:
- /^[\d-]+-stable-ee$/@gitlab-org/security/gitlab
......@@ -12,13 +12,18 @@ import {
GlDropdownItem,
GlDropdownDivider,
GlTooltipDirective,
GlPagination,
} from '@gitlab/ui';
import AccessorUtils from '~/lib/utils/accessor';
import Icon from '~/vue_shared/components/icon.vue';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import { __ } from '~/locale';
import _ from 'underscore';
export default {
FIRST_PAGE: 1,
PREV_PAGE: 1,
NEXT_PAGE: 2,
fields: [
{ key: 'error', label: __('Open errors'), thClass: 'w-70p' },
{ key: 'events', label: __('Events') },
......@@ -42,6 +47,7 @@ export default {
GlTable,
GlFormInput,
Icon,
GlPagination,
TimeAgo,
},
directives: {
......@@ -73,10 +79,28 @@ export default {
data() {
return {
errorSearchQuery: '',
pageValue: this.$options.FIRST_PAGE,
};
},
computed: {
...mapState('list', ['errors', 'loading', 'searchQuery', 'sortField', 'recentSearches']),
...mapState('list', [
'errors',
'loading',
'searchQuery',
'sortField',
'recentSearches',
'pagination',
]),
paginationRequired() {
return !_.isEmpty(this.pagination);
},
},
watch: {
pagination() {
if (typeof this.pagination.previous === 'undefined') {
this.pageValue = this.$options.FIRST_PAGE;
}
},
},
created() {
if (this.errorTrackingEnabled) {
......@@ -103,6 +127,17 @@ export default {
getDetailsLink(errorId) {
return `error_tracking/${errorId}/details`;
},
goToNextPage() {
this.pageValue = this.$options.NEXT_PAGE;
this.startPolling(`${this.indexPath}?cursor=${this.pagination.next.cursor}`);
},
goToPrevPage() {
this.startPolling(`${this.indexPath}?cursor=${this.pagination.previous.cursor}`);
},
goToPage(page) {
window.scrollTo(0, 0);
return page === this.$options.PREV_PAGE ? this.goToPrevPage() : this.goToNextPage();
},
isCurrentSortField(field) {
return field === this.sortField;
},
......@@ -217,7 +252,6 @@ export default {
</span>
</div>
</template>
<template slot="events" slot-scope="errors">
<div class="text-md-right">{{ errors.item.count }}</div>
</template>
......@@ -240,6 +274,15 @@ export default {
</div>
</template>
</gl-table>
<gl-pagination
v-show="!loading"
v-if="paginationRequired"
:prev-page="$options.PREV_PAGE"
:next-page="$options.NEXT_PAGE"
:value="pageValue"
align="center"
@input="goToPage"
/>
</div>
<div v-else-if="userCanEnableErrorTracking">
<gl-empty-state
......
......@@ -23,6 +23,7 @@ export function startPolling({ state, commit, dispatch }) {
if (!data) {
return;
}
commit(types.SET_PAGINATION, data.pagination);
commit(types.SET_ERRORS, data.errors);
commit(types.SET_LOADING, false);
dispatch('stopPolling');
......
......@@ -4,6 +4,7 @@ export const SET_LOADING = 'SET_LOADING';
export const ADD_RECENT_SEARCH = 'ADD_RECENT_SEARCH';
export const CLEAR_RECENT_SEARCHES = 'CLEAR_RECENT_SEARCHES';
export const LOAD_RECENT_SEARCHES = 'LOAD_RECENT_SEARCHES';
export const SET_PAGINATION = 'SET_PAGINATION';
export const SET_ENDPOINT = 'SET_ENDPOINT';
export const SET_SORT_FIELD = 'SET_SORT_FIELD';
export const SET_SEARCH_QUERY = 'SET_SEARCH_QUERY';
......@@ -44,6 +44,9 @@ export default {
throw e;
}
},
[types.SET_PAGINATION](state, pagination) {
state.pagination = pagination;
},
[types.SET_SORT_FIELD](state, field) {
state.sortField = field;
},
......
......@@ -6,4 +6,5 @@ export default () => ({
searchQuery: null,
indexPath: '',
recentSearches: [],
pagination: {},
});
......@@ -162,7 +162,7 @@ export const createCommitPayload = ({
});
export const createNewMergeRequestUrl = (projectUrl, source, target) =>
`${projectUrl}/merge_requests/new?merge_request[source_branch]=${source}&merge_request[target_branch]=${target}&nav_source=webide`;
`${projectUrl}/-/merge_requests/new?merge_request[source_branch]=${source}&merge_request[target_branch]=${target}&nav_source=webide`;
const sortTreesByTypeAndName = (a, b) => {
if (a.type === 'tree' && b.type === 'blob') {
......
......@@ -32,17 +32,17 @@ import { __ } from './locale';
//
// <ul class="nav-links merge-request-tabs">
// <li class="notes-tab active">
// <a data-action="notes" data-target="#notes" data-toggle="tab" href="/foo/bar/merge_requests/1">
// <a data-action="notes" data-target="#notes" data-toggle="tab" href="/foo/bar/-/merge_requests/1">
// Discussion
// </a>
// </li>
// <li class="commits-tab">
// <a data-action="commits" data-target="#commits" data-toggle="tab" href="/foo/bar/merge_requests/1/commits">
// <a data-action="commits" data-target="#commits" data-toggle="tab" href="/foo/bar/-/merge_requests/1/commits">
// Commits
// </a>
// </li>
// <li class="diffs-tab">
// <a data-action="diffs" data-target="#diffs" data-toggle="tab" href="/foo/bar/merge_requests/1/diffs">
// <a data-action="diffs" data-target="#diffs" data-toggle="tab" href="/foo/bar/-/merge_requests/1/diffs">
// Diffs
// </a>
// </li>
......@@ -260,17 +260,17 @@ export default class MergeRequestTabs {
//
// Examples:
//
// location.pathname # => "/namespace/project/merge_requests/1"
// location.pathname # => "/namespace/project/-/merge_requests/1"
// setCurrentAction('diffs')
// location.pathname # => "/namespace/project/merge_requests/1/diffs"
// location.pathname # => "/namespace/project/-/merge_requests/1/diffs"
//
// location.pathname # => "/namespace/project/merge_requests/1/diffs"
// location.pathname # => "/namespace/project/-/merge_requests/1/diffs"
// setCurrentAction('show')
// location.pathname # => "/namespace/project/merge_requests/1"
// location.pathname # => "/namespace/project/-/merge_requests/1"
//
// location.pathname # => "/namespace/project/merge_requests/1/diffs"
// location.pathname # => "/namespace/project/-/merge_requests/1/diffs"
// setCurrentAction('commits')
// location.pathname # => "/namespace/project/merge_requests/1/commits"
// location.pathname # => "/namespace/project/-/merge_requests/1/commits"
//
// Returns the new URL String
setCurrentAction(action) {
......
......@@ -44,15 +44,14 @@ def show
expires_in ttl, directives
disposition = uploader.embeddable? ? 'inline' : 'attachment'
uploaders = [uploader, *uploader.versions.values]
uploader = uploaders.find { |version| version.filename == params[:filename] }
file_uploader = [uploader, *uploader.versions.values].find do |version|
version.filename == params[:filename]
end
return render_404 unless uploader
return render_404 unless file_uploader
workhorse_set_content_type!
send_upload(uploader, attachment: uploader.filename, disposition: disposition)
send_upload(file_uploader, attachment: file_uploader.filename, disposition: content_disposition)
end
def authorize
......@@ -83,6 +82,14 @@ def set_request_format_from_path_extension
end
end
def content_disposition
if uploader.embeddable? || uploader.pdf?
'inline'
else
'attachment'
end
end
def uploader_class
raise NotImplementedError
end
......
......@@ -10,6 +10,7 @@ class Snippet < BasePermissionType
permission_field :read_snippet, method: :can_read_snippet?
permission_field :update_snippet, method: :can_update_snippet?
permission_field :admin_snippet, method: :can_admin_snippet?
permission_field :report_snippet, method: :can_report_as_spam?
end
end
end
......@@ -686,6 +686,7 @@ def sidebar_operations_paths
error_tracking
user
gcp
logs
]
end
......
......@@ -23,7 +23,6 @@ class Build < CommitStatus
belongs_to :runner
belongs_to :trigger_request
belongs_to :erased_by, class_name: 'User'
belongs_to :resource_group, class_name: 'Ci::ResourceGroup', inverse_of: :builds
RUNNER_FEATURES = {
upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? },
......@@ -35,7 +34,6 @@ class Build < CommitStatus
}.freeze
has_one :deployment, as: :deployable, class_name: 'Deployment'
has_one :resource, class_name: 'Ci::Resource', inverse_of: :build
has_many :trace_sections, class_name: 'Ci::BuildTraceSection'
has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id
......@@ -443,15 +441,6 @@ def has_environment?
environment.present?
end
def requires_resource?
Feature.enabled?(:ci_resource_group, project) &&
self.resource_group_id.present? && resource.nil?
end
def retains_resource?
self.resource_group_id.present? && resource.present?
end
def starts_environment?
has_environment? && self.environment_action == 'start'
end
......
# frozen_string_literal: true
module Ci
class Resource < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :resource_group, class_name: 'Ci::ResourceGroup', inverse_of: :resources
belongs_to :build, class_name: 'Ci::Build', inverse_of: :resource
scope :free, -> { where(build: nil) }
scope :retained_by, -> (build) { where(build: build) }
end
end
# frozen_string_literal: true
module Ci
class ResourceGroup < ApplicationRecord
extend Gitlab::Ci::Model
belongs_to :project, inverse_of: :resource_groups
has_many :resources, class_name: 'Ci::Resource', inverse_of: :resource_group
has_many :builds, class_name: 'Ci::Build', inverse_of: :resource_group
validates :key,
length: { maximum: 255 },
format: { with: Gitlab::Regex.environment_name_regex,
message: Gitlab::Regex.environment_name_regex_message }
before_create :ensure_resource
def retain_resource_for(build)
resources.free.limit(1).update_all(build_id: build.id) > 0
end
def release_resource_from(build)
resources.retained_by(build).update_all(build_id: nil) > 0
end
private
def ensure_resource
# Currently we only support one resource per group, which means
# maximum one build can be set to the resource group, thus builds
# belong to the same resource group are executed once at time.
self.resources.build if self.resources.empty?
end
end
end
......@@ -285,7 +285,6 @@ class Project < ApplicationRecord
has_many :pipeline_schedules, class_name: 'Ci::PipelineSchedule'
has_many :project_deploy_tokens
has_many :deploy_tokens, through: :project_deploy_tokens
has_many :resource_groups, class_name: 'Ci::ResourceGroup', inverse_of: :project
has_one :auto_devops, class_name: 'ProjectAutoDevops', inverse_of: :project, autosave: true
has_many :custom_attributes, class_name: 'ProjectCustomAttribute'
......@@ -741,7 +740,7 @@ def daily_statistics_enabled?
end
def unlink_forks_upon_visibility_decrease_enabled?
Feature.enabled?(:unlink_fork_network_upon_visibility_decrease, self)
Feature.enabled?(:unlink_fork_network_upon_visibility_decrease, self, default_enabled: true)
end
def empty_repo?
......
......@@ -62,7 +62,7 @@ def merge_request_title
end
def merge_request_url
"#{project_url}/merge_requests/#{merge_request_iid}"
"#{project_url}/-/merge_requests/#{merge_request_iid}"
end
# overridden in EE
......
......@@ -184,7 +184,7 @@ def create_merge_request_message(data)
description = obj_attr[:description]
title = render_line(obj_attr[:title])
merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}"
merge_request_url = "#{project_url}/-/merge_requests/#{merge_request_id}"
merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>"
message = ["#{user_name} #{state} #{merge_request_link} in " \
"#{project_link}: <b>#{title}</b>"]
......
......@@ -10,6 +10,9 @@ class UserPolicy < BasePolicy
desc "The profile is private"
condition(:private_profile, scope: :subject, score: 0) { @subject.private_profile? }
desc "The user is blocked"
condition(:blocked_user, scope: :subject, score: 0) { @subject.blocked? }
rule { ~restricted_public_level }.enable :read_user
rule { ~anonymous }.enable :read_user
......@@ -20,5 +23,5 @@ class UserPolicy < BasePolicy
end
rule { default }.enable :read_user_profile
rule { private_profile & ~(user_is_self | admin) }.prevent :read_user_profile
rule { (private_profile | blocked_user) & ~(user_is_self | admin) }.prevent :read_user_profile
end
......@@ -23,6 +23,10 @@ def can_admin_snippet?
can_access_resource?("admin")
end
def can_report_as_spam?
snippet.submittable_as_spam_by?(current_user)
end
private
def can_access_resource?(ability_prefix)
......
......@@ -5,7 +5,7 @@ class RetryBuildService < ::BaseService
CLONE_ACCESSORS = %i[pipeline project ref tag options name
allow_failure stage stage_id stage_idx trigger_request
yaml_variables when environment coverage_regex
description tag_list protected needs resource_group].freeze
description tag_list protected needs].freeze
def execute(build)
reprocess!(build).tap do |new_build|
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment