-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathFileEntryStatus.vue
More file actions
148 lines (133 loc) · 2.73 KB
/
FileEntryStatus.vue
File metadata and controls
148 lines (133 loc) · 2.73 KB
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
<!--
- SPDX-FileCopyrightText: 2024 LibreCode coop and LibreCode contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div v-if="statusText !== 'none'"
class="status-chip"
:class="'status-chip--' + statusToVariant(status)"
:title="statusText">
<div class="status-chip__text">{{ statusText }}</div>
<NcIconSvgWrapper class="status-chip__icon" :svg="statusIcon" :size="20" />
</div>
</template>
<script>
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import { fileStatus } from '../../../helpers/fileStatus.js'
export default {
name: 'FileEntryStatus',
components: {
NcIconSvgWrapper,
},
props: {
statusText: {
type: String,
required: true,
default: 'none',
},
status: {
type: Number,
required: true,
default: 0,
},
signers: {
type: Array,
default: () => [],
},
},
computed: {
statusIcon() {
const statusInfo = fileStatus.find(item => item.id === this.status)
return statusInfo?.icon || ''
},
},
methods: {
statusToVariant(status) {
// Status 0 can be "no signers" (error/red) or "draft" (gray)
if (status === 0) {
return this.signers.length === 0 ? 'error' : 'draft'
}
switch (Number(status)) {
case 1:
return 'available'
case 2:
return 'partial'
case 3:
return 'signed'
default:
return 'secondary'
}
},
},
}
</script>
<style lang="scss" scoped>
.status-chip {
--chip-size: 24px;
--chip-radius: 12px;
display: inline-block;
min-height: var(--chip-size);
max-width: 100%;
padding: 4px 12px;
border-radius: var(--chip-radius);
line-height: 1.3;
text-align: center;
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
hyphens: auto;
vertical-align: middle;
&__text {
display: inline-block;
max-width: 100%;
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
}
&__icon {
display: none;
}
&--error {
background-color: var(--color-error);
color: var(--color-error-text);
}
&--draft {
background-color: #E0E0E0;
color: #424242;
}
&--available {
background-color: #FFF3CD;
color: #856404;
}
&--partial {
background-color: #FFF3CD;
color: #856404;
}
&--signed {
background-color: #D4EDDA;
color: #155724;
}
&--secondary {
background-color: var(--color-primary-element-light);
color: var(--color-primary-element-light-text);
}
// Mobile: show only icon
@media (max-width: 768px) {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: var(--chip-size);
max-width: var(--chip-size);
width: var(--chip-size);
height: var(--chip-size);
padding: 0;
background-color: transparent !important;
&__text {
display: none;
}
&__icon {
display: block;
}
}
}
</style>