summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages/details/components/maven_installation.vue
blob: 6974de993442630e9de82f31097a87933813a43c (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
147
148
149
150
151
152
153
<script>
import { GlLink, GlSprintf } from '@gitlab/ui';
import { mapGetters, mapState } from 'vuex';
import { s__ } from '~/locale';
import InstallationTitle from '~/packages/details/components/installation_title.vue';
import CodeInstruction from '~/vue_shared/components/registry/code_instruction.vue';

import { TrackingActions, TrackingLabels } from '../constants';

export default {
  name: 'MavenInstallation',
  components: {
    InstallationTitle,
    CodeInstruction,
    GlLink,
    GlSprintf,
  },
  data() {
    return {
      instructionType: 'maven',
    };
  },
  computed: {
    ...mapState(['mavenHelpPath']),
    ...mapGetters([
      'mavenInstallationXml',
      'mavenInstallationCommand',
      'mavenSetupXml',
      'gradleGroovyInstalCommand',
      'gradleGroovyAddSourceCommand',
      'gradleKotlinInstalCommand',
      'gradleKotlinAddSourceCommand',
    ]),
    showMaven() {
      return this.instructionType === 'maven';
    },
    showGroovy() {
      return this.instructionType === 'groovy';
    },
  },
  i18n: {
    xmlText: s__(
      `PackageRegistry|Copy and paste this inside your %{codeStart}pom.xml%{codeEnd} %{codeStart}dependencies%{codeEnd} block.`,
    ),
    setupText: s__(
      `PackageRegistry|If you haven't already done so, you will need to add the below to your %{codeStart}pom.xml%{codeEnd} file.`,
    ),
    helpText: s__(
      'PackageRegistry|For more information on the Maven registry, %{linkStart}see the documentation%{linkEnd}.',
    ),
  },
  trackingActions: { ...TrackingActions },
  TrackingLabels,
  installOptions: [
    { value: 'maven', label: s__('PackageRegistry|Maven XML') },
    { value: 'groovy', label: s__('PackageRegistry|Gradle Groovy DSL') },
    { value: 'kotlin', label: s__('PackageRegistry|Gradle Kotlin DSL') },
  ],
};
</script>

<template>
  <div>
    <installation-title
      package-type="maven"
      :options="$options.installOptions"
      @change="instructionType = $event"
    />

    <template v-if="showMaven">
      <p>
        <gl-sprintf :message="$options.i18n.xmlText">
          <template #code="{ content }">
            <code>{{ content }}</code>
          </template>
        </gl-sprintf>
      </p>

      <code-instruction
        :instruction="mavenInstallationXml"
        :copy-text="s__('PackageRegistry|Copy Maven XML')"
        :tracking-action="$options.trackingActions.COPY_MAVEN_XML"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
        multiline
      />

      <code-instruction
        :label="s__('PackageRegistry|Maven Command')"
        :instruction="mavenInstallationCommand"
        :copy-text="s__('PackageRegistry|Copy Maven command')"
        :tracking-action="$options.trackingActions.COPY_MAVEN_COMMAND"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
      />

      <h3 class="gl-font-lg">{{ s__('PackageRegistry|Registry setup') }}</h3>
      <p>
        <gl-sprintf :message="$options.i18n.setupText">
          <template #code="{ content }">
            <code>{{ content }}</code>
          </template>
        </gl-sprintf>
      </p>
      <code-instruction
        :instruction="mavenSetupXml"
        :copy-text="s__('PackageRegistry|Copy Maven registry XML')"
        :tracking-action="$options.trackingActions.COPY_MAVEN_SETUP"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
        multiline
      />
      <gl-sprintf :message="$options.i18n.helpText">
        <template #link="{ content }">
          <gl-link :href="mavenHelpPath" target="_blank">{{ content }}</gl-link>
        </template>
      </gl-sprintf>
    </template>
    <template v-else-if="showGroovy">
      <code-instruction
        class="gl-mb-5"
        :label="s__('PackageRegistry|Gradle Groovy DSL install command')"
        :instruction="gradleGroovyInstalCommand"
        :copy-text="s__('PackageRegistry|Copy Gradle Groovy DSL install command')"
        :tracking-action="$options.trackingActions.COPY_GRADLE_INSTALL_COMMAND"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
      />
      <code-instruction
        :label="s__('PackageRegistry|Add Gradle Groovy DSL repository command')"
        :instruction="gradleGroovyAddSourceCommand"
        :copy-text="s__('PackageRegistry|Copy add Gradle Groovy DSL repository command')"
        :tracking-action="$options.trackingActions.COPY_GRADLE_ADD_TO_SOURCE_COMMAND"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
        multiline
      />
    </template>
    <template v-else>
      <code-instruction
        class="gl-mb-5"
        :label="s__('PackageRegistry|Gradle Kotlin DSL install command')"
        :instruction="gradleKotlinInstalCommand"
        :copy-text="s__('PackageRegistry|Copy Gradle Kotlin DSL install command')"
        :tracking-action="$options.trackingActions.COPY_KOTLIN_INSTALL_COMMAND"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
      />
      <code-instruction
        :label="s__('PackageRegistry|Add Gradle Kotlin DSL repository command')"
        :instruction="gradleKotlinAddSourceCommand"
        :copy-text="s__('PackageRegistry|Copy add Gradle Kotlin DSL repository command')"
        :tracking-action="$options.trackingActions.COPY_KOTLIN_ADD_TO_SOURCE_COMMAND"
        :tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
        multiline
      />
    </template>
  </div>
</template>