All files / app/assets/javascripts/packages_and_registries/package_registry/components/list publish_method.vue

100% Statements 6/6
100% Branches 4/4
100% Functions 3/3
100% Lines 6/6

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  4x 4x 4x                                   3x     2x                   21x                                                      
<script>
import { GlIcon, GlLink } from '@gitlab/ui';
import { __, s__ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
 
export default {
  name: 'PublishMethod',
  components: {
    ClipboardButton,
    GlIcon,
    GlLink,
  },
  props: {
    pipeline: {
      type: Object,
      required: false,
      default: null,
    },
  },
  computed: {
    hasPipeline() {
      return Boolean(this.pipeline);
    },
    packageShaShort() {
      return this.pipeline?.sha?.substring(0, 8);
    },
  },
  i18n: {
    COPY_COMMIT_SHA: __('Copy commit SHA'),
    MANUALLY_PUBLISHED: s__('PackageRegistry|Manually Published'),
  },
};
</script>
 
<template>
  <div class="gl-display-flex gl-align-items-center">
    <template v-if="hasPipeline">
      <gl-icon name="git-merge" class="gl-mr-2" />
      <span data-testid="pipeline-ref" class="gl-mr-2">{{ pipeline.ref }}</span>
 
      <gl-icon name="commit" class="gl-mr-2" />
      <gl-link data-testid="pipeline-sha" :href="pipeline.commitPath" class="gl-mr-2">{{
        packageShaShort
      }}</gl-link>
 
      <clipboard-button
        :text="pipeline.sha"
        :title="$options.i18n.COPY_COMMIT_SHA"
        category="tertiary"
        size="small"
      />
    </template>
 
    <template v-else>
      <gl-icon name="upload" class="gl-mr-2" />
      <span data-testid="manually-published">
        {{ $options.i18n.MANUALLY_PUBLISHED }}
      </span>
    </template>
  </div>
</template>