summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/empty_state.vue
blob: e40c37b50951fc998a176c7fbdfe3bef01466885 (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
<script>
import { GlEmptyState, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import { ENVIRONMENTS_SCOPE } from '../constants';

export default {
  components: {
    GlEmptyState,
    GlLink,
  },
  inject: ['newEnvironmentPath'],
  props: {
    helpPath: {
      type: String,
      required: true,
    },
    scope: {
      type: String,
      required: true,
    },
    hasTerm: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    title() {
      return this.hasTerm
        ? this.$options.i18n.searchingTitle
        : this.$options.i18n.title[this.scope];
    },
    content() {
      return this.hasTerm ? this.$options.i18n.searchingContent : this.$options.i18n.content;
    },
    buttonText() {
      return this.hasTerm ? this.$options.i18n.newEnvironmentButtonLabel : '';
    },
  },
  i18n: {
    title: {
      [ENVIRONMENTS_SCOPE.AVAILABLE]: s__("Environments|You don't have any environments."),
      [ENVIRONMENTS_SCOPE.STOPPED]: s__("Environments|You don't have any stopped environments."),
    },
    content: s__(
      'Environments|Environments are places where code gets deployed, such as staging or production.',
    ),
    searchingTitle: s__('Environments|No results found'),
    searchingContent: s__('Environments|Edit your search and try again'),
    link: s__('Environments|How do I create an environment?'),
    newEnvironmentButtonLabel: s__('Environments|New environment'),
  },
};
</script>
<template>
  <gl-empty-state :primary-button-text="buttonText" :primary-button-link="newEnvironmentPath">
    <template #title>
      <h4>{{ title }}</h4>
    </template>
    <template #description>
      <p>{{ content }}</p>
      <gl-link v-if="!hasTerm" :href="helpPath">{{ $options.i18n.link }}</gl-link>
    </template>
  </gl-empty-state>
</template>