Skip to content

Commit

Permalink
change download modal
Browse files Browse the repository at this point in the history
Signed-off-by: shevijacobson <shevijacob@gmail.com>
  • Loading branch information
Shevijacobson committed Nov 4, 2024
1 parent b0a806a commit 365ec09
Showing 1 changed file with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import {
DropdownItem,
Modal,
Tooltip,
FormGroup,
FormSelect,
FormSelectOption,
TextContent,
} from "@patternfly/react-core";
import {
CodeIcon,
PencilAltIcon,
TagIcon,
WarningTriangleIcon,
Expand Down Expand Up @@ -157,7 +158,7 @@ export const ApplicationsTable: React.FC = () => {

const [isDownloadModalOpen, setIsDownloadModalOpen] = useState(false);

const [selectedFormat, setSelectedFormat] = useState<"json" | "yaml">("json");
const [selectedFormat, setSelectedFormat] = useState<string>("json");

const [assessmentToEdit, setAssessmentToEdit] = useState<Assessment | null>(
null
Expand All @@ -178,6 +179,16 @@ export const ApplicationsTable: React.FC = () => {
const [endOfAppImportPeriod, setEndOfAppImportPeriod] = useState<dayjs.Dayjs>(
dayjs()
);
const onChange = (
_event: React.FormEvent<HTMLSelectElement>,
value: string
) => {
setSelectedFormat(value);
};
const formats = [
{ value: "json", label: "JSON", disabled: false },
{ value: "yaml", label: "YAML", disabled: false },
];

const [
saveApplicationsCredentialsModalState,
Expand Down Expand Up @@ -1365,31 +1376,28 @@ export const ApplicationsTable: React.FC = () => {
/>
</div>
<Modal
isOpen={isDownloadModalOpen}
variant="small"
title={t("actions.download", { what: "analysis details reports" })}
isOpen={isDownloadModalOpen}
onClose={() => setIsDownloadModalOpen(false)}
>
<FormGroup label="Select Format" fieldId="format-select">
<div>
<Button
variant={selectedFormat === "json" ? "primary" : "secondary"}
onClick={() => setSelectedFormat("json")}
>
{<CodeIcon />} JSON
</Button>
<Button
variant={selectedFormat === "yaml" ? "primary" : "secondary"}
onClick={() => setSelectedFormat("yaml")}
>
{<CodeIcon />} YAML
</Button>
</div>
<p>Selected Format: {selectedFormat}</p>
</FormGroup>
<Button variant="primary" onClick={handleDownload}>
{t("actions.download")}
</Button>
<TextContent>{"Select format"}</TextContent>

<FormSelect
value={selectedFormat}
onChange={onChange}
aria-label="FormSelect Input"
ouiaId="BasicFormSelect"
>
{formats.map((option, index) => (
<FormSelectOption
isDisabled={option.disabled}
key={index}
value={option.value}
label={option.label}
/>
))}
</FormSelect>
</Modal>
</ConditionalRender>
);
Expand Down

0 comments on commit 365ec09

Please sign in to comment.