Welcome to mirror list, hosted at ThFree Co, Russian Federation.

integration_form_actions.vue « components « edit « integrations « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a9d7c1ca37896cae9489f723af4e20b6b4bd8f0f (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<script>
import { GlButton, GlModalDirective } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapState, mapGetters } from 'vuex';
import { integrationLevels } from '~/integrations/constants';
import ConfirmationModal from './confirmation_modal.vue';
import ResetConfirmationModal from './reset_confirmation_modal.vue';

export default {
  name: 'IntegrationFormActions',
  components: {
    GlButton,
    ConfirmationModal,
    ResetConfirmationModal,
  },
  directives: {
    GlModal: GlModalDirective,
  },
  props: {
    hasSections: {
      type: Boolean,
      required: true,
    },
    isSaving: {
      type: Boolean,
      required: false,
      default: false,
    },
    isTesting: {
      type: Boolean,
      required: false,
      default: false,
    },
    isResetting: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    ...mapGetters(['propsSource']),
    ...mapState(['customState']),
    isInstanceOrGroupLevel() {
      return (
        this.customState.integrationLevel === integrationLevels.INSTANCE ||
        this.customState.integrationLevel === integrationLevels.GROUP
      );
    },
    showResetButton() {
      return this.isInstanceOrGroupLevel && this.propsSource.resetPath;
    },
    showTestButton() {
      return this.propsSource.canTest;
    },
    disableButtons() {
      return Boolean(this.isSaving || this.isResetting || this.isTesting);
    },
  },
  methods: {
    onSaveClick() {
      this.$emit('save');
    },
    onTestClick() {
      this.$emit('test');
    },
    onResetClick() {
      this.$emit('reset');
    },
  },
};
</script>
<template>
  <section class="gl-lg-display-flex gl-justify-content-space-between">
    <div>
      <template v-if="isInstanceOrGroupLevel">
        <gl-button
          v-gl-modal.confirmSaveIntegration
          category="primary"
          variant="confirm"
          :loading="isSaving"
          :disabled="disableButtons"
          data-testid="save-button"
          data-qa-selector="save_changes_button"
        >
          {{ __('Save changes') }}
        </gl-button>
        <confirmation-modal @submit="onSaveClick" />
      </template>
      <gl-button
        v-else
        category="primary"
        variant="confirm"
        type="submit"
        :loading="isSaving"
        :disabled="disableButtons"
        data-testid="save-button"
        data-qa-selector="save_changes_button"
        @click.prevent="onSaveClick"
      >
        {{ __('Save changes') }}
      </gl-button>

      <gl-button
        v-if="showTestButton"
        category="secondary"
        variant="confirm"
        :loading="isTesting"
        :disabled="disableButtons"
        data-testid="test-button"
        @click.prevent="onTestClick"
      >
        {{ __('Test settings') }}
      </gl-button>

      <gl-button
        :href="propsSource.cancelPath"
        data-testid="cancel-button"
        :disabled="disableButtons"
        >{{ __('Cancel') }}</gl-button
      >
    </div>

    <template v-if="showResetButton">
      <gl-button
        v-gl-modal.confirmResetIntegration
        category="tertiary"
        variant="danger"
        :loading="isResetting"
        :disabled="disableButtons"
        data-testid="reset-button"
      >
        {{ __('Reset') }}
      </gl-button>

      <reset-confirmation-modal @reset="onResetClick" />
    </template>
  </section>
</template>