summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/alert_management/components/alert_management_empty_state.vue
blob: c5ff2dc0d11696c05f941a421778b187894c8917 (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
<script>
import { GlEmptyState, GlButton, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import alertsHelpUrlQuery from '../graphql/queries/alert_help_url.query.graphql';

export default {
  i18n: {
    emptyState: {
      opsgenie: {
        title: s__('AlertManagement|Opsgenie is enabled'),
        info: s__(
          'AlertManagement|You have enabled the Opsgenie integration. Your alerts will be visible directly in Opsgenie.',
        ),
        buttonText: s__('AlertManagement|View alerts in Opsgenie'),
      },
      gitlab: {
        title: s__('AlertManagement|Surface alerts in GitLab'),
        info: s__(
          'AlertManagement|Display alerts from all your monitoring tools directly within GitLab. Streamline the investigation of your alerts and the escalation of alerts to incidents.',
        ),
        buttonText: s__('AlertManagement|Authorize external service'),
      },
    },
    moreInformation: s__('AlertManagement|More information'),
  },
  components: {
    GlEmptyState,
    GlButton,
    GlLink,
  },
  apollo: {
    alertsHelpUrl: {
      query: alertsHelpUrlQuery,
    },
  },
  inject: [
    'enableAlertManagementPath',
    'userCanEnableAlertManagement',
    'emptyAlertSvgPath',
    'opsgenieMvcEnabled',
    'opsgenieMvcTargetUrl',
  ],
  data() {
    return {
      alertsHelpUrl: '',
    };
  },
  computed: {
    emptyState() {
      return {
        ...(this.opsgenieMvcEnabled
          ? this.$options.i18n.emptyState.opsgenie
          : this.$options.i18n.emptyState.gitlab),
        link: this.opsgenieMvcEnabled ? this.opsgenieMvcTargetUrl : this.enableAlertManagementPath,
      };
    },
    alertsCanBeEnabled() {
      return this.userCanEnableAlertManagement || this.opsgenieMvcEnabled;
    },
  },
};
</script>
<template>
  <div>
    <gl-empty-state :title="emptyState.title" :svg-path="emptyAlertSvgPath">
      <template #description>
        <div class="gl-display-block">
          <span>{{ emptyState.info }}</span>
          <gl-link v-if="!opsgenieMvcEnabled" :href="alertsHelpUrl" target="_blank">
            {{ $options.i18n.moreInformation }}
          </gl-link>
        </div>
        <div v-if="alertsCanBeEnabled" class="gl-display-block center gl-pt-4">
          <gl-button category="primary" variant="success" :href="emptyState.link">
            {{ emptyState.buttonText }}
          </gl-button>
        </div>
      </template>
    </gl-empty-state>
  </div>
</template>