summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/stop_environment_modal.vue
blob: c78d86e9b977af5ffad5e8537f6f5b45b5f94b17 (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
<script>
import { GlTooltipDirective } from '@gitlab/ui';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__, sprintf } from '~/locale';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
import eventHub from '../event_hub';

export default {
  id: 'stop-environment-modal',
  name: 'StopEnvironmentModal',

  components: {
    GlModal,
    LoadingButton,
  },

  directives: {
    GlTooltip: GlTooltipDirective,
  },

  props: {
    environment: {
      type: Object,
      required: true,
    },
  },

  computed: {
    noStopActionMessage() {
      return sprintf(
        s__(
          `Environments|Note that this action will stop the environment,
        but it will %{emphasisStart}not%{emphasisEnd} have an effect on any existing deployment
        due to no “stop environment action” being defined
        in the %{ciConfigLinkStart}.gitlab-ci.yml%{ciConfigLinkEnd} file.`,
        ),
        {
          emphasisStart: '<strong>',
          emphasisEnd: '</strong>',
          ciConfigLinkStart:
            '<a href="https://docs.gitlab.com/ee/ci/yaml/" target="_blank" rel="noopener noreferrer">',
          ciConfigLinkEnd: '</a>',
        },
        false,
      );
    },
  },

  methods: {
    onSubmit() {
      eventHub.$emit('stopEnvironment', this.environment);
    },
  },
};
</script>

<template>
  <gl-modal
    :id="$options.id"
    :footer-primary-button-text="s__('Environments|Stop environment')"
    footer-primary-button-variant="danger"
    @submit="onSubmit"
  >
    <template slot="header">
      <h4 class="modal-title d-flex mw-100">
        Stopping
        <span v-gl-tooltip :title="environment.name" class="text-truncate ml-1 mr-1 flex-fill">{{
          environment.name
        }}</span>
        ?
      </h4>
    </template>

    <p>{{ s__('Environments|Are you sure you want to stop this environment?') }}</p>

    <div v-if="!environment.has_stop_action" class="warning_message">
      <p v-html="noStopActionMessage"></p>
      <a
        href="https://docs.gitlab.com/ee/ci/environments.html#stopping-an-environment"
        target="_blank"
        rel="noopener noreferrer"
        >{{ s__('Environments|Learn more about stopping environments') }}</a
      >
    </div>
  </gl-modal>
</template>