Skip to content

Commit 999f47e

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 20bd3b7 commit 999f47e

File tree

109 files changed

+1274
-30044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1274
-30044
lines changed

app/assets/javascripts/lib/utils/axios_startup_calls.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ const setupAxiosStartupCalls = axios => {
3434
});
3535

3636
// eslint-disable-next-line promise/no-nesting
37-
return res.json().then(data => ({
38-
data,
39-
status: res.status,
40-
statusText: res.statusText,
41-
headers: fetchHeaders,
42-
config: req,
43-
request: req,
44-
}));
37+
return res
38+
.clone()
39+
.json()
40+
.then(data => ({
41+
data,
42+
status: res.status,
43+
statusText: res.statusText,
44+
headers: fetchHeaders,
45+
config: req,
46+
request: req,
47+
}));
4548
});
4649
}
4750

app/assets/javascripts/monitoring/components/dashboard_actions_menu.vue

+43-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
GlTooltipDirective,
1212
} from '@gitlab/ui';
1313
import CustomMetricsFormFields from '~/custom_metrics/components/custom_metrics_form_fields.vue';
14+
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
15+
import { PANEL_NEW_PAGE } from '../router/constants';
1416
import DuplicateDashboardModal from './duplicate_dashboard_modal.vue';
1517
import CreateDashboardModal from './create_dashboard_modal.vue';
1618
import { s__ } from '~/locale';
@@ -36,6 +38,7 @@ export default {
3638
GlTooltip: GlTooltipDirective,
3739
TrackEvent: TrackEventDirective,
3840
},
41+
mixins: [glFeatureFlagsMixin()],
3942
props: {
4043
addingMetricsAvailable: {
4144
type: Boolean,
@@ -56,6 +59,10 @@ export default {
5659
type: String,
5760
required: true,
5861
},
62+
isOotbDashboard: {
63+
type: Boolean,
64+
required: true,
65+
},
5966
},
6067
data() {
6168
return { customMetricsFormIsValid: null };
@@ -72,15 +79,22 @@ export default {
7279
},
7380
isMenuItemEnabled() {
7481
return {
82+
addPanel: !this.isOotbDashboard,
7583
createDashboard: Boolean(this.projectPath),
7684
editDashboard: this.selectedDashboard?.can_edit,
7785
};
7886
},
7987
isMenuItemShown() {
8088
return {
89+
addPanel: this.glFeatures.metricsDashboardNewPanelPage,
8190
duplicateDashboard: this.isOutOfTheBoxDashboard,
8291
};
8392
},
93+
newPanelPageLocation() {
94+
// Retains params/query if any
95+
const { params, query } = this.$route ?? {};
96+
return { name: PANEL_NEW_PAGE, params, query };
97+
},
8498
},
8599
methods: {
86100
...mapActions('monitoringDashboard', ['toggleStarredValue']),
@@ -117,7 +131,9 @@ export default {
117131
starDashboard: s__('Metrics|Star dashboard'),
118132
unstarDashboard: s__('Metrics|Unstar dashboard'),
119133
addMetric: s__('Metrics|Add metric'),
120-
editDashboardInfo: s__('Metrics|Duplicate this dashboard to edit dashboard YAML'),
134+
addPanel: s__('Metrics|Add panel'),
135+
addPanelInfo: s__('Metrics|Duplicate this dashboard to add panel or edit dashboard YAML.'),
136+
editDashboardInfo: s__('Metrics|Duplicate this dashboard to add panel or edit dashboard YAML.'),
121137
editDashboard: s__('Metrics|Edit dashboard YAML'),
122138
createDashboard: s__('Metrics|Create new dashboard'),
123139
},
@@ -176,6 +192,32 @@ export default {
176192
</gl-modal>
177193
</template>
178194
195+
<template v-if="isMenuItemShown.addPanel">
196+
<gl-new-dropdown-item
197+
v-if="isMenuItemEnabled.addPanel"
198+
data-testid="add-panel-item-enabled"
199+
:to="newPanelPageLocation"
200+
>
201+
{{ $options.i18n.addPanel }}
202+
</gl-new-dropdown-item>
203+
204+
<!--
205+
wrapper for tooltip as button can be `disabled`
206+
https://bootstrap-vue.org/docs/components/tooltip#disabled-elements
207+
-->
208+
<div v-else v-gl-tooltip :title="$options.i18n.addPanelInfo">
209+
<gl-new-dropdown-item
210+
:alt="$options.i18n.addPanelInfo"
211+
:to="newPanelPageLocation"
212+
data-testid="add-panel-item-disabled"
213+
disabled
214+
class="gl-cursor-not-allowed"
215+
>
216+
<span class="gl-text-gray-400">{{ $options.i18n.addPanel }}</span>
217+
</gl-new-dropdown-item>
218+
</div>
219+
</template>
220+
179221
<gl-new-dropdown-item
180222
v-if="isMenuItemEnabled.editDashboard"
181223
:href="selectedDashboard ? selectedDashboard.project_blob_path : null"

app/assets/javascripts/monitoring/components/dashboard_header.vue

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ export default {
118118
shouldShowSettingsButton() {
119119
return this.canAccessOperationsSettings && this.operationsSettingsPath;
120120
},
121+
isOOTBDashboard() {
122+
return this.selectedDashboard?.out_of_the_box_dashboard ?? false;
123+
},
121124
},
122125
methods: {
123126
...mapActions('monitoringDashboard', ['filterEnvironments']),
@@ -266,6 +269,7 @@ export default {
266269
:custom-metrics-path="customMetricsPath"
267270
:validate-query-path="validateQueryPath"
268271
:default-branch="defaultBranch"
272+
:is-ootb-dashboard="isOOTBDashboard"
269273
/>
270274
</div>
271275

app/assets/javascripts/monitoring/queries/getAnnotations.query.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query getAnnotations(
55
$startingFrom: Time!
66
) {
77
project(fullPath: $projectPath) {
8+
id
89
environments(name: $environmentName) {
910
nodes {
1011
id

app/assets/javascripts/monitoring/queries/getEnvironments.query.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
query getEnvironments($projectPath: ID!, $search: String, $states: [String!]) {
22
project(fullPath: $projectPath) {
3+
id
34
data: environments(search: $search, states: $states) {
45
environments: nodes {
56
name

app/assets/javascripts/monitoring/router/routes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { DASHBOARD_PAGE, PANEL_NEW_PAGE } from './constants';
1313
export default [
1414
{
1515
name: PANEL_NEW_PAGE,
16-
path: '/:dashboard(.*)?/panel/new',
16+
path: '/:dashboard(.+)?/panel/new',
1717
component: PanelNewPage,
1818
},
1919
{
2020
name: DASHBOARD_PAGE,
21-
path: '/:dashboard(.*)?',
21+
path: '/:dashboard(.+)?',
2222
component: DashboardPage,
2323
},
2424
];

app/assets/javascripts/notes/components/notes_app.vue

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ export default {
136136
}
137137
138138
window.addEventListener('hashchange', this.handleHashChanged);
139+
140+
eventHub.$on('notesApp.updateIssuableConfidentiality', this.setConfidentiality);
139141
},
140142
updated() {
141143
this.$nextTick(() => {
@@ -146,6 +148,7 @@ export default {
146148
beforeDestroy() {
147149
this.stopPolling();
148150
window.removeEventListener('hashchange', this.handleHashChanged);
151+
eventHub.$off('notesApp.updateIssuableConfidentiality', this.setConfidentiality);
149152
},
150153
methods: {
151154
...mapActions([
@@ -164,6 +167,7 @@ export default {
164167
'startTaskList',
165168
'convertToDiscussion',
166169
'stopPolling',
170+
'setConfidentiality',
167171
]),
168172
discussionIsIndividualNoteAndNotConverted(discussion) {
169173
return discussion.individual_note && !this.convertedDisscussionIds.includes(discussion.id);

app/assets/javascripts/notes/stores/actions.js

+26-23
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@ import Api from '~/api';
2121

2222
let eTagPoll;
2323

24-
export const updateConfidentialityOnIssue = ({ commit, getters }, { confidential, fullPath }) => {
25-
const { iid } = getters.getNoteableData;
26-
27-
return utils.gqClient
28-
.mutate({
29-
mutation: updateIssueConfidentialMutation,
30-
variables: {
31-
input: {
32-
projectPath: fullPath,
33-
iid: String(iid),
34-
confidential,
35-
},
36-
},
37-
})
38-
.then(({ data }) => {
39-
const {
40-
issueSetConfidential: { issue },
41-
} = data;
42-
43-
commit(types.SET_ISSUE_CONFIDENTIAL, issue.confidential);
44-
});
45-
};
46-
4724
export const updateLockedAttribute = ({ commit, getters }, { locked, fullPath }) => {
4825
const { iid, targetType } = getters.getNoteableData;
4926

@@ -712,3 +689,29 @@ export const updateAssignees = ({ commit }, assignees) => {
712689
export const updateDiscussionPosition = ({ commit }, updatedPosition) => {
713690
commit(types.UPDATE_DISCUSSION_POSITION, updatedPosition);
714691
};
692+
693+
export const updateConfidentialityOnIssuable = (
694+
{ getters, commit },
695+
{ confidential, fullPath },
696+
) => {
697+
const { iid } = getters.getNoteableData;
698+
699+
return utils.gqClient
700+
.mutate({
701+
mutation: updateIssueConfidentialMutation,
702+
variables: {
703+
input: {
704+
projectPath: fullPath,
705+
iid: String(iid),
706+
confidential,
707+
},
708+
},
709+
})
710+
.then(({ data }) => {
711+
const {
712+
issueSetConfidential: { issue },
713+
} = data;
714+
715+
setConfidentiality({ commit }, issue.confidential);
716+
});
717+
};

app/assets/javascripts/pages/projects/commit/show/index.js

+37-13
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,47 @@ import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
77
import MiniPipelineGraph from '~/mini_pipeline_graph_dropdown';
88
import initNotes from '~/init_notes';
99
import initChangesDropdown from '~/init_changes_dropdown';
10-
import initDiffNotes from '~/diff_notes/diff_notes_bundle';
1110
import { fetchCommitMergeRequests } from '~/commit_merge_requests';
1211
import '~/sourcegraph/load';
12+
import { handleLocationHash } from '~/lib/utils/common_utils';
13+
import axios from '~/lib/utils/axios_utils';
14+
import syntaxHighlight from '~/syntax_highlight';
15+
import flash from '~/flash';
16+
import { __ } from '~/locale';
1317

1418
document.addEventListener('DOMContentLoaded', () => {
1519
const hasPerfBar = document.querySelector('.with-performance-bar');
1620
const performanceHeight = hasPerfBar ? 35 : 0;
17-
new Diff();
18-
new ZenMode();
19-
new ShortcutsNavigation();
20-
new MiniPipelineGraph({
21-
container: '.js-commit-pipeline-graph',
22-
}).bindEvents();
23-
initNotes();
24-
initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight + performanceHeight);
25-
// eslint-disable-next-line no-jquery/no-load
26-
$('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
27-
fetchCommitMergeRequests();
28-
initDiffNotes();
21+
const filesContainer = $('.js-diffs-batch');
22+
const initAfterPageLoad = () => {
23+
new Diff();
24+
new ZenMode();
25+
new ShortcutsNavigation();
26+
new MiniPipelineGraph({
27+
container: '.js-commit-pipeline-graph',
28+
}).bindEvents();
29+
initNotes();
30+
initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight + performanceHeight);
31+
// eslint-disable-next-line no-jquery/no-load
32+
$('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
33+
fetchCommitMergeRequests();
34+
};
35+
36+
if (filesContainer.length) {
37+
const batchPath = filesContainer.data('diffFilesPath');
38+
39+
axios
40+
.get(batchPath)
41+
.then(({ data }) => {
42+
filesContainer.html($(data.html));
43+
syntaxHighlight(filesContainer);
44+
handleLocationHash();
45+
initAfterPageLoad();
46+
})
47+
.catch(() => {
48+
flash(__('An error occurred while retrieving diff files'));
49+
});
50+
} else {
51+
initAfterPageLoad();
52+
}
2953
});

0 commit comments

Comments
 (0)