Skip to content

Commit

Permalink
change download modal
Browse files Browse the repository at this point in the history
Signed-off-by: shevijacobson <[email protected]>
  • Loading branch information
Shevijacobson committed Nov 2, 2024
1 parent 88ce250 commit b1130e3
Showing 1 changed file with 47 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import {
DropdownItem,
Modal,
Tooltip,
FormGroup,
ModalVariant,
FormSelect,
FormSelectOption,
TextContent,
} from "@patternfly/react-core";
import {
CodeIcon,
PencilAltIcon,
TagIcon,
WarningTriangleIcon,
Expand Down Expand Up @@ -157,7 +159,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 +180,17 @@ 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: "select one", label: "Select one", disabled: true },
{ value: "json", label: "JSON", disabled: false },
{ value: "yaml", label: "YAML", disabled: false },
];

const [
saveApplicationsCredentialsModalState,
Expand Down Expand Up @@ -1365,31 +1378,40 @@ export const ApplicationsTable: React.FC = () => {
/>
</div>
<Modal
variant={ModalVariant.small}
title={t("actions.download", { what: "analysis details" })}
isOpen={isDownloadModalOpen}
variant="small"
title={t("actions.download", { what: "analysis details reports" })}
onClose={() => setIsDownloadModalOpen(false)}
actions={[
<Button key="confirm" variant="primary" onClick={handleDownload}>
Download
</Button>,
<Button
key="cancel"
variant="link"
onClick={() => setIsDownloadModalOpen(false)}
>
Cancel
</Button>,
]}
>
<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 b1130e3

Please sign in to comment.