<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves # # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Redesigned in-app notifications with a new toast-based UI style. * Error messages are now dismissible and expandable to reveal detailed server response information. * Success and error notifications now appear consistently across the application with improved visibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import React, { useContext } from "react";
|
|
import { InjectedRouter } from "react-router";
|
|
|
|
import UnsupportedScreenSize from "layouts/UnsupportedScreenSize";
|
|
|
|
import { AppContext } from "context/app";
|
|
import classNames from "classnames";
|
|
|
|
import paths from "router/paths";
|
|
import SiteTopNav from "components/top_nav/SiteTopNav";
|
|
import CommandPalette from "components/CommandPalette";
|
|
import { QueryParams } from "utilities/url";
|
|
import shouldShowUnsupportedScreen from "layouts/UnsupportedScreenSize/helpers";
|
|
|
|
interface ICoreLayoutProps {
|
|
children: React.ReactNode;
|
|
router: InjectedRouter; // v3
|
|
// TODO: standardize typing and usage of location across app components
|
|
location: {
|
|
pathname: string;
|
|
search: string;
|
|
hash?: string;
|
|
query: QueryParams;
|
|
};
|
|
}
|
|
|
|
const CoreLayout = ({ children, router, location }: ICoreLayoutProps) => {
|
|
const { config, currentUser } = useContext(AppContext);
|
|
|
|
const onLogoutUser = async () => {
|
|
const { LOGOUT } = paths;
|
|
router.push(LOGOUT);
|
|
};
|
|
|
|
const onUserMenuItemClick = (path: string) => {
|
|
router.push(path);
|
|
};
|
|
|
|
if (!currentUser || !config) {
|
|
return null;
|
|
}
|
|
|
|
const coreWrapperClassnames = classNames("core-wrapper", {
|
|
"low-width-supported": !shouldShowUnsupportedScreen(location.pathname),
|
|
});
|
|
|
|
return (
|
|
<div className="app-wrap">
|
|
<CommandPalette />
|
|
{shouldShowUnsupportedScreen(location.pathname) && (
|
|
<UnsupportedScreenSize />
|
|
)}
|
|
<nav className="site-nav-container">
|
|
<SiteTopNav
|
|
config={config}
|
|
currentUser={currentUser}
|
|
location={location}
|
|
onLogoutUser={onLogoutUser}
|
|
onUserMenuItemClick={onUserMenuItemClick}
|
|
/>
|
|
</nav>
|
|
<div className={coreWrapperClassnames}>{children}</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default CoreLayout;
|