Commit e4be6d84 authored by Denys Mishunov's avatar Denys Mishunov

Merge branch '220935' into 'master'

Update pinned links to use GlButton

See merge request gitlab-org/gitlab!34620
parents 65574929 260cec16
<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" target="_blank"
data-testid="publishedIncidentUrl" :icon="link.icon"
> size="small"
<icon name="tanuki" :size="14" /> class="gl-font-weight-bold gl-mb-5"
<strong class="vertical-align-top">{{ __('Published on status page') }}</strong> :data-testid="link.id"
</gl-link> >{{ link.text }}</gl-button
</div> >
<div v-if="zoomMeetingUrl"> </div>
<gl-link </template>
:href="zoomMeetingUrl"
target="_blank"
class="btn btn-inverted btn-secondary btn-sm text-dark mb-3"
data-testid="zoomMeetingUrl"
>
<icon name="brand-zoom" :size="14" />
<strong class="vertical-align-top">{{ __('Join Zoom meeting') }}</strong>
</gl-link>
</div>
</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