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

asset_links_form.vue « components « releases « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7299fd24ec5329896af5c5044084ed5d350bd38d (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
<script>
import { mapState, mapActions } from 'vuex';
import {
  GlSprintf,
  GlLink,
  GlFormGroup,
  GlDeprecatedButton,
  GlIcon,
  GlTooltipDirective,
  GlFormInput,
} from '@gitlab/ui';

export default {
  name: 'AssetLinksForm',
  components: { GlSprintf, GlLink, GlFormGroup, GlDeprecatedButton, GlIcon, GlFormInput },
  directives: { GlTooltip: GlTooltipDirective },
  computed: {
    ...mapState('detail', ['release', 'releaseAssetsDocsPath']),
  },
  created() {
    this.addEmptyAssetLink();
  },
  methods: {
    ...mapActions('detail', [
      'addEmptyAssetLink',
      'updateAssetLinkUrl',
      'updateAssetLinkName',
      'removeAssetLink',
    ]),
    onAddAnotherClicked() {
      this.addEmptyAssetLink();
    },
    onRemoveClicked(linkId) {
      this.removeAssetLink(linkId);
    },
    onUrlInput(linkIdToUpdate, newUrl) {
      this.updateAssetLinkUrl({ linkIdToUpdate, newUrl });
    },
    onLinkTitleInput(linkIdToUpdate, newName) {
      this.updateAssetLinkName({ linkIdToUpdate, newName });
    },
  },
};
</script>

<template>
  <div class="d-flex flex-column release-assets-links-form">
    <h2 class="text-4">{{ __('Release assets') }}</h2>
    <p class="m-0">
      <gl-sprintf
        :message="
          __(
            'Add %{linkStart}assets%{linkEnd} to your Release. GitLab automatically includes read-only assets, like source code and release evidence.',
          )
        "
      >
        <template #link="{ content }">
          <gl-link
            :href="releaseAssetsDocsPath"
            target="_blank"
            :aria-label="__('Release assets documentation')"
          >
            {{ content }}
          </gl-link>
        </template>
      </gl-sprintf>
    </p>
    <h3 class="text-3">{{ __('Links') }}</h3>
    <p>
      {{
        __(
          'Point to any links you like: documentation, built binaries, or other related materials. These can be internal or external links from your GitLab instance.',
        )
      }}
    </p>
    <div
      v-for="(link, index) in release.assets.links"
      :key="link.id"
      class="d-flex flex-column flex-sm-row align-items-stretch align-items-sm-end"
    >
      <gl-form-group
        class="url-field form-group flex-grow-1 mr-sm-4"
        :label="__('URL')"
        :label-for="`asset-url-${index}`"
      >
        <gl-form-input
          :id="`asset-url-${index}`"
          :value="link.url"
          type="text"
          class="form-control"
          @change="onUrlInput(link.id, $event)"
        />
      </gl-form-group>

      <gl-form-group
        class="link-title-field flex-grow-1 mr-sm-4"
        :label="__('Link title')"
        :label-for="`asset-link-name-${index}`"
      >
        <gl-form-input
          :id="`asset-link-name-${index}`"
          :value="link.name"
          type="text"
          class="form-control"
          @change="onLinkTitleInput(link.id, $event)"
        />
      </gl-form-group>

      <gl-deprecated-button
        v-gl-tooltip
        class="mb-5 mb-sm-3 flex-grow-0 flex-shrink-0 remove-button"
        :aria-label="__('Remove asset link')"
        :title="__('Remove asset link')"
        @click="onRemoveClicked(link.id)"
      >
        <gl-icon class="m-0" name="remove" />
        <span class="d-inline d-sm-none">{{ __('Remove asset link') }}</span>
      </gl-deprecated-button>
    </div>
    <gl-deprecated-button
      variant="link"
      class="align-self-end mb-5 mb-sm-0"
      @click="onAddAnotherClicked"
    >
      {{ __('Add another link') }}
    </gl-deprecated-button>
  </div>
</template>