Commit 260cec16 authored by David O'Regan's avatar David O'Regan Committed by Denys Mishunov

Resolve merge feedback

We are updating the pinned link component to use an
abstraction to remove duplicate HTML and
abstract strings to constants.
parent 1fee822f
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import { STATUS_PAGE_PUBLISHED, JOIN_ZOOM_MEETING } from '../constants';
export default { export default {
components: { components: {
Icon, GlButton,
GlLink,
}, },
props: { props: {
zoomMeetingUrl: { zoomMeetingUrl: {
...@@ -19,32 +18,46 @@ export default { ...@@ -19,32 +18,46 @@ export default {
default: '', default: '',
}, },
}, },
computed: {
pinnedLinks() {
return [
{
id: 'publishedIncidentUrl',
url: this.publishedIncidentUrl,
text: STATUS_PAGE_PUBLISHED,
icon: 'tanuki',
},
{
id: 'zoomMeetingUrl',
url: this.zoomMeetingUrl,
text: JOIN_ZOOM_MEETING,
icon: 'brand-zoom',
},
];
},
},
methods: {
needsPaddingClass(i) {
return i < this.pinnedLinks.length - 1;
},
},
}; };
</script> </script>
<template> <template>
<div class="border-bottom gl-mb-6 gl-display-flex gl-justify-content-start"> <div class="border-bottom gl-mb-6 gl-display-flex gl-justify-content-start">
<div v-if="publishedIncidentUrl" class="gl-pr-3"> <template v-for="(link, i) in pinnedLinks">
<gl-link <div v-if="link.url" :key="link.id" :class="{ 'gl-pr-3': needsPaddingClass(i) }">
:href="publishedIncidentUrl" <gl-button
target="_blank" :href="link.url"
class="btn btn-inverted btn-secondary btn-sm text-dark mb-3"
data-testid="publishedIncidentUrl"
>
<icon name="tanuki" :size="14" />
<strong class="vertical-align-top">{{ __('Published on status page') }}</strong>
</gl-link>
</div>
<div v-if="zoomMeetingUrl">
<gl-link
:href="zoomMeetingUrl"
target="_blank" target="_blank"
class="btn btn-inverted btn-secondary btn-sm text-dark mb-3" :icon="link.icon"
data-testid="zoomMeetingUrl" size="small"
class="gl-font-weight-bold gl-mb-5"
:data-testid="link.id"
>{{ link.text }}</gl-button
> >
<icon name="brand-zoom" :size="14" />
<strong class="vertical-align-top">{{ __('Join Zoom meeting') }}</strong>
</gl-link>
</div> </div>
</template>
</div> </div>
</template> </template>
...@@ -15,3 +15,6 @@ export const IssuableType = { ...@@ -15,3 +15,6 @@ export const IssuableType = {
Epic: 'epic', Epic: 'epic',
MergeRequest: 'merge_request', MergeRequest: 'merge_request',
}; };
export const STATUS_PAGE_PUBLISHED = __('Published on status page');
export const JOIN_ZOOM_MEETING = __('Join Zoom meeting');
---
title: Update pinned links to use GlButton
merge_request: 34620
author:
type: other
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import PinnedLinks from '~/issue_show/components/pinned_links.vue'; import PinnedLinks from '~/issue_show/components/pinned_links.vue';
import { STATUS_PAGE_PUBLISHED, JOIN_ZOOM_MEETING } from '~/issue_show/constants';
const plainZoomUrl = 'https://zoom.us/j/123456789'; const plainZoomUrl = 'https://zoom.us/j/123456789';
const plainStatusUrl = 'https://status.com'; const plainStatusUrl = 'https://status.com';
...@@ -8,7 +9,7 @@ const plainStatusUrl = 'https://status.com'; ...@@ -8,7 +9,7 @@ const plainStatusUrl = 'https://status.com';
describe('PinnedLinks', () => { describe('PinnedLinks', () => {
let wrapper; let wrapper;
const findLinks = () => wrapper.findAll(GlLink); const findButtons = () => wrapper.findAll(GlButton);
const createComponent = props => { const createComponent = props => {
wrapper = shallowMount(PinnedLinks, { wrapper = shallowMount(PinnedLinks, {
...@@ -26,10 +27,10 @@ describe('PinnedLinks', () => { ...@@ -26,10 +27,10 @@ describe('PinnedLinks', () => {
}); });
expect( expect(
findLinks() findButtons()
.at(0) .at(0)
.text(), .text(),
).toBe('Join Zoom meeting'); ).toBe(JOIN_ZOOM_MEETING);
}); });
it('displays Status link', () => { it('displays Status link', () => {
...@@ -38,10 +39,10 @@ describe('PinnedLinks', () => { ...@@ -38,10 +39,10 @@ describe('PinnedLinks', () => {
}); });
expect( expect(
findLinks() findButtons()
.at(0) .at(0)
.text(), .text(),
).toBe('Published on status page'); ).toBe(STATUS_PAGE_PUBLISHED);
}); });
it('does not render if there are no links', () => { it('does not render if there are no links', () => {
...@@ -50,6 +51,6 @@ describe('PinnedLinks', () => { ...@@ -50,6 +51,6 @@ describe('PinnedLinks', () => {
publishedIncidentUrl: '', publishedIncidentUrl: '',
}); });
expect(wrapper.find(GlLink).exists()).toBe(false); expect(findButtons()).toHaveLength(0);
}); });
}); });
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