Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-01-26 09:09:23 +00:00
parent 71616b047e
commit 6fb22ef2ea
9 changed files with 106 additions and 22 deletions

View File

@ -4,6 +4,7 @@ import { s__ } from '~/locale';
import getPipelineCountByStatus from '../graphql/queries/get_pipeline_count_by_status.query.graphql'; import getPipelineCountByStatus from '../graphql/queries/get_pipeline_count_by_status.query.graphql';
import getProjectPipelineStatistics from '../graphql/queries/get_project_pipeline_statistics.query.graphql'; import getProjectPipelineStatistics from '../graphql/queries/get_project_pipeline_statistics.query.graphql';
import PipelineCharts from './pipeline_charts.vue'; import PipelineCharts from './pipeline_charts.vue';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import { import {
DEFAULT, DEFAULT,
@ -36,6 +37,8 @@ const defaultCountValues = {
}, },
}; };
const charts = ['pipelines', 'deployments'];
export default { export default {
components: { components: {
GlAlert, GlAlert,
@ -56,7 +59,11 @@ export default {
}, },
}, },
data() { data() {
const [chart] = getParameterValues('chart') || charts;
const tab = charts.indexOf(chart);
return { return {
chart,
selectedTab: tab >= 0 ? tab : 0,
showFailureAlert: false, showFailureAlert: false,
failureType: null, failureType: null,
analytics: { ...defaultAnalyticsValues }, analytics: { ...defaultAnalyticsValues },
@ -172,6 +179,11 @@ export default {
this.showFailureAlert = true; this.showFailureAlert = true;
this.failureType = type; this.failureType = type;
}, },
onTabChange(index) {
this.selectedTab = index;
const path = mergeUrlParams({ chart: charts[index] }, window.location.pathname);
updateHistory({ url: path });
},
}, },
errorTexts: { errorTexts: {
[LOAD_ANALYTICS_FAILURE]: s__( [LOAD_ANALYTICS_FAILURE]: s__(
@ -190,7 +202,7 @@ export default {
<gl-alert v-if="showFailureAlert" :variant="failure.variant" @dismiss="hideAlert">{{ <gl-alert v-if="showFailureAlert" :variant="failure.variant" @dismiss="hideAlert">{{
failure.text failure.text
}}</gl-alert> }}</gl-alert>
<gl-tabs v-if="shouldRenderDeploymentFrequencyCharts"> <gl-tabs v-if="shouldRenderDeploymentFrequencyCharts" :value="selectedTab" @input="onTabChange">
<gl-tab :title="__('Pipelines')"> <gl-tab :title="__('Pipelines')">
<pipeline-charts <pipeline-charts
:counts="formattedCounts" :counts="formattedCounts"

View File

@ -1,9 +1,13 @@
<script> <script>
/* eslint-disable vue/no-v-html */ /* eslint-disable vue/no-v-html */
import emptyStateSVG from 'icons/_mr_widget_empty_state.svg'; import emptyStateSVG from 'icons/_mr_widget_empty_state.svg';
import { GlButton } from '@gitlab/ui';
export default { export default {
name: 'MRWidgetNothingToMerge', name: 'MRWidgetNothingToMerge',
components: {
GlButton,
},
props: { props: {
mr: { mr: {
type: Object, type: Object,
@ -25,11 +29,13 @@ export default {
<span v-html="emptyStateSVG"></span> <span v-html="emptyStateSVG"></span>
</div> </div>
<div class="text col-md-7 order-md-first col-12"> <div class="text col-md-7 order-md-first col-12">
<span>{{ <p class="highlight">
s__( {{
'mrWidgetNothingToMerge|Merge requests are a place to propose changes you have made to a project and discuss those changes with others.', s__(
) 'mrWidgetNothingToMerge|Merge requests are a place to propose changes you have made to a project and discuss those changes with others.',
}}</span> )
}}
</p>
<p> <p>
{{ {{
s__( s__(
@ -45,9 +51,14 @@ export default {
}} }}
</p> </p>
<div> <div>
<a v-if="mr.newBlobPath" :href="mr.newBlobPath" class="btn btn-inverted btn-success">{{ <gl-button
__('Create file') v-if="mr.newBlobPath"
}}</a> :href="mr.newBlobPath"
category="secondary"
variant="success"
>
{{ __('Create file') }}
</gl-button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -375,13 +375,14 @@ $mr-widget-min-height: 69px;
} }
.text { .text {
span {
font-weight: $gl-font-weight-bold;
}
p { p {
margin-top: $gl-padding; margin-top: $gl-padding;
} }
.highlight {
margin: 0 0 $gl-padding;
font-weight: $gl-font-weight-bold;
}
} }
} }

View File

@ -0,0 +1,5 @@
---
title: Apply GitLab UI for create file button in MR
merge_request: 51795
author: Yogi (@yo)
type: other

View File

@ -11261,7 +11261,7 @@ type Group {
): [VulnerableProjectsByGrade!]! ): [VulnerableProjectsByGrade!]!
""" """
Vulnerability scanners reported on the project vulnerabilties of the group and its subgroups Vulnerability scanners reported on the project vulnerabilities of the group and its subgroups
""" """
vulnerabilityScanners( vulnerabilityScanners(
""" """
@ -11966,7 +11966,7 @@ type InstanceSecurityDashboard {
vulnerabilityGrades: [VulnerableProjectsByGrade!]! vulnerabilityGrades: [VulnerableProjectsByGrade!]!
""" """
Vulnerability scanners reported on the vulnerabilties from projects selected in Instance Security Dashboard Vulnerability scanners reported on the vulnerabilities from projects selected in Instance Security Dashboard
""" """
vulnerabilityScanners( vulnerabilityScanners(
""" """
@ -19650,7 +19650,7 @@ type Project {
): VulnerabilitiesCountByDayConnection ): VulnerabilitiesCountByDayConnection
""" """
Vulnerability scanners reported on the project vulnerabilties Vulnerability scanners reported on the project vulnerabilities
""" """
vulnerabilityScanners( vulnerabilityScanners(
""" """

View File

@ -30680,7 +30680,7 @@
}, },
{ {
"name": "vulnerabilityScanners", "name": "vulnerabilityScanners",
"description": "Vulnerability scanners reported on the project vulnerabilties of the group and its subgroups", "description": "Vulnerability scanners reported on the project vulnerabilities of the group and its subgroups",
"args": [ "args": [
{ {
"name": "after", "name": "after",
@ -32690,7 +32690,7 @@
}, },
{ {
"name": "vulnerabilityScanners", "name": "vulnerabilityScanners",
"description": "Vulnerability scanners reported on the vulnerabilties from projects selected in Instance Security Dashboard", "description": "Vulnerability scanners reported on the vulnerabilities from projects selected in Instance Security Dashboard",
"args": [ "args": [
{ {
"name": "after", "name": "after",
@ -57062,7 +57062,7 @@
}, },
{ {
"name": "vulnerabilityScanners", "name": "vulnerabilityScanners",
"description": "Vulnerability scanners reported on the project vulnerabilties", "description": "Vulnerability scanners reported on the project vulnerabilities",
"args": [ "args": [
{ {
"name": "after", "name": "after",

View File

@ -1693,7 +1693,7 @@ Autogenerated return type of GitlabSubscriptionActivate.
| `vulnerabilitiesCountByDay` | VulnerabilitiesCountByDayConnection | Number of vulnerabilities per day for the projects in the group and its subgroups | | `vulnerabilitiesCountByDay` | VulnerabilitiesCountByDayConnection | Number of vulnerabilities per day for the projects in the group and its subgroups |
| `vulnerabilitiesCountByDayAndSeverity` **{warning-solid}** | VulnerabilitiesCountByDayAndSeverityConnection | **Deprecated:** Use `vulnerabilitiesCountByDay`. Deprecated in 13.3. | | `vulnerabilitiesCountByDayAndSeverity` **{warning-solid}** | VulnerabilitiesCountByDayAndSeverityConnection | **Deprecated:** Use `vulnerabilitiesCountByDay`. Deprecated in 13.3. |
| `vulnerabilityGrades` | VulnerableProjectsByGrade! => Array | Represents vulnerable project counts for each grade | | `vulnerabilityGrades` | VulnerableProjectsByGrade! => Array | Represents vulnerable project counts for each grade |
| `vulnerabilityScanners` | VulnerabilityScannerConnection | Vulnerability scanners reported on the project vulnerabilties of the group and its subgroups | | `vulnerabilityScanners` | VulnerabilityScannerConnection | Vulnerability scanners reported on the project vulnerabilities of the group and its subgroups |
| `vulnerabilitySeveritiesCount` | VulnerabilitySeveritiesCount | Counts for each vulnerability severity in the group and its subgroups | | `vulnerabilitySeveritiesCount` | VulnerabilitySeveritiesCount | Counts for each vulnerability severity in the group and its subgroups |
| `webUrl` | String! | Web URL of the group. | | `webUrl` | String! | Web URL of the group. |
@ -1818,7 +1818,7 @@ A block of time for which a participant is on-call..
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `projects` | ProjectConnection! | Projects selected in Instance Security Dashboard | | `projects` | ProjectConnection! | Projects selected in Instance Security Dashboard |
| `vulnerabilityGrades` | VulnerableProjectsByGrade! => Array | Represents vulnerable project counts for each grade | | `vulnerabilityGrades` | VulnerableProjectsByGrade! => Array | Represents vulnerable project counts for each grade |
| `vulnerabilityScanners` | VulnerabilityScannerConnection | Vulnerability scanners reported on the vulnerabilties from projects selected in Instance Security Dashboard | | `vulnerabilityScanners` | VulnerabilityScannerConnection | Vulnerability scanners reported on the vulnerabilities from projects selected in Instance Security Dashboard |
| `vulnerabilitySeveritiesCount` | VulnerabilitySeveritiesCount | Counts for each vulnerability severity from projects selected in Instance Security Dashboard | | `vulnerabilitySeveritiesCount` | VulnerabilitySeveritiesCount | Counts for each vulnerability severity from projects selected in Instance Security Dashboard |
### InstanceStatisticsMeasurement ### InstanceStatisticsMeasurement
@ -2824,7 +2824,7 @@ Autogenerated return type of PipelineRetry.
| `visibility` | String | Visibility of the project | | `visibility` | String | Visibility of the project |
| `vulnerabilities` | VulnerabilityConnection | Vulnerabilities reported on the project | | `vulnerabilities` | VulnerabilityConnection | Vulnerabilities reported on the project |
| `vulnerabilitiesCountByDay` | VulnerabilitiesCountByDayConnection | Number of vulnerabilities per day for the project | | `vulnerabilitiesCountByDay` | VulnerabilitiesCountByDayConnection | Number of vulnerabilities per day for the project |
| `vulnerabilityScanners` | VulnerabilityScannerConnection | Vulnerability scanners reported on the project vulnerabilties | | `vulnerabilityScanners` | VulnerabilityScannerConnection | Vulnerability scanners reported on the project vulnerabilities |
| `vulnerabilitySeveritiesCount` | VulnerabilitySeveritiesCount | Counts for each vulnerability severity in the project | | `vulnerabilitySeveritiesCount` | VulnerabilitySeveritiesCount | Counts for each vulnerability severity in the project |
| `webUrl` | String | Web URL of the project | | `webUrl` | String | Web URL of the project |
| `wikiEnabled` | Boolean | Indicates if Wikis are enabled for the current user | | `wikiEnabled` | Boolean | Indicates if Wikis are enabled for the current user |

View File

@ -5,6 +5,13 @@ require 'spec_helper'
RSpec.describe 'Projects > Show > User sees Git instructions' do RSpec.describe 'Projects > Show > User sees Git instructions' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do
# Reset user notification settings between examples to prevent
# validation failure on NotificationSetting.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/299822#note_492817174
user.notification_settings.reset
end
shared_examples_for 'redirects to the sign in page' do shared_examples_for 'redirects to the sign in page' do
it 'redirects to the sign in page' do it 'redirects to the sign in page' do
expect(current_path).to eq(new_user_session_path) expect(current_path).to eq(new_user_session_path)

View File

@ -3,12 +3,17 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { GlTabs, GlTab } from '@gitlab/ui'; import { GlTabs, GlTab } from '@gitlab/ui';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import Component from '~/projects/pipelines/charts/components/app.vue'; import Component from '~/projects/pipelines/charts/components/app.vue';
import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue'; import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue';
import getPipelineCountByStatus from '~/projects/pipelines/charts/graphql/queries/get_pipeline_count_by_status.query.graphql'; import getPipelineCountByStatus from '~/projects/pipelines/charts/graphql/queries/get_pipeline_count_by_status.query.graphql';
import getProjectPipelineStatistics from '~/projects/pipelines/charts/graphql/queries/get_project_pipeline_statistics.query.graphql'; import getProjectPipelineStatistics from '~/projects/pipelines/charts/graphql/queries/get_project_pipeline_statistics.query.graphql';
import { mockPipelineCount, mockPipelineStatistics } from '../mock_data'; import { mockPipelineCount, mockPipelineStatistics } from '../mock_data';
jest.mock('~/lib/utils/url_utility');
const projectPath = 'gitlab-org/gitlab'; const projectPath = 'gitlab-org/gitlab';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(VueApollo); localVue.use(VueApollo);
@ -115,6 +120,49 @@ describe('ProjectsPipelinesChartsApp', () => {
expect(findGlTabAt(1).attributes('title')).toBe('Deployments'); expect(findGlTabAt(1).attributes('title')).toBe('Deployments');
expect(findDeploymentFrequencyCharts().exists()).toBe(true); expect(findDeploymentFrequencyCharts().exists()).toBe(true);
}); });
it('sets the tab and url when a tab is clicked', async () => {
let chartsPath;
setWindowLocation(`${TEST_HOST}/gitlab-org/gitlab-test/-/pipelines/charts`);
mergeUrlParams.mockImplementation(({ chart }, path) => {
expect(chart).toBe('deployments');
expect(path).toBe(window.location.pathname);
chartsPath = `${path}?chart=${chart}`;
return chartsPath;
});
updateHistory.mockImplementation(({ url }) => {
expect(url).toBe(chartsPath);
});
const tabs = findGlTabs();
expect(tabs.attributes('value')).toBe('0');
tabs.vm.$emit('input', 1);
await wrapper.vm.$nextTick();
expect(tabs.attributes('value')).toBe('1');
});
});
describe('when provided with a query param', () => {
it.each`
chart | tab
${'deployments'} | ${'1'}
${'pipelines'} | ${'0'}
${'fake'} | ${'0'}
${''} | ${'0'}
`('shows the correct tab for URL parameter "$chart"', ({ chart, tab }) => {
setWindowLocation(`${TEST_HOST}/gitlab-org/gitlab-test/-/pipelines/charts?chart=${chart}`);
getParameterValues.mockImplementation((name) => {
expect(name).toBe('chart');
return chart ? [chart] : [];
});
createComponent({ provide: { shouldRenderDeploymentFrequencyCharts: true } });
expect(findGlTabs().attributes('value')).toBe(tab);
});
}); });
describe('when shouldRenderDeploymentFrequencyCharts is false', () => { describe('when shouldRenderDeploymentFrequencyCharts is false', () => {