mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
use LinkButton in dashboard/users/SectionTabs
This commit is contained in:
parent
32f835c865
commit
0d90ac39f1
1 changed files with 44 additions and 33 deletions
|
@ -1,49 +1,60 @@
|
|||
import React, { FunctionComponent } from 'react';
|
||||
|
||||
import globalize from 'lib/globalize';
|
||||
import { navigate } from '../../../utils/dashboard';
|
||||
import LinkButton from '../../../elements/emby-button/LinkButton';
|
||||
|
||||
type IProps = {
|
||||
activeTab: string;
|
||||
};
|
||||
|
||||
const createLinkElement = (activeTab: string) => ({
|
||||
__html: `<a href="#"
|
||||
is="emby-linkbutton"
|
||||
data-role="button"
|
||||
class="${activeTab === 'useredit' ? 'ui-btn-active' : ''}"
|
||||
onclick="Dashboard.navigate('/dashboard/users/profile', true);">
|
||||
${globalize.translate('Profile')}
|
||||
</a>
|
||||
<a href="#"
|
||||
is="emby-linkbutton"
|
||||
data-role="button"
|
||||
class="${activeTab === 'userlibraryaccess' ? 'ui-btn-active' : ''}"
|
||||
onclick="Dashboard.navigate('/dashboard/users/access', true);">
|
||||
${globalize.translate('TabAccess')}
|
||||
</a>
|
||||
<a href="#"
|
||||
is="emby-linkbutton"
|
||||
data-role="button"
|
||||
class="${activeTab === 'userparentalcontrol' ? 'ui-btn-active' : ''}"
|
||||
onclick="Dashboard.navigate('/dashboard/users/parentalcontrol', true);">
|
||||
${globalize.translate('TabParentalControl')}
|
||||
</a>
|
||||
<a href="#"
|
||||
is="emby-linkbutton"
|
||||
data-role="button"
|
||||
class="${activeTab === 'userpassword' ? 'ui-btn-active' : ''}"
|
||||
onclick="Dashboard.navigate('/dashboard/users/password', true);">
|
||||
${globalize.translate('HeaderPassword')}
|
||||
</a>`
|
||||
});
|
||||
function useNavigate(url: string): () => void {
|
||||
return React.useCallback(() => {
|
||||
navigate(url, true).catch(err => {
|
||||
console.warn('Error navigating to dashboard url', err);
|
||||
});
|
||||
}, [url]);
|
||||
}
|
||||
|
||||
const SectionTabs: FunctionComponent<IProps> = ({ activeTab }: IProps) => {
|
||||
const onClickProfile = useNavigate('/dashboard/users/profile');
|
||||
const onClickAccess = useNavigate('/dashboard/users/access');
|
||||
const onClickParentalControl = useNavigate('/dashboard/users/parentalcontrol');
|
||||
const clickPassword = useNavigate('/dashboard/users/password');
|
||||
return (
|
||||
<div
|
||||
data-role='controlgroup'
|
||||
data-type='horizontal'
|
||||
className='localnav'
|
||||
dangerouslySetInnerHTML={createLinkElement(activeTab)}
|
||||
/>
|
||||
className='localnav'>
|
||||
<LinkButton
|
||||
href='#'
|
||||
data-role='button'
|
||||
className={activeTab === 'useredit' ? 'ui-btn-active' : ''}
|
||||
onClick={onClickProfile}>
|
||||
{globalize.translate('Profile')}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
href='#'
|
||||
data-role='button'
|
||||
className={activeTab === 'userlibraryaccess' ? 'ui-btn-active' : ''}
|
||||
onClick={onClickAccess}>
|
||||
{globalize.translate('TabAccess')}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
href='#'
|
||||
data-role='button'
|
||||
className={activeTab === 'userparentalcontrol' ? 'ui-btn-active' : ''}
|
||||
onClick={onClickParentalControl}>
|
||||
{globalize.translate('TabParentalControl')}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
href='#'
|
||||
data-role='button'
|
||||
className={activeTab === 'userpassword' ? 'ui-btn-active' : ''}
|
||||
onClick={clickPassword}>
|
||||
{globalize.translate('HeaderPassword')}
|
||||
</LinkButton>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue