Commit 3a10bfdb authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 07e418b1 ca72809c
/* eslint-disable import/prefer-default-export */
export const makeDataSeries = (queryResults, defaultConfig) =>
queryResults.reduce((acc, result) => {
const data = result.values.filter(([, value]) => !Number.isNaN(value));
if (!data.length) {
return acc;
}
const relevantMetric = defaultConfig.name.toLowerCase().replace(' ', '_');
const name = result.metric[relevantMetric];
const series = { data };
if (name) {
series.name = `${defaultConfig.name}: ${name}`;
}
return acc.concat({ ...defaultConfig, ...series });
}, []);
......@@ -5,6 +5,7 @@ import { debounceByAnimationFrame } from '~/lib/utils/common_utils';
import { getSvgIconPathContent } from '~/lib/utils/icon_utils';
import Icon from '~/vue_shared/components/icon.vue';
import { chartHeight, graphTypes, lineTypes } from '../../constants';
import { makeDataSeries } from '~/helpers/monitor_helper';
let debouncedResize;
......@@ -63,7 +64,7 @@ export default {
},
computed: {
chartData() {
return this.graphData.queries.map(query => {
return this.graphData.queries.reduce((acc, query) => {
const { appearance } = query;
const lineType =
appearance && appearance.line && appearance.line.type
......@@ -74,9 +75,8 @@ export default {
? appearance.line.width
: undefined;
return {
const series = makeDataSeries(query.result, {
name: this.formatLegendLabel(query),
data: this.concatenateResults(query.result),
lineStyle: {
type: lineType,
width: lineWidth,
......@@ -87,8 +87,10 @@ export default {
? appearance.area.opacity
: undefined,
},
};
});
});
return acc.concat(series);
}, []);
},
chartOptions() {
return {
......@@ -175,9 +177,6 @@ export default {
this.setSvg('scroll-handle');
},
methods: {
concatenateResults(results) {
return results.reduce((acc, result) => acc.concat(result.values), []);
},
formatLegendLabel(query) {
return `${query.label}`;
},
......
---
title: Allow task lists that follow a blockquote to work correctly
merge_request: 26937
author:
type: fixed
---
title: Fix multiple series queries on metrics dashboard
merge_request: 26514
author:
type: fixed
......@@ -42,7 +42,9 @@ module Banzai
def call
@text.gsub(REGEX) do
if $~[:quote]
$~[:quote].gsub(/^/, "> ").gsub(/^> $/, ">")
# keep the same number of source lines/positions by replacing the
# fence lines with newlines
"\n" + $~[:quote].gsub(/^/, "> ").gsub(/^> $/, ">") + "\n"
else
$~[0]
end
......
......@@ -43,7 +43,7 @@ describe 'Issues > User uses quick actions', :js do
describe 'issue-only commands' do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
before do
project.add_maintainer(user)
......@@ -57,6 +57,7 @@ describe 'Issues > User uses quick actions', :js do
end
it_behaves_like 'confidential quick action'
it_behaves_like 'remove_due_date quick action'
describe 'adding a due date from note' do
let(:issue) { create(:issue, project: project) }
......@@ -76,24 +77,6 @@ describe 'Issues > User uses quick actions', :js do
end
end
describe 'removing a due date from note' do
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
it_behaves_like 'remove_due_date action available and due date can be removed'
context 'when the current user cannot update the due date' do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
gitlab_sign_out
sign_in(guest)
visit project_issue_path(project, issue)
end
it_behaves_like 'remove_due_date action not available'
end
end
describe 'toggling the WIP prefix from the title from note' do
let(:issue) { create(:issue, project: project) }
......
......@@ -57,6 +57,7 @@ describe 'Merge request > User uses quick actions', :js do
end
it_behaves_like 'merge quick action'
it_behaves_like 'target_branch quick action'
describe 'toggling the WIP prefix in the title from note' do
context 'when the current user can toggle the WIP prefix' do
......@@ -104,83 +105,5 @@ describe 'Merge request > User uses quick actions', :js do
end
end
end
describe '/target_branch command in merge request' do
let(:another_project) { create(:project, :public, :repository) }
let(:new_url_opts) { { merge_request: { source_branch: 'feature' } } }
before do
another_project.add_maintainer(user)
sign_in(user)
end
it 'changes target_branch in new merge_request' do
visit project_new_merge_request_path(another_project, new_url_opts)
fill_in "merge_request_title", with: 'My brand new feature'
fill_in "merge_request_description", with: "le feature \n/target_branch fix\nFeature description:"
click_button "Submit merge request"
merge_request = another_project.merge_requests.first
expect(merge_request.description).to eq "le feature \nFeature description:"
expect(merge_request.target_branch).to eq 'fix'
end
it 'does not change target branch when merge request is edited' do
new_merge_request = create(:merge_request, source_project: another_project)
visit edit_project_merge_request_path(another_project, new_merge_request)
fill_in "merge_request_description", with: "Want to update target branch\n/target_branch fix\n"
click_button "Save changes"
new_merge_request = another_project.merge_requests.first
expect(new_merge_request.description).to include('/target_branch')
expect(new_merge_request.target_branch).not_to eq('fix')
end
end
describe '/target_branch command from note' do
context 'when the current user can change target branch' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'changes target branch from a note' do
add_note("message start \n/target_branch merge-test\n message end.")
wait_for_requests
expect(page).not_to have_content('/target_branch')
expect(page).to have_content('message start')
expect(page).to have_content('message end.')
expect(merge_request.reload.target_branch).to eq 'merge-test'
end
it 'does not fail when target branch does not exists' do
add_note('/target_branch totally_not_existing_branch')
expect(page).not_to have_content('/target_branch')
expect(merge_request.target_branch).to eq 'feature'
end
end
context 'when current user can not change target branch' do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
it 'does not change target branch' do
add_note('/target_branch merge-test')
expect(page).not_to have_content '/target_branch merge-test'
expect(merge_request.target_branch).to eq 'feature'
end
end
end
end
end
......@@ -18,10 +18,13 @@ Double `>>>` inside code block:
Blockquote outside code block:
> Quote
Code block inside blockquote:
> Quote
>
> ```
......@@ -30,8 +33,10 @@ Code block inside blockquote:
>
> Quote
Single `>>>` inside code block inside blockquote:
> Quote
>
> ```
......@@ -42,8 +47,10 @@ Single `>>>` inside code block inside blockquote:
>
> Quote
Double `>>>` inside code block inside blockquote:
> Quote
>
> ```
......@@ -56,6 +63,7 @@ Double `>>>` inside code block inside blockquote:
>
> Quote
Single `>>>` inside HTML:
<pre>
......@@ -76,10 +84,13 @@ Double `>>>` inside HTML:
Blockquote outside HTML:
> Quote
HTML inside blockquote:
> Quote
>
> <pre>
......@@ -88,8 +99,10 @@ HTML inside blockquote:
>
> Quote
Single `>>>` inside HTML inside blockquote:
> Quote
>
> <pre>
......@@ -100,8 +113,10 @@ Single `>>>` inside HTML inside blockquote:
>
> Quote
Double `>>>` inside HTML inside blockquote:
> Quote
>
> <pre>
......@@ -113,3 +128,4 @@ Double `>>>` inside HTML inside blockquote:
> </pre>
>
> Quote
import * as monitorHelper from '~/helpers/monitor_helper';
describe('monitor helper', () => {
const defaultConfig = { default: true, name: 'default name' };
const name = 'data name';
const series = [[1, 1], [2, 2], [3, 3]];
const data = ({ metric = { default_name: name }, values = series } = {}) => [{ metric, values }];
describe('makeDataSeries', () => {
const expectedDataSeries = [
{
...defaultConfig,
data: series,
},
];
it('converts query results to data series', () => {
expect(monitorHelper.makeDataSeries(data({ metric: {} }), defaultConfig)).toEqual(
expectedDataSeries,
);
});
it('returns an empty array if no query results exist', () => {
expect(monitorHelper.makeDataSeries([], defaultConfig)).toEqual([]);
});
it('handles multi-series query results', () => {
const expectedData = { ...expectedDataSeries[0], name: 'default name: data name' };
expect(monitorHelper.makeDataSeries([...data(), ...data()], defaultConfig)).toEqual([
expectedData,
expectedData,
]);
});
it('excludes NaN values', () => {
expect(
monitorHelper.makeDataSeries(
data({ metric: {}, values: [[1, 1], [2, NaN]] }),
defaultConfig,
),
).toEqual([{ ...expectedDataSeries[0], data: [[1, 1]] }]);
});
});
});
......@@ -13,6 +13,6 @@ describe Banzai::Filter::BlockquoteFenceFilter do
end
it 'allows trailing whitespace on blockquote fence lines' do
expect(filter(">>> \ntest\n>>> ")).to eq("> test")
expect(filter(">>> \ntest\n>>> ")).to eq("\n> test\n")
end
end
......@@ -58,8 +58,10 @@ describe Issues::BuildService do
"> That has a quote\n"\
">>>\n"
note_result = " > This is a string\n"\
" > \n"\
" > > with a blockquote\n"\
" > > > That has a quote\n"
" > > > That has a quote\n"\
" > \n"
discussion = create(:diff_note_on_merge_request, note: note_text).to_discussion
expect(service.item_for_discussion(discussion)).to include(note_result)
end
......
......@@ -113,4 +113,25 @@ describe TaskListToggleService do
expect(toggler.execute).to be_falsey
end
it 'properly handles a GitLab blockquote' do
markdown =
<<-EOT.strip_heredoc
>>>
gitlab blockquote
>>>
* [ ] Task 1
* [x] Task 2
EOT
markdown_html = Banzai::Pipeline::FullPipeline.call(markdown, project: nil)[:output].to_html
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: true,
line_source: '* [ ] Task 1', line_number: 5)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[4]).to eq "* [x] Task 1\n"
expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
end
end
# frozen_string_literal: true
shared_examples 'remove_due_date action not available' do
it 'does not remove the due date' do
add_note("/remove_due_date")
shared_examples 'remove_due_date quick action' do
context 'remove_due_date action available and due date can be removed' do
it 'removes the due date accordingly' do
add_note('/remove_due_date')
expect(page).not_to have_content 'Commands applied'
expect(page).not_to have_content '/remove_due_date'
end
end
expect(page).not_to have_content '/remove_due_date'
expect(page).to have_content 'Commands applied'
visit project_issue_path(project, issue)
shared_examples 'remove_due_date action available and due date can be removed' do
it 'removes the due date accordingly' do
add_note('/remove_due_date')
page.within '.due_date' do
expect(page).to have_content 'No due date'
end
end
end
expect(page).not_to have_content '/remove_due_date'
expect(page).to have_content 'Commands applied'
context 'remove_due_date action not available' do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
gitlab_sign_out
sign_in(guest)
visit project_issue_path(project, issue)
end
visit project_issue_path(project, issue)
it 'does not remove the due date' do
add_note("/remove_due_date")
page.within '.due_date' do
expect(page).to have_content 'No due date'
expect(page).not_to have_content 'Commands applied'
expect(page).not_to have_content '/remove_due_date'
end
end
end
# frozen_string_literal: true
shared_examples 'target_branch quick action' do
describe '/target_branch command in merge request' do
let(:another_project) { create(:project, :public, :repository) }
let(:new_url_opts) { { merge_request: { source_branch: 'feature' } } }
before do
another_project.add_maintainer(user)
sign_in(user)
end
it 'changes target_branch in new merge_request' do
visit project_new_merge_request_path(another_project, new_url_opts)
fill_in "merge_request_title", with: 'My brand new feature'
fill_in "merge_request_description", with: "le feature \n/target_branch fix\nFeature description:"
click_button "Submit merge request"
merge_request = another_project.merge_requests.first
expect(merge_request.description).to eq "le feature \nFeature description:"
expect(merge_request.target_branch).to eq 'fix'
end
it 'does not change target branch when merge request is edited' do
new_merge_request = create(:merge_request, source_project: another_project)
visit edit_project_merge_request_path(another_project, new_merge_request)
fill_in "merge_request_description", with: "Want to update target branch\n/target_branch fix\n"
click_button "Save changes"
new_merge_request = another_project.merge_requests.first
expect(new_merge_request.description).to include('/target_branch')
expect(new_merge_request.target_branch).not_to eq('fix')
end
end
describe '/target_branch command from note' do
context 'when the current user can change target branch' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'changes target branch from a note' do
add_note("message start \n/target_branch merge-test\n message end.")
wait_for_requests
expect(page).not_to have_content('/target_branch')
expect(page).to have_content('message start')
expect(page).to have_content('message end.')
expect(merge_request.reload.target_branch).to eq 'merge-test'
end
it 'does not fail when target branch does not exists' do
add_note('/target_branch totally_not_existing_branch')
expect(page).not_to have_content('/target_branch')
expect(merge_request.target_branch).to eq 'feature'
end
end
context 'when current user can not change target branch' do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
it 'does not change target branch' do
add_note('/target_branch merge-test')
expect(page).not_to have_content '/target_branch merge-test'
expect(merge_request.target_branch).to eq 'feature'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment