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

122 lines
3.7 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';
2021-01-03 14:25:43 +05:30
import { GlLink, GlLoadingIcon, GlSafeHtmlDirective as SafeHtml } 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,
2020-10-24 23:57:45 +05:30
GlLink,
2019-07-07 11:18:12 +05:30
GlLoadingIcon,
2019-02-15 15:39:39 +05:30
},
2021-01-03 14:25:43 +05:30
directives: {
SafeHtml,
},
2019-07-07 11:18:12 +05:30
computed: {
2020-10-24 23:57:45 +05:30
...mapState(['installed', 'isLoading', 'hasFunctionData', 'helpPath', 'statusPath']),
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">
2020-07-28 23:09:34 +05:30
<gl-loading-icon v-if="checkingInstalled" size="lg" class="gl-mt-3 gl-mb-3" />
2019-09-04 21:01:54 +05:30
<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>
2020-07-28 23:09:34 +05:30
<gl-loading-icon v-if="isLoading" size="lg" class="gl-mt-3 gl-mb-3 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>
2021-01-03 14:25:43 +05:30
<li v-safe-html="noServerlessConfigFile"></li>
<li v-safe-html="noGitlabYamlConfigured"></li>
<li v-safe-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">
2020-10-24 23:57:45 +05:30
<gl-link :href="helpPath" class="btn btn-success">{{
s__('Serverless|Learn more about Serverless')
}}</gl-link>
2019-02-15 15:39:39 +05:30
</div>
</div>
</div>
</div>
2020-10-24 23:57:45 +05:30
<empty-state v-else />
2019-02-15 15:39:39 +05:30
</section>
</template>