Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export default {
* @return {boolean}
*/
canBeSharedWritable() {
// TODO: read-write sharing is not implemented for federated calendars yet
return !this.sharee.isRemoteUser
return this.calendar.canCreateObject || this.calendar.canModifyObject
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/mixins/EditorMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default {
return true
}

return calendar.readOnly
return !calendar.canCreateObject && !calendar.canModifyObject
},
isSharedWithMe() {
if (!this.calendarObject) {
Expand Down
12 changes: 12 additions & 0 deletions src/models/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ function getDefaultCalendarObject(props = {}) {
canBeShared: false,
// Whether or not the calendar can be published by me
canBePublished: false,
// Whether or not I can create objects in this calendar
canCreateObject: false,
// Whether or not I can modify objects in this calendar
canModifyObject: false,
// Whether or not I can delete objects in this calendar
canDeleteObject: false,
// Reference to cdav-lib object
dav: false,
// All calendar-objects from this calendar that have already been fetched
Expand Down Expand Up @@ -86,6 +92,9 @@ function mapDavCollectionToCalendar(calendar, currentUserPrincipal) {
const readOnly = !calendar.isWriteable()
const canBeShared = calendar.isShareable()
const canBePublished = calendar.isPublishable()
const canCreateObject = calendar.currentUserPrivilegeSet.includes('{DAV:}bind') || calendar.currentUserPrivilegeSet.includes('{DAV:}write') || calendar.currentUserPrivilegeSet.includes('{DAV:}all') === true
const canModifyObject = calendar.currentUserPrivilegeSet.includes('{DAV:}write-content') || calendar.currentUserPrivilegeSet.includes('{DAV:}write') || calendar.currentUserPrivilegeSet.includes('{DAV:}all') === true
const canDeleteObject = calendar.currentUserPrivilegeSet.includes('{DAV:}unbind') || calendar.currentUserPrivilegeSet.includes('{DAV:}write') || calendar.currentUserPrivilegeSet.includes('{DAV:}all') === true
Comment on lines +95 to +97
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth it to add these in cdav library instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Yes that makes sense! I will do that, but at the moment this is so we can get a feature out... Then I will modify the dav-library

const order = calendar.order || 0
const url = calendar.url
const publishURL = calendar.publishURL || null
Expand Down Expand Up @@ -146,6 +155,9 @@ function mapDavCollectionToCalendar(calendar, currentUserPrincipal) {
publishURL,
canBeShared,
canBePublished,
canCreateObject,
canModifyObject,
canDeleteObject,
shares,
timezone,
transparency,
Expand Down
68 changes: 59 additions & 9 deletions tests/javascript/unit/models/calendar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isSharedWithMe: false,
canBeShared: false,
canBePublished: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
dav: false,
calendarObjects: [],
fetchedTimeRanges: [],
Expand Down Expand Up @@ -66,6 +69,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isSharedWithMe: false,
canBeShared: false,
canBePublished: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
dav: false,
calendarObjects: [],
fetchedTimeRanges: [],
Expand All @@ -88,6 +94,7 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
enabled: true,
timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
transparency: 'opaque',
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -109,6 +116,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -135,6 +145,7 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
transparency: 'transparent',
enabled: false,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -156,6 +167,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
transparency: 'transparent',
url: '/foo/bar',
Expand All @@ -179,7 +193,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isPublishable: () => true,
order: undefined,
publishURL: undefined,
enabled: undefined
enabled: undefined,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -201,6 +216,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -224,7 +242,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isPublishable: () => true,
order: undefined,
publishURL: undefined,
enabled: undefined
enabled: undefined,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -246,6 +265,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: true,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -269,7 +291,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isPublishable: () => true,
order: undefined,
publishURL: undefined,
enabled: true
enabled: true,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -291,6 +314,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -314,7 +340,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isPublishable: () => true,
order: undefined,
publishURL: undefined,
enabled: true
enabled: true,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -336,6 +363,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -359,7 +389,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isPublishable: () => true,
order: undefined,
publishURL: undefined,
enabled: true
enabled: true,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -381,6 +412,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -404,7 +438,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
isPublishable: () => true,
order: undefined,
publishURL: undefined,
enabled: true
enabled: true,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -426,6 +461,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand Down Expand Up @@ -499,7 +537,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
'{http://owncloud.org/ns}read'
]
}
]
],
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand Down Expand Up @@ -527,6 +566,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand Down Expand Up @@ -624,7 +666,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
'{http://owncloud.org/ns}read'
]
}
]
],
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject)).toEqual({
Expand All @@ -644,6 +687,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: true,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: null,
transparency: 'opaque',
url: '/foo/bar',
Expand All @@ -668,7 +714,8 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
order: undefined,
publishURL: undefined,
timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
enabled: false
enabled: false,
currentUserPrivilegeSet: [],
}

expect(mapDavCollectionToCalendar(cdavObject, {
Expand All @@ -690,6 +737,9 @@ describe('Test suite: Calendar model (models/calendar.js)', () => {
supportsJournals: false,
supportsTasks: false,
isSharedWithMe: false,
canCreateObject: false,
canDeleteObject: false,
canModifyObject: false,
timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
transparency: 'opaque',
url: '/remote.php/dav/calendars/admin/personal/',
Expand Down
4 changes: 2 additions & 2 deletions vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
// Required for transforming CSS files
pool: 'vmForks',
// Increase timeouts for slow CI environments
testTimeout: 120000, // 2 minutes per test
hookTimeout: 30000, // 30 seconds for hooks
testTimeout: 300000, // 2 minutes per test
hookTimeout: 60000, // 60 seconds for hooks
},
});
Loading