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

ci_resource_components.vue « details « components « catalog « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 85dfa12c7566c900ca488aabbc55e043df23e3f2 (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
<script>
import { GlLoadingIcon, GlTableLite } from '@gitlab/ui';
import { createAlert } from '~/alert';
import { __, s__ } from '~/locale';
import getCiCatalogResourceComponents from '../../graphql/queries/get_ci_catalog_resource_components.query.graphql';

export default {
  components: {
    GlLoadingIcon,
    GlTableLite,
  },
  props: {
    resourceId: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      components: [],
    };
  },
  apollo: {
    components: {
      query: getCiCatalogResourceComponents,
      variables() {
        return {
          id: this.resourceId,
        };
      },
      update(data) {
        return data?.ciCatalogResource?.components?.nodes || [];
      },
      error() {
        createAlert({ message: this.$options.i18n.fetchError });
      },
    },
  },
  computed: {
    isLoading() {
      return this.$apollo.queries.components.loading;
    },
  },
  methods: {
    generateSnippet(componentPath) {
      // This is not to be translated because it is our CI yaml syntax.
      // eslint-disable-next-line @gitlab/require-i18n-strings
      return `include:
  - component: ${componentPath}`;
    },
    humanizeBoolean(bool) {
      return bool ? __('Yes') : __('No');
    },
  },
  fields: [
    {
      key: 'name',
      label: s__('CiCatalogComponent|Parameters'),
      thClass: 'gl-w-40p',
    },
    {
      key: 'defaultValue',
      label: s__('CiCatalogComponent|Default Value'),
      thClass: 'gl-w-40p',
    },
    {
      key: 'required',
      label: s__('CiCatalogComponent|Mandatory'),
      thClass: 'gl-w-20p',
    },
  ],
  i18n: {
    inputTitle: s__('CiCatalogComponent|Inputs'),
    fetchError: s__("CiCatalogComponent|There was an error fetching this resource's components"),
  },
};
</script>

<template>
  <div>
    <gl-loading-icon v-if="isLoading" size="lg" />
    <template v-else>
      <div
        v-for="component in components"
        :key="component.id"
        class="gl-mb-8"
        data-testid="component-section"
      >
        <h3 class="gl-font-size-h2" data-testid="component-name">{{ component.name }}</h3>
        <p class="gl-mt-5">{{ component.description }}</p>
        <pre class="gl-w-85p gl-py-4">{{ generateSnippet(component.path) }}</pre>
        <div class="gl-mt-5">
          <b class="gl-display-block gl-mb-4"> {{ $options.i18n.inputTitle }}</b>
          <gl-table-lite :items="component.inputs.nodes" :fields="$options.fields">
            <template #cell(required)="{ item }">
              {{ humanizeBoolean(item.required) }}
            </template>
          </gl-table-lite>
        </div>
      </div>
    </template>
  </div>
</template>