mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
## Issue - First batch of @iansltx 's work of cleaning up lint warnings #43387 ## Description - Quick PR review and grabbed as many confirmed low-risk quick wins as I could `git checkout lint-cleanup <file/path/1> <file/path/2>` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes This release contains internal code improvements with one minor UI tweak: * **Style** * Dropdown menu background color adjusted for clearer contrast in action lists * **Refactor** * Improved type safety across the codebase with stricter TypeScript annotations * Removed unused imports and constants to reduce code clutter * Enhanced React hook dependency arrays for more consistent component behavior <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Rachel Perkins <rachel@Rachels-MacBook-Pro.local> Co-authored-by: Ian Littman <iansltx@gmail.com>
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import React, { useEffect } from "react";
|
|
import { InjectedRouter, browserHistory } from "react-router";
|
|
|
|
import paths from "router/paths";
|
|
|
|
import Button from "components/buttons/Button";
|
|
import Icon from "components/Icon/Icon";
|
|
|
|
const baseClass = "authentication-nav";
|
|
|
|
interface IAuthenticationNav {
|
|
previousLocation?: string;
|
|
router?: InjectedRouter;
|
|
}
|
|
|
|
const AuthenticationNav = ({
|
|
previousLocation,
|
|
router,
|
|
}: IAuthenticationNav): JSX.Element => {
|
|
useEffect(() => {
|
|
const closeWithEscapeKey = (e: KeyboardEvent) => {
|
|
if (e.key === "Escape" && router) {
|
|
router.push(paths.LOGIN);
|
|
}
|
|
};
|
|
|
|
document.addEventListener("keydown", closeWithEscapeKey);
|
|
|
|
return () => {
|
|
document.removeEventListener("keydown", closeWithEscapeKey);
|
|
};
|
|
}, [router]);
|
|
|
|
const onClick = (): void => {
|
|
if (previousLocation) {
|
|
browserHistory.push(previousLocation);
|
|
} else browserHistory.goBack();
|
|
};
|
|
|
|
return (
|
|
<div className={`${baseClass}__back`}>
|
|
<Button
|
|
onClick={onClick}
|
|
className={`${baseClass}__back-link`}
|
|
variant="inverse"
|
|
>
|
|
<Icon name="close" color="core-fleet-black" />
|
|
</Button>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AuthenticationNav;
|