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

index.vue « new_dropdown « components « ide « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 769e9b79cadbd5a8d8fdc4262b11970085fc497e (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
<script>
  import { mapActions } from 'vuex';
  import icon from '~/vue_shared/components/icon.vue';
  import newModal from './modal.vue';
  import upload from './upload.vue';

  export default {
    components: {
      icon,
      newModal,
      upload,
    },
    props: {
      branch: {
        type: String,
        required: true,
      },
      path: {
        type: String,
        required: true,
      },
    },
    data() {
      return {
        openModal: false,
        modalType: '',
        dropdownOpen: false,
      };
    },
    methods: {
      ...mapActions([
        'createTempEntry',
      ]),
      createNewItem(type) {
        this.modalType = type;
        this.openModal = true;
        this.dropdownOpen = false;
      },
      hideModal() {
        this.openModal = false;
      },
      openDropdown() {
        this.dropdownOpen = !this.dropdownOpen;
      },
    },
  };
</script>

<template>
  <div class="ide-new-btn">
    <div
      class="dropdown"
      :class="{
        open: dropdownOpen,
      }"
    >
      <button
        type="button"
        class="btn btn-sm btn-default dropdown-toggle add-to-tree"
        aria-label="Create new file or directory"
        @click.stop="openDropdown()"
      >
        <icon
          name="plus"
          :size="12"
          css-classes="pull-left"
        />
        <icon
          name="arrow-down"
          :size="12"
          css-classes="pull-left"
        />
      </button>
      <ul class="dropdown-menu dropdown-menu-right">
        <li>
          <a
            href="#"
            role="button"
            @click.stop.prevent="createNewItem('blob')"
          >
            {{ __('New file') }}
          </a>
        </li>
        <li>
          <upload
            :branch-id="branch"
            :path="path"
            @create="createTempEntry"
          />
        </li>
        <li>
          <a
            href="#"
            role="button"
            @click.stop.prevent="createNewItem('tree')"
          >
            {{ __('New directory') }}
          </a>
        </li>
      </ul>
    </div>
    <new-modal
      v-if="openModal"
      :type="modalType"
      :branch-id="branch"
      :path="path"
      @hide="hideModal"
      @create="createTempEntry"
    />
  </div>
</template>