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

repo_edit_button.vue « components « repo « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f47b6c33fa29c81f76e03791fbb5169397d10af2 (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
<script>
import Store from '../stores/repo_store';
import RepoMixin from '../mixins/repo_mixin';

export default {
  data: () => Store,
  mixins: [RepoMixin],
  computed: {
    buttonLabel() {
      return this.editMode ? this.__('Cancel edit') : this.__('Edit');
    },

    buttonIcon() {
      return this.editMode ? [] : ['fa', 'fa-pencil'];
    },
  },
  methods: {
    editClicked() {
      if (this.changedFiles.length) {
        this.dialog.open = true;
        return;
      }
      this.editMode = !this.editMode;
      Store.toggleBlobView();
    },
  },

  watch: {
    editMode() {
      if (this.editMode) {
        $('.project-refs-form').addClass('disabled');
        $('.js-tree-ref-target-holder').show();
      } else {
        $('.project-refs-form').removeClass('disabled');
        $('.js-tree-ref-target-holder').hide();
      }
    },
  },
};
</script>

<template>
<button class="btn btn-default" @click.prevent="editClicked" v-cloak v-if="isCommitable && !activeFile.render_error" :disabled="binary">
  <i :class="buttonIcon"></i>
  <span>{{buttonLabel}}</span>
</button>
</template>