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

repo_file_buttons.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: ce6c677ecc68e32abb354baed588b885b473cce9 (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
139
140
141
142
143
144
145
146
<script>
import Store from '../stores/repo_store';
import Helper from '../helpers/repo_helper';
import RepoMixin from '../mixins/repo_mixin';
import BlobViewerMixin from '../mixins/blob_viewer_mixin';

export default {
  data: () => Store,
  props: {
    activeBlobViewers: { type: Object, required: false },
    selectedBlobViewerType: { type: String, required: false },
  },
  mixins: [RepoMixin, BlobViewerMixin],

  computed: {
    rawDownloadButtonLabel() {
      return this.binary ? 'Download' : 'Raw';
    },

    canPreview() {
      return Helper.isRenderable();
    },

    copySourceStatus() {
      if (!this.viewerIsSimple) {
        return `Switch to the source to copy it to the clipboard`;
      }

      return `Copy source to clipboard`;
    }
  },

  methods: {
    rawPreviewToggle: Store.toggleRawPreview,
  },
};
</script>

<template>
  <div id="repo-file-buttons">
    <a
      :href="activeFile.raw_path"
      target="_blank"
      class="btn btn-default raw"
      rel="noopener noreferrer">
      {{rawDownloadButtonLabel}}
    </a>

    <div class="viewer-switcher btn-group">
      <button
        v-if="canDisplayRichViewer"
        aria-label="Display source"
        class="btn btn-default btn-sm js-blob-viewer-switch-btn has-tooltip"
        :class='{ active: viewerIsSimple }'
        :disabled="viewerIsSimple"
        data-container="body"
        title=""
        data-original-title="Display source">
        <i
          aria-hidden="true"
          data-hidden="true"
          class="fa fa-code">
        </i>
      </button>

      <button
        v-if="canDisplayRichViewer"
        aria-label="Display rendered file"
        class="btn btn-default btn-sm js-blob-viewer-switch-btn has-tooltip active"
        :class='{ active: viewerIsRich }'
        :disabled="viewerIsRich"
        data-container="body"
        title=""
        data-original-title="Display rendered file">
        <i
          aria-hidden="true"
          data-hidden="true"
          class="fa fa-file-text-o">
        </i>
      </button>

      <button
        class="btn btn-sm js-copy-blob-source-btn"
        data-toggle="tooltip"
        data-placement="bottom"
        data-container="body"
        data-class="btn btn-sm js-copy-blob-source-btn"
        data-title="Copy source to clipboard"
        data-clipboard-target=".blob-content[data-blob-id='cc85e5de40f49d03b59fdaffaafa23a18a07acb2']"
        :disabled="viewerIsRich"
        type="button"
        title="copySourceStatus"
        aria-label="Copy source to clipboard"
        data-original-title="Copy source to clipboard">
        <i
          aria-hidden="true"
          data-hidden="true"
          class="fa fa-clipboard">
        </i>
      </button>

      <a
        class="btn btn-sm has-tooltip"
        target="_blank"
        rel="noopener noreferrer"
        title=""
        data-container="body"
        href="/gitlab-org/gitlab-ce/raw/master/app/views/projects/blob/_viewer.html.haml"
        data-original-title="Open raw">
        <i
          aria-hidden="true"
          data-hidden="true"
          class="fa fa-file-code-o">
        </i>
      </a>
    </div>
    <div
      class="btn-group"
      role="group"
      aria-label="File actions">
      <a
        :href="activeFile.blame_path"
        class="btn btn-default blame">
        Blame
      </a>
      <a
        :href="activeFile.commits_path"
        class="btn btn-default history">
        History
      </a>
      <a
        :href="activeFile.permalink"
        class="btn btn-default permalink">
        Permalink
      </a>
    </div>

    <a
      v-if="canPreview"
      href="#"
      @click.prevent="rawPreviewToggle"
      class="btn btn-default preview">
      {{activeFileLabel}}
    </a>
  </div>
</template>