Skip to content

Commit 8d3f7d0

Browse files
authored
Merge 93bf685 into 15012a4
2 parents 15012a4 + 93bf685 commit 8d3f7d0

6 files changed

Lines changed: 91 additions & 72 deletions

File tree

js/viewer-main.js

Lines changed: 34 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/viewer-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 30 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"dependencies": {
4040
"@nextcloud/auth": "^1.3.0",
4141
"@nextcloud/axios": "^1.3.3",
42+
"@nextcloud/dialogs": "^2.0.0",
4243
"@nextcloud/paths": "^1.1.2",
4344
"@nextcloud/router": "^1.1.0",
4445
"@nextcloud/vue": "^2.3.0",

src/views/Viewer.vue

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,25 @@
102102
</template>
103103

104104
<script>
105-
import { getRootPath } from '../utils/davUtils'
105+
import Vue from 'vue'
106+
107+
import '@nextcloud/dialogs/styles/toast.scss'
108+
import { showError } from '@nextcloud/dialogs'
109+
106110
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
107111
import isFullscreen from '@nextcloud/vue/dist/Mixins/isFullscreen'
108112
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile'
109113
import Modal from '@nextcloud/vue/dist/Components/Modal'
110-
import Vue from 'vue'
111114
112115
import { extractFilePaths, sortCompare } from '../utils/fileUtils'
116+
import { getRootPath } from '../utils/davUtils'
117+
import cancelableRequest from '../utils/CancelableRequest'
113118
import Error from '../components/Error'
114119
import File from '../models/file'
115-
import Mime from '../mixins/Mime'
116-
import getFileList from '../services/FileList'
117-
import getFileInfo from '../services/FileInfo'
118120
import filesActionHandler from '../services/FilesActionHandler'
119-
120-
import cancelableRequest from '../utils/CancelableRequest'
121+
import getFileInfo from '../services/FileInfo'
122+
import getFileList from '../services/FileList'
123+
import Mime from '../mixins/Mime'
121124
122125
export default {
123126
name: 'Viewer',
@@ -341,6 +344,14 @@ export default {
341344
// get original mime
342345
let mime = fileInfo.mime
343346
347+
// if we don't have a handler for this mime, abort
348+
if (!(mime in this.components)) {
349+
console.error('The following file could not be displayed', fileName, fileInfo)
350+
showError(t('viewer', 'There is no plugin available to display this file type'))
351+
this.close()
352+
return
353+
}
354+
344355
// check if part of a group, if so retrieve full files list
345356
const group = this.mimeGroups[mime]
346357
if (this.files && this.files.length > 0) {
@@ -381,14 +392,9 @@ export default {
381392
mime = mime.split('/')[0]
382393
}
383394
384-
// if we have a valid mime, show it!
385-
if (this.components[mime]) {
386-
this.currentFile = new File(fileInfo, mime, this.components[mime])
387-
this.updatePreviousNext()
388-
} else {
389-
console.error('The following file could not be displayed', fileName, fileInfo)
390-
this.close()
391-
}
395+
// show file
396+
this.currentFile = new File(fileInfo, mime, this.components[mime])
397+
this.updatePreviousNext()
392398
393399
// if sidebar was opened before, let's update the file
394400
this.changeSidebar()

webpack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ const config = {
1313
test: /\.m?js$/,
1414
loader: 'babel-loader',
1515
exclude: BabelLoaderExcludeNodeModulesExcept([
16+
'@nextcloud/dialogs',
17+
'@nextcloud/event-bus',
1618
'camelcase',
1719
'fast-xml-parser',
1820
'hot-patcher',
21+
'semver',
1922
'vue-plyr',
2023
'webdav',
24+
'toastify-js',
2125
]),
2226
},
2327
{

0 commit comments

Comments
 (0)