Skip to content

Commit d5a2407

Browse files
author
Guillaume Chau
committed
fix(ui): FileDiffView: display error message
1 parent 8e5448c commit d5a2407

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

packages/@vue/cli-ui/src/components/FileDiffView.vue

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="toolbar">
44
<VueIcon icon="cached"/>
55
<div class="title">{{ $t('org.vue.components.file-diff-view.files-changed') }}</div>
6-
<div class="file-count">{{ fileDiffs.length }}</div>
6+
<div class="file-count">{{ fileDiffs && fileDiffs.length }}</div>
77
<div class="vue-ui-spacer"/>
88
<VueInput
99
v-model="search"
@@ -22,21 +22,28 @@
2222
/>
2323
</div>
2424
<div class="list">
25-
<FileDiff
26-
v-for="fileDiff of filteredList"
27-
:key="fileDiff.id"
28-
:file-diff="fileDiff"
29-
:collapsed="!!collapsed[fileDiff.id]"
30-
@update:collapsed="value => $set(collapsed, fileDiff.id, value)"
31-
/>
25+
<div v-if="error || !fileDiffs" class="vue-ui-empty">
26+
<VueIcon icon="error" class="empty-icon"/>
27+
<span>{{ $t('org.vue.components.file-diff-view.error') }}</span>
28+
</div>
3229

33-
<div v-if="!filteredList.length" class="vue-ui-empty">
30+
<div v-else-if="!filteredList.length" class="vue-ui-empty">
3431
<VueIcon icon="check_circle" class="empty-icon"/>
3532
<span>{{ $t('org.vue.components.file-diff-view.empty') }}</span>
3633
</div>
34+
35+
<template v-else>
36+
<FileDiff
37+
v-for="fileDiff of filteredList"
38+
:key="fileDiff.id"
39+
:file-diff="fileDiff"
40+
:collapsed="!!collapsed[fileDiff.id]"
41+
@update:collapsed="value => $set(collapsed, fileDiff.id, value)"
42+
/>
43+
</template>
3744
</div>
3845
<div class="actions-bar">
39-
<template v-if="fileDiffs.length">
46+
<template v-if="!error && fileDiffs && fileDiffs.length">
4047
<VueButton
4148
icon-left="vertical_align_bottom"
4249
:label="$t('org.vue.components.file-diff-view.actions.commit')"
@@ -133,7 +140,8 @@ export default {
133140
search: '',
134141
loading: 0,
135142
commitMessage: '',
136-
showCommitModal: false
143+
showCommitModal: false,
144+
error: null
137145
}
138146
},
139147
@@ -142,7 +150,16 @@ export default {
142150
query: FILE_DIFFS,
143151
loadingKey: 'loading',
144152
fetchPolicy: 'network-only',
145-
result () {
153+
error (error) {
154+
this.error = error
155+
},
156+
result (result) {
157+
if (result.errors && result.errors.length) {
158+
this.error = result.errors[0]
159+
return
160+
}
161+
162+
this.error = null
146163
this.fileDiffs.forEach(fileDiff => {
147164
if (typeof this.collapsed[fileDiff.id] === 'undefined' && (
148165
fileDiff.binary ||
@@ -158,12 +175,14 @@ export default {
158175
159176
computed: {
160177
allCollapsed () {
178+
if (!this.fileDiffs) return false
161179
return !this.fileDiffs.find(
162180
fileDiff => !this.collapsed[fileDiff.id]
163181
)
164182
},
165183
166184
filteredList () {
185+
if (!this.fileDiffs) return []
167186
const search = this.search.trim()
168187
if (search) {
169188
const reg = new RegExp(search.replace(/\s+/g, '.*'), 'i')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy