[FIX] Cannot open admin when server uses ROOT_URL with subpath (#18105) (#18147)

pull/18051/head
Omar Chehab 5 years ago committed by GitHub
parent ff7c7816a8
commit 96dd97d823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      client/admin/sidebar/AdminSidebar.js

@ -9,6 +9,7 @@ import { useReactiveValue } from '../../hooks/useReactiveValue';
import { useSettings } from '../../contexts/SettingsContext';
import { useTranslation } from '../../contexts/TranslationContext';
import { useRoutePath, useCurrentRoute } from '../../contexts/RouterContext';
import { useAbsoluteUrl } from '../../contexts/ServerContext';
import { useAtLeastOnePermission } from '../../contexts/AuthorizationContext';
import SettingsProvider from '../../providers/SettingsProvider';
import { sidebarItems } from '../sidebarItems';
@ -175,12 +176,14 @@ export default React.memo(function AdminSidebar() {
const currentRoute = useCurrentRoute();
const currentPath = useRoutePath(...currentRoute);
const absoluteUrl = useAbsoluteUrl();
useEffect(() => {
if (!currentPath.startsWith('/admin/')) {
const { pathname: adminPath } = new URL(absoluteUrl('admin/'));
if (!currentPath.startsWith(adminPath)) {
SideNav.closeFlex();
}
}, [currentRoute, currentPath]);
}, [absoluteUrl, currentPath]);
// TODO: uplift this provider
return <SettingsProvider privileged>

Loading…
Cancel
Save