mirror of
https://github.com/fleetdm/fleet
synced 2026-05-14 20:48:35 +00:00
relates to #22373 This implements the UI for the install software setup experience in the UI. This includes: **updating the nav sidebar**  **creating a new install software card**  **select software modal for selecting which software to install** ** - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - [x] Manual QA for all new/changed functionality
44 lines
1 KiB
TypeScript
44 lines
1 KiB
TypeScript
import React from "react";
|
|
import { Link } from "react-router";
|
|
import classnames from "classnames";
|
|
|
|
import { buildQueryStringFromParams, QueryParams } from "utilities/url";
|
|
import { pick } from "lodash";
|
|
|
|
const baseClass = "link-with-context";
|
|
|
|
interface ILinkWithContextProps {
|
|
children: React.ReactChild | React.ReactChild[];
|
|
currentQueryParams: QueryParams;
|
|
to: string;
|
|
withParams: {
|
|
type: "query";
|
|
names: string[];
|
|
};
|
|
className?: string;
|
|
}
|
|
|
|
const LinkWithContext = ({
|
|
children,
|
|
currentQueryParams,
|
|
to,
|
|
withParams,
|
|
className,
|
|
}: ILinkWithContextProps): JSX.Element => {
|
|
const classNames = classnames(baseClass, className);
|
|
|
|
let queryString = "";
|
|
if (withParams.type === "query") {
|
|
const newParams = pick(currentQueryParams, withParams.names);
|
|
queryString = buildQueryStringFromParams(newParams);
|
|
}
|
|
return (
|
|
<Link
|
|
className={classNames}
|
|
to={queryString.length ? `${to}?${queryString}` : to}
|
|
>
|
|
{children}
|
|
</Link>
|
|
);
|
|
};
|
|
export default LinkWithContext;
|