Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
5d756f9966
commit
e0df70a614
9 changed files with 108 additions and 41 deletions
|
@ -1,9 +1,7 @@
|
|||
<script>
|
||||
/* eslint-disable vue/no-v-html */
|
||||
import { GlTooltipDirective, GlLink, GlButton } from '@gitlab/ui';
|
||||
import { numberToHumanSize } from '~/lib/utils/number_utils';
|
||||
import { __, sprintf } from '~/locale';
|
||||
import scrollDown from '../svg/scroll_down.svg';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
@ -13,7 +11,6 @@ export default {
|
|||
directives: {
|
||||
GlTooltip: GlTooltipDirective,
|
||||
},
|
||||
scrollDown,
|
||||
props: {
|
||||
erasePath: {
|
||||
type: String,
|
||||
|
@ -87,7 +84,6 @@ export default {
|
|||
v-gl-tooltip.body
|
||||
:title="s__('Job|Show complete raw')"
|
||||
:href="rawPath"
|
||||
class="controllers-buttons"
|
||||
data-testid="job-raw-link-controller"
|
||||
icon="doc-text"
|
||||
/>
|
||||
|
@ -98,7 +94,7 @@ export default {
|
|||
:title="s__('Job|Erase job log')"
|
||||
:href="erasePath"
|
||||
:data-confirm="__('Are you sure you want to erase this build?')"
|
||||
class="controllers-buttons"
|
||||
class="gl-ml-3"
|
||||
data-testid="job-log-erase-link"
|
||||
data-method="post"
|
||||
icon="remove"
|
||||
|
@ -106,25 +102,24 @@ export default {
|
|||
<!-- eo links -->
|
||||
|
||||
<!-- scroll buttons -->
|
||||
<div v-gl-tooltip :title="s__('Job|Scroll to top')" class="controllers-buttons">
|
||||
<div v-gl-tooltip :title="s__('Job|Scroll to top')" class="gl-ml-3">
|
||||
<gl-button
|
||||
:disabled="isScrollTopDisabled"
|
||||
class="btn-scroll btn-transparent btn-blank"
|
||||
class="btn-scroll"
|
||||
data-testid="job-controller-scroll-top"
|
||||
icon="scroll_up"
|
||||
@click="handleScrollToTop"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-gl-tooltip :title="s__('Job|Scroll to bottom')" class="controllers-buttons">
|
||||
<div v-gl-tooltip :title="s__('Job|Scroll to bottom')" class="gl-ml-3">
|
||||
<gl-button
|
||||
:disabled="isScrollBottomDisabled"
|
||||
class="js-scroll-bottom btn-scroll btn-transparent btn-blank"
|
||||
class="js-scroll-bottom btn-scroll"
|
||||
data-testid="job-controller-scroll-bottom"
|
||||
icon="scroll_down"
|
||||
:class="{ animate: isScrollingDown }"
|
||||
@click="handleScrollToBottom"
|
||||
v-html="$options.scrollDown"
|
||||
/>
|
||||
</div>
|
||||
<!-- eo scroll buttons -->
|
||||
|
|
|
@ -36,10 +36,10 @@ export default {
|
|||
v-gl-modal="modalId"
|
||||
:aria-label="$options.i18n.retryLabel"
|
||||
category="primary"
|
||||
variant="info"
|
||||
variant="confirm"
|
||||
>{{ $options.i18n.retryLabel }}</gl-button
|
||||
>
|
||||
<gl-link v-else :href="href" data-method="post" rel="nofollow"
|
||||
<gl-link v-else :href="href" class="btn gl-button btn-confirm" data-method="post" rel="nofollow"
|
||||
>{{ $options.i18n.retryLabel }}
|
||||
</gl-link>
|
||||
</template>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path class="scroll-arrow" d="M8 10.4142L4.29289 6.70711C3.90237 6.31658 3.90237 5.68342 4.29289 5.2929C4.68342 4.90237 5.31658 4.90237 5.70711 5.2929L7 6.58579L7 1C7 0.447715 7.44772 0 8 0C8.55229 0 9 0.447715 9 1L9 6.58579L10.2929 5.2929C10.6834 4.90237 11.3166 4.90237 11.7071 5.2929C12.0976 5.68342 12.0976 6.31658 11.7071 6.70711L8 10.4142Z"/>
|
||||
<path class="scroll-dot" d="M8 16C9.10457 16 10 15.1046 10 14C10 12.8954 9.10457 12 8 12C6.89543 12 6 12.8954 6 14C6 15.1046 6.89543 16 8 16Z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 597 B |
|
@ -102,7 +102,7 @@ export default {
|
|||
data-qa-selector="pipeline_header"
|
||||
data-testid="ci-header-content"
|
||||
>
|
||||
<section class="header-main-content">
|
||||
<section class="header-main-content gl-mr-3">
|
||||
<ci-icon-badge :status="status" />
|
||||
|
||||
<strong data-testid="ci-header-item-text"> {{ itemName }} #{{ itemId }} </strong>
|
||||
|
@ -142,12 +142,16 @@ export default {
|
|||
</template>
|
||||
</section>
|
||||
|
||||
<section v-if="$slots.default" data-testid="ci-header-action-buttons" class="gl-display-flex">
|
||||
<section
|
||||
v-if="$slots.default"
|
||||
data-testid="ci-header-action-buttons"
|
||||
class="gl-display-flex gl-mr-3"
|
||||
>
|
||||
<slot></slot>
|
||||
</section>
|
||||
<gl-button
|
||||
v-if="hasSidebarButton"
|
||||
class="d-sm-none js-sidebar-build-toggle gl-ml-auto"
|
||||
class="gl-md-display-none gl-ml-auto gl-align-self-start js-sidebar-build-toggle"
|
||||
icon="chevron-double-lg-left"
|
||||
:aria-label="__('Toggle sidebar')"
|
||||
@click="onClickSidebarButton"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Update buttons on a job page to conform to the Pajamas design system
|
||||
merge_request: 55858
|
||||
author:
|
||||
type: other
|
|
@ -74,6 +74,7 @@ module Gitlab
|
|||
def validate!
|
||||
raise "--dir option is required" unless input_dir.present?
|
||||
raise "Invalid dir #{input_dir}, allowed options are #{VALID_INPUT_DIRS.join(', ')}" unless directory.present?
|
||||
raise "Metric definition with key path '#{key_path}' already exists" if metric_definition_exists?
|
||||
end
|
||||
|
||||
def ee?
|
||||
|
@ -88,11 +89,23 @@ module Gitlab
|
|||
#
|
||||
# 20210201124931_g_project_management_issue_title_changed_weekly.yml
|
||||
def file_name
|
||||
"#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{key_path.split('.').last}"
|
||||
"#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{metric_name}"
|
||||
end
|
||||
|
||||
def directory
|
||||
@directory ||= TIME_FRAME_DIRS.find { |d| d.match?(input_dir) }
|
||||
end
|
||||
|
||||
def metric_name
|
||||
key_path.split('.').last
|
||||
end
|
||||
|
||||
def metric_definitions
|
||||
@definitions ||= Gitlab::Usage::MetricDefinition.definitions
|
||||
end
|
||||
|
||||
def metric_definition_exists?
|
||||
metric_definitions[key_path].present?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ describe('Job Sidebar Retry Button', () => {
|
|||
|
||||
expect(findRetryButton().attributes()).toMatchObject({
|
||||
category: 'primary',
|
||||
variant: 'info',
|
||||
variant: 'confirm',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
15
spec/generator_helper.rb
Normal file
15
spec/generator_helper.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Redirect stdout so specs don't have so much noise
|
||||
config.before(:all) do
|
||||
$stdout = StringIO.new
|
||||
end
|
||||
|
||||
# Reset stdout
|
||||
config.after(:all) do
|
||||
$stdout = STDOUT
|
||||
end
|
||||
end
|
|
@ -1,36 +1,75 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'rails/generators/testing/behaviour'
|
||||
require 'generator_helper'
|
||||
|
||||
RSpec.describe Gitlab::UsageMetricDefinitionGenerator do
|
||||
let(:temp_dir) { Dir.mktmpdir }
|
||||
describe 'Validation' do
|
||||
let(:key_path) { 'counter.category.event' }
|
||||
let(:dir) { '7d' }
|
||||
let(:options) { [key_path, '--dir', dir, '--pretend'] }
|
||||
|
||||
before do
|
||||
stub_const("#{described_class}::TOP_LEVEL_DIR", temp_dir)
|
||||
end
|
||||
subject { described_class.start(options) }
|
||||
|
||||
context 'with product_intelligence_metrics_names_suggestions feature ON' do
|
||||
it 'adds name key to metric definition' do
|
||||
stub_feature_flags(product_intelligence_metrics_names_suggestions: true)
|
||||
it 'does not raise an error' do
|
||||
expect { subject }.not_to raise_error
|
||||
end
|
||||
|
||||
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('some name')
|
||||
described_class.new(['counts_weekly.test_metric'], { 'dir' => '7d' }).invoke_all
|
||||
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
|
||||
context 'with a missing directory' do
|
||||
let(:options) { [key_path, '--pretend'] }
|
||||
|
||||
expect(YAML.safe_load(File.read(metric_definition_path))).to include("name" => "some name")
|
||||
it 'raises an error' do
|
||||
expect { subject }.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an invalid directory' do
|
||||
let(:dir) { '8d' }
|
||||
|
||||
it 'raises an error' do
|
||||
expect { subject }.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an already existing metric with the same key_path' do
|
||||
before do
|
||||
allow(Gitlab::Usage::MetricDefinition).to receive(:definitions).and_return(Hash[key_path, 'definition'])
|
||||
end
|
||||
|
||||
it 'raises an error' do
|
||||
expect { subject }.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with product_intelligence_metrics_names_suggestions feature OFF' do
|
||||
it 'adds name key to metric definition' do
|
||||
stub_feature_flags(product_intelligence_metrics_names_suggestions: false)
|
||||
describe 'Name suggestions' do
|
||||
let(:temp_dir) { Dir.mktmpdir }
|
||||
|
||||
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).not_to receive(:generate)
|
||||
described_class.new(['counts_weekly.test_metric'], { 'dir' => '7d' }).invoke_all
|
||||
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
|
||||
before do
|
||||
stub_const("#{described_class}::TOP_LEVEL_DIR", temp_dir)
|
||||
end
|
||||
|
||||
expect(YAML.safe_load(File.read(metric_definition_path)).keys).not_to include(:name)
|
||||
context 'with product_intelligence_metrics_names_suggestions feature ON' do
|
||||
it 'adds name key to metric definition' do
|
||||
stub_feature_flags(product_intelligence_metrics_names_suggestions: true)
|
||||
|
||||
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).to receive(:generate).and_return('some name')
|
||||
described_class.new(['counts_weekly.test_metric'], { 'dir' => '7d' }).invoke_all
|
||||
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
|
||||
|
||||
expect(YAML.safe_load(File.read(metric_definition_path))).to include("name" => "some name")
|
||||
end
|
||||
end
|
||||
|
||||
context 'with product_intelligence_metrics_names_suggestions feature OFF' do
|
||||
it 'adds name key to metric definition' do
|
||||
stub_feature_flags(product_intelligence_metrics_names_suggestions: false)
|
||||
|
||||
expect(::Gitlab::Usage::Metrics::NamesSuggestions::Generator).not_to receive(:generate)
|
||||
described_class.new(['counts_weekly.test_metric'], { 'dir' => '7d' }).invoke_all
|
||||
metric_definition_path = Dir.glob(File.join(temp_dir, 'metrics/counts_7d/*_test_metric.yml')).first
|
||||
|
||||
expect(YAML.safe_load(File.read(metric_definition_path)).keys).not_to include(:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue