Commit 1bc65d29 authored by Kushal Pandya's avatar Kushal Pandya

Use popover to show help text

parent 88ccc95f
<script> <script>
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip'; import popover from '~/vue_shared/directives/popover';
import Icon from '~/vue_shared/components/icon.vue'; 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';
import geoNodeSyncSettings from './geo_node_sync_settings.vue'; import GeoNodeSyncSettings from './geo_node_sync_settings.vue';
import geoNodeEventStatus from './geo_node_event_status.vue'; import GeoNodeEventStatus from './geo_node_event_status.vue';
export default { export default {
components: { components: {
Icon, Icon,
stackedProgressBar, StackedProgressBar,
geoNodeSyncSettings, GeoNodeSyncSettings,
geoNodeEventStatus, GeoNodeEventStatus,
}, },
directives: { directives: {
tooltip, popover,
}, },
props: { props: {
itemTitle: { itemTitle: {
...@@ -62,15 +62,15 @@ ...@@ -62,15 +62,15 @@
required: false, required: false,
default: false, default: false,
}, },
helpText: { helpInfo: {
type: String, type: [Boolean, Object],
required: false, required: false,
default: '', default: false,
}, },
}, },
computed: { computed: {
hasHelpText() { hasHelpInfo() {
return this.helpText !== ''; return typeof this.helpInfo === 'object';
}, },
isValueTypePlain() { isValueTypePlain() {
return this.itemValueType === VALUE_TYPE.PLAIN; return this.itemValueType === VALUE_TYPE.PLAIN;
...@@ -84,6 +84,26 @@ ...@@ -84,6 +84,26 @@
isCustomTypeSync() { isCustomTypeSync() {
return this.customType === CUSTOM_TYPE.SYNC; return this.customType === CUSTOM_TYPE.SYNC;
}, },
popoverConfig() {
return {
html: true,
trigger: 'click',
placement: 'top',
template: `
<div class="popover geo-node-detail-popover" role="tooltip">
<div class="arrow"></div>
<p class="popover-title"></p>
<div class="popover-content"></div>
</div>
`,
title: this.helpInfo.title,
content: `
<a href="${this.helpInfo.url}">
${this.helpInfo.urlText}
</a>
`,
};
},
}, },
}; };
</script> </script>
...@@ -95,12 +115,11 @@ ...@@ -95,12 +115,11 @@
{{ itemTitle }} {{ itemTitle }}
</span> </span>
<icon <icon
v-tooltip v-popover="popoverConfig"
v-if="hasHelpText" v-if="hasHelpInfo"
css-classes="node-detail-help-text prepend-left-5" css-classes="node-detail-help-text prepend-left-5"
name="question" name="question"
:size="12" :size="12"
:title="helpText"
/> />
</div> </div>
<div <div
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import { VALUE_TYPE } from '../../constants'; import { VALUE_TYPE, HELP_INFO_URLS } from '../../constants';
import GeoNodeDetailItem from '../geo_node_detail_item.vue'; import GeoNodeDetailItem from '../geo_node_detail_item.vue';
import SectionRevealButton from './section_reveal_button.vue'; import SectionRevealButton from './section_reveal_button.vue';
...@@ -55,7 +55,11 @@ ...@@ -55,7 +55,11 @@
successLabel: s__('GeoNodes|Checksummed'), successLabel: s__('GeoNodes|Checksummed'),
neutraLabel: s__('GeoNodes|Not checksummed'), neutraLabel: s__('GeoNodes|Not checksummed'),
failureLabel: s__('GeoNodes|Failed'), failureLabel: s__('GeoNodes|Failed'),
helpText: s__('GeoNodes|Repositories checksummed for verification with their counterparts on Secondary nodes'), helpInfo: {
title: s__('GeoNodes|Repositories checksummed for verification with their counterparts on Secondary nodes'),
url: HELP_INFO_URLS.REPOSITORY_VERIFICATION,
urlText: s__('GeoNodes|Learn more about Repository checksum progress'),
},
}, },
{ {
itemTitle: s__('GeoNodes|Wiki checksum progress'), itemTitle: s__('GeoNodes|Wiki checksum progress'),
...@@ -64,7 +68,11 @@ ...@@ -64,7 +68,11 @@
successLabel: s__('GeoNodes|Checksummed'), successLabel: s__('GeoNodes|Checksummed'),
neutraLabel: s__('GeoNodes|Not checksummed'), neutraLabel: s__('GeoNodes|Not checksummed'),
failureLabel: s__('GeoNodes|Failed'), failureLabel: s__('GeoNodes|Failed'),
helpText: s__('GeoNodes|Wikis checksummed for verification with their counterparts on Secondary nodes'), helpInfo: {
title: s__('GeoNodes|Wikis checksummed for verification with their counterparts on Secondary nodes'),
url: HELP_INFO_URLS.REPOSITORY_VERIFICATION,
urlText: s__('GeoNodes|Learn more about Wiki checksum progress'),
},
}, },
); );
} }
...@@ -101,7 +109,11 @@ ...@@ -101,7 +109,11 @@
successLabel: s__('GeoNodes|Verified'), successLabel: s__('GeoNodes|Verified'),
neutraLabel: s__('GeoNodes|Unverified'), neutraLabel: s__('GeoNodes|Unverified'),
failureLabel: s__('GeoNodes|Failed'), failureLabel: s__('GeoNodes|Failed'),
helpText: s__('GeoNodes|Repositories verified with their counterparts on the Primary node'), helpInfo: {
title: s__('GeoNodes|Repositories verified with their counterparts on the Primary node'),
url: HELP_INFO_URLS.REPOSITORY_VERIFICATION,
urlText: s__('GeoNodes|Learn more about Repository checksum progress'),
},
}, },
{ {
itemTitle: s__('GeoNodes|Wiki verification progress'), itemTitle: s__('GeoNodes|Wiki verification progress'),
...@@ -110,7 +122,11 @@ ...@@ -110,7 +122,11 @@
successLabel: s__('GeoNodes|Verified'), successLabel: s__('GeoNodes|Verified'),
neutraLabel: s__('GeoNodes|Unverified'), neutraLabel: s__('GeoNodes|Unverified'),
failureLabel: s__('GeoNodes|Failed'), failureLabel: s__('GeoNodes|Failed'),
helpText: s__('GeoNodes|Wikis verified with their counterparts on the Primary node'), helpInfo: {
title: s__('GeoNodes|Wikis verified with their counterparts on the Primary node'),
url: HELP_INFO_URLS.CHECKSUMS,
urlText: s__('GeoNodes|Learn more about Wiki checksum progress'),
},
}, },
]; ];
...@@ -149,7 +165,7 @@ ...@@ -149,7 +165,7 @@
:neutral-label="nodeDetailItem.neutraLabel" :neutral-label="nodeDetailItem.neutraLabel"
:failure-label="nodeDetailItem.failureLabel" :failure-label="nodeDetailItem.failureLabel"
:custom-type="nodeDetailItem.customType" :custom-type="nodeDetailItem.customType"
:help-text="nodeDetailItem.helpText" :help-info="nodeDetailItem.helpInfo"
/> />
</div> </div>
</template> </template>
......
...@@ -27,3 +27,5 @@ export const TIME_DIFF = { ...@@ -27,3 +27,5 @@ export const TIME_DIFF = {
FIVE_MINS: 300, FIVE_MINS: 300,
HOUR: 3600, HOUR: 3600,
}; };
export const HELP_INFO_URLS = { REPOSITORY_VERIFICATION: 'https://docs.gitlab.com/ee/administration/geo/disaster_recovery/background_verification.html#repository-verification', CHECKSUMS: 'https://docs.gitlab.com/ee/administration/geo/disaster_recovery/background_verification.html#using-checksums-to-compare-geo-nodes' };
...@@ -37,13 +37,13 @@ describe('GeoNodeDetailItemComponent', () => { ...@@ -37,13 +37,13 @@ describe('GeoNodeDetailItemComponent', () => {
vm.$destroy(); vm.$destroy();
}); });
it('renders item title help text icon and tooltip', () => { it('renders item title help info icon and popover with help info', () => {
const helpText = 'Foo title tooltip'; const helpInfo = { title: 'Foo title tooltip', url: 'https://docs.gitlab.com', urlText: 'Help' };
const vm = createComponent({ helpText }); const vm = createComponent({ helpInfo });
const helpTextEl = vm.$el.querySelector('.node-detail-help-text'); const helpTextIconEl = vm.$el.querySelector('.node-detail-help-text');
expect(helpTextEl).not.toBeNull(); expect(helpTextIconEl).not.toBeNull();
expect(helpTextEl.dataset.originalTitle).toBe(helpText); expect(helpTextIconEl.querySelector('use').getAttribute('xlink:href')).toContain('question');
vm.$destroy(); vm.$destroy();
}); });
......
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