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 React, { FunctionComponent } from 'react';
|
||||||
|
|
||||||
import globalize from 'lib/globalize';
|
import globalize from 'lib/globalize';
|
||||||
|
import { navigate } from '../../../utils/dashboard';
|
||||||
|
import LinkButton from '../../../elements/emby-button/LinkButton';
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createLinkElement = (activeTab: string) => ({
|
function useNavigate(url: string): () => void {
|
||||||
__html: `<a href="#"
|
return React.useCallback(() => {
|
||||||
is="emby-linkbutton"
|
navigate(url, true).catch(err => {
|
||||||
data-role="button"
|
console.warn('Error navigating to dashboard url', err);
|
||||||
class="${activeTab === 'useredit' ? 'ui-btn-active' : ''}"
|
});
|
||||||
onclick="Dashboard.navigate('/dashboard/users/profile', true);">
|
}, [url]);
|
||||||
${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>`
|
|
||||||
});
|
|
||||||
|
|
||||||
const SectionTabs: FunctionComponent<IProps> = ({ activeTab }: IProps) => {
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
data-role='controlgroup'
|
data-role='controlgroup'
|
||||||
data-type='horizontal'
|
data-type='horizontal'
|
||||||
className='localnav'
|
className='localnav'>
|
||||||
dangerouslySetInnerHTML={createLinkElement(activeTab)}
|
<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