Skip to content

Commit

Permalink
[FIX] Directory default tab (#17283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Apr 14, 2020
1 parent 6b303c4 commit d00a452
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
22 changes: 11 additions & 11 deletions app/ui/client/views/app/components/Directory/DirectoryTable.js
Expand Up @@ -27,23 +27,23 @@ export function Markdown({ children, ...props }) {

const LoadingRow = ({ cols }) => <Table.Row>
<Table.Cell>
<Flex.Container>
<Box>
<Flex.Item>
<Skeleton variant='rect' height={40} width={40} />
</Flex.Item>
<Box mi='x8' grow={1}>
<Skeleton width='100%' />
<Skeleton width='100%' />
</Box>
<Box display='flex'>
<Flex.Item>
<Skeleton variant='rect' height={40} width={40} />
</Flex.Item>
<Box mi='x8' flexGrow={1}>
<Skeleton width='100%' />
<Skeleton width='100%' />
</Box>
</Flex.Container>
</Box>
</Table.Cell>
{ Array.from({ length: cols - 1 }, (_, i) => <Table.Cell key={i}>
<Skeleton width='100%' />
</Table.Cell>)}
</Table.Row>;

const style = { minHeight: '40px' };

export function DirectoryTable({
data = {},
renderRow,
Expand Down Expand Up @@ -79,7 +79,7 @@ export function DirectoryTable({
return <>
<Flex.Container direction='column'>
<Box>
<Box mb='x16' display='flex' flexDirection='column'>
<Box mb='x16' display='flex' flexDirection='column' style={style}>
<TextInput placeholder={searchPlaceholder} addon={<Icon name='magnifier' size='x20'/>} onChange={handleChange} value={text} />
</Box>
{channels && !channels.length
Expand Down
8 changes: 5 additions & 3 deletions app/ui/client/views/app/components/Directory/index.js
Expand Up @@ -13,6 +13,8 @@ const avatarBase = { baseUrl: '/avatar/' };
export function DirectoryPage() {
const t = useTranslation();

const defaultTab = useSetting('Accounts_Directory_DefaultView');

const federationEnabled = useSetting('FEDERATION_Enabled');

const tab = useRouteParameter('tab');
Expand All @@ -22,13 +24,13 @@ export function DirectoryPage() {

useEffect(() => {
if (!tab || (tab === 'external' && !federationEnabled)) {
return goToDirectory.replacingState({ tab: 'channels' });
return goToDirectory.replacingState({ tab: defaultTab });
}
}, [tab, federationEnabled]);
}, [tab, federationEnabled, defaultTab]);

return <Avatar.Context.Provider value={avatarBase}><Page>
<Page.Header title={t('Directory')} />
<Tabs>
<Tabs flexShrink={0} >
<Tabs.Item selected={tab === 'channels'} onClick={handleTabClick('channels')}>{t('Channels')}</Tabs.Item>
<Tabs.Item selected={tab === 'users'} onClick={handleTabClick('users')}>{t('Users')}</Tabs.Item>
{ federationEnabled && <Tabs.Item selected={tab === 'external'} onClick={handleTabClick('external')}>{t('External_Users')}</Tabs.Item> }
Expand Down

0 comments on commit d00a452

Please sign in to comment.