Commit bcc94af1 authored by Kyle Mann's avatar Kyle Mann Committed by Mark Florian

Add text import button

parent a0adf4a2
<script> <script>
import { GlPopover, GlIcon, GlLink, GlButton, GlTooltipDirective } from '@gitlab/ui'; import { GlPopover, GlIcon, GlLink, GlButton, GlTooltipDirective } from '@gitlab/ui';
import { s__ } from '~/locale'; import { __, s__ } from '~/locale';
import createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
...@@ -29,6 +29,16 @@ export default { ...@@ -29,6 +29,16 @@ export default {
isPreparingCsvExport: false, isPreparingCsvExport: false,
showPopover: localStorage.getItem(STORAGE_KEY) !== 'true', showPopover: localStorage.getItem(STORAGE_KEY) !== 'true',
}), }),
computed: {
buttonProps() {
const { isPreparingCsvExport } = this;
return {
title: __('Export as CSV'),
loading: isPreparingCsvExport,
...(!isPreparingCsvExport ? { icon: 'export' } : {}),
};
},
},
methods: { methods: {
closePopover() { closePopover() {
this.showPopover = false; this.showPopover = false;
...@@ -66,17 +76,11 @@ export default { ...@@ -66,17 +76,11 @@ export default {
<gl-button <gl-button
ref="csvExportButton" ref="csvExportButton"
v-gl-tooltip.hover v-gl-tooltip.hover
class="align-self-center" class="gl-align-self-center"
:title="__('Export as CSV')" v-bind="buttonProps"
:loading="isPreparingCsvExport"
@click="initiateCsvExport" @click="initiateCsvExport"
> >
<gl-icon {{ __('Export') }}
v-if="!isPreparingCsvExport"
ref="exportIcon"
name="export"
class="mr-0 gl-display-block"
/>
<gl-popover <gl-popover
ref="popover" ref="popover"
:target="() => $refs.csvExportButton.$el" :target="() => $refs.csvExportButton.$el"
......
...@@ -25,7 +25,6 @@ describe('Csv Button Export', () => { ...@@ -25,7 +25,6 @@ describe('Csv Button Export', () => {
const findPopoverButton = () => wrapper.find({ ref: 'popoverButton' }); const findPopoverButton = () => wrapper.find({ ref: 'popoverButton' });
const findPopover = () => wrapper.find({ ref: 'popover' }); const findPopover = () => wrapper.find({ ref: 'popover' });
const findCsvExportButton = () => wrapper.find({ ref: 'csvExportButton' }); const findCsvExportButton = () => wrapper.find({ ref: 'csvExportButton' });
const findExportIcon = () => wrapper.find({ ref: 'exportIcon' });
const createComponent = () => { const createComponent = () => {
return shallowMount(CsvExportButton, { return shallowMount(CsvExportButton, {
...@@ -101,7 +100,7 @@ describe('Csv Button Export', () => { ...@@ -101,7 +100,7 @@ describe('Csv Button Export', () => {
}); });
it('displays the export icon when not loading and the loading icon when loading', () => { it('displays the export icon when not loading and the loading icon when loading', () => {
expect(findExportIcon().props('name')).toBe('export'); expect(findCsvExportButton().props('icon')).toBe('export');
expect(findCsvExportButton().props('loading')).toBe(false); expect(findCsvExportButton().props('loading')).toBe(false);
wrapper.setData({ wrapper.setData({
...@@ -109,7 +108,7 @@ describe('Csv Button Export', () => { ...@@ -109,7 +108,7 @@ describe('Csv Button Export', () => {
}); });
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(findExportIcon().exists()).toBe(false); expect(findCsvExportButton().props('icon')).toBeFalsy();
expect(findCsvExportButton().props('loading')).toBe(true); expect(findCsvExportButton().props('loading')).toBe(true);
}); });
}); });
......
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