Skip to content

Commit

Permalink
fix: New component compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Dec 27, 2023
1 parent 5bee06c commit 5945876
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ export default {
const { settings } = result?.data?.data || {}
for (const settingKey in settings) {
if (settingKey === 'use_groups' || settingKey === 'edit_groups') {
this.settings[settingKey] = settings[settingKey] ? settings[settingKey].split('|') : []
continue
}
this.settings[settingKey] = settings[settingKey]
}
this.checkFrontend()
Expand Down Expand Up @@ -727,6 +731,10 @@ export default {
const { settings } = result?.data?.data || {}
for (const settingKey in settings) {
if (settingKey === 'use_groups' || settingKey === 'edit_groups') {
this.settings[settingKey] = settings[settingKey] ? settings[settingKey].split('|') : []
continue
}
this.settings[settingKey] = settings[settingKey]
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingsSelectTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const xmlToTagList = (xml) => {
continue
}
if (tag['d:status']['#text'] !== 'HTTP/1.1 200 OK') {
if ((tag['d:status']['#text'] ?? null) !== 'HTTP/1.1 200 OK') {
continue
}
result.push({
Expand Down
30 changes: 15 additions & 15 deletions src/view/FilesAppIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { getFilePickerBuilder } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import { emit } from '@nextcloud/event-bus'
import { getCurrentDirectory } from '../helpers/filesApp.js'
import {
Expand Down Expand Up @@ -168,28 +170,26 @@ export default {
console.error('[FilesAppIntegration] insertGraphic is not supported')
}

const insertFileFromPath = (path) => {
const insertFileFromPath = async (path) => {
const filename = path.substring(path.lastIndexOf('/') + 1)
$.ajax({
type: 'POST',
url: generateUrl('apps/richdocuments/assets'),
data: {
path,
},
}).done(function(resp) {
insertFile(filename, resp.url)
})
const { data } = await axios.post(generateUrl('apps/richdocuments/assets'), { path })
insertFile(filename, data.url)
}

if (this.handlers.insertGraphic && this.handlers.insertGraphic(this, { insertFileFromPath })) {
return
}

OC.dialogs.filepicker(t('richdocuments', 'Insert from {name}', { name: OC.theme.name }), function(path, type) {
if (type === OC.dialogs.FILEPICKER_TYPE_CHOOSE) {
insertFileFromPath(path)
}
}, false, ['image/png', 'image/gif', 'image/jpeg', 'image/svg'], true, OC.dialogs.FILEPICKER_TYPE_CHOOSE)
getFilePickerBuilder(t('richdocuments', 'Insert image from {name}', { name: OC.theme.name }))
.setMimeTypeFilter(['image/png', 'image/gif', 'image/jpeg', 'image/svg'])
.addButton({
label: t('richdocuments', 'Insert image'),
callback: (files) => {
insertFileFromPath(files[0].path)
},
})
.build()
.pick()
},

getFileList() {
Expand Down
4 changes: 2 additions & 2 deletions src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div v-if="showLoadingIndicator"
class="office-viewer__loading-overlay"
:class="{ debug: debug }">
<NcEmptyContent v-if="!error" :title="t('richdocuments', 'Loading {filename} …', { filename: basename }, 1, {escape: false})">
<NcEmptyContent v-if="!error" :name="t('richdocuments', 'Loading {filename} …', { filename: basename }, 1, {escape: false})">
<template #icon>
<NcLoadingIcon />
</template>
Expand All @@ -35,7 +35,7 @@
</NcButton>
</template>
</NcEmptyContent>
<NcEmptyContent v-else :title="t('richdocuments', 'Document loading failed')" :description="errorMessage">
<NcEmptyContent v-else :name="t('richdocuments', 'Document loading failed')" :description="errorMessage">
<template #icon>
<AlertOctagonOutline />
</template>
Expand Down
5 changes: 5 additions & 0 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ import '../css/filetypes.scss'
import Office from './view/Office.vue'
import { getCapabilities } from '@nextcloud/capabilities'

// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken)
// eslint-disable-next-line
__webpack_public_path__ = OC.linkTo('richdocuments', 'js/')

const supportedMimes = getCapabilities().richdocuments.mimetypes

if (OCA.Viewer) {
Expand Down

0 comments on commit 5945876

Please sign in to comment.