summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repository/components/web_ide_link.vue
blob: 6549d5a387860add3705082c993f22ef504dd296 (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 TreeActionLink from './tree_action_link.vue';
import { __ } from '~/locale';
import { webIDEUrl } from '~/lib/utils/url_utility';

export default {
  components: {
    TreeActionLink,
  },
  props: {
    projectPath: {
      type: String,
      required: true,
    },
    refSha: {
      type: String,
      required: true,
    },
    canPushCode: {
      type: Boolean,
      required: false,
      default: true,
    },
    forkPath: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    showLinkToFork() {
      return !this.canPushCode && this.forkPath;
    },
    text() {
      return this.showLinkToFork ? __('Edit fork in Web IDE') : __('Web IDE');
    },
    path() {
      const path = this.showLinkToFork ? this.forkPath : this.projectPath;
      return webIDEUrl(`/${path}/edit/${this.refSha}/-/${this.$route.params.path || ''}`);
    },
  },
};
</script>

<template>
  <tree-action-link :path="path" :text="text" data-qa-selector="web_ide_button" />
</template>