Skip to content

Commit 8dbf049

Browse files
committed
fix(capabilities): conditionally show links to calendar
Signed-off-by: Maksim Sukharev <[email protected]>
1 parent 2053724 commit 8dbf049

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

src/components/CalendarEventsDialog.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import type { Conversation, Participant } from '../types/index.ts'
88
99
import { showSuccess } from '@nextcloud/dialogs'
10+
import { loadState } from '@nextcloud/initial-state'
1011
import { n, t } from '@nextcloud/l10n'
1112
import moment from '@nextcloud/moment'
1213
import { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'
@@ -27,7 +28,6 @@ import IconAccountSearch from 'vue-material-design-icons/AccountSearch.vue'
2728
import IconCalendarBlank from 'vue-material-design-icons/CalendarBlank.vue'
2829
import IconCheck from 'vue-material-design-icons/Check.vue'
2930
import IconPlus from 'vue-material-design-icons/Plus.vue'
30-
import IconReload from 'vue-material-design-icons/Reload.vue'
3131
import SelectableParticipant from './BreakoutRoomsEditor/SelectableParticipant.vue'
3232
import CalendarEventSmall from './UIShared/CalendarEventSmall.vue'
3333
import ContactSelectionBubble from './UIShared/ContactSelectionBubble.vue'
@@ -40,6 +40,8 @@ import { useGroupwareStore } from '../stores/groupware.ts'
4040
import { convertToUnix } from '../utils/formattedTime.ts'
4141
import { getDisplayNameWithFallback } from '../utils/getDisplayName.ts'
4242
43+
const isCalendarEnabled = loadState('spreed', 'calendar_enabled', true)
44+
4345
const props = defineProps<{
4446
token: string
4547
container?: string
@@ -72,8 +74,9 @@ const upcomingEvents = computed(() => {
7274
? (event.start <= now) ? t('spreed', 'Now') : moment(event.start * 1000).calendar()
7375
: ''
7476
const color = calendars.value[event.calendarUri]?.color ?? usernameToColor(event.calendarUri).color
77+
const href = isCalendarEnabled ? (event.calendarAppUrl ?? undefined) : undefined
7578
76-
return { ...event, start, color, href: event.calendarAppUrl ?? undefined }
79+
return { ...event, start, color, href }
7780
})
7881
})
7982

src/components/ConversationSettings/BasicInfo.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<template>
77
<Fragment>
88
<!-- eslint-disable-next-line vue/no-v-html -->
9-
<p v-if="canFullModerate && isEventConversation" class="app-settings-section__hint" v-html="calendarHint" />
9+
<p v-if="isCalendarEnabled && canFullModerate && isEventConversation" class="app-settings-section__hint" v-html="calendarHint" />
1010
<h4 class="app-settings-section__subtitle">
1111
{{ t('spreed', 'Name') }}
1212
</h4>
@@ -47,6 +47,7 @@
4747

4848
<script>
4949
import { showError } from '@nextcloud/dialogs'
50+
import { loadState } from '@nextcloud/initial-state'
5051
import { t } from '@nextcloud/l10n'
5152
import { generateUrl } from '@nextcloud/router'
5253
import { Fragment } from 'vue-frag'
@@ -55,6 +56,7 @@ import ConversationAvatarEditor from './ConversationAvatarEditor.vue'
5556
import { CONVERSATION } from '../../constants.ts'
5657
import { getTalkConfig, hasTalkFeature } from '../../services/CapabilitiesManager.ts'
5758
59+
const isCalendarEnabled = loadState('spreed', 'calendar_enabled', true)
5860
const supportsAvatar = hasTalkFeature('local', 'avatar')
5961
const maxDescriptionLength = getTalkConfig('local', 'conversations', 'description-length') || 500
6062
@@ -81,6 +83,7 @@ export default {
8183
8284
setup() {
8385
return {
86+
isCalendarEnabled,
8487
supportsAvatar,
8588
CONVERSATION,
8689
maxDescriptionLength,

src/components/Dashboard/EventCard.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
import type { DashboardEventRoom } from '../../types/index.ts'
99
10+
import { loadState } from '@nextcloud/initial-state'
1011
import { getCanonicalLocale, getLanguage, n, t } from '@nextcloud/l10n'
1112
import { imagePath } from '@nextcloud/router'
1213
import usernameToColor from '@nextcloud/vue/functions/usernameToColor'
@@ -25,6 +26,8 @@ import { useStore } from '../../composables/useStore.js'
2526
import { CONVERSATION } from '../../constants.ts'
2627
import { formattedTime, ONE_DAY_IN_MS } from '../../utils/formattedTime.ts'
2728
29+
const isCalendarEnabled = loadState('spreed', 'calendar_enabled', true)
30+
2831
const props = defineProps<{
2932
eventRoom: DashboardEventRoom
3033
}>()
@@ -213,7 +216,8 @@ function handleJoin({ call = false } = {}) {
213216
</template>
214217
{{ t('spreed', 'View conversation') }}
215218
</NcButton>
216-
<NcButton type="tertiary"
219+
<NcButton v-if="isCalendarEnabled"
220+
type="tertiary"
217221
:href="props.eventRoom.eventLink"
218222
target="_blank"
219223
:title="t('spreed', 'View event on Calendar')"

src/components/Dashboard/TalkDashboard.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const canModerateSipDialOut = hasTalkFeature('local', 'sip-support-dialout')
4141
&& getTalkConfig('local', 'call', 'sip-dialout-enabled')
4242
&& getTalkConfig('local', 'call', 'can-enable-sip')
4343
const canStartConversations = getTalkConfig('local', 'conversations', 'can-create')
44+
const isCalendarEnabled = loadState('spreed', 'calendar_enabled', true)
4445
const isDirectionRTL = isRTL()
4546
4647
const store = useStore()
@@ -267,7 +268,8 @@ function scrollEventCards({ direction }: { direction: 'backward' | 'forward' })
267268
<span class="secondary_text">
268269
{{ t('spreed', 'Schedule a meeting with a colleague from your calendar') }}
269270
</span>
270-
<NcButton class="talk-dashboard__calendar-button"
271+
<NcButton v-if="isCalendarEnabled"
272+
class="talk-dashboard__calendar-button"
271273
type="secondary"
272274
:href="generateUrl('apps/calendar')"
273275
target="_blank">

src/components/RightSidebar/RightSidebarContent.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
UserProfileData,
1111
} from '../../types/index.ts'
1212
13+
import { loadState } from '@nextcloud/initial-state'
1314
import { t } from '@nextcloud/l10n'
1415
import moment from '@nextcloud/moment'
1516
import { generateUrl } from '@nextcloud/router'
@@ -38,10 +39,12 @@ type MutualEvent = {
3839
uri: DashboardEvent['eventLink']
3940
name: DashboardEvent['eventName']
4041
start: string
41-
href: DashboardEvent['eventLink']
42+
href?: DashboardEvent['eventLink']
4243
color: string
4344
}
4445
46+
const isCalendarEnabled = loadState('spreed', 'calendar_enabled', true)
47+
4548
const props = defineProps<{
4649
isUser: boolean
4750
state: 'default' | 'search'
@@ -135,7 +138,7 @@ const mutualEventsInformation = computed<MutualEvent[]>(() => {
135138
uri: event.eventLink,
136139
name: event.eventName,
137140
start,
138-
href: event.eventLink,
141+
href: isCalendarEnabled ? event.eventLink : undefined,
139142
color: event.calendars[0]?.calendarColor ?? 'var(--color-primary)',
140143
}
141144
})

src/components/UIShared/CalendarEventSmall.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const props = defineProps<{
2121
<a class="calendar-event__item"
2222
:class="{ 'calendar-event__item--thumb': !href }"
2323
:href="href"
24-
:title="t('spreed', 'Open Calendar')"
24+
:title="href ? t('spreed', 'Open Calendar') : name ?? undefined"
2525
:tabindex="0"
2626
target="_blank">
2727
<span class="calendar-event__badge" :style="{ backgroundColor: color }" />

0 commit comments

Comments
 (0)