Commit 24bf932b authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '271250-fe-devops-report-adding-preparing-state-and-tooltips-in-segment-table-3' into 'master'

DevOps Report: Add table cell tooltips

See merge request gitlab-org/gitlab!49687
parents 635a14b6 d74bd943
<script> <script>
import { GlTooltipDirective } from '@gitlab/ui';
import { DEVOPS_ADOPTION_STRINGS } from '../constants';
const {
tableCell: { trueText, falseText },
} = DEVOPS_ADOPTION_STRINGS;
export default { export default {
name: 'DevopsAdoptionTableCellFlag', name: 'DevopsAdoptionTableCellFlag',
directives: {
GlTooltip: GlTooltipDirective,
},
props: { props: {
enabled: { enabled: {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
}, },
data() {
return {
tooltipText: this.enabled ? trueText : falseText,
};
},
}; };
</script> </script>
<template> <template>
<span class="circle" :class="{ 'circle-enabled': enabled }"></span> <span
v-gl-tooltip.hover="tooltipText"
class="circle"
:class="{ 'circle-enabled': enabled }"
></span>
</template> </template>
...@@ -93,6 +93,10 @@ export const DEVOPS_ADOPTION_STRINGS = { ...@@ -93,6 +93,10 @@ export const DEVOPS_ADOPTION_STRINGS = {
confirm: s__('DevopsAdoption|Delete segment'), confirm: s__('DevopsAdoption|Delete segment'),
error: s__('DevopsAdoption|An error occured while deleting the segment. Please try again.'), error: s__('DevopsAdoption|An error occured while deleting the segment. Please try again.'),
}, },
tableCell: {
trueText: s__('DevopsAdoption|Adopted'),
falseText: s__('DevopsAdoption|Not adopted'),
},
}; };
export const DEVOPS_ADOPTION_TABLE_TEST_IDS = { export const DEVOPS_ADOPTION_TABLE_TEST_IDS = {
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import DevopsAdoptionTableCellFlag from 'ee/admin/dev_ops_report/components/devops_adoption_table_cell_flag.vue'; import DevopsAdoptionTableCellFlag from 'ee/admin/dev_ops_report/components/devops_adoption_table_cell_flag.vue';
describe('DevopsAdoptionTableCellFlag', () => { describe('DevopsAdoptionTableCellFlag', () => {
...@@ -10,6 +11,9 @@ describe('DevopsAdoptionTableCellFlag', () => { ...@@ -10,6 +11,9 @@ describe('DevopsAdoptionTableCellFlag', () => {
enabled: true, enabled: true,
...props, ...props,
}, },
directives: {
GlTooltip: createMockDirective(),
},
}); });
}; };
...@@ -18,17 +22,35 @@ describe('DevopsAdoptionTableCellFlag', () => { ...@@ -18,17 +22,35 @@ describe('DevopsAdoptionTableCellFlag', () => {
wrapper = null; wrapper = null;
}); });
it('contains the circle-enabled class when enabled', () => { describe('enabled', () => {
createComponent(); beforeEach(() => createComponent());
it('contains the circle-enabled class', () => {
expect(wrapper.classes()).toContain('circle'); expect(wrapper.classes()).toContain('circle');
expect(wrapper.classes()).toContain('circle-enabled'); expect(wrapper.classes()).toContain('circle-enabled');
}); });
it('does not contain the circle-enabled class when disabled', () => { it('contains a tooltip', () => {
createComponent({ enabled: false }); const tooltip = getBinding(wrapper.element, 'gl-tooltip');
expect(tooltip).toBeDefined();
expect(tooltip.value).toBe('Adopted');
});
});
describe('disabled', () => {
beforeEach(() => createComponent({ enabled: false }));
it('does not contain the circle-enabled class', () => {
expect(wrapper.classes()).toContain('circle'); expect(wrapper.classes()).toContain('circle');
expect(wrapper.classes()).not.toContain('circle-enabled'); expect(wrapper.classes()).not.toContain('circle-enabled');
}); });
it('contains a tooltip', () => {
const tooltip = getBinding(wrapper.element, 'gl-tooltip');
expect(tooltip).toBeDefined();
expect(tooltip.value).toBe('Not adopted');
});
});
}); });
...@@ -9607,6 +9607,9 @@ msgstr "" ...@@ -9607,6 +9607,9 @@ msgstr ""
msgid "DevopsAdoption|Add new segment" msgid "DevopsAdoption|Add new segment"
msgstr "" msgstr ""
msgid "DevopsAdoption|Adopted"
msgstr ""
msgid "DevopsAdoption|An error occured while deleting the segment. Please try again." msgid "DevopsAdoption|An error occured while deleting the segment. Please try again."
msgstr "" msgstr ""
...@@ -9679,6 +9682,9 @@ msgstr "" ...@@ -9679,6 +9682,9 @@ msgstr ""
msgid "DevopsAdoption|No filter results." msgid "DevopsAdoption|No filter results."
msgstr "" msgstr ""
msgid "DevopsAdoption|Not adopted"
msgstr ""
msgid "DevopsAdoption|Pipelines" msgid "DevopsAdoption|Pipelines"
msgstr "" msgstr ""
......
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