Commit a0fdf1ba authored by Mark Florian's avatar Mark Florian

Merge branch 'pb-move-artifacts-to-ellipsis-dropdown' into 'master'

Build pipeline mutli action dropdown

See merge request gitlab-org/gitlab!59667
parents 7962ee89 0c576fbd
<script>
import {
GlDropdown,
GlDropdownItem,
GlDropdownSectionHeader,
GlSprintf,
GlTooltipDirective,
} from '@gitlab/ui';
import { __ } from '~/locale';
export default {
i18n: {
artifacts: __('Artifacts'),
downloadArtifact: __('Download %{name} artifact'),
artifactSectionHeader: __('Download artifacts'),
},
directives: {
GlTooltip: GlTooltipDirective,
},
components: {
GlDropdown,
GlDropdownItem,
GlDropdownSectionHeader,
GlSprintf,
},
props: {
artifacts: {
type: Array,
required: true,
},
},
};
</script>
<template>
<gl-dropdown
v-gl-tooltip
:title="$options.i18n.artifacts"
:text="$options.i18n.artifacts"
:aria-label="$options.i18n.artifacts"
icon="ellipsis_v"
data-testid="pipeline-multi-actions-dropdown"
right
lazy
text-sr-only
no-caret
>
<gl-dropdown-section-header>{{
$options.i18n.artifactSectionHeader
}}</gl-dropdown-section-header>
<gl-dropdown-item
v-for="(artifact, i) in artifacts"
:key="i"
:href="artifact.path"
rel="nofollow"
download
data-testid="artifact-item"
>
<gl-sprintf :message="$options.i18n.downloadArtifact">
<template #name>{{ artifact.name }}</template>
</gl-sprintf>
</gl-dropdown-item>
</gl-dropdown>
</template>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlButton, GlTooltipDirective, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlTooltipDirective, GlModalDirective } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
import PipelinesArtifactsComponent from './pipelines_artifacts.vue'; import PipelineMultiActions from './pipeline_multi_actions.vue';
import PipelinesManualActions from './pipelines_manual_actions.vue'; import PipelinesManualActions from './pipelines_manual_actions.vue';
export default { export default {
...@@ -16,8 +16,8 @@ export default { ...@@ -16,8 +16,8 @@ export default {
}, },
components: { components: {
GlButton, GlButton,
PipelineMultiActions,
PipelinesManualActions, PipelinesManualActions,
PipelinesArtifactsComponent,
}, },
props: { props: {
pipeline: { pipeline: {
...@@ -80,11 +80,6 @@ export default { ...@@ -80,11 +80,6 @@ export default {
<div class="btn-group"> <div class="btn-group">
<pipelines-manual-actions v-if="actions.length > 0" :actions="actions" /> <pipelines-manual-actions v-if="actions.length > 0" :actions="actions" />
<pipelines-artifacts-component
v-if="pipeline.details.artifacts.length"
:artifacts="pipeline.details.artifacts"
/>
<gl-button <gl-button
v-if="pipeline.flags.retryable" v-if="pipeline.flags.retryable"
v-gl-tooltip.hover v-gl-tooltip.hover
...@@ -114,6 +109,11 @@ export default { ...@@ -114,6 +109,11 @@ export default {
class="js-pipelines-cancel-button" class="js-pipelines-cancel-button"
@click="handleCancelClick" @click="handleCancelClick"
/> />
<pipeline-multi-actions
v-if="pipeline.details.artifacts.length"
:artifacts="pipeline.details.artifacts"
/>
</div> </div>
</div> </div>
</template> </template>
---
title: Change artifacts download button to a vertical ellipsis menu
merge_request: 59667
author:
type: changed
...@@ -457,20 +457,20 @@ RSpec.describe 'Pipelines', :js do ...@@ -457,20 +457,20 @@ RSpec.describe 'Pipelines', :js do
visit_project_pipelines visit_project_pipelines
end end
it 'has artifacts' do it 'has artifacts dropdown' do
expect(page).to have_selector('.build-artifacts') expect(page).to have_selector('[data-testid="pipeline-multi-actions-dropdown"]')
end end
it 'has artifacts download dropdown' do it 'has artifacts download dropdown' do
find('.js-pipeline-dropdown-download').click find('[data-testid="pipeline-multi-actions-dropdown"]').click
expect(page).to have_link(with_artifacts.file_type) expect(page).to have_link(with_artifacts.file_type)
end end
it 'has download attribute on download links' do it 'has download attribute on download links' do
find('.js-pipeline-dropdown-download').click find('[data-testid="pipeline-multi-actions-dropdown"]').click
expect(page).to have_selector('a', text: 'Download') expect(page).to have_selector('a', text: 'Download')
page.all('.build-artifacts a', text: 'Download').each do |link| page.all('[data-testid="artifact-item"]', text: 'Download').each do |link|
expect(link[:download]).to eq '' expect(link[:download]).to eq ''
end end
end end
...@@ -488,7 +488,7 @@ RSpec.describe 'Pipelines', :js do ...@@ -488,7 +488,7 @@ RSpec.describe 'Pipelines', :js do
visit_project_pipelines visit_project_pipelines
end end
it { expect(page).not_to have_selector('.build-artifacts') } it { expect(page).not_to have_selector('[data-testid="artifact-item"]') }
end end
context 'without artifacts' do context 'without artifacts' do
...@@ -503,7 +503,7 @@ RSpec.describe 'Pipelines', :js do ...@@ -503,7 +503,7 @@ RSpec.describe 'Pipelines', :js do
visit_project_pipelines visit_project_pipelines
end end
it { expect(page).not_to have_selector('.build-artifacts') } it { expect(page).not_to have_selector('[data-testid="artifact-item"]') }
end end
context 'with trace artifact' do context 'with trace artifact' do
...@@ -514,7 +514,7 @@ RSpec.describe 'Pipelines', :js do ...@@ -514,7 +514,7 @@ RSpec.describe 'Pipelines', :js do
end end
it 'does not show trace artifact as artifacts' do it 'does not show trace artifact as artifacts' do
expect(page).not_to have_selector('.build-artifacts') expect(page).not_to have_selector('[data-testid="artifact-item"]')
end end
end end
end end
......
import { GlDropdown, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import PipelineMultiActions from '~/pipelines/components/pipelines_list/pipeline_multi_actions.vue';
describe('Pipeline Multi Actions Dropdown', () => {
let wrapper;
const artifactItemTestId = 'artifact-item';
const defaultProps = {
artifacts: [
{
name: 'job my-artifact',
path: '/download/path',
},
{
name: 'job-2 my-artifact-2',
path: '/download/path-two',
},
],
};
const createComponent = (props = defaultProps) => {
wrapper = extendedWrapper(
shallowMount(PipelineMultiActions, {
propsData: {
...defaultProps,
...props,
},
stubs: {
GlSprintf,
},
}),
);
};
const findDropdown = () => wrapper.findComponent(GlDropdown);
const findAllArtifactItems = () => wrapper.findAllByTestId(artifactItemTestId);
const findFirstArtifactItem = () => wrapper.findByTestId(artifactItemTestId);
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('should render the dropdown', () => {
expect(findDropdown().exists()).toBe(true);
});
describe('Artifacts', () => {
it('should render all the provided artifacts', () => {
expect(findAllArtifactItems()).toHaveLength(defaultProps.artifacts.length);
});
it('should render the correct artifact name and path', () => {
expect(findFirstArtifactItem().attributes('href')).toBe(defaultProps.artifacts[0].path);
expect(findFirstArtifactItem().text()).toBe(
`Download ${defaultProps.artifacts[0].name} artifact`,
);
});
});
});
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