From 6fb22ef2ea39f92edf9b237f6e3eca6121c8298b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 26 Jan 2021 09:09:23 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../pipelines/charts/components/app.vue | 14 +++++- .../components/states/nothing_to_merge.vue | 27 +++++++---- .../stylesheets/pages/merge_requests.scss | 9 ++-- .../yo-gl-button-create-file-mr.yml | 5 ++ .../graphql/reference/gitlab_schema.graphql | 6 +-- doc/api/graphql/reference/gitlab_schema.json | 6 +-- doc/api/graphql/reference/index.md | 6 +-- .../show/user_sees_git_instructions_spec.rb | 7 +++ .../pipelines/charts/components/app_spec.js | 48 +++++++++++++++++++ 9 files changed, 106 insertions(+), 22 deletions(-) create mode 100644 changelogs/unreleased/yo-gl-button-create-file-mr.yml diff --git a/app/assets/javascripts/projects/pipelines/charts/components/app.vue b/app/assets/javascripts/projects/pipelines/charts/components/app.vue index 7bb62cf4a73..61b899896bc 100644 --- a/app/assets/javascripts/projects/pipelines/charts/components/app.vue +++ b/app/assets/javascripts/projects/pipelines/charts/components/app.vue @@ -4,6 +4,7 @@ import { s__ } from '~/locale'; import getPipelineCountByStatus from '../graphql/queries/get_pipeline_count_by_status.query.graphql'; import getProjectPipelineStatistics from '../graphql/queries/get_project_pipeline_statistics.query.graphql'; import PipelineCharts from './pipeline_charts.vue'; +import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility'; import { DEFAULT, @@ -36,6 +37,8 @@ const defaultCountValues = { }, }; +const charts = ['pipelines', 'deployments']; + export default { components: { GlAlert, @@ -56,7 +59,11 @@ export default { }, }, data() { + const [chart] = getParameterValues('chart') || charts; + const tab = charts.indexOf(chart); return { + chart, + selectedTab: tab >= 0 ? tab : 0, showFailureAlert: false, failureType: null, analytics: { ...defaultAnalyticsValues }, @@ -172,6 +179,11 @@ export default { this.showFailureAlert = true; this.failureType = type; }, + onTabChange(index) { + this.selectedTab = index; + const path = mergeUrlParams({ chart: charts[index] }, window.location.pathname); + updateHistory({ url: path }); + }, }, errorTexts: { [LOAD_ANALYTICS_FAILURE]: s__( @@ -190,7 +202,7 @@ export default { {{ failure.text }} - + /* eslint-disable vue/no-v-html */ import emptyStateSVG from 'icons/_mr_widget_empty_state.svg'; +import { GlButton } from '@gitlab/ui'; export default { name: 'MRWidgetNothingToMerge', + components: { + GlButton, + }, props: { mr: { type: Object, @@ -25,11 +29,13 @@ export default {
- {{ - 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.', + ) + }} +

{{ s__( @@ -45,9 +51,14 @@ export default { }}

- {{ - __('Create file') - }} + + {{ __('Create file') }} +
diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index 1a223ec0f73..58f8cf09780 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -375,13 +375,14 @@ $mr-widget-min-height: 69px; } .text { - span { - font-weight: $gl-font-weight-bold; - } - p { margin-top: $gl-padding; } + + .highlight { + margin: 0 0 $gl-padding; + font-weight: $gl-font-weight-bold; + } } } diff --git a/changelogs/unreleased/yo-gl-button-create-file-mr.yml b/changelogs/unreleased/yo-gl-button-create-file-mr.yml new file mode 100644 index 00000000000..670edb8d862 --- /dev/null +++ b/changelogs/unreleased/yo-gl-button-create-file-mr.yml @@ -0,0 +1,5 @@ +--- +title: Apply GitLab UI for create file button in MR +merge_request: 51795 +author: Yogi (@yo) +type: other diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql index 85ead1fabb9..35aeb52fd18 100644 --- a/doc/api/graphql/reference/gitlab_schema.graphql +++ b/doc/api/graphql/reference/gitlab_schema.graphql @@ -11261,7 +11261,7 @@ type Group { ): [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( """ @@ -11966,7 +11966,7 @@ type InstanceSecurityDashboard { 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( """ @@ -19650,7 +19650,7 @@ type Project { ): VulnerabilitiesCountByDayConnection """ - Vulnerability scanners reported on the project vulnerabilties + Vulnerability scanners reported on the project vulnerabilities """ vulnerabilityScanners( """ diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json index a38e743f862..0f6e0743ccb 100644 --- a/doc/api/graphql/reference/gitlab_schema.json +++ b/doc/api/graphql/reference/gitlab_schema.json @@ -30680,7 +30680,7 @@ }, { "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": [ { "name": "after", @@ -32690,7 +32690,7 @@ }, { "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": [ { "name": "after", @@ -57062,7 +57062,7 @@ }, { "name": "vulnerabilityScanners", - "description": "Vulnerability scanners reported on the project vulnerabilties", + "description": "Vulnerability scanners reported on the project vulnerabilities", "args": [ { "name": "after", diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 5eb76275e34..f50cacf0cb9 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -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 | | `vulnerabilitiesCountByDayAndSeverity` **{warning-solid}** | VulnerabilitiesCountByDayAndSeverityConnection | **Deprecated:** Use `vulnerabilitiesCountByDay`. Deprecated in 13.3. | | `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 | | `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 | | `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 | ### InstanceStatisticsMeasurement @@ -2824,7 +2824,7 @@ Autogenerated return type of PipelineRetry. | `visibility` | String | Visibility of the project | | `vulnerabilities` | VulnerabilityConnection | Vulnerabilities reported on 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 | | `webUrl` | String | Web URL of the project | | `wikiEnabled` | Boolean | Indicates if Wikis are enabled for the current user | diff --git a/spec/features/projects/show/user_sees_git_instructions_spec.rb b/spec/features/projects/show/user_sees_git_instructions_spec.rb index febdb70de86..e6157887c12 100644 --- a/spec/features/projects/show/user_sees_git_instructions_spec.rb +++ b/spec/features/projects/show/user_sees_git_instructions_spec.rb @@ -5,6 +5,13 @@ require 'spec_helper' RSpec.describe 'Projects > Show > User sees Git instructions' do 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 it 'redirects to the sign in page' do expect(current_path).to eq(new_user_session_path) diff --git a/spec/frontend/projects/pipelines/charts/components/app_spec.js b/spec/frontend/projects/pipelines/charts/components/app_spec.js index 44329944097..07eb8198edb 100644 --- a/spec/frontend/projects/pipelines/charts/components/app_spec.js +++ b/spec/frontend/projects/pipelines/charts/components/app_spec.js @@ -3,12 +3,17 @@ import { createLocalVue, shallowMount } from '@vue/test-utils'; import VueApollo from 'vue-apollo'; import { GlTabs, GlTab } from '@gitlab/ui'; 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 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 getProjectPipelineStatistics from '~/projects/pipelines/charts/graphql/queries/get_project_pipeline_statistics.query.graphql'; import { mockPipelineCount, mockPipelineStatistics } from '../mock_data'; +jest.mock('~/lib/utils/url_utility'); + const projectPath = 'gitlab-org/gitlab'; const localVue = createLocalVue(); localVue.use(VueApollo); @@ -115,6 +120,49 @@ describe('ProjectsPipelinesChartsApp', () => { expect(findGlTabAt(1).attributes('title')).toBe('Deployments'); 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', () => {