-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [AnalysisWizard] Language discovery changes (#1951)
Resolves #1950 UI Tests PR: 1136 Needs: konveyor/tackle-ui-tests#1136 Includes: - Provide a "(Show All)" option to display all targets regardless of language tags. Adds a new component to handle this new menu type. - Populate the options list from the Provider field of the fetched targets. - Initially select the languages based on the tags, of tag category "Language", across the applications selected for analysis. - Update TS type for Target to reflect the provider type changing to a string[]. - Covers the hub change to the task model described here: >The application Analysis fields used to correlated to task by addon. This needs to be updated to correlate by kind == "analyzer" (when not blank) else fallback on addon == "analyzer". The fallback is needed to correlate tasks created in previous releases. - Each target card should always display a label with it's provider. This will allow cards that belong to different providers to be differentiated when more than one language is selected. <img width="1360" alt="Screenshot 2024-06-12 at 3 37 47 PM" src="https://github.com/konveyor/tackle2-ui/assets/11218376/085de6c1-3b56-4532-ab38-81732da377e6"> --------- Signed-off-by: Ian Bolton <[email protected]> Co-authored-by: Radoslaw Szwajkowski <[email protected]>
- Loading branch information
1 parent
0cce0d8
commit ea2005b
Showing
5 changed files
with
204 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React from "react"; | ||
import { | ||
Select, | ||
SelectOption, | ||
SelectList, | ||
MenuToggle, | ||
Badge, | ||
SelectOptionProps, | ||
MenuToggleElement, | ||
} from "@patternfly/react-core"; | ||
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; | ||
|
||
export interface ISimpleSelectBasicProps { | ||
onChange: (selection: string | string[]) => void; | ||
options: SelectOptionProps[]; | ||
value?: string[]; | ||
placeholderText?: string; | ||
id?: string; | ||
toggleId?: string; | ||
toggleAriaLabel?: string; | ||
selectMultiple?: boolean; | ||
width?: number; | ||
noResultsFoundText?: string; | ||
hideClearButton?: false; | ||
} | ||
|
||
export const SimpleSelectCheckbox: React.FC<ISimpleSelectBasicProps> = ({ | ||
onChange, | ||
options, | ||
value, | ||
placeholderText = "Select...", | ||
id, | ||
toggleId, | ||
toggleAriaLabel, | ||
width, | ||
}) => { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const [selectOptions, setSelectOptions] = React.useState<SelectOptionProps[]>( | ||
[{ value: "show-all", label: "Show All", children: "Show All" }, ...options] | ||
); | ||
|
||
React.useEffect(() => { | ||
const updatedOptions = [ | ||
{ value: "show-all", label: "Show All", children: "Show All" }, | ||
...options, | ||
]; | ||
setSelectOptions(updatedOptions); | ||
}, [options]); | ||
|
||
const onToggleClick = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const onSelect = ( | ||
_event: React.MouseEvent<Element, MouseEvent> | undefined, | ||
selectionValue: string | number | undefined | ||
) => { | ||
if (!value || !selectionValue) { | ||
return; | ||
} | ||
let newValue: string[] = []; | ||
if (selectionValue === "show-all") { | ||
newValue = | ||
value.length === options.length ? [] : options.map((opt) => opt.value); | ||
} else { | ||
if (value.includes(selectionValue as string)) { | ||
newValue = value.filter((item) => item !== selectionValue); | ||
} else { | ||
newValue = [...value, selectionValue as string]; | ||
} | ||
} | ||
onChange(newValue); | ||
}; | ||
|
||
return ( | ||
<Select | ||
role="menu" | ||
id={id} | ||
isOpen={isOpen} | ||
selected={value} | ||
onSelect={onSelect} | ||
onOpenChange={setIsOpen} | ||
toggle={(toggleref: React.Ref<MenuToggleElement>) => ( | ||
<MenuToggle | ||
aria-label={toggleAriaLabel} | ||
id={toggleId} | ||
ref={toggleref} | ||
onClick={onToggleClick} | ||
style={{ width: width && width + "px" }} | ||
isExpanded={isOpen} | ||
> | ||
<span className={spacing.mrSm}>{placeholderText}</span> | ||
{value && value.length > 0 && <Badge isRead>{value.length}</Badge>} | ||
</MenuToggle> | ||
)} | ||
aria-label={toggleAriaLabel} | ||
> | ||
<SelectList> | ||
{selectOptions.map((option, index) => ( | ||
<SelectOption | ||
id={`checkbox-for-${option.value}`} | ||
hasCheckbox | ||
key={option.value} | ||
isFocused={index === 0} | ||
onClick={(e) => { | ||
onSelect(e, option.value); | ||
}} | ||
isSelected={ | ||
option.value === "show-all" | ||
? value?.length === options.length | ||
: value?.includes(option.value as string) | ||
} | ||
{...option} | ||
> | ||
{option.children || option.value} | ||
</SelectOption> | ||
))} | ||
</SelectList> | ||
</Select> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters