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

0% Statements 0/4
0% Branches 0/4
0% Functions 0/4
0% Lines 0/4

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                                                                                                               
<script>
import { GlLink, GlSprintf } from '@gitlab/ui';
import { __ } from '~/locale';
 
export default {
  components: {
    GlLink,
    GlSprintf,
  },
  inject: {
    gitlabUserPath: {
      default: '',
    },
  },
  props: {
    user: {
      type: Object,
      required: false,
      default: null,
    },
  },
  computed: {
    gitlabUserName() {
      return gon.current_username ?? this.user?.username;
    },
    gitlabUserHandle() {
      return this.gitlabUserName ? `@${this.gitlabUserName}` : undefined;
    },
    gitlabUserLink() {
      return this.gitlabUserPath ?? `${gon.relative_root_url}/${this.gitlabUserName}`;
    },
    signedInText() {
      return this.gitlabUserHandle
        ? this.$options.i18n.signedInAsUserText
        : this.$options.i18n.signedInText;
    },
  },
  i18n: {
    signedInAsUserText: __('Signed in to GitLab as %{user_link}'),
    signedInText: __('Signed in to GitLab'),
  },
};
</script>
 
<template>
  <div class="gl-font-base">
    <gl-sprintf :message="signedInText">
      <template #user_link>
        <gl-link data-testid="gitlab-user-link" :href="gitlabUserLink" target="_blank">
          {{ gitlabUserHandle }}
        </gl-link>
      </template>
    </gl-sprintf>
  </div>
</template>