Skip to content

Commit ceef2ed

Browse files
committed
Add error handling for file manager
1 parent 92a9146 commit ceef2ed

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

resources/assets/scripts/components/server/subpages/FileManager.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<div v-if="loading">
44
<div class="spinner spinner-xl blue"></div>
55
</div>
6+
<div v-else-if="!loading && errorMessage">
7+
<div class="alert error" v-text="errorMessage"></div>
8+
</div>
69
<div class="filemanager" v-else>
710
<div class="header">
811
<div class="flex-none w-8"></div>
@@ -34,6 +37,7 @@
3437

3538
<script>
3639
import filter from 'lodash/filter';
40+
import isObject from 'lodash/isObject';
3741
import format from 'date-fns/format';
3842
import { mapState } from 'vuex';
3943
import { FileTextIcon, FolderIcon, Link2Icon } from 'vue-feather-icons';
@@ -44,18 +48,33 @@
4448
4549
computed: {
4650
...mapState('server', ['server', 'credentials']),
51+
...mapState('socket', ['connected']),
4752
},
4853
4954
watch: {
55+
/**
56+
* Watch the current directory setting and when it changes update the file listing.
57+
*/
5058
currentDirectory: function () {
5159
this.listDirectory();
5260
},
61+
62+
/**
63+
* When we reconnect to the Daemon make sure we grab a listing of all of the files
64+
* so that the error message disappears and we then load in a fresh listing.
65+
*/
66+
connected: function () {
67+
if (this.connected) {
68+
this.listDirectory();
69+
}
70+
}
5371
},
5472
5573
data: function () {
5674
return {
5775
currentDirectory: '/',
5876
loading: true,
77+
errorMessage: null,
5978
6079
directories: [],
6180
editableFiles: [],
@@ -88,8 +107,16 @@
88107
});
89108
90109
this.editableFiles = response.data.editable;
110+
this.errorMessage = null;
111+
})
112+
.catch(err => {
113+
console.error({ err });
114+
if (err.response.data && isObject(err.response.data.errors)) {
115+
err.response.data.errors.forEach(error => {
116+
this.errorMessage = error.detail;
117+
});
118+
}
91119
})
92-
.catch(console.error)
93120
.finally(() => {
94121
this.loading = false;
95122
});

0 commit comments

Comments
 (0)