All files / app/assets/javascripts/jira_connect/subscriptions/components compatibility_alert.vue

100% Statements 2/2
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74              2x                                                                                             34x                                      
<script>
import { GlAlert, GlSprintf, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import { helpPagePath } from '~/helpers/help_page_helper';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
 
const COMPATIBILITY_ALERT_STATE_KEY = 'compatibility_alert_dismissed';
 
export default {
  name: 'CompatibilityAlert',
  components: {
    GlAlert,
    GlSprintf,
    GlLink,
    LocalStorageSync,
  },
  mixins: [glFeatureFlagMixin()],
  data() {
    return {
      alertDismissed: false,
    };
  },
  computed: {
    shouldShowAlert() {
      return !this.alertDismissed;
    },
    isOauthSelfManagedEnabled() {
      return this.glFeatures.jiraConnectOauth && this.glFeatures.jiraConnectOauthSelfManaged;
    },
    alertBody() {
      return this.isOauthSelfManagedEnabled
        ? this.$options.i18n.body
        : this.$options.i18n.bodyDotCom;
    },
  },
  methods: {
    dismissAlert() {
      this.alertDismissed = true;
    },
  },
  i18n: {
    title: s__('Integrations|Known limitations'),
    body: s__(
      'Integrations|Adding a namespace only works in browsers that allow cross-site cookies. %{linkStart}Learn more%{linkEnd}.',
    ),
    bodyDotCom: s__(
      'Integrations|This integration only works with GitLab.com. Adding a namespace only works in browsers that allow cross-site cookies. %{linkStart}Learn more%{linkEnd}.',
    ),
  },
  DOCS_LINK_URL: helpPagePath('integration/jira/connect-app'),
  COMPATIBILITY_ALERT_STATE_KEY,
};
</script>
<template>
  <local-storage-sync
    v-model="alertDismissed"
    :storage-key="$options.COMPATIBILITY_ALERT_STATE_KEY"
  >
    <gl-alert
      v-if="shouldShowAlert"
      variant="info"
      :title="$options.i18n.title"
      @dismiss="dismissAlert"
    >
      <gl-sprintf :message="alertBody">
        <template #link="{ content }">
          <gl-link :href="$options.DOCS_LINK_URL" target="_blank">{{ content }}</gl-link>
        </template>
      </gl-sprintf>
    </gl-alert>
  </local-storage-sync>
</template>