All files / app/assets/javascripts/releases/components app_show.vue

80% Statements 8/10
100% Branches 4/4
100% Functions 6/6
80% Lines 8/10

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              1x                                       17x           10x 4x     6x       14x 6x           4x                                                  
<script>
import { createAlert } from '~/alert';
import { s__ } from '~/locale';
import { popCreateReleaseNotification } from '~/releases/release_notification_service';
import oneReleaseQuery from '../graphql/queries/one_release.query.graphql';
import { convertGraphQLRelease } from '../util';
import ReleaseBlock from './release_block.vue';
import ReleaseSkeletonLoader from './release_skeleton_loader.vue';
 
export default {
  name: 'ReleaseShowApp',
  components: {
    ReleaseBlock,
    ReleaseSkeletonLoader,
  },
  inject: {
    fullPath: {
      default: '',
    },
    tagName: {
      default: '',
    },
  },
  apollo: {
    release: {
      query: oneReleaseQuery,
      variables() {
        return {
          fullPath: this.fullPath,
          tagName: this.tagName,
        };
      },
      update(data) {
        if (data.project?.release) {
          return convertGraphQLRelease(data.project.release);
        }
 
        return null;
      },
      result(result) {
        // Handle the case where the query succeeded but didn't return any data
        if (!result.error && !this.release) {
          this.showFlash(
            new Error(`No release found in project "${this.fullPath}" with tag "${this.tagName}"`),
          );
        }
      },
      error(error) {
        this.showFlash(error);
      },
    },
  },
  mounted() {
    popCreateReleaseNotification(this.fullPath);
  },
  methods: {
    showFlash(error) {
      createAlert({
        message: s__('Release|Something went wrong while getting the release details.'),
        captureError: true,
        error,
      });
    },
  },
};
</script>
<template>
  <div class="gl-mt-3">
    <release-skeleton-loader v-if="$apollo.queries.release.loading" />
 
    <release-block v-else-if="release" :release="release" />
  </div>
</template>