Read about our upcoming Code of Conduct on this issue

settings_dropdown.vue 2.59 KB
Newer Older
Phil Hughes's avatar
Phil Hughes committed
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
<script>
import { mapActions, mapGetters, mapState } from 'vuex';
import { GlButton } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';

export default {
  components: {
    GlButton,
    Icon,
  },
  computed: {
    ...mapGetters('diffs', ['isInlineView', 'isParallelView']),
    ...mapState('diffs', ['renderTreeList', 'showWhitespace']),
  },
  methods: {
    ...mapActions('diffs', [
      'setInlineDiffViewType',
      'setParallelDiffViewType',
      'setRenderTreeList',
      'setShowWhitespace',
    ]),
  },
};
</script>

<template>
  <div class="dropdown">
    <button
      type="button"
      class="btn btn-default js-show-diff-settings"
      data-toggle="dropdown"
      data-display="static"
    >
34
      <icon name="settings" /> <icon name="chevron-down" />
Phil Hughes's avatar
Phil Hughes committed
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
    </button>
    <div class="dropdown-menu dropdown-menu-right p-2 pt-3 pb-3">
      <div>
        <span class="bold d-block mb-1">{{ __('File browser') }}</span>
        <div class="btn-group d-flex">
          <gl-button
            :class="{ active: !renderTreeList }"
            class="w-100 js-list-view"
            @click="setRenderTreeList(false)"
          >
            {{ __('List view') }}
          </gl-button>
          <gl-button
            :class="{ active: renderTreeList }"
            class="w-100 js-tree-view"
            @click="setRenderTreeList(true)"
          >
            {{ __('Tree view') }}
          </gl-button>
        </div>
      </div>
      <div class="mt-2">
        <span class="bold d-block mb-1">{{ __('Compare changes') }}</span>
        <div class="btn-group d-flex js-diff-view-buttons">
          <gl-button
            id="inline-diff-btn"
            :class="{ active: isInlineView }"
            class="w-100 js-inline-diff-button"
            data-view-type="inline"
            @click="setInlineDiffViewType"
          >
            {{ __('Inline') }}
          </gl-button>
          <gl-button
            id="parallel-diff-btn"
            :class="{ active: isParallelView }"
            class="w-100 js-parallel-diff-button"
            data-view-type="parallel"
            @click="setParallelDiffViewType"
          >
            {{ __('Side-by-side') }}
          </gl-button>
        </div>
      </div>
      <div class="mt-2">
        <label class="mb-0">
          <input
            id="show-whitespace"
            type="checkbox"
            :checked="showWhitespace"
            @change="setShowWhitespace({ showWhitespace: $event.target.checked, pushState: true })"
          />
          {{ __('Show whitespace changes') }}
        </label>
      </div>
    </div>
  </div>
</template>