fleet/frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/ViewYamlModal/ViewYamlModal.tsx
RachelElysia c9e66b221e
Frontend: Lint warning cleanup part 1 (#43411)
## 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>
2026-04-10 19:49:52 -05:00

92 lines
2.4 KiB
TypeScript

import React, { useContext } from "react";
import { AppContext } from "context/app";
import { LEARN_MORE_ABOUT_BASE_LINK } from "utilities/constants";
import { ISoftwarePackage } from "interfaces/software";
import Modal from "components/Modal";
import Button from "components/buttons/Button";
import CustomLink from "components/CustomLink";
import InputField from "components/forms/fields/InputField";
import Editor from "components/Editor";
import { hyphenateString } from "utilities/strings/stringUtils";
import createPackageYaml from "./helpers";
const baseClass = "view-yaml-modal";
interface IViewYamlModalProps {
softwareTitleName: string;
iconUrl?: string | null;
displayName?: string;
softwarePackage: ISoftwarePackage;
onExit: () => void;
isScriptPackage?: boolean;
}
const ViewYamlModal = ({
softwareTitleName,
iconUrl,
displayName,
softwarePackage,
onExit,
isScriptPackage = false,
}: IViewYamlModalProps) => {
const { config } = useContext(AppContext);
const repositoryUrl = config?.gitops?.repository_url;
const { name, version, url, hash_sha256: sha256 } = softwarePackage;
const packageYaml = createPackageYaml({
softwareTitle: softwareTitleName,
packageName: name,
version,
url,
sha256,
iconUrl: iconUrl || null,
displayName,
isScriptPackage,
});
const hyphenatedSoftwareTitle = hyphenateString(softwareTitleName);
return (
<Modal className={baseClass} title="YAML" onExit={onExit}>
{repositoryUrl && (
<p>
Manage in <CustomLink url={repositoryUrl} text="YAML" newTab />.
</p>
)}
<div className={`${baseClass}__form-fields`}>
<InputField
enableCopy
readOnly
name="filename"
label="Filename"
value={`${hyphenatedSoftwareTitle}.package.yml`}
/>
<Editor
label="Contents"
value={packageYaml}
enableCopy
helpText={
<>
If you added advanced options, learn how to{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/yaml-packages`}
text="add them to your YAML"
newTab
/>
.
</>
}
/>
</div>
<div className="modal-cta-wrap">
<Button onClick={onExit}>Close</Button>
</div>
</Modal>
);
};
export default ViewYamlModal;