diff options
-rw-r--r-- | apps/files/src/services/FileInfo.js | 29 | ||||
-rw-r--r-- | apps/files/src/views/Sidebar.vue | 25 |
2 files changed, 22 insertions, 32 deletions
diff --git a/apps/files/src/services/FileInfo.js b/apps/files/src/services/FileInfo.js index c09af45f495..0b3b0040c26 100644 --- a/apps/files/src/services/FileInfo.js +++ b/apps/files/src/services/FileInfo.js @@ -21,6 +21,7 @@ */ import axios from '@nextcloud/axios' +import { davGetDefaultPropfind } from '@nextcloud/files' /** * @param {any} url - @@ -29,33 +30,7 @@ export default async function(url) { const response = await axios({ method: 'PROPFIND', url, - data: `<?xml version="1.0"?> - <d:propfind xmlns:d="DAV:" - xmlns:oc="http://owncloud.org/ns" - xmlns:nc="http://nextcloud.org/ns" - xmlns:ocs="http://open-collaboration-services.org/ns"> - <d:prop> - <d:getlastmodified /> - <d:getetag /> - <d:getcontenttype /> - <d:resourcetype /> - <oc:fileid /> - <oc:permissions /> - <oc:size /> - <d:getcontentlength /> - <nc:has-preview /> - <nc:mount-type /> - <nc:is-encrypted /> - <ocs:share-permissions /> - <nc:share-attributes /> - <oc:tags /> - <oc:favorite /> - <oc:comments-unread /> - <oc:owner-id /> - <oc:owner-display-name /> - <oc:share-types /> - </d:prop> - </d:propfind>`, + data: davGetDefaultPropfind(), }) // TODO: create new parser or use cdav-lib when available diff --git a/apps/files/src/views/Sidebar.vue b/apps/files/src/views/Sidebar.vue index b17aa93e63e..a2da72ce792 100644 --- a/apps/files/src/views/Sidebar.vue +++ b/apps/files/src/views/Sidebar.vue @@ -88,20 +88,22 @@ </NcAppSidebar> </template> <script> +import { emit } from '@nextcloud/event-bus' import { encodePath } from '@nextcloud/paths' +import { File, Folder } from '@nextcloud/files' +import { getCurrentUser } from '@nextcloud/auth' +import { Type as ShareTypes } from '@nextcloud/sharing' import $ from 'jquery' import axios from '@nextcloud/axios' -import { emit } from '@nextcloud/event-bus' import moment from '@nextcloud/moment' -import { Type as ShareTypes } from '@nextcloud/sharing' import NcAppSidebar from '@nextcloud/vue/dist/Components/NcAppSidebar.js' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' import FileInfo from '../services/FileInfo.js' -import SidebarTab from '../components/SidebarTab.vue' import LegacyView from '../components/LegacyView.vue' +import SidebarTab from '../components/SidebarTab.vue' import SystemTags from '../../../systemtags/src/components/SystemTags.vue' export default { @@ -253,7 +255,7 @@ export default { return { key: 'error', // force key to re-render subname: '', - title: '', + name: '', class: { 'app-sidebar--full': this.isFullScreen, }, @@ -263,7 +265,7 @@ export default { return { loading: this.loading, subname: '', - title: '', + name: '', class: { 'app-sidebar--full': this.isFullScreen, }, @@ -396,6 +398,19 @@ export default { ${state ? '</d:set>' : '</d:remove>'} </d:propertyupdate>`, }) + + /** + * TODO: adjust this when the Sidebar is finally using File/Folder classes + * @see https://github.com/nextcloud/server/blob/8a75cb6e72acd42712ab9fea22296aa1af863ef5/apps/files/src/views/favorites.ts#L83-L115 + */ + const isDir = this.fileInfo.type === 'dir' + const Node = isDir ? Folder : File + emit(state ? 'files:favorites:added' : 'files:favorites:removed', new Node({ + fileid: this.fileInfo.id, + source: this.davPath, + root: `/files/${getCurrentUser().uid}`, + mime: isDir ? undefined : this.fileInfo.mimetype, + })) } catch (error) { OC.Notification.showTemporary(t('files', 'Unable to change the favourite state of the file')) console.error('Unable to change favourite state', error) |