summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/issue_show/components/pinned_links.vue
blob: 7a54b26bc2bc482f753476d1f4ee7c229be4398f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script>
import { GlLink } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';

export default {
  components: {
    Icon,
    GlLink,
  },
  props: {
    descriptionHtml: {
      type: String,
      required: true,
    },
  },
  computed: {
    linksInDescription() {
      const el = document.createElement('div');
      el.innerHTML = this.descriptionHtml;
      return [...el.querySelectorAll('a')].map(a => a.href);
    },
    // Detect links matching the following formats:
    // Zoom Start links: https://zoom.us/s/<meeting-id>
    // Zoom Join links: https://zoom.us/j/<meeting-id>
    // Personal Zoom links: https://zoom.us/my/<meeting-id>
    // Vanity Zoom links: https://gitlab.zoom.us/j/<meeting-id> (also /s and /my)
    zoomHref() {
      const zoomRegex = /^https:\/\/([\w\d-]+\.)?zoom\.us\/(s|j|my)\/.+/;
      return this.linksInDescription.reduce((acc, currentLink) => {
        let lastLink = acc;
        if (zoomRegex.test(currentLink)) {
          lastLink = currentLink;
        }
        return lastLink;
      }, '');
    },
  },
};
</script>

<template>
  <div v-if="zoomHref" class="border-bottom mb-3 mt-n2">
    <gl-link
      :href="zoomHref"
      target="_blank"
      class="btn btn-inverted btn-secondary btn-sm text-dark mb-3"
    >
      <icon name="brand-zoom" :size="14" />
      <strong class="vertical-align-top">{{ __('Join Zoom meeting') }}</strong>
    </gl-link>
  </div>
</template>