mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-09-04 02:15:43 +00:00
* Introduced tsconfig.app.json and tsconfig.base.json * yarn.lock * Introduced tsconfig.app.json, tsconfig.base.jsonfig. * Refactored eslint.config.js to latest structure * Returned previous recommended rules. * More rules * Force import rules * Check * Check * Cleanup ESLint configuration and plugins * Cleanup heap: "writable",DD_RUM: "writable" from ESLint configuration * "scripts" moved to the top of package.json
40 lines
926 B
TypeScript
40 lines
926 B
TypeScript
import { type ReactNode } from "react";
|
|
import { NavLink, useLocation, useParams } from "react-router";
|
|
|
|
import { useAppContext } from "../context/AppContext";
|
|
|
|
const LinkWithSearchParams = ({
|
|
to,
|
|
...props
|
|
}: {
|
|
to: string;
|
|
end?: boolean;
|
|
exclude?: string[];
|
|
className?: string;
|
|
children: ReactNode;
|
|
}) => {
|
|
const { search } = useLocation();
|
|
const { context = "" } = useParams();
|
|
const { clusterMode } = useAppContext();
|
|
|
|
const params = new URLSearchParams(search);
|
|
// For state we don't want to keep while navigating
|
|
props.exclude?.forEach((key) => {
|
|
params.delete(key);
|
|
});
|
|
|
|
let prefixedUrl = to;
|
|
|
|
if (!clusterMode && context) {
|
|
prefixedUrl = `/${encodeURIComponent(context)}${to}`;
|
|
} else {
|
|
prefixedUrl = to;
|
|
}
|
|
|
|
const url = `${prefixedUrl}/?${params.toString()}`;
|
|
|
|
return <NavLink data-cy="navigation-link" to={url} {...props} />;
|
|
};
|
|
|
|
export default LinkWithSearchParams;
|