2025-05-22 13:47:57 +00:00
|
|
|
import React, { useContext } from "react";
|
|
|
|
|
|
|
|
|
|
import { AppContext } from "context/app";
|
|
|
|
|
|
|
|
|
|
import { LEARN_MORE_ABOUT_BASE_LINK } from "utilities/constants";
|
2026-02-06 16:19:35 +00:00
|
|
|
import { ISoftwarePackage } from "interfaces/software";
|
2025-05-22 13:47:57 +00:00
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
|
2025-05-22 19:59:15 +00:00
|
|
|
import { hyphenateString } from "utilities/strings/stringUtils";
|
2026-02-25 23:43:23 +00:00
|
|
|
import createPackageYaml from "./helpers";
|
2025-05-22 13:47:57 +00:00
|
|
|
|
|
|
|
|
const baseClass = "view-yaml-modal";
|
|
|
|
|
|
|
|
|
|
interface IViewYamlModalProps {
|
|
|
|
|
softwareTitleName: string;
|
2025-09-05 22:31:03 +00:00
|
|
|
softwareTitleId: number;
|
|
|
|
|
teamId: number;
|
|
|
|
|
iconUrl?: string | null;
|
2025-12-02 17:03:15 +00:00
|
|
|
displayName?: string;
|
2025-05-22 13:47:57 +00:00
|
|
|
softwarePackage: ISoftwarePackage;
|
|
|
|
|
onExit: () => void;
|
2025-10-24 13:42:55 +00:00
|
|
|
isScriptPackage?: boolean;
|
2025-11-12 18:35:35 +00:00
|
|
|
isIosOrIpadosApp?: boolean;
|
2025-05-22 13:47:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ViewYamlModal = ({
|
|
|
|
|
softwareTitleName,
|
2025-09-05 22:31:03 +00:00
|
|
|
iconUrl,
|
2025-12-02 17:03:15 +00:00
|
|
|
displayName,
|
2025-05-22 13:47:57 +00:00
|
|
|
softwarePackage,
|
|
|
|
|
onExit,
|
2025-10-24 13:42:55 +00:00
|
|
|
isScriptPackage = false,
|
2025-05-22 13:47:57 +00:00
|
|
|
}: IViewYamlModalProps) => {
|
|
|
|
|
const { config } = useContext(AppContext);
|
|
|
|
|
const repositoryUrl = config?.gitops?.repository_url;
|
2025-11-04 12:55:57 +00:00
|
|
|
const { name, version, url, hash_sha256: sha256 } = softwarePackage;
|
|
|
|
|
|
2025-05-22 13:47:57 +00:00
|
|
|
const packageYaml = createPackageYaml({
|
|
|
|
|
softwareTitle: softwareTitleName,
|
|
|
|
|
packageName: name,
|
|
|
|
|
version,
|
|
|
|
|
url,
|
|
|
|
|
sha256,
|
2025-09-05 22:31:03 +00:00
|
|
|
iconUrl: iconUrl || null,
|
2025-12-02 17:03:15 +00:00
|
|
|
displayName,
|
2025-11-04 12:55:57 +00:00
|
|
|
isScriptPackage,
|
2025-05-22 13:47:57 +00:00
|
|
|
});
|
|
|
|
|
|
2025-05-22 19:59:15 +00:00
|
|
|
const hyphenatedSoftwareTitle = hyphenateString(softwareTitleName);
|
2025-05-22 13:47:57 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal className={baseClass} title="YAML" onExit={onExit}>
|
2026-03-10 22:30:55 +00:00
|
|
|
{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">
|
2026-03-23 15:59:18 +00:00
|
|
|
<Button onClick={onExit}>Close</Button>
|
2026-03-10 22:30:55 +00:00
|
|
|
</div>
|
2025-05-22 13:47:57 +00:00
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ViewYamlModal;
|