Commit bb38153e authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

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

DevOps Report: Add tooltips to table headings

See merge request gitlab-org/gitlab!49577
parents f6ffe2d8 cec99db0
<script> <script>
import { GlTable, GlButton, GlPopover, GlModalDirective } from '@gitlab/ui'; import {
import { s__ } from '~/locale'; GlTable,
GlButton,
GlPopover,
GlModalDirective,
GlTooltipDirective,
GlIcon,
} from '@gitlab/ui';
import DevopsAdoptionTableCellFlag from './devops_adoption_table_cell_flag.vue'; import DevopsAdoptionTableCellFlag from './devops_adoption_table_cell_flag.vue';
import DevopsAdoptionDeleteModal from './devops_adoption_delete_modal.vue'; import DevopsAdoptionDeleteModal from './devops_adoption_delete_modal.vue';
import { import {
...@@ -15,6 +21,19 @@ const fieldOptions = { ...@@ -15,6 +21,19 @@ const fieldOptions = {
thAttr: { 'data-testid': DEVOPS_ADOPTION_TABLE_TEST_IDS.TABLE_HEADERS }, thAttr: { 'data-testid': DEVOPS_ADOPTION_TABLE_TEST_IDS.TABLE_HEADERS },
}; };
const { table: i18n } = DEVOPS_ADOPTION_STRINGS;
const headers = [
'name',
'issueOpened',
'mergeRequestOpened',
'mergeRequestApproved',
'runnerConfigured',
'pipelineSucceeded',
'deploySucceeded',
'securityScanSucceeded',
].map(key => ({ key, ...i18n.headers[key], ...fieldOptions }));
export default { export default {
name: 'DevopsAdoptionTable', name: 'DevopsAdoptionTable',
components: { components: {
...@@ -23,57 +42,19 @@ export default { ...@@ -23,57 +42,19 @@ export default {
GlButton, GlButton,
GlPopover, GlPopover,
DevopsAdoptionDeleteModal, DevopsAdoptionDeleteModal,
GlIcon,
}, },
i18n: DEVOPS_ADOPTION_STRINGS.table, i18n,
devopsSegmentModalId: DEVOPS_ADOPTION_SEGMENT_MODAL_ID, devopsSegmentModalId: DEVOPS_ADOPTION_SEGMENT_MODAL_ID,
devopsSegmentDeleteModalId: DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID, devopsSegmentDeleteModalId: DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID,
directives: { directives: {
GlTooltip: GlTooltipDirective,
GlModal: GlModalDirective, GlModal: GlModalDirective,
}, },
tableHeaderFields: [ tableHeaderFields: [
{ ...headers,
key: 'name',
label: s__('DevopsAdoption|Segment'),
...fieldOptions,
},
{
key: 'issueOpened',
label: s__('DevopsAdoption|Issues'),
...fieldOptions,
},
{
key: 'mergeRequestOpened',
label: s__('DevopsAdoption|MRs'),
...fieldOptions,
},
{
key: 'mergeRequestApproved',
label: s__('DevopsAdoption|Approvals'),
...fieldOptions,
},
{
key: 'runnerConfigured',
label: s__('DevopsAdoption|Runners'),
...fieldOptions,
},
{
key: 'pipelineSucceeded',
label: s__('DevopsAdoption|Pipelines'),
...fieldOptions,
},
{
key: 'deploySucceeded',
label: s__('DevopsAdoption|Deploys'),
...fieldOptions,
},
{
key: 'securityScanSucceeded',
label: s__('DevopsAdoption|Scanning'),
...fieldOptions,
},
{ {
key: 'actions', key: 'actions',
label: '',
tdClass: 'actions-cell', tdClass: 'actions-cell',
...fieldOptions, ...fieldOptions,
}, },
...@@ -100,6 +81,9 @@ export default { ...@@ -100,6 +81,9 @@ export default {
setSelectedSegment(segment) { setSelectedSegment(segment) {
this.$emit('set-selected-segment', segment); this.$emit('set-selected-segment', segment);
}, },
slotName(key) {
return `head(${key})`;
},
}, },
}; };
</script> </script>
...@@ -111,6 +95,19 @@ export default { ...@@ -111,6 +95,19 @@ export default {
thead-class="gl-border-t-0 gl-border-b-solid gl-border-b-1 gl-border-b-gray-100" thead-class="gl-border-t-0 gl-border-b-solid gl-border-b-1 gl-border-b-gray-100"
stacked="sm" stacked="sm"
> >
<template v-for="header in $options.tableHeaderFields" #[slotName(header.key)]>
<div :key="header.key" class="gl-display-flex gl-align-items-center">
<span>{{ header.label }}</span>
<gl-icon
v-if="header.tooltip"
v-gl-tooltip.hover="header.tooltip"
name="information-o"
class="gl-text-gray-200 gl-ml-1"
:size="14"
/>
</div>
</template>
<template #cell(name)="{ item }"> <template #cell(name)="{ item }">
<div :data-testid="$options.testids.SEGMENT"> <div :data-testid="$options.testids.SEGMENT">
<strong>{{ item.name }}</strong> <strong>{{ item.name }}</strong>
......
...@@ -52,6 +52,39 @@ export const DEVOPS_ADOPTION_STRINGS = { ...@@ -52,6 +52,39 @@ export const DEVOPS_ADOPTION_STRINGS = {
table: { table: {
editButton: s__('DevopsAdoption|Edit segment'), editButton: s__('DevopsAdoption|Edit segment'),
deleteButton: s__('DevopsAdoption|Delete segment'), deleteButton: s__('DevopsAdoption|Delete segment'),
headers: {
name: {
label: s__('DevopsAdoption|Segment'),
},
issueOpened: {
label: s__('DevopsAdoption|Issues'),
tooltip: s__('DevopsAdoption|At least 1 issue opened'),
},
mergeRequestOpened: {
label: s__('DevopsAdoption|MRs'),
tooltip: s__('DevopsAdoption|At least 1 MR opened'),
},
mergeRequestApproved: {
label: s__('DevopsAdoption|Approvals'),
tooltip: s__('DevopsAdoption|At least 1 approval on an MR'),
},
runnerConfigured: {
label: s__('DevopsAdoption|Runners'),
tooltip: s__('DevopsAdoption|Runner configured for project/group'),
},
pipelineSucceeded: {
label: s__('DevopsAdoption|Pipelines'),
tooltip: s__('DevopsAdoption|At least 1 pipeline successfully run'),
},
deploySucceeded: {
label: s__('DevopsAdoption|Deploys'),
tooltip: s__('DevopsAdoption|At least 1 deploy'),
},
securityScanSucceeded: {
label: s__('DevopsAdoption|Scanning'),
tooltip: s__('DevopsAdoption|At least 1 security scan of any type run in pipeline'),
},
},
}, },
deleteModal: { deleteModal: {
title: s__('DevopsAdoption|Confirm delete segment'), title: s__('DevopsAdoption|Confirm delete segment'),
......
import { GlTable, GlButton } from '@gitlab/ui'; import { GlTable, GlButton, GlIcon } from '@gitlab/ui';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import DevopsAdoptionTable from 'ee/admin/dev_ops_report/components/devops_adoption_table.vue'; import DevopsAdoptionTable from 'ee/admin/dev_ops_report/components/devops_adoption_table.vue';
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';
import { DEVOPS_ADOPTION_TABLE_TEST_IDS as TEST_IDS } from 'ee/admin/dev_ops_report/constants'; import { DEVOPS_ADOPTION_TABLE_TEST_IDS as TEST_IDS } from 'ee/admin/dev_ops_report/constants';
...@@ -13,6 +14,9 @@ describe('DevopsAdoptionTable', () => { ...@@ -13,6 +14,9 @@ describe('DevopsAdoptionTable', () => {
propsData: { propsData: {
segments: devopsAdoptionSegmentsData.nodes, segments: devopsAdoptionSegmentsData.nodes,
}, },
directives: {
GlTooltip: createMockDirective(),
},
}); });
}; };
...@@ -32,13 +36,48 @@ describe('DevopsAdoptionTable', () => { ...@@ -32,13 +36,48 @@ describe('DevopsAdoptionTable', () => {
const findColSubComponent = (colTestId, childComponent) => const findColSubComponent = (colTestId, childComponent) =>
findCol(colTestId).find(childComponent); findCol(colTestId).find(childComponent);
it('displays the correct table headers', () => { describe('table headings', () => {
const headers = findTable().findAll(`[data-testid="${TEST_IDS.TABLE_HEADERS}"]`); let headers;
beforeEach(() => {
headers = findTable().findAll(`[data-testid="${TEST_IDS.TABLE_HEADERS}"]`);
});
it('displays the correct number of headings', () => {
expect(headers).toHaveLength(devopsAdoptionTableHeaders.length);
});
describe.each(devopsAdoptionTableHeaders)(
'header fields',
({ label, tooltip: tooltipText, index }) => {
let headerWrapper;
expect(headers).toHaveLength(devopsAdoptionTableHeaders.length); beforeEach(() => {
headerWrapper = headers.at(index);
});
devopsAdoptionTableHeaders.forEach((headerText, i) => it(`displays the correct table heading text for "${label}"`, () => {
expect(headers.at(i).text()).toEqual(headerText), expect(headerWrapper.text()).toBe(label);
});
describe(`helper information for "${label}"`, () => {
const expected = Boolean(tooltipText);
it(`${expected ? 'displays' : "doesn't display"} an information icon`, () => {
expect(headerWrapper.find(GlIcon).exists()).toBe(expected);
});
if (expected) {
it('includes a tooltip', () => {
const icon = headerWrapper.find(GlIcon);
const tooltip = getBinding(icon.element, 'gl-tooltip');
expect(tooltip).toBeDefined();
expect(tooltip.value).toBe(tooltipText);
});
}
});
},
); );
}); });
......
...@@ -66,15 +66,51 @@ export const devopsAdoptionSegmentsDataEmpty = { ...@@ -66,15 +66,51 @@ export const devopsAdoptionSegmentsDataEmpty = {
}; };
export const devopsAdoptionTableHeaders = [ export const devopsAdoptionTableHeaders = [
'Segment', {
'Issues', index: 0,
'MRs', label: 'Segment',
'Approvals', tooltip: null,
'Runners', },
'Pipelines', {
'Deploys', index: 1,
'Scanning', label: 'Issues',
'', tooltip: 'At least 1 issue opened',
},
{
index: 2,
label: 'MRs',
tooltip: 'At least 1 MR opened',
},
{
index: 3,
label: 'Approvals',
tooltip: 'At least 1 approval on an MR',
},
{
index: 4,
label: 'Runners',
tooltip: 'Runner configured for project/group',
},
{
index: 5,
label: 'Pipelines',
tooltip: 'At least 1 pipeline successfully run',
},
{
index: 6,
label: 'Deploys',
tooltip: 'At least 1 deploy',
},
{
index: 7,
label: 'Scanning',
tooltip: 'At least 1 security scan of any type run in pipeline',
},
{
index: 8,
label: '',
tooltip: null,
},
]; ];
export const segmentName = 'Foooo'; export const segmentName = 'Foooo';
......
...@@ -9619,6 +9619,24 @@ msgstr "" ...@@ -9619,6 +9619,24 @@ msgstr ""
msgid "DevopsAdoption|Are you sure that you would like to delete %{name}?" msgid "DevopsAdoption|Are you sure that you would like to delete %{name}?"
msgstr "" msgstr ""
msgid "DevopsAdoption|At least 1 MR opened"
msgstr ""
msgid "DevopsAdoption|At least 1 approval on an MR"
msgstr ""
msgid "DevopsAdoption|At least 1 deploy"
msgstr ""
msgid "DevopsAdoption|At least 1 issue opened"
msgstr ""
msgid "DevopsAdoption|At least 1 pipeline successfully run"
msgstr ""
msgid "DevopsAdoption|At least 1 security scan of any type run in pipeline"
msgstr ""
msgid "DevopsAdoption|Confirm delete segment" msgid "DevopsAdoption|Confirm delete segment"
msgstr "" msgstr ""
...@@ -9664,6 +9682,9 @@ msgstr "" ...@@ -9664,6 +9682,9 @@ msgstr ""
msgid "DevopsAdoption|Pipelines" msgid "DevopsAdoption|Pipelines"
msgstr "" msgstr ""
msgid "DevopsAdoption|Runner configured for project/group"
msgstr ""
msgid "DevopsAdoption|Runners" msgid "DevopsAdoption|Runners"
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