Skip to content

Commit

Permalink
Add latest changes from gitlab-org/gitlab@master
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLab Bot committed Oct 1, 2020
1 parent a7e81ad commit 635d82b
Show file tree
Hide file tree
Showing 32 changed files with 303 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export default {
},
inject: {
svgPath: {
type: String,
default: '',
},
docsLink: {
type: String,
default: '',
},
primaryButtonPath: {
type: String,
default: '',
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ export default {
},
inject: {
isAdmin: {
type: Boolean,
default: false,
},
svgPath: {
type: String,
default: '',
},
docsLink: {
type: String,
default: '',
},
primaryButtonPath: {
type: String,
default: '',
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<script>
import $ from 'jquery';
import { mapActions, mapState } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui';
import { GlIcon, GlLoadingIcon } from '@gitlab/ui';
import DropdownButton from '~/vue_shared/components/dropdown/dropdown_button.vue';
export default {
components: {
DropdownButton,
GlIcon,
GlLoadingIcon,
},
props: {
Expand Down Expand Up @@ -85,7 +86,7 @@ export default {
type="search"
class="dropdown-input-field qa-dropdown-filter-input"
/>
<i aria-hidden="true" class="fa fa-search dropdown-input-search"></i>
<gl-icon name="search" class="dropdown-input-search" aria-hidden="true" />
</div>
<div class="dropdown-content">
<gl-loading-icon v-if="showLoading" size="lg" />
Expand Down
19 changes: 19 additions & 0 deletions app/assets/javascripts/lib/utils/datetime_utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,3 +743,22 @@ export const differenceInMilliseconds = (startDate, endDate = Date.now()) => {
const endDateInMS = endDate instanceof Date ? endDate.getTime() : endDate;
return endDateInMS - startDateInMS;
};

/**
* A utility which returns a new date at the first day of the month for any given date.
*
* @param {Date} date
*
* @return {Date} the date at the first day of the month
*/
export const dateAtFirstDayOfMonth = date => new Date(newDate(date).setDate(1));

/**
* A utility function which checks if two dates match.
*
* @param {Date|Int} date1 Can be either a date object or a unix timestamp.
* @param {Date|Int} date2 Can be either a date object or a unix timestamp.
*
* @return {Boolean} true if the dates match
*/
export const datesMatch = (date1, date2) => differenceInMilliseconds(date1, date2) === 0;
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script>
import { GlIcon } from '@gitlab/ui';
import { __ } from '~/locale';
export default {
components: {
GlIcon,
},
props: {
placeholderText: {
type: String,
Expand Down Expand Up @@ -41,5 +45,6 @@ export default {
autocomplete="off"
/>
<i class="fa fa-search dropdown-input-search" aria-hidden="true" data-hidden="true"> </i>
<gl-icon name="search" class="dropdown-input-search" aria-hidden="true" data-hidden="true" />
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,12 @@ export default {
@keydown="onKeydown($event)"
@keyup="onKeyup($event)"
/>
<i
:class="{
hidden: showClearInputButton,
}"
<gl-icon
name="search"
class="dropdown-input-search"
:class="{ hidden: showClearInputButton }"
aria-hidden="true"
class="fa fa-search dropdown-input-search"
></i>
/>
<gl-icon
name="close"
class="dropdown-input-clear"
Expand Down
4 changes: 0 additions & 4 deletions app/assets/stylesheets/pages/diff.scss
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,6 @@
margin-left: 0;
border-left: 0;
}

.file-actions .dropdown {
height: 28px;
}
}

table.code {
Expand Down
28 changes: 19 additions & 9 deletions app/finders/group_members_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,22 @@ def initialize(group, user = nil, params: {})
@params = params
end

# rubocop: disable CodeReuse/ActiveRecord
def execute(include_relations: [:inherited, :direct])
group_members = group.members
group_members = group_members_list
relations = []

return group_members if include_relations == [:direct]

relations << group_members if include_relations.include?(:direct)

if include_relations.include?(:inherited) && group.parent
parents_members = GroupMember.non_request.non_minimal_access
.where(source_id: group.ancestors.select(:id))
.where.not(user_id: group.users.select(:id))
parents_members = relation_group_members(group.ancestors)

relations << parents_members
end

if include_relations.include?(:descendants)
descendant_members = GroupMember.non_request.non_minimal_access
.where(source_id: group.descendants.select(:id))
.where.not(user_id: group.users.select(:id))
descendant_members = relation_group_members(group.descendants)

relations << descendant_members
end
Expand All @@ -47,7 +42,6 @@ def execute(include_relations: [:inherited, :direct])
members = find_union(relations, GroupMember)
filter_members(members)
end
# rubocop: enable CodeReuse/ActiveRecord

private

Expand All @@ -67,6 +61,22 @@ def filter_members(members)
def can_manage_members
Ability.allowed?(user, :admin_group_member, group)
end

def group_members_list
group.members
end

def relation_group_members(relation)
all_group_members(relation).non_minimal_access
end

# rubocop: disable CodeReuse/ActiveRecord
def all_group_members(relation)
GroupMember.non_request
.where(source_id: relation.select(:id))
.where.not(user_id: group.users.select(:id))
end
# rubocop: enable CodeReuse/ActiveRecord
end

GroupMembersFinder.prepend_if_ee('EE::GroupMembersFinder')
1 change: 1 addition & 0 deletions app/graphql/mutations/base_mutation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
prepend Gitlab::Graphql::Authorize::AuthorizeResource
prepend Gitlab::Graphql::CopyFieldDescription
prepend ::Gitlab::Graphql::GlobalIDCompatibility

ERROR_MESSAGE = 'You cannot perform write operations on a read-only instance'

Expand Down
7 changes: 6 additions & 1 deletion app/graphql/mutations/ci/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
module Mutations
module Ci
class Base < BaseMutation
argument :id, ::Types::GlobalIDType[::Ci::Pipeline],
PipelineID = ::Types::GlobalIDType[::Ci::Pipeline]

argument :id, PipelineID,
required: true,
description: 'The id of the pipeline to mutate'

private

def find_object(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = PipelineID.coerce_isolated_input(id)
GlobalID::Locator.locate(id)
end
end
Expand Down
9 changes: 8 additions & 1 deletion app/graphql/mutations/design_management/move.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ def resolve(**args)
private

def parameters(**args)
args.transform_values { |id| GitlabSchema.find_by_gid(id) }.transform_values(&:sync).tap do |hash|
args.transform_values { |id| find_design(id) }.transform_values(&:sync).tap do |hash|
hash.each { |k, design| not_found(args[k]) unless current_user.can?(:read_design, design) }
end
end

def find_design(id)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = DesignID.coerce_isolated_input(id)
GitlabSchema.object_from_id(id)
end

def not_found(gid)
raise Gitlab::Graphql::Errors::ResourceNotAvailable, "Resource not available: #{gid}"
end
Expand Down
1 change: 1 addition & 0 deletions app/graphql/resolvers/base_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Resolvers
class BaseResolver < GraphQL::Schema::Resolver
extend ::Gitlab::Utils::Override
include ::Gitlab::Utils::StrongMemoize
include ::Gitlab::Graphql::GlobalIDCompatibility

def self.single
@single ||= Class.new(self) do
Expand Down
16 changes: 16 additions & 0 deletions app/graphql/types/global_id_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# frozen_string_literal: true

module GraphQLExtensions
module ScalarExtensions
# Allow ID to unify with GlobalID Types
def ==(other)
if name == 'ID' && other.is_a?(self.class) &&
other.type_class.ancestors.include?(::Types::GlobalIDType)
return true
end

super
end
end
end

::GraphQL::ScalarType.prepend(GraphQLExtensions::ScalarExtensions)

module Types
class GlobalIDType < BaseScalar
graphql_name 'GlobalID'
Expand Down
15 changes: 12 additions & 3 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class QueryType < ::Types::BaseObject

field :milestone, ::Types::MilestoneType,
null: true,
description: 'Find a milestone',
resolve: -> (_obj, args, _ctx) { GitlabSchema.find_by_gid(args[:id]) } do
description: 'Find a milestone' do
argument :id, ::Types::GlobalIDType[Milestone],
required: true,
description: 'Find a milestone by its ID'
Expand Down Expand Up @@ -86,7 +85,17 @@ def design_management
end

def issue(id:)
GitlabSchema.object_from_id(id, expected_type: ::Issue)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[::Issue].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end

def milestone(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[Milestone].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/groups/group_members_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def group_member_select_options
end

def render_invite_member_for_group(group, default_access_level)
render 'shared/members/invite_member', submit_url: group_group_members_path(group), access_levels: GroupMember.access_level_roles, default_access_level: default_access_level
render 'shared/members/invite_member', submit_url: group_group_members_path(group), access_levels: group.access_level_roles, default_access_level: default_access_level
end

def linked_groups_data_json(group_links)
Expand Down
9 changes: 9 additions & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def members_with_parents
end

group_hierarchy_members = GroupMember.active_without_invites_and_requests
.non_minimal_access
.where(source_id: source_ids)

GroupMember.from_union([group_hierarchy_members,
Expand Down Expand Up @@ -550,6 +551,14 @@ def default_owner
owners.first || parent&.default_owner || owner
end

def access_level_roles
GroupMember.access_level_roles
end

def access_level_values
access_level_roles.values
end

private

def update_two_factor_requirement
Expand Down
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def update_tracked_fields!(request)
-> { where(members: { access_level: [Gitlab::Access::REPORTER, Gitlab::Access::DEVELOPER, Gitlab::Access::MAINTAINER, Gitlab::Access::OWNER] }) },
through: :group_members,
source: :group
has_many :minimal_access_group_members, -> { where(access_level: [Gitlab::Access::MINIMAL_ACCESS]) }, source: 'GroupMember', class_name: 'GroupMember'
has_many :minimal_access_groups, through: :minimal_access_group_members, source: :group

# Projects
has_many :groups_projects, through: :groups, source: :projects
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/groups/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
%div
= users_select_tag(:user_ids, multiple: true, email_user: true, skip_ldap: @group.ldap_synced?, scope: :all)
.gl-mt-3
= select_tag :access_level, options_for_select(GroupMember.access_level_roles), class: "project-access-select select2"
= select_tag :access_level, options_for_select(@group.access_level_roles), class: "project-access-select select2"
%hr
= button_tag _('Add users to group'), class: "btn btn-success"
= render 'shared/members/requests', membership_source: @group, requesters: @requesters, force_mobile_view: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Add No Access Role for top group members
merge_request: 40942
author:
type: added
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Don't expose http_request_duration_seconds metrics in sidekiq exporter
merge_request: 43941
author:
type: performance
5 changes: 5 additions & 0 deletions changelogs/unreleased/mw-replace-fa-search-icons.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Replace fa-search fontawesome icons with GitLab SVG in Vue components
merge_request: 43879
author:
type: changed
7 changes: 7 additions & 0 deletions config/feature_flags/licensed/minimal_access_role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: minimal_access_role
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40942
rollout_issue_url:
group: group::access
type: licensed
default_enabled: true
4 changes: 3 additions & 1 deletion config/initializers/7_prometheus_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def prometheus_default_multiproc_dir

Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION }, 1)

Gitlab::Metrics::RequestsRackMiddleware.initialize_http_request_duration_seconds
unless Gitlab::Runtime.sidekiq?
Gitlab::Metrics::RequestsRackMiddleware.initialize_http_request_duration_seconds
end
rescue IOError => e
Gitlab::ErrorTracking.track_exception(e)
Gitlab::Metrics.error_detected!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ DRIs:
|------------------------------|------------------------|
| Product | Jackie Porter |
| Leadership | Daniel Croft |
| Engineering | TBD |
| Engineering | Kamil Trzciński |

Domain Experts:

Expand Down
Loading

0 comments on commit 635d82b

Please sign in to comment.