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
|
<script>
import { GlLoadingIcon, GlEmptyState } from '@gitlab/ui';
import { s__, __ } from '~/locale';
import ProjectsList from '~/vue_shared/components/projects_list/projects_list.vue';
import { createAlert } from '~/alert';
import projectsQuery from '../graphql/queries/projects.query.graphql';
import { formatProjects } from '../utils';
export default {
i18n: {
errorMessage: s__(
'Organization|An error occurred loading the projects. Please refresh the page to try again.',
),
emptyState: {
title: s__("Organization|You don't have any projects yet."),
description: s__(
'GroupsEmptyState|Projects are where you can store your code, access issues, wiki, and other features of Gitlab.',
),
primaryButtonText: __('New project'),
},
},
components: {
ProjectsList,
GlLoadingIcon,
GlEmptyState,
},
inject: {
projectsEmptyStateSvgPath: {},
newProjectPath: {
default: null,
},
},
props: {
shouldShowEmptyStateButtons: {
type: Boolean,
required: false,
default: false,
},
listItemClass: {
type: [String, Array, Object],
required: false,
default: '',
},
},
data() {
return {
projects: [],
};
},
apollo: {
projects: {
query: projectsQuery,
update(data) {
return formatProjects(data.organization.projects.nodes);
},
error(error) {
createAlert({ message: this.$options.i18n.errorMessage, error, captureError: true });
},
},
},
computed: {
isLoading() {
return this.$apollo.queries.projects.loading;
},
emptyStateProps() {
const baseProps = {
svgHeight: 144,
svgPath: this.projectsEmptyStateSvgPath,
title: this.$options.i18n.emptyState.title,
description: this.$options.i18n.emptyState.description,
};
if (this.shouldShowEmptyStateButtons && this.newProjectPath) {
return {
...baseProps,
primaryButtonLink: this.newProjectPath,
primaryButtonText: this.$options.i18n.emptyState.primaryButtonText,
};
}
return baseProps;
},
},
};
</script>
<template>
<gl-loading-icon v-if="isLoading" class="gl-mt-5" size="md" />
<projects-list
v-else-if="projects.length"
:projects="projects"
show-project-icon
:list-item-class="listItemClass"
/>
<gl-empty-state v-else v-bind="emptyStateProps" />
</template>
|