diff --git a/src/components/AppNavigation/CalendarList/CalendarListItem.vue b/src/components/AppNavigation/CalendarList/CalendarListItem.vue index 06c6624639..d07495335d 100644 --- a/src/components/AppNavigation/CalendarList/CalendarListItem.vue +++ b/src/components/AppNavigation/CalendarList/CalendarListItem.vue @@ -1,6 +1,8 @@ - - + :class="{deleted: isBeingDeleted, disabled: !calendar.enabled}" + @click.prevent.stop="toggleEnabled" + @update:menuOpen="actionsMenuOpen = $event"> + @@ -35,178 +37,84 @@ :fill-color="calendar.color" /> - - - - - - - - - - + + - - - - - - {{ $t('calendar', 'Edit name') }} - - - - - - - - - {{ $t('calendar', 'Saving name …') }} - - - - - - {{ $t('calendar', 'Edit color') }} - - - - - - - - - {{ $t('calendar', 'Saving color …') }} - - - - - - {{ $t('calendar', 'Copy private link') }} - - - - - - {{ $t('calendar', 'Export') }} - - - - - - {{ $t('calendar', 'Unshare from me') }} - - - - - - {{ $t('calendar', 'Delete') }} - - - - - - - + + + + + + + + + + + + - {{ $n('calendar', 'Unsharing the calendar in {countdown} second', 'Unsharing the calendar in {countdown} seconds', countdown, { countdown }) }} - - - - - - {{ $n('calendar', 'Deleting the calendar in {countdown} second', 'Deleting the calendar in {countdown} seconds', countdown, { countdown }) }} - - - - - - - - - + + + + + + {{ $t('calendar', 'Edit and share calendar') }} + + + {{ $t('calendar', 'Edit calendar') }} + + + + + + + + + {{ $n('calendar', 'Unsharing the calendar in {countdown} second', 'Unsharing the calendar in {countdown} seconds', countdown, { countdown }) }} + + + + + + {{ $n('calendar', 'Deleting the calendar in {countdown} second', 'Deleting the calendar in {countdown} seconds', countdown, { countdown }) }} + + diff --git a/src/components/AppNavigation/CalendarList/CalendarListItemSharingPublishItem.vue b/src/components/AppNavigation/EditCalendarModal/PublishCalendar.vue similarity index 64% rename from src/components/AppNavigation/CalendarList/CalendarListItemSharingPublishItem.vue rename to src/components/AppNavigation/EditCalendarModal/PublishCalendar.vue index baf0a91588..2f5320da6b 100644 --- a/src/components/AppNavigation/CalendarList/CalendarListItemSharingPublishItem.vue +++ b/src/components/AppNavigation/EditCalendarModal/PublishCalendar.vue @@ -1,6 +1,8 @@ - - - - + + + + - - - - - - {{ $t('calendar', 'Publish calendar') }} - - - {{ $t('calendar', 'Publishing calendar') }} - - + + {{ $t('calendar', 'Share link') }} + - - - + + + {{ $t('calendar', 'Copy public link') }} - - - - - - - - - {{ $t('calendar', 'Send link to calendar via email') }} - - - - - - {{ $t('calendar', 'Enter one address') }} - - - - {{ $t('calendar', 'Sending email …') }} - + + - - - - - {{ $t('calendar', 'Copy subscription link') }} - - - - {{ $t('calendar', 'Copying link …') }} - - - - - - {{ $t('calendar', 'Copied link') }} - - - - - - {{ $t('calendar', 'Could not copy link') }} - + + + + + + {{ $t('calendar', 'Send link to calendar via email') }} + + + + + + {{ $t('calendar', 'Enter one address') }} + + + + {{ $t('calendar', 'Sending email …') }} + - - - - - {{ $t('calendar', 'Copy embedding code') }} - - - - {{ $t('calendar', 'Copying code …') }} - - - - - - {{ $t('calendar', 'Copied code') }} - - - - - - {{ $t('calendar', 'Could not copy code') }} - + + + + + {{ $t('calendar', 'Copy subscription link') }} + + + + {{ $t('calendar', 'Copying link …') }} + + + + + + {{ $t('calendar', 'Copied link') }} + + + + + + {{ $t('calendar', 'Could not copy link') }} + + + + + + + {{ $t('calendar', 'Copy embedding code') }} + + + + {{ $t('calendar', 'Copying code …') }} + + + + + + {{ $t('calendar', 'Copied code') }} + + + + + + {{ $t('calendar', 'Could not copy code') }} + - + + + + + {{ $t('calendar', 'Delete share link') }} + + + + {{ $t('calendar', 'Deleting share link …') }} + + + + + - + - {{ $t('calendar', 'Delete share link') }} - - - - {{ $t('calendar', 'Deleting share link …') }} - - - + + + + + diff --git a/src/components/AppNavigation/CalendarList/CalendarListItemSharingShareItem.vue b/src/components/AppNavigation/EditCalendarModal/ShareItem.vue similarity index 66% rename from src/components/AppNavigation/CalendarList/CalendarListItemSharingShareItem.vue rename to src/components/AppNavigation/EditCalendarModal/ShareItem.vue index 8f1f79e3fd..caa93b6d1b 100644 --- a/src/components/AppNavigation/CalendarList/CalendarListItemSharingShareItem.vue +++ b/src/components/AppNavigation/EditCalendarModal/ShareItem.vue @@ -1,6 +1,8 @@ - - - - - - + + + + + + + {{ sharee.displayName }} + - - - {{ $t('calendar', 'can edit') }} - - + + {{ $t('calendar', 'can edit') }} - - + {{ $t('calendar', 'Unshare with {displayName}', { displayName: sharee.displayName }) }} - - - + + + + + diff --git a/src/components/AppNavigation/CalendarList/CalendarListItemSharingSearch.vue b/src/components/AppNavigation/EditCalendarModal/SharingSearch.vue similarity index 94% rename from src/components/AppNavigation/CalendarList/CalendarListItemSharingSearch.vue rename to src/components/AppNavigation/EditCalendarModal/SharingSearch.vue index cfae4c5de2..d8c26a606d 100644 --- a/src/components/AppNavigation/CalendarList/CalendarListItemSharingSearch.vue +++ b/src/components/AppNavigation/EditCalendarModal/SharingSearch.vue @@ -4,6 +4,7 @@ - - @author Georg Ehrke - @author Jakob Röhrl + - @author Richard Steinmetz - - @license AGPL-3.0-or-later - @@ -23,23 +24,24 @@ --> - + {{ $t('calendar', 'No users or groups') }} - + + + diff --git a/src/store/calendars.js b/src/store/calendars.js index bbb5f2721e..e39545c7bc 100644 --- a/src/store/calendars.js +++ b/src/store/calendars.js @@ -48,6 +48,7 @@ import { IMPORT_STAGE_IMPORTING, IMPORT_STAGE_PROCESSING, } from '../models/consts.js' +import { showError } from '@nextcloud/dialogs' const state = { calendars: [], @@ -57,6 +58,7 @@ const state = { deletedCalendarObjects: [], calendarsById: {}, initialCalendarsLoaded: false, + editCalendarModal: undefined, } const mutations = { @@ -378,6 +380,25 @@ const mutations = { markCalendarAsNotLoading(state, { calendar }) { state.calendarsById[calendar.id].loading = false }, + + showEditCalendarModal(state, { calendarId }) { + state.editCalendarModal = { + calendarId, + } + }, + + hideEditCalendarModal(state) { + state.editCalendarModal = undefined + }, + + setCalendarDeleteCountdown(state, { calendar, countdown }) { + Vue.set(state.calendarsById[calendar.id], 'countdown', countdown) + }, + + setCalendarDeleteHandles(state, { calendar, deleteTimeout, deleteInterval }) { + Vue.set(state.calendarsById[calendar.id], 'deleteTimeout', deleteTimeout) + Vue.set(state.calendarsById[calendar.id], 'deleteInterval', deleteInterval) + }, } const getters = { @@ -555,6 +576,8 @@ const getters = { return true }) }, + + editCalendarModal: (state) => state.editCalendarModal, } const actions = { @@ -719,6 +742,44 @@ const actions = { context.commit('removeDeletedCalendar', { calendar }) }, + deleteCalendarAfterTimeout(context, { calendar, countdown = 7 }) { + context.commit('setCalendarDeleteCountdown', { calendar, countdown }) + const deleteInterval = setInterval(() => { + countdown-- + + if (countdown < 0) { + countdown = 0 + } + + context.commit('setCalendarDeleteCountdown', { calendar, countdown }) + }, 1000) + const deleteTimeout = setTimeout(async () => { + try { + await context.dispatch('deleteCalendar', { calendar }) + } catch (error) { + showError(t('calendar', 'An error occurred, unable to delete the calendar.')) + console.error(error) + } finally { + clearInterval(deleteInterval) + } + }, 7000) + context.commit('setCalendarDeleteHandles', { + calendar, + deleteInterval, + deleteTimeout, + }) + }, + + cancelCalendarDeletion(context, { calendar }) { + if (calendar.deleteInterval) clearInterval(calendar.deleteInterval) + if (calendar.deleteTimeout) clearTimeout(calendar.deleteTimeout) + context.commit('setCalendarDeleteHandles', { + calendar, + deleteInterval: undefined, + deleteTimeout: undefined, + }) + }, + async restoreCalendar({ commit, state }, { calendar }) { await state.trashBin.restore(calendar.url) diff --git a/src/views/Calendar.vue b/src/views/Calendar.vue index 1805cde7f5..b7ff073445 100644 --- a/src/views/Calendar.vue +++ b/src/views/Calendar.vue @@ -33,6 +33,7 @@ :loading-calendars="loadingCalendars" /> + @@ -73,6 +74,7 @@ import CalendarListNew from '../components/AppNavigation/CalendarList/CalendarLi import EmbedTopNavigation from '../components/AppNavigation/EmbedTopNavigation.vue' import EmptyCalendar from '../components/EmptyCalendar.vue' import CalendarGrid from '../components/CalendarGrid.vue' +import EditCalendarModal from '../components/AppNavigation/EditCalendarModal.vue' // Import CalDAV related methods import { @@ -118,6 +120,7 @@ export default { AppNavigationSpacer, CalendarListNew, Trashbin, + EditCalendarModal, }, data() { return {
+ {{ $t('calendar', 'Share link') }} +
+ {{ sharee.displayName }} +