fleet/frontend/components/LinkWithContext/LinkWithContext.tsx
Gabriel Hernandez 3729b4b98d
Install software setup experience UI (#22651)
relates to #22373

This implements the UI for the install software setup experience in the
UI. This includes:

**updating the nav sidebar**


![image](https://github.com/user-attachments/assets/91928a23-13cc-430b-b207-ba226df32b86)

**creating a new install software card**


![image](https://github.com/user-attachments/assets/8b4a9495-4119-4360-9f31-53ac41b83316)

**select software modal for selecting which software to install**


![image](https://github.com/user-attachments/assets/a3b4b786-ab8e-42b2-8feb-4b2a83e69af9)**


- [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
2024-10-09 16:09:38 +01:00

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;