Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-03-18 12:09:01 +00:00
parent 0da3ea5374
commit 19d46f60a3
21 changed files with 254 additions and 47 deletions

View File

@ -37,7 +37,7 @@ If applicable, any groups/projects that are happy to have this feature turned on
- [ ] Enable on GitLab.com for individual groups/projects listed above and verify behaviour (`/chatops run feature set --project=gitlab-org/gitlab feature_name true`)
- [ ] Coordinate a time to enable the flag with the SRE oncall and release managers
- In `#production` mention `@sre-oncall` and `@release-managers`. Once an SRE on call and Release Manager on call confirm, you can proceed with the rollout
- [ ] Announce on the issue an estimated time this will be enabled on GitLab.com
- [ ] Announce on the issue an estimated time this will be enabled on GitLab.com. **Note**: Once a feature rollout has started, it is not necessary to inform `@sre-oncall`/`@release-managers` at each stage of the gradual rollout.
- [ ] Enable on GitLab.com by running chatops command in `#production` (`/chatops run feature set feature_name true`)
- [ ] Cross post chatops Slack command to `#support_gitlab-com` ([more guidance when this is necessary in the dev docs](https://docs.gitlab.com/ee/development/feature_flags/controls.html#where-to-run-commands)) and in your team channel
- [ ] Announce on the issue that the flag has been enabled

View File

@ -0,0 +1,44 @@
## What does this MR do?
<!--
Please describe why the end-to-end test is being quarantined/ de-quarantined.
Please note that the aim of quarantining a test is not to get back a green pipeline, but rather to reduce
the noise (due to constantly failing tests, flaky tests, and so on) so that new failures are not missed.
-->
### E2E Test Failure issue(s)
<!-- Please link to the respective E2E test failure issue. -->
### Check-list
- [ ] General code guidelines check-list
- [ ] [Code review guidelines](https://docs.gitlab.com/ee/development/code_review.html)
- [ ] [Style guides](https://docs.gitlab.com/ee/development/contributing/style_guides.html)
- [ ] Quarantine test check-list
- [ ] Follow the [Quarantining Tests guide](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#quarantining-tests).
- [ ] Confirm the test has a [`quarantine:` tag with the specified quarantine type](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#quarantined-test-types).
- [ ] Note if the test should be [quarantined for a specific environment](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/environment_selection.html#quarantining-a-test-for-a-specific-environment).
- [ ] Dequarantine test check-list
- [ ] Follow the [Dequarantining Tests guide](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests).
- [ ] Confirm the test consistently passes on the target GitLab environment(s).
- [ ] (Optionally) [Trigger a manual GitLab-QA pipeline](https://about.gitlab.com/handbook/engineering/quality/guidelines/tips-and-tricks/#running-gitlab-qa-pipeline-against-a-specific-gitlab-release) against a specific GitLab environment using the `RELEASE` variable from the `package-and-qa` job of the current Merge Request.
- [ ] To ensure a faster turnaround, ask in the `#quality` Slack channel for someone to review and merge the merge request, rather than assigning it directly.
<!-- Base labels. -->
/label ~"Quality" ~"QA" ~"feature" ~"feature::maintenance"
<!-- Labels to pick into auto-deploy. -->
/label ~"Pick into auto-deploy" ~"priority::1" ~"severity::1"
<!--
Choose the stage that appears in the test path, e.g. ~"devops::create" for
`qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb`.
-->
/label ~devops::
<!-- Select the current milestone. -->
/milestone %

View File

@ -1 +1 @@
eb6ecf6f96946849761c1fcdcaf0bda15fc000f9
a88ceb12912277ab1e07ca325792df40550e6bcc

View File

@ -1,6 +1,7 @@
import $ from 'jquery';
import { once } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import { darkModeEnabled } from '~/lib/utils/color_utils';
import { __, sprintf } from '~/locale';
// Renders diagrams and flowcharts from text using Mermaid in any element with the
@ -27,37 +28,34 @@ let renderedMermaidBlocks = 0;
let mermaidModule = {};
export function initMermaid(mermaid) {
let theme = 'neutral';
if (darkModeEnabled()) {
theme = 'dark';
}
mermaid.initialize({
// mermaid core options
mermaid: {
startOnLoad: false,
},
// mermaidAPI options
theme,
flowchart: {
useMaxWidth: true,
htmlLabels: false,
},
securityLevel: 'strict',
});
return mermaid;
}
function importMermaidModule() {
return import(/* webpackChunkName: 'mermaid' */ 'mermaid')
.then((mermaid) => {
let theme = 'neutral';
const ideDarkThemes = ['dark', 'solarized-dark', 'monokai'];
if (
ideDarkThemes.includes(window.gon?.user_color_scheme) &&
// if on the Web IDE page
document.querySelector('.ide')
) {
theme = 'dark';
}
mermaid.initialize({
// mermaid core options
mermaid: {
startOnLoad: false,
},
// mermaidAPI options
theme,
flowchart: {
useMaxWidth: true,
htmlLabels: false,
},
securityLevel: 'strict',
});
mermaidModule = mermaid;
return mermaid;
mermaidModule = initMermaid(mermaid);
})
.catch((err) => {
flash(sprintf(__("Can't load mermaid module: %{err}"), { err }));

View File

@ -43,3 +43,15 @@ export const validateHexColor = (color = '') => {
return /^#([0-9A-F]{3}){1,2}$/i.test(color);
};
export function darkModeEnabled() {
const ideDarkThemes = ['dark', 'solarized-dark', 'monokai'];
// eslint-disable-next-line @gitlab/require-i18n-strings
const isWebIde = document.body.dataset.page.startsWith('ide:');
if (isWebIde) {
return ideDarkThemes.includes(window.gon?.user_color_scheme);
}
return document.body.classList.contains('gl-dark');
}

View File

@ -27,7 +27,7 @@ module AlertManagement
first_id = project.alert_management_http_integrations
.ordered_by_id
.select(:id)
.at_most(1)
.limit(1)
@collection = collection.id_in(first_id)
end

View File

@ -135,6 +135,8 @@ module CommitsHelper
end
def cherry_pick_projects_data(project)
return [] unless Feature.enabled?(:pick_into_project, project, default_enabled: :yaml)
target_projects(project).map do |project|
{
id: project.id.to_s,

View File

@ -42,10 +42,6 @@ class ApplicationRecord < ActiveRecord::Base
false
end
def self.at_most(count)
limit(count)
end
def self.safe_find_or_create_by!(*args, &block)
safe_find_or_create_by(*args, &block).tap do |record|
raise ActiveRecord::RecordNotFound unless record.present?

View File

@ -17,7 +17,7 @@ module MergeRequests
.opened
.by_target_branch(merge_request.source_branch)
.preload_source_project
.at_most(MAX_RETARGET_MERGE_REQUESTS)
.limit(MAX_RETARGET_MERGE_REQUESTS)
other_merge_requests.find_each do |other_merge_request|
# Update only MRs on projects that we have access to

View File

@ -16,4 +16,4 @@
= render "shared/import_form", f: f
.form-actions
= f.submit 'Start import', class: "gl-button btn btn-success"
= f.submit 'Start import', class: "gl-button btn btn-confirm"

View File

@ -0,0 +1,5 @@
---
title: Move from btn-success to btn-confirm in imports directory
merge_request: 56336
author: Yogi (@yo)
type: changed

View File

@ -0,0 +1,5 @@
---
title: Fix mermaid diagrams in dark mode
merge_request: 56183
author:
type: fixed

View File

@ -6,6 +6,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Migration to Vue 3
Preparations for a Vue 3 migration are tracked in epic [&3174](https://gitlab.com/groups/gitlab-org/-/epics/3174)
In order to prepare for the eventual migration to Vue 3.x, we should be wary about adding the following features to the codebase:
## Vue filters

View File

@ -9836,6 +9836,78 @@ Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_fixed_monthly`
Counts of MAU setting epic start date as fixed
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210315055624_g_project_management_users_setting_epic_start_date_as_fixed_monthly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_fixed_weekly`
Counts of WAU setting epic start date as fixed
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210315054905_g_project_management_users_setting_epic_start_date_as_fixed_weekly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_inherited_monthly`
Counts of MAU setting epic start date as inherited
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210315055439_g_project_management_users_setting_epic_start_date_as_inherited_monthly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_setting_epic_start_date_as_inherited_weekly`
Counts of WAU setting epic start date as inherited
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210315055342_g_project_management_users_setting_epic_start_date_as_inherited_weekly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_notes_monthly`
Counts of MAU updating epic notes
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210314234202_g_project_management_users_updating_epic_notes_monthly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.epics_usage.g_project_management_users_updating_epic_notes_weekly`
Counts of WAU updating epic notes
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210314234041_g_project_management_users_updating_epic_notes_weekly.yml)
Group: `group:product planning`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.ide_edit.g_edit_by_sfe_monthly`
Missing description

View File

@ -32,7 +32,7 @@ pre-push:
tags: backend style
files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
glob: '*.rb'
run: bundle exec rubocop --parallel --force-exclusion {files}
run: REVEAL_RUBOCOP_TODO=0 bundle exec rubocop --parallel --force-exclusion {files}
vale: # Requires Vale: https://docs.gitlab.com/ee/development/documentation/#install-linters
tags: documentation style
files: git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD

View File

@ -38,7 +38,7 @@ module Gitlab
def fetch_page(relation)
relation = relation.by_updated_at
notes = relation.at_most(LIMIT + 1).to_a
notes = relation.limit(LIMIT + 1).to_a
return [notes, false] unless notes.size > LIMIT

View File

@ -9,8 +9,26 @@
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_updating_epic_notes
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_destroying_epic_notes
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_setting_epic_start_date_as_fixed
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
- name: g_project_management_users_setting_epic_start_date_as_inherited
category: epics_usage
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity

View File

@ -0,0 +1,25 @@
import { initMermaid } from '~/behaviors/markdown/render_mermaid';
import * as ColorUtils from '~/lib/utils/color_utils';
describe('Render mermaid diagrams for Gitlab Flavoured Markdown', () => {
it.each`
darkMode | expectedTheme
${false} | ${'neutral'}
${true} | ${'dark'}
`('is $darkMode $expectedTheme', async ({ darkMode, expectedTheme }) => {
jest.spyOn(ColorUtils, 'darkModeEnabled').mockImplementation(() => darkMode);
const mermaid = {
initialize: jest.fn(),
};
await initMermaid(mermaid);
expect(mermaid.initialize).toHaveBeenCalledTimes(1);
expect(mermaid.initialize).toHaveBeenCalledWith(
expect.objectContaining({
theme: expectedTheme,
}),
);
});
});

View File

@ -1,4 +1,9 @@
import { textColorForBackground, hexToRgb, validateHexColor } from '~/lib/utils/color_utils';
import {
textColorForBackground,
hexToRgb,
validateHexColor,
darkModeEnabled,
} from '~/lib/utils/color_utils';
describe('Color utils', () => {
describe('Converting hex code to rgb', () => {
@ -47,4 +52,24 @@ describe('Color utils', () => {
expect(validateHexColor(color)).toEqual(output);
});
});
describe('darkModeEnabled', () => {
it.each`
page | bodyClass | ideTheme | expected
${'ide:index'} | ${'gl-dark'} | ${'monokai-light'} | ${false}
${'ide:index'} | ${'ui-light'} | ${'monokai'} | ${true}
${'groups:issues:index'} | ${'ui-light'} | ${'monokai'} | ${false}
${'groups:issues:index'} | ${'gl-dark'} | ${'monokai-light'} | ${true}
`(
'is $expected on $page with $bodyClass body class and $ideTheme IDE theme',
async ({ page, bodyClass, ideTheme, expected }) => {
document.body.outerHTML = `<body class="${bodyClass}" data-page="${page}"></body>`;
window.gon = {
user_color_scheme: ideTheme,
};
expect(darkModeEnabled()).toBe(expected);
},
);
});
});

View File

@ -257,5 +257,15 @@ RSpec.describe CommitsHelper do
{ id: forked_project.id.to_s, name: forked_project.full_path, refsUrl: refs_project_path(forked_project) }
])
end
context 'pick_into_project is disabled' do
before do
stub_feature_flags(pick_into_project: false)
end
it 'does not calculate target projects' do
expect(helper.cherry_pick_projects_data(project)).to eq([])
end
end
end
end

View File

@ -93,13 +93,6 @@ RSpec.describe ApplicationRecord do
end
end
describe '.at_most' do
it 'limits the number of records returned' do
create_list(:user, 3)
expect(User.at_most(2).count).to eq(2)
end
end
describe '.where_exists' do
it 'produces a WHERE EXISTS query' do
user = create(:user)