Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-04 18:07:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-04 18:07:36 +0300
commitaa542224bb345acf0cb9a1a606f0a802c16b0336 (patch)
tree496540a29aec55c6faeec7b0140824547046ae6c /app
parent2494b608a460c46c759ad84bb29e6cc3447499a1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/zen_mode.js32
-rw-r--r--app/assets/stylesheets/framework/ci_variable_list.scss10
-rw-r--r--app/assets/stylesheets/pages/milestone.scss7
-rw-r--r--app/finders/container_repositories_finder.rb38
-rw-r--r--app/helpers/milestones_helper.rb9
-rw-r--r--app/models/container_repository.rb3
-rw-r--r--app/models/global_milestone.rb2
-rw-r--r--app/models/project.rb1
-rw-r--r--app/models/release.rb4
-rw-r--r--app/views/ci/group_variables/_content.html.haml1
-rw-r--r--app/views/ci/group_variables/_header.html.haml5
-rw-r--r--app/views/ci/group_variables/_index.html.haml13
-rw-r--r--app/views/ci/group_variables/_variable_header.html.haml5
-rw-r--r--app/views/ci/variables/_index.html.haml5
-rw-r--r--app/views/shared/milestones/_milestone.html.haml14
15 files changed, 104 insertions, 45 deletions
diff --git a/app/assets/javascripts/zen_mode.js b/app/assets/javascripts/zen_mode.js
index 7a60ab1380f..044d703630e 100644
--- a/app/assets/javascripts/zen_mode.js
+++ b/app/assets/javascripts/zen_mode.js
@@ -1,4 +1,4 @@
-/* eslint-disable func-names, consistent-return, camelcase, class-methods-use-this */
+/* eslint-disable consistent-return, camelcase, class-methods-use-this */
// Zen Mode (full screen) textarea
//
@@ -47,26 +47,16 @@ export default class ZenMode {
e.preventDefault();
return $(e.currentTarget).trigger('zen_mode:leave');
});
- $(document).on(
- 'zen_mode:enter',
- (function(_this) {
- return function(e) {
- return _this.enter(
- $(e.target)
- .closest('.md-area')
- .find('.zen-backdrop'),
- );
- };
- })(this),
- );
- $(document).on(
- 'zen_mode:leave',
- (function(_this) {
- return function() {
- return _this.exit();
- };
- })(this),
- );
+ $(document).on('zen_mode:enter', e => {
+ this.enter(
+ $(e.target)
+ .closest('.md-area')
+ .find('.zen-backdrop'),
+ );
+ });
+ $(document).on('zen_mode:leave', () => {
+ this.exit();
+ });
$(document).on('keydown', e => {
// Esc
if (e.keyCode === 27) {
diff --git a/app/assets/stylesheets/framework/ci_variable_list.scss b/app/assets/stylesheets/framework/ci_variable_list.scss
index 28d7492b99c..cae7b9b5e46 100644
--- a/app/assets/stylesheets/framework/ci_variable_list.scss
+++ b/app/assets/stylesheets/framework/ci_variable_list.scss
@@ -99,3 +99,13 @@
color: $gl-text-color-disabled;
}
}
+
+.group-variable-list {
+ color: $gray-700;
+
+ .table-section:not(:first-child) {
+ @include media-breakpoint-down(sm) {
+ border-top: hidden;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/pages/milestone.scss b/app/assets/stylesheets/pages/milestone.scss
index 00d84df1650..b399662997c 100644
--- a/app/assets/stylesheets/pages/milestone.scss
+++ b/app/assets/stylesheets/pages/milestone.scss
@@ -30,7 +30,8 @@ $status-box-line-height: 26px;
margin-bottom: $gl-padding-4;
}
- .milestone-progress {
+ .milestone-progress,
+ .milestone-release-links {
a {
color: $blue-600;
}
@@ -238,10 +239,6 @@ $status-box-line-height: 26px;
}
}
-.milestone-range {
- color: $gl-text-color-tertiary;
-}
-
@include media-breakpoint-down(xs) {
.milestone-banner-text,
.milestone-banner-link {
diff --git a/app/finders/container_repositories_finder.rb b/app/finders/container_repositories_finder.rb
index eb91d7f825b..34921df840b 100644
--- a/app/finders/container_repositories_finder.rb
+++ b/app/finders/container_repositories_finder.rb
@@ -1,34 +1,38 @@
# frozen_string_literal: true
class ContainerRepositoriesFinder
- # id: group or project id
- # container_type: :group or :project
- def initialize(id:, container_type:)
- @id = id
- @type = container_type.to_sym
+ VALID_SUBJECTS = [Group, Project].freeze
+
+ def initialize(user:, subject:)
+ @user = user
+ @subject = subject
end
def execute
- if project_type?
- project.container_repositories
- else
- group.container_repositories
- end
+ raise ArgumentError, "invalid subject_type" unless valid_subject_type?
+ return unless authorized?
+
+ return project_repositories if @subject.is_a?(Project)
+ return group_repositories if @subject.is_a?(Group)
end
private
- attr_reader :id, :type
+ def valid_subject_type?
+ VALID_SUBJECTS.include?(@subject.class)
+ end
+
+ def project_repositories
+ return unless @subject.container_registry_enabled
- def project_type?
- type == :project
+ @subject.container_repositories
end
- def project
- Project.find(id)
+ def group_repositories
+ ContainerRepository.for_group_and_its_subgroups(@subject)
end
- def group
- Group.find(id)
+ def authorized?
+ Ability.allowed?(@user, :read_container_image, @subject)
end
end
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb
index e769734f27b..60165e0d0a4 100644
--- a/app/helpers/milestones_helper.rb
+++ b/app/helpers/milestones_helper.rb
@@ -170,6 +170,15 @@ module MilestonesHelper
content.join('<br />').html_safe
end
+ def recent_releases_with_counts(milestone)
+ total_count = milestone.releases.size
+ return [[], 0, 0] if total_count == 0
+
+ recent_releases = milestone.releases.recent.to_a
+ more_count = total_count - recent_releases.size
+ [recent_releases, total_count, more_count]
+ end
+
def milestone_tooltip_due_date(milestone)
if milestone.due_date
"#{milestone.due_date.to_s(:medium)} (#{remaining_days_in_words(milestone.due_date, milestone.start_date)})"
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb
index 7a3a79cead0..152aa7b3218 100644
--- a/app/models/container_repository.rb
+++ b/app/models/container_repository.rb
@@ -12,6 +12,9 @@ class ContainerRepository < ApplicationRecord
scope :ordered, -> { order(:name) }
scope :with_api_entity_associations, -> { preload(project: [:route, { namespace: :route }]) }
+ scope :for_group_and_its_subgroups, ->(group) do
+ where(project_id: Project.for_group_and_its_subgroups(group).with_container_registry.select(:id))
+ end
# rubocop: disable CodeReuse/ServiceClass
def registry
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb
index 7d766e1f25c..61c62929b61 100644
--- a/app/models/global_milestone.rb
+++ b/app/models/global_milestone.rb
@@ -11,7 +11,7 @@ class GlobalMilestone
delegate :title, :state, :due_date, :start_date, :participants, :project,
:group, :expires_at, :closed?, :iid, :group_milestone?, :safe_title,
- :milestoneish_id, :resource_parent, to: :milestone
+ :milestoneish_id, :resource_parent, :releases, to: :milestone
def to_hash
{
diff --git a/app/models/project.rb b/app/models/project.rb
index 245d29554a3..2cb5af382b6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -395,6 +395,7 @@ class Project < ApplicationRecord
scope :with_project_feature, -> { joins('LEFT JOIN project_features ON projects.id = project_features.project_id') }
scope :with_statistics, -> { includes(:statistics) }
scope :with_shared_runners, -> { where(shared_runners_enabled: true) }
+ scope :with_container_registry, -> { where(container_registry_enabled: true) }
scope :inside_path, ->(path) do
# We need routes alias rs for JOIN so it does not conflict with
# includes(:route) which we use in ProjectsFinder.
diff --git a/app/models/release.rb b/app/models/release.rb
index 1261402712f..ec40e8ec3e2 100644
--- a/app/models/release.rb
+++ b/app/models/release.rb
@@ -28,12 +28,16 @@ class Release < ApplicationRecord
scope :sorted, -> { order(released_at: :desc) }
scope :preloaded, -> { includes(project: :namespace) }
+ scope :with_project_and_namespace, -> { includes(project: :namespace) }
+ scope :recent, -> { sorted.limit(MAX_NUMBER_TO_DISPLAY) }
delegate :repository, to: :project
after_commit :create_evidence!, on: :create
after_commit :notify_new_release, on: :create
+ MAX_NUMBER_TO_DISPLAY = 3
+
def to_param
CGI.escape(tag)
end
diff --git a/app/views/ci/group_variables/_content.html.haml b/app/views/ci/group_variables/_content.html.haml
new file mode 100644
index 00000000000..db5f1021f57
--- /dev/null
+++ b/app/views/ci/group_variables/_content.html.haml
@@ -0,0 +1 @@
+= _("These variables are configured in the parent group settings, and will be active in the current project in addition to the project variables.")
diff --git a/app/views/ci/group_variables/_header.html.haml b/app/views/ci/group_variables/_header.html.haml
new file mode 100644
index 00000000000..71d123ec9f2
--- /dev/null
+++ b/app/views/ci/group_variables/_header.html.haml
@@ -0,0 +1,5 @@
+%h5
+ = _('Group variables (inherited)')
+
+%p
+ = render "ci/group_variables/content"
diff --git a/app/views/ci/group_variables/_index.html.haml b/app/views/ci/group_variables/_index.html.haml
new file mode 100644
index 00000000000..c350ba5caf7
--- /dev/null
+++ b/app/views/ci/group_variables/_index.html.haml
@@ -0,0 +1,13 @@
+- variables = @project.group.self_and_ancestors.map(&:variables).flatten
+
+.row
+ .col-lg-12
+ .group-variable-list
+ = render 'ci/group_variables/variable_header'
+ - variables.each do |variable|
+ .group-variable-row.d-flex.w-100.border-bottom.pt-2.pb-2
+ .table-section.section-40.append-right-10.key
+ = variable.key
+ .table-section.section-40.append-right-10
+ %a.group-origin-link{ href: group_settings_ci_cd_path(variable.group) }
+ = variable.group.name
diff --git a/app/views/ci/group_variables/_variable_header.html.haml b/app/views/ci/group_variables/_variable_header.html.haml
new file mode 100644
index 00000000000..1a3168cf781
--- /dev/null
+++ b/app/views/ci/group_variables/_variable_header.html.haml
@@ -0,0 +1,5 @@
+.group-variable-keys.d-flex.w-100.align-items-center.pb-2.border-bottom
+ .bold.table-section.section-40.append-right-10
+ = s_('Key')
+ .bold.table-section.section-40.append-right-10
+ = s_('Origin')
diff --git a/app/views/ci/variables/_index.html.haml b/app/views/ci/variables/_index.html.haml
index 94102b4dcd0..7ae5c48b93c 100644
--- a/app/views/ci/variables/_index.html.haml
+++ b/app/views/ci/variables/_index.html.haml
@@ -24,3 +24,8 @@
= n_('Hide value', 'Hide values', @variables.size)
- else
= n_('Reveal value', 'Reveal values', @variables.size)
+ - if !@group && @project.group
+ .settings-header.border-top.prepend-top-20
+ = render 'ci/group_variables/header'
+ .settings-content.pr-0
+ = render 'ci/group_variables/index'
diff --git a/app/views/shared/milestones/_milestone.html.haml b/app/views/shared/milestones/_milestone.html.haml
index e99aa3f1ee4..b324f35c338 100644
--- a/app/views/shared/milestones/_milestone.html.haml
+++ b/app/views/shared/milestones/_milestone.html.haml
@@ -12,8 +12,20 @@
- if @project || milestone.is_a?(GlobalMilestone) || milestone.group_milestone?
- if milestone.due_date || milestone.start_date
- .milestone-range.append-bottom-5
+ .text-tertiary.append-bottom-5
= milestone_date_range(milestone)
+ - recent_releases, total_count, more_count = recent_releases_with_counts(milestone)
+ - unless total_count.zero?
+ .text-tertiary.append-bottom-5.milestone-release-links
+ = icon('rocket')
+ = n_('Release', 'Releases', total_count)
+ - recent_releases.each do |release|
+ = link_to release.name, project_releases_path(release.project, anchor: release.tag)
+ - unless release == recent_releases.last
+ &bull;
+ - if total_count > recent_releases.count
+ &bull;
+ = link_to n_('%{count} more release', '%{count} more releases', more_count) % { count: more_count }, project_releases_path(milestone.project)
%div
= render('shared/milestone_expired', milestone: milestone)
- if milestone.group_milestone?