summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/notification/pipeline_notification.vue
blob: 6982586ab120628152873d94ffd80f6e581f2a47 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<script>
import { GlBanner, GlLink, GlSprintf } from '@gitlab/ui';
import createFlash from '~/flash';
import { __ } from '~/locale';
import DismissPipelineNotification from '../../graphql/mutations/dismiss_pipeline_notification.graphql';
import getUserCallouts from '../../graphql/queries/get_user_callouts.query.graphql';

const featureName = 'pipeline_needs_banner';
const enumFeatureName = featureName.toUpperCase();

export default {
  i18n: {
    title: __('View job dependencies in the pipeline graph!'),
    description: __(
      'You can now group jobs in the pipeline graph based on which jobs are configured to run first, if you use the %{codeStart}needs:%{codeEnd} keyword to establish job dependencies in your CI/CD pipelines. %{linkStart}Learn how to speed up your pipeline with needs.%{linkEnd}',
    ),
    buttonText: __('Provide feedback'),
  },
  components: {
    GlBanner,
    GlLink,
    GlSprintf,
  },
  apollo: {
    callouts: {
      query: getUserCallouts,
      update(data) {
        return data?.currentUser?.callouts?.nodes.map((c) => c.featureName);
      },
      error() {
        this.hasError = true;
      },
    },
  },
  inject: ['dagDocPath'],
  data() {
    return {
      callouts: [],
      dismissedAlert: false,
      hasError: false,
    };
  },
  computed: {
    showBanner() {
      return (
        !this.$apollo.queries.callouts?.loading &&
        !this.hasError &&
        !this.dismissedAlert &&
        !this.callouts.includes(enumFeatureName)
      );
    },
  },
  methods: {
    handleClose() {
      this.dismissedAlert = true;
      try {
        this.$apollo.mutate({
          mutation: DismissPipelineNotification,
          variables: {
            featureName,
          },
        });
      } catch {
        createFlash(__('There was a problem dismissing this notification.'));
      }
    },
  },
};
</script>
<template>
  <gl-banner
    v-if="showBanner"
    :title="$options.i18n.title"
    :button-text="$options.i18n.buttonText"
    button-link="https://gitlab.com/gitlab-org/gitlab/-/issues/327688"
    variant="introduction"
    @close="handleClose"
  >
    <p>
      <gl-sprintf :message="$options.i18n.description">
        <template #link="{ content }">
          <gl-link :href="dagDocPath" target="_blank"> {{ content }}</gl-link>
        </template>
        <template #code="{ content }">
          <code>{{ content }}</code>
        </template>
      </gl-sprintf>
    </p>
  </gl-banner>
</template>