Commit a64be11d authored by Miguel Rincon's avatar Miguel Rincon

Replace blank state component with gitlab-ui

This change removes the custom blank state component for pipelines
in favor of using the empty state from gitlab-ui.

This change preserves the text style but it changes the svg image sizes.
parent b91cd321
<script> <script>
import { GlButton, GlLoadingIcon, GlModal, GlLink } from '@gitlab/ui'; import { GlButton, GlEmptyState, GlLoadingIcon, GlModal, GlLink } from '@gitlab/ui';
import { getParameterByName } from '~/lib/utils/common_utils'; import { getParameterByName } from '~/lib/utils/common_utils';
import SvgBlankState from '~/pipelines/components/pipelines_list/blank_state.vue';
import PipelinesTableComponent from '~/pipelines/components/pipelines_list/pipelines_table.vue'; import PipelinesTableComponent from '~/pipelines/components/pipelines_list/pipelines_table.vue';
import eventHub from '~/pipelines/event_hub'; import eventHub from '~/pipelines/event_hub';
import PipelinesMixin from '~/pipelines/mixins/pipelines_mixin'; import PipelinesMixin from '~/pipelines/mixins/pipelines_mixin';
...@@ -13,12 +12,12 @@ import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; ...@@ -13,12 +12,12 @@ import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
components: { components: {
GlButton, GlButton,
GlEmptyState,
GlLink, GlLink,
GlLoadingIcon, GlLoadingIcon,
GlModal, GlModal,
PipelinesTableComponent, PipelinesTableComponent,
TablePagination, TablePagination,
SvgBlankState,
}, },
mixins: [PipelinesMixin, glFeatureFlagMixin()], mixins: [PipelinesMixin, glFeatureFlagMixin()],
props: { props: {
...@@ -183,10 +182,10 @@ export default { ...@@ -183,10 +182,10 @@ export default {
class="prepend-top-20" class="prepend-top-20"
/> />
<svg-blank-state <gl-empty-state
v-else-if="shouldRenderErrorState" v-else-if="shouldRenderErrorState"
:svg-path="errorStateSvgPath" :svg-path="errorStateSvgPath"
:message=" :title="
s__(`Pipelines|There was an error fetching the pipelines. s__(`Pipelines|There was an error fetching the pipelines.
Try again in a few moments or contact your support team.`) Try again in a few moments or contact your support team.`)
" "
......
<script>
export default {
name: 'PipelinesSvgState',
props: {
svgPath: {
type: String,
required: true,
},
message: {
type: String,
required: true,
},
},
};
</script>
<template>
<div class="row empty-state">
<div class="col-12">
<div class="svg-content"><img :src="svgPath" /></div>
</div>
<div class="col-12 text-center">
<div class="text-content">
<h4>{{ message }}</h4>
</div>
</div>
</div>
</template>
<script> <script>
import { GlIcon, GlLoadingIcon } from '@gitlab/ui'; import { GlEmptyState, GlIcon, GlLoadingIcon } from '@gitlab/ui';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import { getParameterByName } from '~/lib/utils/common_utils'; import { getParameterByName } from '~/lib/utils/common_utils';
...@@ -10,7 +10,6 @@ import { ANY_TRIGGER_AUTHOR, RAW_TEXT_WARNING, FILTER_TAG_IDENTIFIER } from '../ ...@@ -10,7 +10,6 @@ import { ANY_TRIGGER_AUTHOR, RAW_TEXT_WARNING, FILTER_TAG_IDENTIFIER } from '../
import PipelinesMixin from '../../mixins/pipelines_mixin'; import PipelinesMixin from '../../mixins/pipelines_mixin';
import PipelinesService from '../../services/pipelines_service'; import PipelinesService from '../../services/pipelines_service';
import { validateParams } from '../../utils'; import { validateParams } from '../../utils';
import SvgBlankState from './blank_state.vue';
import EmptyState from './empty_state.vue'; import EmptyState from './empty_state.vue';
import NavigationControls from './nav_controls.vue'; import NavigationControls from './nav_controls.vue';
import PipelinesFilteredSearch from './pipelines_filtered_search.vue'; import PipelinesFilteredSearch from './pipelines_filtered_search.vue';
...@@ -19,13 +18,13 @@ import PipelinesTableComponent from './pipelines_table.vue'; ...@@ -19,13 +18,13 @@ import PipelinesTableComponent from './pipelines_table.vue';
export default { export default {
components: { components: {
EmptyState, EmptyState,
GlEmptyState,
GlIcon, GlIcon,
GlLoadingIcon, GlLoadingIcon,
NavigationTabs, NavigationTabs,
NavigationControls, NavigationControls,
PipelinesFilteredSearch, PipelinesFilteredSearch,
PipelinesTableComponent, PipelinesTableComponent,
SvgBlankState,
TablePagination, TablePagination,
}, },
mixins: [PipelinesMixin], mixins: [PipelinesMixin],
...@@ -333,19 +332,19 @@ export default { ...@@ -333,19 +332,19 @@ export default {
:can-set-ci="canCreatePipeline" :can-set-ci="canCreatePipeline"
/> />
<svg-blank-state <gl-empty-state
v-else-if="stateToRender === $options.stateMap.error" v-else-if="stateToRender === $options.stateMap.error"
:svg-path="errorStateSvgPath" :svg-path="errorStateSvgPath"
:message=" :title="
s__(`Pipelines|There was an error fetching the pipelines. s__(`Pipelines|There was an error fetching the pipelines.
Try again in a few moments or contact your support team.`) Try again in a few moments or contact your support team.`)
" "
/> />
<svg-blank-state <gl-empty-state
v-else-if="stateToRender === $options.stateMap.emptyTab" v-else-if="stateToRender === $options.stateMap.emptyTab"
:svg-path="noPipelinesSvgPath" :svg-path="noPipelinesSvgPath"
:message="emptyTabMessage" :title="emptyTabMessage"
/> />
<div v-else-if="stateToRender === $options.stateMap.tableList"> <div v-else-if="stateToRender === $options.stateMap.tableList">
......
import { getByText } from '@testing-library/dom';
import { mount } from '@vue/test-utils';
import BlankState from '~/pipelines/components/pipelines_list/blank_state.vue';
describe('Pipelines Blank State', () => {
const wrapper = mount(BlankState, {
propsData: {
svgPath: 'foo',
message: 'Blank State',
},
});
it('should render svg', () => {
expect(wrapper.find('.svg-content img').attributes('src')).toEqual('foo');
});
it('should render message', () => {
expect(getByText(wrapper.element, /Blank State/i)).toBeTruthy();
});
});
import { GlButton, GlFilteredSearch, GlLoadingIcon, GlPagination } from '@gitlab/ui'; import { GlButton, GlEmptyState, GlFilteredSearch, GlLoadingIcon, GlPagination } from '@gitlab/ui';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { chunk } from 'lodash'; import { chunk } from 'lodash';
...@@ -8,8 +8,6 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -8,8 +8,6 @@ import waitForPromises from 'helpers/wait_for_promises';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import BlankState from '~/pipelines/components/pipelines_list/blank_state.vue';
import EmptyState from '~/pipelines/components/pipelines_list/empty_state.vue';
import NavigationControls from '~/pipelines/components/pipelines_list/nav_controls.vue'; import NavigationControls from '~/pipelines/components/pipelines_list/nav_controls.vue';
import PipelinesComponent from '~/pipelines/components/pipelines_list/pipelines.vue'; import PipelinesComponent from '~/pipelines/components/pipelines_list/pipelines.vue';
import PipelinesTableComponent from '~/pipelines/components/pipelines_list/pipelines_table.vue'; import PipelinesTableComponent from '~/pipelines/components/pipelines_list/pipelines_table.vue';
...@@ -58,11 +56,10 @@ describe('Pipelines', () => { ...@@ -58,11 +56,10 @@ describe('Pipelines', () => {
}; };
const findFilteredSearch = () => wrapper.findComponent(GlFilteredSearch); const findFilteredSearch = () => wrapper.findComponent(GlFilteredSearch);
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
const findNavigationTabs = () => wrapper.findComponent(NavigationTabs); const findNavigationTabs = () => wrapper.findComponent(NavigationTabs);
const findNavigationControls = () => wrapper.findComponent(NavigationControls); const findNavigationControls = () => wrapper.findComponent(NavigationControls);
const findPipelinesTable = () => wrapper.findComponent(PipelinesTableComponent); const findPipelinesTable = () => wrapper.findComponent(PipelinesTableComponent);
const findEmptyState = () => wrapper.findComponent(EmptyState);
const findBlankState = () => wrapper.findComponent(BlankState);
const findTablePagination = () => wrapper.findComponent(TablePagination); const findTablePagination = () => wrapper.findComponent(TablePagination);
const findTab = (tab) => wrapper.findByTestId(`pipelines-tab-${tab}`); const findTab = (tab) => wrapper.findByTestId(`pipelines-tab-${tab}`);
...@@ -268,7 +265,7 @@ describe('Pipelines', () => { ...@@ -268,7 +265,7 @@ describe('Pipelines', () => {
}); });
it('should filter pipelines', async () => { it('should filter pipelines', async () => {
expect(findBlankState().text()).toBe('There are currently no pipelines.'); expect(findEmptyState().text()).toBe('There are currently no pipelines.');
}); });
it('should update browser bar', () => { it('should update browser bar', () => {
...@@ -515,7 +512,7 @@ describe('Pipelines', () => { ...@@ -515,7 +512,7 @@ describe('Pipelines', () => {
}); });
it('renders empty state', () => { it('renders empty state', () => {
expect(findBlankState().text()).toBe('There are currently no pipelines.'); expect(findEmptyState().text()).toBe('There are currently no pipelines.');
}); });
it('renders tab empty state finished scope', async () => { it('renders tab empty state finished scope', async () => {
...@@ -528,7 +525,7 @@ describe('Pipelines', () => { ...@@ -528,7 +525,7 @@ describe('Pipelines', () => {
await waitForPromises(); await waitForPromises();
expect(findBlankState().text()).toBe('There are currently no finished pipelines.'); expect(findEmptyState().text()).toBe('There are currently no finished pipelines.');
}); });
}); });
...@@ -599,7 +596,7 @@ describe('Pipelines', () => { ...@@ -599,7 +596,7 @@ describe('Pipelines', () => {
}); });
it('renders empty state', () => { it('renders empty state', () => {
expect(findBlankState().text()).toBe('There are currently no pipelines.'); expect(findEmptyState().text()).toBe('There are currently no pipelines.');
}); });
}); });
}); });
...@@ -688,7 +685,7 @@ describe('Pipelines', () => { ...@@ -688,7 +685,7 @@ describe('Pipelines', () => {
}); });
it('shows error state', () => { it('shows error state', () => {
expect(findBlankState().text()).toBe( expect(findEmptyState().text()).toBe(
'There was an error fetching the pipelines. Try again in a few moments or contact your support team.', 'There was an error fetching the pipelines. Try again in a few moments or contact your support team.',
); );
}); });
...@@ -713,7 +710,7 @@ describe('Pipelines', () => { ...@@ -713,7 +710,7 @@ describe('Pipelines', () => {
}); });
it('shows error state', () => { it('shows error state', () => {
expect(findBlankState().text()).toBe( expect(findEmptyState().text()).toBe(
'There was an error fetching the pipelines. Try again in a few moments or contact your support team.', 'There was an error fetching the pipelines. Try again in a few moments or contact your support team.',
); );
}); });
......
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