summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/projects/prune_unreachable_objects_button.vue
blob: 1387fbb78c0291ee3b02549c3c619ead601a1937 (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
<script>
import { GlButton, GlLink, GlModal, GlModalDirective } from '@gitlab/ui';
import csrf from '~/lib/utils/csrf';
import { s__ } from '~/locale';

export default {
  components: {
    GlButton,
    GlLink,
    GlModal,
  },
  PRUNE_UNREACHABLE_OBJECTS_MODAL_ID: 'prune-objects-modal',
  MODAL_ACTION_PRIMARY: {
    text: s__('UpdateProject|Prune'),
    attributes: [{ variant: 'danger' }],
  },
  MODAL_ACTION_CANCEL: {
    text: s__('UpdateProject|Cancel'),
  },
  directives: {
    GlModal: GlModalDirective,
  },
  props: {
    pruneObjectsPath: {
      type: String,
      required: true,
    },
    pruneObjectsDocPath: {
      type: String,
      required: true,
    },
  },
  computed: {
    csrfToken() {
      return csrf.token;
    },
  },
  methods: {
    submitForm() {
      this.$refs.form.submit();
    },
  },
};
</script>

<template>
  <form ref="form" :action="pruneObjectsPath" method="post">
    <input :value="csrfToken" type="hidden" name="authenticity_token" />
    <input value="true" type="hidden" name="prune" />
    <gl-modal
      :modal-id="$options.PRUNE_UNREACHABLE_OBJECTS_MODAL_ID"
      :title="s__('UpdateProject|Are you sure you want to prune unreachable objects?')"
      :action-primary="$options.MODAL_ACTION_PRIMARY"
      :action-cancel="$options.MODAL_ACTION_CANCEL"
      size="sm"
      :no-focus-on-show="true"
      @ok="submitForm"
    >
      <p>
        {{ s__('UpdateProject|Pruning unreachable objects can lead to repository corruption.') }}
        <gl-link :href="pruneObjectsDocPath" target="_blank">
          {{ s__('UpdateProject|Learn more.') }}
        </gl-link>
        {{ s__('UpdateProject|Are you sure you want to prune?') }}
      </p>
    </gl-modal>
    <gl-button
      v-gl-modal="$options.PRUNE_UNREACHABLE_OBJECTS_MODAL_ID"
      category="primary"
      variant="danger"
    >
      {{ s__('UpdateProject|Prune unreachable objects') }}
    </gl-button>
  </form>
</template>