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
5 changes: 5 additions & 0 deletions .changeset/eleven-laws-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an issue where the outlook calendar items list is not rendering properly
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, States, StatesIcon, StatesTitle, StatesSubtitle, ButtonGroup, Button } from '@rocket.chat/fuselage';
import { Box, States, StatesIcon, StatesTitle, StatesSubtitle, ButtonGroup, Button, Throbber } from '@rocket.chat/fuselage';
import { useResizeObserver } from '@rocket.chat/fuselage-hooks';
import { useTranslation, useSetting } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
Expand All @@ -12,7 +12,6 @@ import {
ContextualbarClose,
ContextualbarContent,
ContextualbarFooter,
ContextualbarSkeleton,
} from '../../../components/Contextualbar';
import { VirtualizedScrollbars } from '../../../components/CustomScrollbars';
import { getErrorMessage } from '../../../lib/errorHandling';
Expand Down Expand Up @@ -40,10 +39,6 @@ const OutlookEventsList = ({ onClose, changeRoute }: OutlookEventsListProps): Re
debounceDelay: 200,
});

if (calendarListResult.isLoading) {
return <ContextualbarSkeleton />;
}

const calendarEvents = calendarListResult.data;
const total = calendarEvents?.length || 0;

Expand All @@ -54,87 +49,57 @@ const OutlookEventsList = ({ onClose, changeRoute }: OutlookEventsListProps): Re
<ContextualbarTitle>{t('Outlook_calendar')}</ContextualbarTitle>
<ContextualbarClose onClick={onClose} />
</ContextualbarHeader>

{hasOutlookMethods && !authEnabled && total === 0 && (
<>
<ContextualbarContent paddingInline={0} ref={ref} color='default'>
<Box display='flex' flexDirection='column' justifyContent='center' height='100%'>
<States>
<StatesIcon name='user' />
<StatesTitle>{t('Log_in_to_sync')}</StatesTitle>
</States>
</Box>
</ContextualbarContent>
<ContextualbarFooter>
<Box mbs={8}>
<ButtonGroup stretch>
<Button primary loading={syncOutlookCalendar.isPending} onClick={() => syncOutlookCalendar.mutate()}>
{t('Login')}
</Button>
</ButtonGroup>
</Box>
</ContextualbarFooter>
</>
)}

{(authEnabled || !hasOutlookMethods) && (
<>
<ContextualbarContent paddingInline={0} ref={ref} color='default'>
{(total === 0 || calendarListResult.isError) && (
<Box display='flex' flexDirection='column' justifyContent='center' height='100%'>
{calendarListResult.isError && (
<States>
<StatesIcon name='circle-exclamation' variation='danger' />
<StatesTitle>{t('Something_went_wrong')}</StatesTitle>
<StatesSubtitle>{getErrorMessage(calendarListResult.error)}</StatesSubtitle>
</States>
)}
{!calendarListResult.isError && total === 0 && (
<States>
<StatesIcon name='calendar' />
<StatesTitle>{t('No_history')}</StatesTitle>
</States>
)}
</Box>
)}
{calendarListResult.isSuccess && calendarListResult.data.length > 0 && (
<Box flexGrow={1} flexShrink={1} overflow='hidden' display='flex'>
<VirtualizedScrollbars>
<Virtuoso
style={{
height: blockSize,
width: inlineSize,
}}
totalCount={total}
overscan={25}
data={calendarEvents}
itemContent={(_index, calendarData): ReactElement => <OutlookEventItem {...calendarData} />}
/>
</VirtualizedScrollbars>
</Box>
)}
</ContextualbarContent>
<ContextualbarFooter>
<ContextualbarContent paddingInline={0} color='default'>
<Box flexGrow={1} flexShrink={1} overflow='hidden' display='flex' justifyContent='center' ref={ref}>
{calendarListResult.isPending && <Throbber size='x12' />}
{calendarListResult.isError && (
<States>
<StatesIcon name='circle-exclamation' variation='danger' />
<StatesTitle>{t('Something_went_wrong')}</StatesTitle>
<StatesSubtitle>{getErrorMessage(calendarListResult.error)}</StatesSubtitle>
</States>
)}
{!calendarListResult.isPending && total === 0 && (
<States>
<StatesIcon name='calendar' />
<StatesTitle>{t('No_history')}</StatesTitle>
</States>
)}
{calendarListResult.isSuccess && calendarListResult.data.length > 0 && (
<VirtualizedScrollbars>
<Virtuoso
style={{
height: blockSize,
width: inlineSize,
}}
totalCount={total}
overscan={25}
data={calendarEvents}
itemContent={(_index, calendarData): ReactElement => <OutlookEventItem {...calendarData} />}
/>
</VirtualizedScrollbars>
)}
</Box>
</ContextualbarContent>
<ContextualbarFooter>
<ButtonGroup stretch>
{authEnabled && <Button onClick={changeRoute}>{t('Calendar_settings')}</Button>}
{outlookUrl && (
<Button icon='new-window' onClick={() => window.open(outlookUrl, '_blank')}>
{t('Open_Outlook')}
</Button>
)}
</ButtonGroup>
{hasOutlookMethods && (
<Box mbs={8}>
<ButtonGroup stretch>
{authEnabled && <Button onClick={changeRoute}>{t('Calendar_settings')}</Button>}
{outlookUrl && (
<Button icon='new-window' onClick={() => window.open(outlookUrl, '_blank')}>
{t('Open_Outlook')}
</Button>
)}
<Button primary loading={syncOutlookCalendar.isPending} onClick={() => syncOutlookCalendar.mutate()}>
{authEnabled ? t('Sync') : t('Log_in_to_sync')}
</Button>
</ButtonGroup>
{hasOutlookMethods && (
<Box mbs={8}>
<ButtonGroup stretch>
<Button primary loading={syncOutlookCalendar.isPending} onClick={() => syncOutlookCalendar.mutate()}>
{t('Sync')}
</Button>
</ButtonGroup>
</Box>
)}
</ContextualbarFooter>
</>
)}
</Box>
)}
</ContextualbarFooter>
</>
);
};
Expand Down
Loading