*/
import axios from '@nextcloud/axios'
+import { davGetDefaultPropfind } from '@nextcloud/files'
/**
* @param {any} 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
</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 {
return {
key: 'error', // force key to re-render
subname: '',
- title: '',
+ name: '',
class: {
'app-sidebar--full': this.isFullScreen,
},
return {
loading: this.loading,
subname: '',
- title: '',
+ name: '',
class: {
'app-sidebar--full': this.isFullScreen,
},
${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)