debian-mirror-gitlab/app/assets/javascripts/serverless/components/functions.vue

140 lines
3.9 KiB
Vue
Raw Normal View History

2019-02-15 15:39:39 +05:30
<script>
2019-07-07 11:18:12 +05:30
import { mapState, mapActions, mapGetters } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui';
2020-01-01 13:55:28 +05:30
import { sprintf, s__ } from '~/locale';
2019-03-02 22:35:43 +05:30
import EnvironmentRow from './environment_row.vue';
2019-02-15 15:39:39 +05:30
import EmptyState from './empty_state.vue';
2019-09-04 21:01:54 +05:30
import { CHECKING_INSTALLED } from '../constants';
2019-02-15 15:39:39 +05:30
export default {
components: {
2019-03-02 22:35:43 +05:30
EnvironmentRow,
2019-02-15 15:39:39 +05:30
EmptyState,
2019-07-07 11:18:12 +05:30
GlLoadingIcon,
2019-02-15 15:39:39 +05:30
},
props: {
clustersPath: {
type: String,
required: true,
},
helpPath: {
type: String,
required: true,
},
2019-07-07 11:18:12 +05:30
statusPath: {
type: String,
required: true,
2019-02-15 15:39:39 +05:30
},
2019-05-18 00:54:41 +05:30
},
2019-07-07 11:18:12 +05:30
computed: {
2019-09-04 21:01:54 +05:30
...mapState(['installed', 'isLoading', 'hasFunctionData']),
2019-07-07 11:18:12 +05:30
...mapGetters(['getFunctions']),
2019-09-04 21:01:54 +05:30
checkingInstalled() {
return this.installed === CHECKING_INSTALLED;
},
isInstalled() {
return this.installed === true;
},
2019-09-30 21:07:59 +05:30
noServerlessConfigFile() {
return sprintf(
s__(
'Serverless|Your repository does not have a corresponding %{startTag}serverless.yml%{endTag} file.',
),
{ startTag: '<code>', endTag: '</code>' },
2020-01-01 13:55:28 +05:30
false,
2019-09-30 21:07:59 +05:30
);
},
noGitlabYamlConfigured() {
return sprintf(
s__('Serverless|Your %{startTag}.gitlab-ci.yml%{endTag} file is not properly configured.'),
{ startTag: '<code>', endTag: '</code>' },
2020-01-01 13:55:28 +05:30
false,
2019-09-30 21:07:59 +05:30
);
},
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>' },
2020-01-01 13:55:28 +05:30
false,
2019-09-30 21:07:59 +05:30
);
},
2019-07-07 11:18:12 +05:30
},
created() {
this.fetchFunctions({
functionsPath: this.statusPath,
});
},
methods: {
...mapActions(['fetchFunctions']),
},
2019-02-15 15:39:39 +05:30
};
</script>
<template>
2020-03-13 15:44:24 +05:30
<section id="serverless-functions" class="flex-grow">
2019-09-04 21:01:54 +05:30
<gl-loading-icon
v-if="checkingInstalled"
2020-04-22 19:07:51 +05:30
size="lg"
2019-09-04 21:01:54 +05:30
class="prepend-top-default append-bottom-default"
/>
<div v-else-if="isInstalled">
2019-02-15 15:39:39 +05:30
<div v-if="hasFunctionData">
2019-09-04 21:01:54 +05:30
<template>
<div class="groups-list-tree-container js-functions-wrapper">
2019-03-02 22:35:43 +05:30
<ul class="content-list group-list-tree">
<environment-row
2019-07-07 11:18:12 +05:30
v-for="(env, index) in getFunctions"
2019-03-02 22:35:43 +05:30
:key="index"
:env="env"
:env-name="index"
/>
</ul>
2019-02-15 15:39:39 +05:30
</div>
2019-03-02 22:35:43 +05:30
</template>
2019-09-04 21:01:54 +05:30
<gl-loading-icon
v-if="isLoading"
2020-04-22 19:07:51 +05:30
size="lg"
2019-09-04 21:01:54 +05:30
class="prepend-top-default append-bottom-default js-functions-loader"
/>
2019-02-15 15:39:39 +05:30
</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">
{{
2019-09-30 21:07:59 +05:30
s__(
'Serverless|There is currently no function data available from Knative. This could be for a variety of reasons including:',
)
2019-02-15 15:39:39 +05:30
}}
</p>
<ul>
2020-01-01 13:55:28 +05:30
<li v-html="noServerlessConfigFile"></li>
<li v-html="noGitlabYamlConfigured"></li>
<li v-html="mismatchedServerlessFunctions"></li>
2019-09-30 21:07:59 +05:30
<li>{{ s__('Serverless|The deploy job has not finished.') }}</li>
2019-02-15 15:39:39 +05:30
</ul>
<p>
{{
2019-09-30 21:07:59 +05:30
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.',
)
2019-02-15 15:39:39 +05:30
}}
</p>
<div class="text-center">
<a :href="helpPath" class="btn btn-success">
{{ s__('Serverless|Learn more about Serverless') }}
</a>
</div>
</div>
</div>
</div>
<empty-state v-else :clusters-path="clustersPath" :help-path="helpPath" />
</section>
</template>