Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 2e97152f authored by Georg Ehrke's avatar Georg Ehrke Committed by GitHub
Browse files

Merge pull request #1581 from nextcloud/feature/223/add_timezone_prop_to_calendar

Add timezone at creation of calendar
parents 3f9d1ad3 fe1fdaf0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4362,7 +4362,7 @@
      }
    },
    "calendar-js": {
      "version": "git+https://github.com/georgehrke/calendar-js.git#04c9848de8e1bc6842dc2aca37ff75caa9eaf9c7",
      "version": "git+https://github.com/georgehrke/calendar-js.git#fc37c335684f6f76c6869aa9ef661d8aba42ded4",
      "from": "git+https://github.com/georgehrke/calendar-js.git",
      "requires": {
        "ical.js": "^1.3.0",
+4 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ export const getDefaultCalendarObject = (props = {}) => Object.assign({}, {
	supportsTasks: false,
	// The principal uri of the owner
	owner: '',
	// Timezone set for this calendar
	timezone: null,
	// List of shares
	shares: [],
	// Published url
@@ -99,6 +101,7 @@ export function mapDavCollectionToCalendar(calendar, currentUserPrincipal) {
	const order = calendar.order || 0
	const url = calendar.url
	const publishURL = calendar.publishURL || null
	const timezone = calendar.timezone || null

	let isSharedWithMe = false
	if (!currentUserPrincipal) {
@@ -152,6 +155,7 @@ export function mapDavCollectionToCalendar(calendar, currentUserPrincipal) {
		canBeShared,
		canBePublished,
		shares,
		timezone,
		dav: calendar
	}
}
+19 −2
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ import { getDefaultCalendarObject, mapDavCollectionToCalendar } from '../models/
import pLimit from 'p-limit'
import { uidToHexColor } from '../utils/color.js'
import { translate } from '@nextcloud/l10n'
import getTimezoneManager from '../services/timezoneDataProviderService.js'
import Timezone from 'calendar-js/src/timezones/timezone.js'
import CalendarComponent from 'calendar-js/src/components/calendarComponent.js'

const state = {
	calendars: [],
@@ -460,10 +463,24 @@ const actions = {
	 * @param {Object} data.displayName The name of the new calendar
	 * @param {Object} data.color The color of the new calendar
	 * @param {Object} data.order The order of the new calendar
	 * @param {String[]=} data.components The supported components of the calendar
	 * @param {String=} data.timezone The timezoneId
	 * @returns {Promise}
	 */
	async appendCalendar(context, { displayName, color, order }) {
		return client.calendarHomes[0].createCalendarCollection(displayName, color, ['VEVENT'], order)
	async appendCalendar(context, { displayName, color, order, components = ['VEVENT'], timezone = null }) {
		if (timezone === null) {
			timezone = context.getters.getResolvedTimezone
		}

		let timezoneIcs = null
		const timezoneObject = getTimezoneManager().getTimezoneForId(timezone)
		if (timezoneObject !== Timezone.utc && timezoneObject !== Timezone.floating) {
			const calendar = CalendarComponent.fromEmpty()
			calendar.addComponent(timezoneObject.toTimezoneComponent())
			timezoneIcs = calendar.toICS(false)
		}

		return client.calendarHomes[0].createCalendarCollection(displayName, color, components, order, timezoneIcs)
			.then((response) => {
				const calendar = mapDavCollectionToCalendar(response, context.getters.getCurrentUserPrincipal)
				context.commit('addCalendar', { calendar })
+15 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ describe('models/calendar test suite', () => {
			owner: '',
			shares: [],
			publishURL: null,
			timezone: null,
			url: '',
			readOnly: false,
			order: 0,
@@ -69,6 +70,7 @@ describe('models/calendar test suite', () => {
			owner: '',
			shares: [],
			publishURL: null,
			timezone: null,
			url: '',
			readOnly: false,
			order: 0,
@@ -93,7 +95,8 @@ describe('models/calendar test suite', () => {
			isPublishable: () => true,
			order: undefined,
			publishURL: undefined,
			enabled: true
			enabled: true,
			timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
		}

		expect(mapDavCollectionToCalendar(cdavObject, {
@@ -115,6 +118,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
			url: '/foo/bar'
		})
	})
@@ -131,6 +135,7 @@ describe('models/calendar test suite', () => {
			isPublishable: () => true,
			order: undefined,
			publishURL: undefined,
			timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
			enabled: false
		}

@@ -153,6 +158,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: 'BEGIN:VCALENDAR...END:VCALENDAR',
			url: '/foo/bar'
		})
	})
@@ -191,6 +197,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -229,6 +236,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: true,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -267,6 +275,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -305,6 +314,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -343,6 +353,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -381,6 +392,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -490,6 +502,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: false,
			timezone: null,
			url: '/foo/bar'
		})
	})
@@ -568,6 +581,7 @@ describe('models/calendar test suite', () => {
			supportsJournals: false,
			supportsTasks: false,
			isSharedWithMe: true,
			timezone: null,
			url: '/foo/bar'
		})
	})