Skip to content

Commit 539748d

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent f2109f5 commit 539748d

File tree

28 files changed

+582
-49
lines changed

28 files changed

+582
-49
lines changed

.vale.ini

-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ MinAlertLevel = suggestion
88
[*.md]
99
BasedOnStyles = gitlab_base, gitlab_docs
1010

11-
# Disable the front matter check until we migrate titles to Hugo format
12-
gitlab_docs.FrontMatter = NO
13-
1411
# Ignore SVG markup
1512
TokenIgnores = (\*\*\{\w*\}\*\*)

app/assets/javascripts/rapid_diffs/options_menu/adapter.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import Vue from 'vue';
22
import { GlDisclosureDropdown } from '@gitlab/ui';
33

4+
function getMenuItems(container) {
5+
return JSON.parse(container.querySelector('script').textContent);
6+
}
7+
48
export const OptionsMenuAdapter = {
59
clicks: {
610
toggleOptionsMenu(event) {
711
const button = event.target.closest('.js-options-button');
12+
const menuContainer = button.parentElement;
13+
const items = getMenuItems(menuContainer);
814

915
if (!this.sink.optionsMenu) {
1016
this.sink.optionsMenu = new Vue({
11-
el: Vue.version.startsWith('2') ? button : button.parentElement,
17+
el: Vue.version.startsWith('2') ? button : menuContainer,
1218
name: 'GlDisclosureDropdown',
1319
render: (createElement = Vue.h) =>
1420
createElement(GlDisclosureDropdown, {
@@ -18,6 +24,7 @@ export const OptionsMenuAdapter = {
1824
noCaret: true,
1925
category: 'tertiary',
2026
size: 'small',
27+
items,
2128
},
2229
}),
2330
});

app/components/rapid_diffs/diff_file_header_component.html.haml

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
-# * toggle file comments
1212
-# * submodule compare
1313
14+
- view_title = _('View file @ %{commitSha}') % { commitSha: Commit.truncate_sha(@diff_file.content_sha) }
15+
- view_href = project_blob_path(@diff_file.repository.project, helpers.tree_join(@diff_file.content_sha, @diff_file.new_path))
16+
- options_menu_items = [ { "text": "#{view_title}", "href": "#{view_href}" } ].to_json
17+
1418
.rd-diff-file-header{ data: { testid: 'rd-diff-file-header' } }
1519
.rd-diff-file-toggle<
1620
= render Pajamas::ButtonComponent.new(category: :tertiary, size: :small, icon: 'chevron-down', button_options: { class: 'rd-diff-file-toggle-button', data: { opened: '', click: 'toggleFile' }, aria: { label: _('Hide file contents') } })
@@ -51,4 +55,7 @@
5155
%span{ "data-testid" => "js-file-deletion-line" }= @diff_file.removed_lines
5256
.rd-diff-file-options-menu
5357
.js-options-menu
58+
-# <script> here is likely the most effective way to minimize bytes: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/182850#note_2387011092
59+
%script{ type: "application/json" }
60+
= options_menu_items.html_safe
5461
= render Pajamas::ButtonComponent.new(category: :tertiary, size: :small, icon: 'ellipsis_v', button_options: { class: 'js-options-button', data: { click: 'toggleOptionsMenu' }, aria: { label: _('Options') } })

app/models/issue.rb

+8
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,14 @@ def autoclose_by_merged_closing_merge_request?
817817
project.autoclose_referenced_issues
818818
end
819819

820+
def epic_work_item?
821+
work_item_type&.epic?
822+
end
823+
824+
def group_epic_work_item?
825+
epic_work_item? && group_level?
826+
end
827+
820828
private
821829

822830
def project_level_readable_by?(user)

app/policies/issue_policy.rb

+19-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ def epics_license_available?
1313
false
1414
end
1515

16+
# Not available in FOSS.
17+
# This method is Overridden in EE
18+
def project_work_item_epics_available?
19+
false
20+
end
21+
1622
# rubocop:disable Cop/UserAdmin -- specifically check the admin attribute
1723
desc "User can read confidential issues"
1824
condition(:can_read_confidential) do
@@ -47,17 +53,22 @@ def epics_license_available?
4753
end
4854
end
4955

50-
# group level issues license for now is equivalent to epics license. We'll have to migrate epics license to
51-
# work items context once epics are fully migrated to work items.
52-
condition(:group_level_issues_license_available) do
53-
epics_license_available?
54-
end
55-
5656
# this is temporarily needed until we rollout implementation of move and clone for all work item types
5757
condition(:supports_move_and_clone, scope: :subject) do
5858
@subject.supports_move_and_clone?
5959
end
6060

61+
condition(:work_item_type_available, scope: :subject) do
62+
if group_issue?
63+
# For now all work item types at group-level require the epics licensed feature
64+
epics_license_available?
65+
elsif @subject.epic_work_item?
66+
project_work_item_epics_available?
67+
else
68+
true
69+
end
70+
end
71+
6172
rule { group_issue & can?(:read_group) }.policy do
6273
enable :create_note
6374
end
@@ -168,9 +179,9 @@ def epics_license_available?
168179
prevent :destroy_issue
169180
end
170181

171-
# IMPORTANT: keep the prevent rules as last rules defined in the policy, as these are based on
182+
# IMPORTANT: keep the prevention rules as last rules defined in the policy, as these are based on
172183
# all abilities defined up to this point.
173-
rule { group_issue & ~group_level_issues_license_available }.policy do
184+
rule { ~work_item_type_available }.policy do
174185
prevent(*::IssuePolicy.ability_map.map.keys)
175186
end
176187
end

app/policies/work_item_policy.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class WorkItemPolicy < IssuePolicy
4141
prevent :delete_work_item
4242
end
4343

44+
rule { can_report_spam }.enable :report_spam
45+
4446
# IMPORTANT: keep the prevent rules as last rules defined in the policy, as these are based on
4547
# all abilities defined up to this point.
46-
rule { group_issue & ~group_level_issues_license_available }.policy do
48+
rule { ~work_item_type_available }.policy do
4749
prevent(*::WorkItemPolicy.ability_map.map.keys)
4850
end
49-
50-
rule { can_report_spam }.enable :report_spam
5151
end
5252

5353
WorkItemPolicy.prepend_mod

app/services/import/placeholder_memberships/create_service.rb

+26-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ module PlaceholderMemberships
55
class CreateService
66
include Services::ReturnServiceResponses
77

8-
def initialize(source_user:, access_level:, expires_at: nil, group: nil, project: nil)
8+
def initialize(
9+
source_user:, access_level:, expires_at: nil, group: nil, project: nil,
10+
ignore_duplicate_errors: false)
11+
@ignore_duplicate_errors = ignore_duplicate_errors
912
@reference = Import::Placeholders::Membership.new(
1013
source_user: source_user,
1114
namespace_id: source_user.namespace_id,
@@ -19,12 +22,33 @@ def initialize(source_user:, access_level:, expires_at: nil, group: nil, project
1922
def execute
2023
return success(reference: reference) if reference.save
2124

25+
if ignore_duplicate_errors?(reference)
26+
log_duplicate_membership
27+
return success(reference: reference)
28+
end
29+
2230
error(reference.errors.full_messages, :bad_request)
2331
end
2432

2533
private
2634

27-
attr_reader :reference
35+
attr_reader :reference, :ignore_duplicate_errors
36+
37+
def ignore_duplicate_errors?(reference)
38+
ignore_duplicate_errors && (reference.errors.of_kind?(:project_id, :taken) ||
39+
reference.errors.of_kind?(:group_id, :taken))
40+
end
41+
42+
def log_duplicate_membership
43+
logger.info(
44+
message: 'Project or group has already been taken. Skipping placeholder membership creation',
45+
reference: reference
46+
)
47+
end
48+
49+
def logger
50+
@logger ||= ::Import::Framework::Logger.build
51+
end
2852
end
2953
end
3054
end

db/migrate/20240820135108_create_ai_code_suggestion_events.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class CreateAiCodeSuggestionEvents < Gitlab::Database::Migration[2.2]
66

77
def up
88
# rubocop:disable Migration/Datetime -- "timestamp" is a column name
9-
create_table :ai_code_suggestion_events, # rubocop:disable Migration/EnsureFactoryForTable -- code_suggestion_event
9+
create_table :ai_code_suggestion_events,
1010
options: 'PARTITION BY RANGE (timestamp)',
1111
primary_key: [:id, :timestamp] do |t|
1212
t.bigserial :id, null: false

doc/.vale/gitlab_docs/FrontMatter.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ script: |
3737
hasError = true
3838
}
3939
40-
// First check if we have a title key at all
41-
hasTitleKey := text.re_match("(?m)^[tT]itle:", frontmatter)
42-
// Then check if it has content (anything but whitespace) after the colon
43-
hasValidTitle := text.re_match("(?m)^[tT]itle:[^\\n]*[^\\s][^\\n]*$", frontmatter)
40+
// Check if the page has redirect_to (these pages don't need titles)
41+
hasRedirectTo := text.re_match("(?m)^redirect_to:", frontmatter)
4442
45-
if !hasError && (!hasTitleKey || !hasValidTitle) {
46-
hasError = true
43+
if !hasRedirectTo {
44+
// First check if we have a title key at all
45+
hasTitleKey := text.re_match("(?m)^[tT]itle:", frontmatter)
46+
// Then check if it has content (anything but whitespace) after the colon
47+
hasValidTitle := text.re_match("(?m)^[tT]itle:[^\\n]*[^\\s][^\\n]*$", frontmatter)
48+
49+
if !hasError && (!hasTitleKey || !hasValidTitle) {
50+
hasError = true
51+
}
4752
}
4853
}
4954

0 commit comments

Comments
 (0)