diff --git a/src/components/Page.tsx b/src/components/Page.tsx index be1253740..c4677fee4 100644 --- a/src/components/Page.tsx +++ b/src/components/Page.tsx @@ -6,6 +6,7 @@ type PageProps = { id: string, // id is required for libraryMenu title?: string, isBackButtonEnabled?: boolean, + isMenuButtonEnabled?: boolean, isNowPlayingBarEnabled?: boolean, isThemeMediaSupported?: boolean }; @@ -20,6 +21,7 @@ const Page: FunctionComponent> = ({ className = '', title, isBackButtonEnabled = true, + isMenuButtonEnabled = false, isNowPlayingBarEnabled = true, isThemeMediaSupported = false }) => { @@ -60,6 +62,7 @@ const Page: FunctionComponent> = ({ className={`page ${className}`} data-title={title} data-backbutton={`${isBackButtonEnabled}`} + data-menubutton={`${isMenuButtonEnabled}`} > {children} diff --git a/src/components/dashboard/users/UserPasswordForm.tsx b/src/components/dashboard/users/UserPasswordForm.tsx index bc2e3d9fa..d7467fd1b 100644 --- a/src/components/dashboard/users/UserPasswordForm.tsx +++ b/src/components/dashboard/users/UserPasswordForm.tsx @@ -40,11 +40,11 @@ const UserPasswordForm: FunctionComponent = ({userId}: IProps) => { let showLocalAccessSection = false; if (user.HasConfiguredPassword) { - (page.querySelector('.btnResetPassword') as HTMLDivElement).classList.remove('hide'); + (page.querySelector('#btnResetPassword') as HTMLDivElement).classList.remove('hide'); (page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.remove('hide'); showLocalAccessSection = true; } else { - (page.querySelector('.btnResetPassword') as HTMLDivElement).classList.add('hide'); + (page.querySelector('#btnResetPassword') as HTMLDivElement).classList.add('hide'); (page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.add('hide'); } @@ -65,11 +65,11 @@ const UserPasswordForm: FunctionComponent = ({userId}: IProps) => { if (user.HasConfiguredEasyPassword) { txtEasyPassword.placeholder = '******'; - (page.querySelector('.btnResetEasyPassword') as HTMLDivElement).classList.remove('hide'); + (page.querySelector('#btnResetEasyPassword') as HTMLDivElement).classList.remove('hide'); } else { txtEasyPassword.removeAttribute('placeholder'); txtEasyPassword.placeholder = ''; - (page.querySelector('.btnResetEasyPassword') as HTMLDivElement).classList.add('hide'); + (page.querySelector('#btnResetEasyPassword') as HTMLDivElement).classList.add('hide'); } const chkEnableLocalEasyPassword = page.querySelector('.chkEnableLocalEasyPassword') as HTMLInputElement; diff --git a/src/controllers/user/profile/index.html b/src/controllers/user/profile/index.html deleted file mode 100644 index c8fb3ae19..000000000 --- a/src/controllers/user/profile/index.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/src/routes/UserPasswordPage.tsx b/src/routes/UserPasswordPage.tsx index e97f3f3f3..83298b80d 100644 --- a/src/routes/UserPasswordPage.tsx +++ b/src/routes/UserPasswordPage.tsx @@ -4,17 +4,20 @@ import UserPasswordForm from '../components/dashboard/users/UserPasswordForm'; import { getParameterByName } from '../utils/url'; import SectionTitleContainer from '../components/dashboard/elements/SectionTitleContainer'; import Page from '../components/Page'; +import loading from '../components/loading/loading'; const UserPasswordPage: FunctionComponent = () => { const userId = getParameterByName('userId'); const [ userName, setUserName ] = useState(''); const loadUser = useCallback(() => { + loading.show(); window.ApiClient.getUser(userId).then(function (user) { if (!user.Name) { throw new Error('Unexpected null user.Name'); } setUserName(user.Name); + loading.hide(); }); }, [userId]); useEffect(() => { diff --git a/src/components/pages/UserProfilePage.tsx b/src/routes/UserProfilePage.tsx similarity index 86% rename from src/components/pages/UserProfilePage.tsx rename to src/routes/UserProfilePage.tsx index 8862d499b..cebcb460c 100644 --- a/src/components/pages/UserProfilePage.tsx +++ b/src/routes/UserProfilePage.tsx @@ -1,21 +1,20 @@ import { ImageType, UserDto } from '@thornbill/jellyfin-sdk/dist/generated-client'; import React, { FunctionComponent, useEffect, useState, useRef, useCallback } from 'react'; -import Dashboard from '../../utils/dashboard'; -import globalize from '../../scripts/globalize'; -import LibraryMenu from '../../scripts/libraryMenu'; -import { appHost } from '../apphost'; -import confirm from '../confirm/confirm'; -import ButtonElement from '../dashboard/elements/ButtonElement'; -import UserPasswordForm from '../dashboard/users/UserPasswordForm'; -import loading from '../loading/loading'; -import toast from '../toast/toast'; +import Dashboard from '../utils/dashboard'; +import globalize from '../scripts/globalize'; +import LibraryMenu from '../scripts/libraryMenu'; +import { appHost } from '../components/apphost'; +import confirm from '../components/confirm/confirm'; +import ButtonElement from '../components/dashboard/elements/ButtonElement'; +import UserPasswordForm from '../components/dashboard/users/UserPasswordForm'; +import loading from '../components/loading/loading'; +import toast from '../components/toast/toast'; +import { getParameterByName } from '../utils/url'; +import Page from '../components/Page'; -type IProps = { - userId: string; -} - -const UserProfilePage: FunctionComponent = ({userId}: IProps) => { +const UserProfilePage: FunctionComponent = () => { + const userId = getParameterByName('userId'); const [ userName, setUserName ] = useState(''); const element = useRef(null); @@ -145,13 +144,18 @@ const UserProfilePage: FunctionComponent = ({userId}: IProps) => { }, [reloadUser, userId]); return ( -
-
+ +
= ({userId}: IProps) => { userId={userId} />
-
+ + ); }; diff --git a/src/routes/index.tsx b/src/routes/index.tsx index dbfe714e1..072589e85 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -8,6 +8,7 @@ import UserEditPage from './UserEditPage'; import UserLibraryAccessPage from './UserLibraryAccessPage'; import UserParentalControl from './UserParentalControl'; import UserPasswordPage from './UserPasswordPage'; +import UserProfilePage from './UserProfilePage'; import UserProfilesPage from './UserProfilesPage'; const AppRoutes = () => ( @@ -69,6 +70,14 @@ const AppRoutes = () => ( } /> + + + + } + /> {/* Suppress warnings for unhandled routes */} diff --git a/src/scripts/routes.js b/src/scripts/routes.js index d76b8c52d..2135c65ba 100644 --- a/src/scripts/routes.js +++ b/src/scripts/routes.js @@ -77,13 +77,6 @@ import { appRouter } from '../components/appRouter'; controller: 'user/menu/index' }); - defineRoute({ - alias: '/myprofile.html', - path: 'user/profile/index.html', - autoFocus: false, - pageComponent: 'UserProfilePage' - }); - defineRoute({ alias: '/mypreferencescontrols.html', path: 'user/controls/index.html',