-
Notifications
You must be signed in to change notification settings - Fork 19
/
EmptyContent.vue
155 lines (152 loc) · 4.12 KB
/
EmptyContent.vue
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
<div class="empty-content">
<div class="empty-content--wrapper">
<div class="empty-content--icon">
<CheckIcon v-if="isStateOk && dashboard" :size="60" />
<LinkPlusIcon v-else-if="!!isAdminConfigOk && isStateOk && !dashboard && !isSmartPicker" :size="60" />
<OpenProjectIcon v-else-if="!!isSmartPicker && isStateOk" :size="150" class="empty-content--icon--openproject" />
<LinkOffIcon v-else :size="60" />
</div>
<div v-if="!!isAdminConfigOk" class="empty-content--message">
<div v-if="!!isStateOk && isSmartPicker" class="empty-content--message--title" />
<div v-else class="empty-content--message--title">
{{ emptyContentTitleMessage }}
</div>
<div v-if="!!emptyContentSubTitleMessage && !isSmartPicker" class="empty-content--message--sub-title">
{{ emptyContentSubTitleMessage }}
</div>
</div>
<div v-if="showConnectButton" class="empty-content--connect-button">
<OAuthConnectButton :is-admin-config-ok="isAdminConfigOk" :file-info="fileInfo" />
</div>
</div>
</div>
</template>
<script>
import LinkPlusIcon from 'vue-material-design-icons/LinkPlus.vue'
import LinkOffIcon from 'vue-material-design-icons/LinkOff.vue'
import CheckIcon from 'vue-material-design-icons/Check.vue'
import OpenProjectIcon from '../icons/OpenProjectIcon.vue'
import { generateUrl } from '@nextcloud/router'
import { translate as t } from '@nextcloud/l10n'
import OAuthConnectButton from '../OAuthConnectButton.vue'
import { STATE } from '../../utils.js'
export default {
name: 'EmptyContent',
components: { OAuthConnectButton, LinkPlusIcon, LinkOffIcon, CheckIcon, OpenProjectIcon },
props: {
state: {
type: String,
required: true,
default: STATE.OK,
},
isAdminConfigOk: {
type: Boolean,
required: true,
},
errorMessage: {
type: String,
default: '',
},
fileInfo: {
type: Object,
default() {
return {}
},
},
dashboard: {
type: Boolean,
default: false,
},
isSmartPicker: {
type: Boolean,
default: false,
},
isMultipleWorkpackageLinking: {
type: Boolean,
default: false,
},
},
data() {
return {
settingsUrl: generateUrl('/settings/user/openproject'),
}
},
computed: {
isStateOk() {
return this.state === STATE.OK
},
showConnectButton() {
return [STATE.NO_TOKEN, STATE.ERROR].includes(this.state)
},
emptyContentTitleMessage() {
if (this.state === STATE.NO_TOKEN) {
return t('integration_openproject', 'No connection with OpenProject')
} else if (this.state === STATE.CONNECTION_ERROR) {
return t('integration_openproject', 'Error connecting to OpenProject')
} else if (this.state === STATE.FAILED_FETCHING_WORKPACKAGES) {
return t('integration_openproject', 'Could not fetch work packages from OpenProject')
} else if (this.isStateOk) {
if (this.dashboard) {
return t('integration_openproject', 'No OpenProject notifications')
} else if (this.isMultipleWorkpackageLinking) {
return t('integration_openproject', 'Add a new link to all selected files')
}
return t('integration_openproject', 'No OpenProject links yet')
}
return t('integration_openproject', 'Unexpected Error')
},
emptyContentSubTitleMessage() {
if (this.isStateOk && !this.dashboard) {
return t('integration_openproject', 'To add a link, use the search bar above to find the desired work package')
}
return ''
},
},
}
</script>
<style scoped lang="scss">
.empty-content {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
&--wrapper {
height: fit-content;
}
&--icon {
padding: 1vh 0;
display: flex;
align-items: center;
justify-content: center;
&--openproject {
margin: 90px;
display: block;
align-items: center;
justify-content: center;
}
}
&--message {
text-align: center;
&--title {
font-size: 1.2rem;
line-height: 1.4rem;
font-weight: 600;
padding: 4px 12px 12px 12px;
}
&--sub-title {
font-size: 1rem;
line-height: 1.4rem;
text-align: center;
font-weight: 400;
padding: 0 18px;
}
}
&--connect-button {
padding: 1vh 0;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>