debian-mirror-gitlab/app/assets/javascripts/monitoring/components/empty_state.vue

115 lines
3.2 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2020-07-28 23:09:34 +05:30
import { GlLoadingIcon, GlEmptyState } from '@gitlab/ui';
2020-01-01 13:55:28 +05:30
import { __ } from '~/locale';
2020-07-28 23:09:34 +05:30
import { dashboardEmptyStates } from '../constants';
2019-09-30 21:07:59 +05:30
2018-05-09 12:01:36 +05:30
export default {
2019-09-30 21:07:59 +05:30
components: {
2020-07-28 23:09:34 +05:30
GlLoadingIcon,
2019-09-30 21:07:59 +05:30
GlEmptyState,
},
2018-05-09 12:01:36 +05:30
props: {
2020-07-28 23:09:34 +05:30
selectedState: {
type: String,
required: true,
2021-03-08 18:12:59 +05:30
validator: (state) => Object.values(dashboardEmptyStates).includes(state),
2020-07-28 23:09:34 +05:30
},
2018-05-09 12:01:36 +05:30
documentationPath: {
type: String,
required: true,
},
settingsPath: {
type: String,
required: false,
default: '',
},
clustersPath: {
type: String,
required: false,
default: '',
},
emptyGettingStartedSvgPath: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-05-09 12:01:36 +05:30
emptyLoadingSvgPath: {
type: String,
required: true,
},
emptyNoDataSvgPath: {
type: String,
required: true,
},
2020-01-01 13:55:28 +05:30
emptyNoDataSmallSvgPath: {
type: String,
required: true,
},
2018-05-09 12:01:36 +05:30
emptyUnableToConnectSvgPath: {
type: String,
required: true,
},
2019-09-30 21:07:59 +05:30
compact: {
type: Boolean,
required: false,
default: false,
},
2018-05-09 12:01:36 +05:30
},
data() {
return {
2020-07-28 23:09:34 +05:30
/**
* Possible empty states.
* Keys in each state must match GlEmptyState props
*/
2018-05-09 12:01:36 +05:30
states: {
2020-07-28 23:09:34 +05:30
[dashboardEmptyStates.GETTING_STARTED]: {
svgPath: this.emptyGettingStartedSvgPath,
2019-09-30 21:07:59 +05:30
title: __('Get started with performance monitoring'),
description: __(`Stay updated about the performance and health
of your environment by configuring Prometheus to monitor your deployments.`),
2020-07-28 23:09:34 +05:30
primaryButtonText: __('Install on clusters'),
primaryButtonLink: this.clustersPath,
2019-09-30 21:07:59 +05:30
secondaryButtonText: __('Configure existing installation'),
2020-07-28 23:09:34 +05:30
secondaryButtonLink: this.settingsPath,
2018-05-09 12:01:36 +05:30
},
2020-07-28 23:09:34 +05:30
[dashboardEmptyStates.NO_DATA]: {
svgPath: this.emptyNoDataSvgPath,
2019-09-30 21:07:59 +05:30
title: __('No data found'),
description: __(`You are connected to the Prometheus server, but there is currently
no data to display.`),
2020-07-28 23:09:34 +05:30
primaryButtonText: __('Configure Prometheus'),
primaryButtonLink: this.settingsPath,
2019-09-30 21:07:59 +05:30
secondaryButtonText: '',
2020-07-28 23:09:34 +05:30
secondaryButtonLink: '',
2018-05-09 12:01:36 +05:30
},
2020-07-28 23:09:34 +05:30
[dashboardEmptyStates.UNABLE_TO_CONNECT]: {
svgPath: this.emptyUnableToConnectSvgPath,
2019-09-30 21:07:59 +05:30
title: __('Unable to connect to Prometheus server'),
description: __(
'Ensure connectivity is available from the GitLab server to the Prometheus server',
),
2020-07-28 23:09:34 +05:30
primaryButtonText: __('View documentation'),
primaryButtonLink: this.documentationPath,
2019-09-30 21:07:59 +05:30
secondaryButtonText: __('Configure Prometheus'),
2020-07-28 23:09:34 +05:30
secondaryButtonLink: this.settingsPath,
2018-03-17 18:26:18 +05:30
},
},
2018-05-09 12:01:36 +05:30
};
},
computed: {
2020-07-28 23:09:34 +05:30
isLoading() {
return this.selectedState === dashboardEmptyStates.LOADING;
},
2018-05-09 12:01:36 +05:30
currentState() {
return this.states[this.selectedState];
},
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
2020-07-28 23:09:34 +05:30
<div>
<gl-loading-icon v-if="isLoading" size="xl" class="gl-my-9" />
<gl-empty-state v-if="currentState" v-bind="currentState" :compact="compact" />
</div>
2018-03-17 18:26:18 +05:30
</template>