Skip to content

Commit 39623d6

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 5da9546 commit 39623d6

File tree

26 files changed

+418
-135
lines changed

26 files changed

+418
-135
lines changed

app/assets/javascripts/search/store/actions.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { visitUrl, setUrlParams } from '~/lib/utils/url_utility';
44
import { __ } from '~/locale';
55
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from './constants';
66
import * as types from './mutation_types';
7-
import { loadDataFromLS, setFrequentItemToLS } from './utils';
7+
import { loadDataFromLS, setFrequentItemToLS, mergeById } from './utils';
88

99
export const fetchGroups = ({ commit }, search) => {
1010
commit(types.REQUEST_GROUPS);
@@ -41,14 +41,30 @@ export const fetchProjects = ({ commit, state }, search) => {
4141
}
4242
};
4343

44-
export const loadFrequentGroups = ({ commit }) => {
44+
export const loadFrequentGroups = async ({ commit }) => {
4545
const data = loadDataFromLS(GROUPS_LOCAL_STORAGE_KEY);
4646
commit(types.LOAD_FREQUENT_ITEMS, { key: GROUPS_LOCAL_STORAGE_KEY, data });
47+
48+
const promises = data.map((d) => Api.group(d.id));
49+
try {
50+
const inflatedData = mergeById(await Promise.all(promises), data);
51+
commit(types.LOAD_FREQUENT_ITEMS, { key: GROUPS_LOCAL_STORAGE_KEY, data: inflatedData });
52+
} catch {
53+
createFlash({ message: __('There was a problem fetching recent groups.') });
54+
}
4755
};
4856

49-
export const loadFrequentProjects = ({ commit }) => {
57+
export const loadFrequentProjects = async ({ commit }) => {
5058
const data = loadDataFromLS(PROJECTS_LOCAL_STORAGE_KEY);
5159
commit(types.LOAD_FREQUENT_ITEMS, { key: PROJECTS_LOCAL_STORAGE_KEY, data });
60+
61+
const promises = data.map((d) => Api.project(d.id).then((res) => res.data));
62+
try {
63+
const inflatedData = mergeById(await Promise.all(promises), data);
64+
commit(types.LOAD_FREQUENT_ITEMS, { key: PROJECTS_LOCAL_STORAGE_KEY, data: inflatedData });
65+
} catch {
66+
createFlash({ message: __('There was a problem fetching recent projects.') });
67+
}
5268
};
5369

5470
export const setFrequentGroup = ({ state }, item) => {

app/assets/javascripts/search/store/utils.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import AccessorUtilities from '../../lib/utils/accessor';
22
import { MAX_FREQUENT_ITEMS, MAX_FREQUENCY } from './constants';
33

4+
function extractKeys(object, keyList) {
5+
return Object.fromEntries(keyList.map((key) => [key, object[key]]));
6+
}
7+
48
export const loadDataFromLS = (key) => {
59
if (!AccessorUtilities.isLocalStorageAccessSafe()) {
610
return [];
@@ -15,13 +19,16 @@ export const loadDataFromLS = (key) => {
1519
}
1620
};
1721

18-
export const setFrequentItemToLS = (key, data, item) => {
22+
export const setFrequentItemToLS = (key, data, itemData) => {
1923
if (!AccessorUtilities.isLocalStorageAccessSafe()) {
2024
return;
2125
}
2226

27+
const keyList = ['id', 'avatar_url', 'name', 'full_name', 'name_with_namespace', 'frequency'];
28+
2329
try {
24-
const frequentItems = data[key];
30+
const frequentItems = data[key].map((obj) => extractKeys(obj, keyList));
31+
const item = extractKeys(itemData, keyList);
2532
const existingItemIndex = frequentItems.findIndex((i) => i.id === item.id);
2633

2734
if (existingItemIndex >= 0) {
@@ -34,7 +41,7 @@ export const setFrequentItemToLS = (key, data, item) => {
3441
frequentItems.pop();
3542
}
3643

37-
frequentItems.push({ id: item.id, frequency: 1 });
44+
frequentItems.push({ ...item, frequency: 1 });
3845
}
3946

4047
// Sort by frequency
@@ -48,3 +55,10 @@ export const setFrequentItemToLS = (key, data, item) => {
4855
localStorage.removeItem(key);
4956
}
5057
};
58+
59+
export const mergeById = (inflatedData, storedData) => {
60+
return inflatedData.map((data) => {
61+
const stored = storedData?.find((d) => d.id === data.id) || {};
62+
return { ...stored, ...data };
63+
});
64+
};

app/assets/javascripts/search/topbar/components/group_filter.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export default {
2323
return isEmpty(this.initialData) ? ANY_OPTION : this.initialData;
2424
},
2525
},
26-
created() {
27-
this.loadFrequentGroups();
28-
},
2926
methods: {
3027
...mapActions(['fetchGroups', 'setFrequentGroup', 'loadFrequentGroups']),
3128
handleGroupChange(group) {
@@ -52,6 +49,7 @@ export default {
5249
:loading="fetchingGroups"
5350
:selected-item="selectedGroup"
5451
:items="groups"
52+
@first-open="loadFrequentGroups"
5553
@search="fetchGroups"
5654
@change="handleGroupChange"
5755
/>

app/assets/javascripts/search/topbar/components/project_filter.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ export default {
2222
return this.initialData ? this.initialData : ANY_OPTION;
2323
},
2424
},
25-
created() {
26-
this.loadFrequentProjects();
27-
},
2825
methods: {
2926
...mapActions(['fetchProjects', 'setFrequentProject', 'loadFrequentProjects']),
3027
handleProjectChange(project) {
@@ -55,6 +52,7 @@ export default {
5552
:loading="fetchingProjects"
5653
:selected-item="selectedProject"
5754
:items="projects"
55+
@first-open="loadFrequentProjects"
5856
@search="fetchProjects"
5957
@change="handleProjectChange"
6058
/>

app/assets/javascripts/search/topbar/components/searchable_dropdown.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ export default {
6565
data() {
6666
return {
6767
searchText: '',
68+
hasBeenOpened: false,
6869
};
6970
},
7071
methods: {
7172
isSelected(selected) {
7273
return selected.id === this.selectedItem.id;
7374
},
7475
openDropdown() {
76+
if (!this.hasBeenOpened) {
77+
this.hasBeenOpened = true;
78+
this.$emit('first-open');
79+
}
80+
7581
this.$emit('search', this.searchText);
7682
},
7783
resetDropdown() {

app/graphql/types/ci/runner_type.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ class RunnerType < BaseObject
2525
description: 'Indicates the runner is allowed to receive jobs.'
2626
field :status, ::Types::Ci::RunnerStatusEnum, null: false,
2727
description: 'Status of the runner.'
28-
field :version, GraphQL::STRING_TYPE, null: false,
28+
field :version, GraphQL::STRING_TYPE, null: true,
2929
description: 'Version of the runner.'
3030
field :short_sha, GraphQL::STRING_TYPE, null: true,
3131
description: %q(First eight characters of the runner's token used to authenticate new job requests. Used as the runner's unique ID.)
32-
field :revision, GraphQL::STRING_TYPE, null: false,
32+
field :revision, GraphQL::STRING_TYPE, null: true,
3333
description: 'Revision of the runner.'
3434
field :locked, GraphQL::BOOLEAN_TYPE, null: true,
3535
description: 'Indicates the runner is locked.'
3636
field :run_untagged, GraphQL::BOOLEAN_TYPE, null: false,
3737
description: 'Indicates the runner is able to run untagged jobs.'
38-
field :ip_address, GraphQL::STRING_TYPE, null: false,
38+
field :ip_address, GraphQL::STRING_TYPE, null: true,
3939
description: 'IP address of the runner.'
4040
field :runner_type, ::Types::Ci::RunnerTypeEnum, null: false,
4141
description: 'Type of the runner.'

app/models/application_setting/term.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
class ApplicationSetting
44
class Term < ApplicationRecord
55
include CacheMarkdownField
6-
has_many :term_agreements
6+
include NullifyIfBlank
77

8-
validates :terms, presence: true
8+
has_many :term_agreements
99

1010
cache_markdown_field :terms
1111

12+
nullify_if_blank :terms
13+
1214
def self.latest
1315
order(:id).last
1416
end

app/models/integrations/campfire.rb

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module Integrations
44
class Campfire < Integration
5+
include ActionView::Helpers::UrlHelper
6+
57
prop_accessor :token, :subdomain, :room
68
validates :token, presence: true, if: :activated?
79

@@ -13,15 +15,39 @@ def description
1315
'Send notifications about push events to Campfire chat rooms.'
1416
end
1517

18+
def help
19+
docs_link = link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('api/services', anchor: 'campfire'), target: '_blank', rel: 'noopener noreferrer'
20+
s_('CampfireService|Send notifications about push events to Campfire chat rooms. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
21+
end
22+
1623
def self.to_param
1724
'campfire'
1825
end
1926

2027
def fields
2128
[
22-
{ type: 'text', name: 'token', placeholder: '', required: true },
23-
{ type: 'text', name: 'subdomain', placeholder: '' },
24-
{ type: 'text', name: 'room', placeholder: '' }
29+
{
30+
type: 'text',
31+
name: 'token',
32+
title: _('Campfire token'),
33+
placeholder: '',
34+
help: s_('CampfireService|API authentication token from Campfire.'),
35+
required: true
36+
},
37+
{
38+
type: 'text',
39+
name: 'subdomain',
40+
title: _('Campfire subdomain (optional)'),
41+
placeholder: '',
42+
help: s_('CampfireService|The %{code_open}.campfirenow.com%{code_close} subdomain.') % { code_open: '<code>'.html_safe, code_close: '</code>'.html_safe }
43+
},
44+
{
45+
type: 'text',
46+
name: 'room',
47+
title: _('Campfire room ID (optional)'),
48+
placeholder: '123456',
49+
help: s_('CampfireService|From the end of the room URL.')
50+
}
2551
]
2652
end
2753

app/services/application_settings/update_service.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ def invalidate_markdown_cache?
6767
end
6868

6969
def update_terms(terms)
70-
return unless terms.present?
71-
7270
# Avoid creating a new terms record if the text is exactly the same.
73-
terms = terms.strip
71+
terms = terms&.strip
7472
return if terms == @application_setting.terms
7573

7674
ApplicationSetting::Term.create(terms: terms)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
class CreateVulnerabilityFindingEvidenceSources < ActiveRecord::Migration[6.1]
4+
include Gitlab::Database::MigrationHelpers
5+
6+
disable_ddl_transaction!
7+
8+
def up
9+
create_table_with_constraints :vulnerability_finding_evidence_sources do |t|
10+
t.timestamps_with_timezone null: false
11+
12+
t.references :vulnerability_finding_evidence, index: { name: 'finding_evidence_sources_on_finding_evidence_id' }, null: false, foreign_key: { on_delete: :cascade }
13+
t.text :name
14+
t.text :url
15+
16+
t.text_limit :name, 2048
17+
t.text_limit :url, 2048
18+
end
19+
end
20+
21+
def down
22+
with_lock_retries do
23+
drop_table :vulnerability_finding_evidence_sources
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)