Skip to content
Snippets Groups Projects
Commit f6e5f203 authored by Pham Sy Minh's avatar Pham Sy Minh Committed by Jose Ivan Vargas
Browse files

Hide the 'Resync' button when there are no results

Changelog: changed
parent 8396c93a
No related branches found
No related tags found
1 merge request!90787Hide the 'Resync' button when there are no results
......@@ -46,6 +46,9 @@ export default {
this.fetchReplicableItems();
},
},
hasReplicableItems() {
return this.paginationData.total > 0;
},
resyncText() {
return sprintf(this.$options.i18n.resyncAllReplicables, {
replicableType: this.replicableTypeName,
......@@ -100,7 +103,10 @@ export default {
/>
</div>
</div>
<div class="col col-sm-5 d-flex justify-content-end my-1 my-sm-0 w-100">
<div
v-if="hasReplicableItems"
class="col col-sm-5 d-flex justify-content-end my-1 my-sm-0 w-100"
>
<gl-button v-gl-modal-directive="$options.RESYNC_MODAL_ID">{{
$options.i18n.resyncAll
}}</gl-button>
......
......@@ -103,14 +103,24 @@ describe('GeoReplicableFilterBar', () => {
});
describe('Re-sync all button', () => {
it('renders always', () => {
expect(findGlButton().exists()).toBe(true);
it('does not render', () => {
expect(findGlButton().exists()).toBe(false);
});
it('triggers GlModal', () => {
const binding = getBinding(findGlButton().element, 'gl-modal-directive');
describe('when there are results', () => {
beforeEach(() => {
wrapper.vm.$store.state.paginationData.total = 1;
});
it('renders', () => {
expect(findGlButton().exists()).toBe(true);
});
it('triggers GlModal', () => {
const binding = getBinding(findGlButton().element, 'gl-modal-directive');
expect(binding.value).toBe(RESYNC_MODAL_ID);
expect(binding.value).toBe(RESYNC_MODAL_ID);
});
});
});
......@@ -120,7 +130,6 @@ describe('GeoReplicableFilterBar', () => {
});
it('updates title', async () => {
expect(findGlModal().props('title')).toBe('Resync all designs');
wrapper.vm.$store.state.paginationData.total = 1;
await nextTick();
expect(findGlModal().props('title')).toBe('Resync all designs');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment