Commit 3a2afd34 authored by Kushal Pandya's avatar Kushal Pandya

Add helpText support to item title

parent 20b2d7bb
<script> <script>
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue';
import stackedProgressBar from '~/vue_shared/components/stacked_progress_bar.vue'; import stackedProgressBar from '~/vue_shared/components/stacked_progress_bar.vue';
import { VALUE_TYPE, CUSTOM_TYPE } from '../constants'; import { VALUE_TYPE, CUSTOM_TYPE } from '../constants';
...@@ -9,10 +11,14 @@ ...@@ -9,10 +11,14 @@
export default { export default {
components: { components: {
Icon,
stackedProgressBar, stackedProgressBar,
geoNodeSyncSettings, geoNodeSyncSettings,
geoNodeEventStatus, geoNodeEventStatus,
}, },
directives: {
tooltip,
},
props: { props: {
itemTitle: { itemTitle: {
type: String, type: String,
...@@ -56,8 +62,16 @@ ...@@ -56,8 +62,16 @@
required: false, required: false,
default: false, default: false,
}, },
helpText: {
type: String,
required: false,
default: '',
},
}, },
computed: { computed: {
hasHelpText() {
return this.helpText !== '';
},
isValueTypePlain() { isValueTypePlain() {
return this.itemValueType === VALUE_TYPE.PLAIN; return this.itemValueType === VALUE_TYPE.PLAIN;
}, },
...@@ -77,7 +91,17 @@ ...@@ -77,7 +91,17 @@
<template> <template>
<div class="node-detail-item prepend-top-15 prepend-left-10"> <div class="node-detail-item prepend-top-15 prepend-left-10">
<div class="node-detail-title"> <div class="node-detail-title">
{{ itemTitle }} <span>
{{ itemTitle }}
</span>
<icon
v-tooltip
v-if="hasHelpText"
css-classes="node-detail-help-text prepend-left-5"
name="question"
:size="12"
:title="helpText"
/>
</div> </div>
<div <div
v-if="isValueTypePlain" v-if="isValueTypePlain"
......
...@@ -8,7 +8,7 @@ import { rawMockNodeDetails } from '../mock_data'; ...@@ -8,7 +8,7 @@ import { rawMockNodeDetails } from '../mock_data';
const createComponent = (config) => { const createComponent = (config) => {
const Component = Vue.extend(geoNodeDetailItemComponent); const Component = Vue.extend(geoNodeDetailItemComponent);
const defaultConfig = Object.assign({ const defaultConfig = Object.assign({
itemTitle: 'GitLab version:', itemTitle: 'GitLab version',
cssClass: 'node-version', cssClass: 'node-version',
itemValue: '10.4.0-pre', itemValue: '10.4.0-pre',
successLabel: 'Synced', successLabel: 'Synced',
...@@ -26,7 +26,7 @@ describe('GeoNodeDetailItemComponent', () => { ...@@ -26,7 +26,7 @@ describe('GeoNodeDetailItemComponent', () => {
const vm = createComponent(); const vm = createComponent();
expect(vm.$el.classList.contains('node-detail-item')).toBeTruthy(); expect(vm.$el.classList.contains('node-detail-item')).toBeTruthy();
expect(vm.$el.querySelectorAll('.node-detail-title').length).not.toBe(0); expect(vm.$el.querySelectorAll('.node-detail-title').length).not.toBe(0);
expect(vm.$el.querySelector('.node-detail-title').innerText.trim()).toBe('GitLab version:'); expect(vm.$el.querySelector('.node-detail-title').innerText.trim()).toBe('GitLab version');
vm.$destroy(); vm.$destroy();
}); });
...@@ -37,6 +37,16 @@ describe('GeoNodeDetailItemComponent', () => { ...@@ -37,6 +37,16 @@ describe('GeoNodeDetailItemComponent', () => {
vm.$destroy(); vm.$destroy();
}); });
it('renders item title help text icon and tooltip', () => {
const helpText = 'Foo title tooltip';
const vm = createComponent({ helpText });
const helpTextEl = vm.$el.querySelector('.node-detail-help-text');
expect(helpTextEl).not.toBeNull();
expect(helpTextEl.dataset.originalTitle).toBe(helpText);
vm.$destroy();
});
it('renders graph item value', () => { it('renders graph item value', () => {
const vm = createComponent({ const vm = createComponent({
itemValueType: VALUE_TYPE.GRAPH, itemValueType: VALUE_TYPE.GRAPH,
......
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