Skip to content

Commit

Permalink
Merge branch 'main' into custom-target-form
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Bolton <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Oct 27, 2023
2 parents 43f9d4a + fe11195 commit 891d936
Show file tree
Hide file tree
Showing 13 changed files with 564 additions and 172 deletions.
2 changes: 2 additions & 0 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ export interface Application {
assessments?: Ref[];
assessed?: boolean;
archetypes?: Ref[];
risk?: Risk;
confidence?: number;
}

export interface Review {
Expand Down
51 changes: 27 additions & 24 deletions client/src/app/components/SimpleSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,32 @@ export const SimpleSelect: React.FC<ISimpleSelectProps> = ({
}) => {
const [isOpen, setIsOpen] = useState(false);
return (
<Select
menuAppendTo="parent" // prevent menu from being clipped by modal edges
maxHeight={200}
placeholderText={placeholderText}
toggleAriaLabel={toggleAriaLabel}
isOpen={isOpen}
onToggle={(_, isOpen) => setIsOpen(isOpen)}
onSelect={(_, selection) => {
onChange(selection);
if (props.variant !== "checkbox") {
setIsOpen(false);
}
}}
selections={value}
{...props}
>
{options.map((option, index) => (
<SelectOption
key={`${index}-${option.toString()}`}
value={option}
{...(typeof option === "object" && (option as OptionWithValue).props)}
/>
))}
</Select>
<>
<Select
menuAppendTo="parent" // prevent menu from being clipped by modal edges
maxHeight={200}
placeholderText={placeholderText}
toggleAriaLabel={toggleAriaLabel}
isOpen={isOpen}
onToggle={(_, isOpen) => setIsOpen(isOpen)}
onSelect={(_, selection) => {
onChange(selection);
if (props.variant !== "checkbox") {
setIsOpen(false);
}
}}
selections={value}
{...props}
>
{options.map((option, index) => (
<SelectOption
key={`${index}-${option.toString()}`}
value={option}
{...(typeof option === "object" &&
(option as OptionWithValue).props)}
/>
))}
</Select>
</>
);
};
59 changes: 59 additions & 0 deletions client/src/app/components/SimpleSelectBasic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { useState } from "react";

import {
Select,
SelectList,
SelectOption,
MenuToggle,
MenuToggleElement,
} from "@patternfly/react-core";

export interface ISimpleSelectBasicProps {
onChange: (selection: string) => void;
options: string[];
value?: string;
placeholderText?: string;
}

export const SimpleSelectBasic: React.FC<ISimpleSelectBasicProps> = ({
onChange,
options,
value,
placeholderText = "Select...",
}) => {
const [isOpen, setIsOpen] = useState(false);

const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
isFullWidth
ref={toggleRef}
onClick={() => {
setIsOpen(!isOpen);
}}
isExpanded={isOpen}
>
{value || placeholderText || ""}
</MenuToggle>
);

return (
<Select
isOpen={isOpen}
toggle={toggle}
onOpenChange={(isOpen) => setIsOpen(isOpen)}
selected={value}
onSelect={(_, selection) => {
onChange(selection as string);
setIsOpen(false);
}}
>
<SelectList>
{options.map((option, index) => (
<SelectOption key={`${index}-${option.toString()}`} value={option}>
{option.toString()}
</SelectOption>
))}
</SelectList>
</Select>
);
};
Loading

0 comments on commit 891d936

Please sign in to comment.