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

functions.vue « components « serverless « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e9461aa3eadff5dd7bdbf53260318352257ead65 (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
<script>
import {
  GlLink,
  GlAlert,
  GlSprintf,
  GlLoadingIcon,
  GlSafeHtmlDirective as SafeHtml,
} from '@gitlab/ui';
import { mapState, mapActions, mapGetters } from 'vuex';
import { sprintf, s__ } from '~/locale';
import { CHECKING_INSTALLED, DEPRECATION_POST_LINK } from '../constants';
import EmptyState from './empty_state.vue';
import EnvironmentRow from './environment_row.vue';

export default {
  components: {
    EnvironmentRow,
    EmptyState,
    GlLink,
    GlAlert,
    GlSprintf,
    GlLoadingIcon,
  },
  directives: {
    SafeHtml,
  },
  deprecationPostLink: DEPRECATION_POST_LINK,
  computed: {
    ...mapState(['installed', 'isLoading', 'hasFunctionData', 'helpPath', 'statusPath']),
    ...mapGetters(['getFunctions']),

    checkingInstalled() {
      return this.installed === CHECKING_INSTALLED;
    },
    isInstalled() {
      return this.installed === true;
    },
    noServerlessConfigFile() {
      return sprintf(
        s__(
          'Serverless|Your repository does not have a corresponding %{startTag}serverless.yml%{endTag} file.',
        ),
        { startTag: '<code>', endTag: '</code>' },
        false,
      );
    },
    noGitlabYamlConfigured() {
      return sprintf(
        s__('Serverless|Your %{startTag}.gitlab-ci.yml%{endTag} file is not properly configured.'),
        { startTag: '<code>', endTag: '</code>' },
        false,
      );
    },
    mismatchedServerlessFunctions() {
      return sprintf(
        s__(
          "Serverless|The functions listed in the %{startTag}serverless.yml%{endTag} file don't match the namespace of your cluster.",
        ),
        { startTag: '<code>', endTag: '</code>' },
        false,
      );
    },
  },
  created() {
    this.fetchFunctions({
      functionsPath: this.statusPath,
    });
  },
  methods: {
    ...mapActions(['fetchFunctions']),
  },
};
</script>

<template>
  <section id="serverless-functions" class="flex-grow">
    <gl-alert class="gl-mt-6" variant="warning" :dismissible="false">
      <gl-sprintf
        :message="s__('Serverless|Serverless was %{linkStart}deprecated%{linkEnd} in GitLab 14.3.')"
        ><template #link="{ content }"
          ><gl-link :href="$options.deprecationPostLink" target="_blank">{{
            content
          }}</gl-link></template
        ></gl-sprintf
      >
    </gl-alert>

    <gl-loading-icon v-if="checkingInstalled" size="lg" class="gl-mt-3 gl-mb-3" />

    <div v-else-if="isInstalled">
      <div v-if="hasFunctionData">
        <div class="groups-list-tree-container js-functions-wrapper">
          <ul class="content-list group-list-tree">
            <environment-row
              v-for="(env, index) in getFunctions"
              :key="index"
              :env="env"
              :env-name="index"
            />
          </ul>
        </div>
        <gl-loading-icon v-if="isLoading" size="lg" class="gl-mt-3 gl-mb-3 js-functions-loader" />
      </div>
      <div v-else class="empty-state js-empty-state">
        <div class="text-content">
          <h4 class="state-title text-center">{{ s__('Serverless|No functions available') }}</h4>
          <p class="state-description">
            {{
              s__(
                'Serverless|There is currently no function data available from Knative. This could be for a variety of reasons including:',
              )
            }}
          </p>
          <ul>
            <li v-safe-html="noServerlessConfigFile"></li>
            <li v-safe-html="noGitlabYamlConfigured"></li>
            <li v-safe-html="mismatchedServerlessFunctions"></li>
            <li>{{ s__('Serverless|The deploy job has not finished.') }}</li>
          </ul>

          <p>
            {{
              s__(
                'Serverless|If you believe none of these apply, please check back later as the function data may be in the process of becoming available.',
              )
            }}
          </p>
          <div class="text-center">
            <gl-link :href="helpPath" class="btn btn-success">{{
              s__('Serverless|Learn more about Serverless')
            }}</gl-link>
          </div>
        </div>
      </div>
    </div>

    <empty-state v-else />
  </section>
</template>