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

96 lines
2 KiB
Vue
Raw Normal View History

2021-01-03 14:25:43 +05:30
<script>
2021-09-04 01:27:46 +05:30
import { GlAlert, GlEmptyState, GlLink, GlLoadingIcon } from '@gitlab/ui';
2021-01-03 14:25:43 +05:30
export default {
2021-09-04 01:27:46 +05:30
components: { GlAlert, GlEmptyState, GlLink, GlLoadingIcon },
2021-03-08 18:12:59 +05:30
inject: ['errorStateSvgPath', 'featureFlagsHelpPagePath'],
2021-01-03 14:25:43 +05:30
props: {
count: {
required: false,
type: Number,
default: null,
},
alerts: {
required: true,
type: Array,
},
isLoading: {
required: true,
type: Boolean,
},
loadingLabel: {
required: true,
type: String,
},
errorState: {
required: true,
type: Boolean,
},
errorTitle: {
required: true,
type: String,
},
emptyState: {
required: true,
type: Boolean,
},
emptyTitle: {
required: true,
type: String,
},
2021-02-22 17:27:13 +05:30
emptyDescription: {
required: true,
type: String,
},
2021-01-03 14:25:43 +05:30
},
computed: {
itemCount() {
return this.count ?? 0;
},
},
methods: {
clearAlert(index) {
this.$emit('dismissAlert', index);
},
},
};
</script>
<template>
2021-09-04 01:27:46 +05:30
<div>
2021-03-11 19:13:27 +05:30
<gl-alert
v-for="(message, index) in alerts"
:key="index"
data-testid="serverErrors"
variant="danger"
@dismiss="clearAlert(index)"
>
{{ message }}
</gl-alert>
2021-01-03 14:25:43 +05:30
2021-03-11 19:13:27 +05:30
<gl-loading-icon v-if="isLoading" :label="loadingLabel" size="md" class="gl-mt-4" />
2021-01-03 14:25:43 +05:30
2021-03-11 19:13:27 +05:30
<gl-empty-state
v-else-if="errorState"
:title="errorTitle"
2021-09-04 01:27:46 +05:30
:description="s__('FeatureFlags|Try again in a few moments or contact your support team.')"
2021-03-11 19:13:27 +05:30
:svg-path="errorStateSvgPath"
data-testid="error-state"
/>
2021-01-03 14:25:43 +05:30
2021-03-11 19:13:27 +05:30
<gl-empty-state
v-else-if="emptyState"
:title="emptyTitle"
:svg-path="errorStateSvgPath"
data-testid="empty-state"
>
<template #description>
{{ emptyDescription }}
<gl-link :href="featureFlagsHelpPagePath" target="_blank">
{{ s__('FeatureFlags|More information') }}
</gl-link>
</template>
</gl-empty-state>
2021-09-04 01:27:46 +05:30
<slot v-else> </slot>
</div>
2021-01-03 14:25:43 +05:30
</template>