Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Directory default tab #17283

Merged
merged 3 commits into from
Apr 14, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/ui/client/views/app/components/Directory/DirectoryTable.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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