diff --git a/src/apps/dashboard/routes/users/profile.tsx b/src/apps/dashboard/routes/users/profile.tsx index 9ba89001a74..92ef21cf5d4 100644 --- a/src/apps/dashboard/routes/users/profile.tsx +++ b/src/apps/dashboard/routes/users/profile.tsx @@ -9,7 +9,7 @@ import LibraryMenu from '../../../../scripts/libraryMenu'; import ButtonElement from '../../../../elements/ButtonElement'; import CheckBoxElement from '../../../../elements/CheckBoxElement'; import InputElement from '../../../../elements/InputElement'; -import LinkEditUserPreferences from '../../../../components/dashboard/users/LinkEditUserPreferences'; +import LinkButton from '../../../../elements/emby-button/LinkButton'; import SectionTitleContainer from '../../../../elements/SectionTitleContainer'; import SectionTabs from '../../../../components/dashboard/users/SectionTabs'; import loading from '../../../../components/loading/loading'; @@ -38,7 +38,7 @@ function onSaveComplete() { const UserEdit = () => { const [ searchParams ] = useSearchParams(); const userId = searchParams.get('userId'); - const [ userName, setUserName ] = useState(''); + const [ userDto, setUserDto ] = useState(); const [ deleteFoldersAccess, setDeleteFoldersAccess ] = useState([]); const [ authProviders, setAuthProviders ] = useState([]); const [ passwordResetProviders, setPasswordResetProviders ] = useState([]); @@ -147,10 +147,8 @@ const UserEdit = () => { txtUserName.disabled = false; txtUserName.removeAttribute('disabled'); - const lnkEditUserPreferences = page.querySelector('.lnkEditUserPreferences') as HTMLDivElement; - lnkEditUserPreferences.setAttribute('href', 'mypreferencesmenu.html?userId=' + user.Id); LibraryMenu.setTitle(user.Name); - setUserName(user.Name || ''); + setUserDto(user); (page.querySelector('#txtUserName') as HTMLInputElement).value = user.Name || ''; (page.querySelector('.chkIsAdmin') as HTMLInputElement).checked = !!user.Policy?.IsAdministrator; (page.querySelector('.chkDisabled') as HTMLInputElement).checked = !!user.Policy?.IsDisabled; @@ -292,7 +290,7 @@ const UserEdit = () => {
@@ -302,10 +300,9 @@ const UserEdit = () => { className='lnkEditUserPreferencesContainer' style={{ paddingBottom: '1em' }} > - + + {globalize.translate('ButtonEditOtherUserPreferences')} +
diff --git a/src/components/dashboard/users/LinkEditUserPreferences.tsx b/src/components/dashboard/users/LinkEditUserPreferences.tsx deleted file mode 100644 index bc44f458f3e..00000000000 --- a/src/components/dashboard/users/LinkEditUserPreferences.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React, { FunctionComponent } from 'react'; -import globalize from 'lib/globalize'; - -type IProps = { - title?: string; - className?: string; -}; - -const createLinkElement = ({ className, title }: IProps) => ({ - __html: ` - ${title} - ` -}); - -const LinkEditUserPreferences: FunctionComponent = ({ className, title }: IProps) => { - return ( -
- ); -}; - -export default LinkEditUserPreferences; diff --git a/src/components/dashboard/users/SectionTabs.tsx b/src/components/dashboard/users/SectionTabs.tsx index 26076390ae1..905e477b988 100644 --- a/src/components/dashboard/users/SectionTabs.tsx +++ b/src/components/dashboard/users/SectionTabs.tsx @@ -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: ` - ${globalize.translate('Profile')} - - - ${globalize.translate('TabAccess')} - - - ${globalize.translate('TabParentalControl')} - - - ${globalize.translate('HeaderPassword')} - ` -}); +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 = ({ 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 (
+ className='localnav'> + + {globalize.translate('Profile')} + + + {globalize.translate('TabAccess')} + + + {globalize.translate('TabParentalControl')} + + + {globalize.translate('HeaderPassword')} + +
); }; diff --git a/src/components/dashboard/users/UserCardBox.tsx b/src/components/dashboard/users/UserCardBox.tsx index 3f0897672ae..22814d4435d 100644 --- a/src/components/dashboard/users/UserCardBox.tsx +++ b/src/components/dashboard/users/UserCardBox.tsx @@ -4,19 +4,9 @@ import { formatDistanceToNow } from 'date-fns'; import { getLocaleWithSuffix } from '../../../utils/dateFnsLocale'; import globalize from '../../../lib/globalize'; import IconButtonElement from '../../../elements/IconButtonElement'; -import escapeHTML from 'escape-html'; +import LinkButton from '../../../elements/emby-button/LinkButton'; import { getDefaultBackgroundClass } from '../../cardbuilder/cardBuilderUtils'; -const createLinkElement = ({ user, renderImgUrl }: { user: UserDto, renderImgUrl: string }) => ({ - __html: ` - ${renderImgUrl} - ` -}); - type IProps = { user?: UserDto; }; @@ -55,22 +45,21 @@ const UserCardBox: FunctionComponent = ({ user = {} }: IProps) => { const lastSeen = getLastSeenText(user.LastActivityDate); const renderImgUrl = imgUrl ? - `
` : - `
- -
`; +
: +
+ +
; return (
-
+ + {renderImgUrl} +
= ({ user = {} }: IProps) => { />
- {escapeHTML(user.Name)} + {user.Name}
{lastSeen != '' ? lastSeen : ''} diff --git a/src/components/search/SearchSuggestions.tsx b/src/components/search/SearchSuggestions.tsx index fb9c8ac5d9d..809ad294448 100644 --- a/src/components/search/SearchSuggestions.tsx +++ b/src/components/search/SearchSuggestions.tsx @@ -1,17 +1,19 @@ -import React, { type FC } from 'react'; -import { useSearchSuggestions } from 'hooks/searchHook'; +import React, { FunctionComponent } from 'react'; + import Loading from 'components/loading/LoadingComponent'; import { appRouter } from '../router/appRouter'; -import globalize from '../../lib/globalize'; -import LinkButton from 'elements/emby-button/LinkButton'; +import { useSearchSuggestions } from 'hooks/searchHook/useSearchSuggestions'; +import globalize from 'lib/globalize'; +import LinkButton from '../../elements/emby-button/LinkButton'; + import '../../elements/emby-button/emby-button'; -interface SearchSuggestionsProps { - parentId?: string; -} +type SearchSuggestionsProps = { + parentId?: string | null; +}; -const SearchSuggestions: FC = ({ parentId }) => { - const { isLoading, data: suggestions } = useSearchSuggestions(parentId); +const SearchSuggestions: FunctionComponent = ({ parentId }) => { + const { isLoading, data: suggestions } = useSearchSuggestions(parentId || undefined); if (isLoading) return ; @@ -27,15 +29,12 @@ const SearchSuggestions: FC = ({ parentId }) => {
- {suggestions?.map((item) => ( -
+ {suggestions?.map(item => ( +
{item.Name} diff --git a/src/elements/SectionTitleContainer.tsx b/src/elements/SectionTitleContainer.tsx index 88aa01c26c0..933dd1e8f0f 100644 --- a/src/elements/SectionTitleContainer.tsx +++ b/src/elements/SectionTitleContainer.tsx @@ -1,6 +1,7 @@ import React, { FunctionComponent } from 'react'; import IconButtonElement from './IconButtonElement'; -import SectionTitleLinkElement from './SectionTitleLinkElement'; +import LinkButton from './emby-button/LinkButton'; +import globalize from 'lib/globalize'; type IProps = { SectionClassName?: string; @@ -28,11 +29,13 @@ const SectionTitleContainer: FunctionComponent = ({ SectionClassName, ti icon={btnIcon} />} - {isLinkVisible && } + target='_blank' + rel='noopener noreferrer' + href={url}> + {globalize.translate('Help')} + }
); diff --git a/src/elements/SectionTitleLinkElement.tsx b/src/elements/SectionTitleLinkElement.tsx deleted file mode 100644 index 8fd661fc9ca..00000000000 --- a/src/elements/SectionTitleLinkElement.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { FunctionComponent } from 'react'; - -import globalize from 'lib/globalize'; - -const createLinkElement = ({ className, title, href }: { className?: string, title?: string, href?: string }) => ({ - __html: ` - ${title} - ` -}); - -type IProps = { - title?: string; - className?: string; - url?: string -}; - -const SectionTitleLinkElement: FunctionComponent = ({ className, title, url }: IProps) => { - return ( -
- ); -}; - -export default SectionTitleLinkElement; diff --git a/src/elements/emby-button/LinkButton.tsx b/src/elements/emby-button/LinkButton.tsx index 2bce76927c4..77bf39a3f0a 100644 --- a/src/elements/emby-button/LinkButton.tsx +++ b/src/elements/emby-button/LinkButton.tsx @@ -20,6 +20,7 @@ const LinkButton: React.FC = ({ isAutoHideEnabled, href, target, + onClick, children, ...rest }) => { @@ -41,7 +42,8 @@ const LinkButton: React.FC = ({ } else { e.preventDefault(); } - }, [ href, target ]); + onClick?.(e); + }, [ href, target, onClick ]); if (isAutoHideEnabled === true && !appHost.supports('externallinks')) { return null;