forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model Serving UI Improvements (opendatahub-io#937)
- Loading branch information
1 parent
9b79c54
commit ba47d4e
Showing
30 changed files
with
596 additions
and
403 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,14 @@ | ||
import * as React from 'react'; | ||
import ValueUnitField from './ValueUnitField'; | ||
import { CPU_UNITS } from '../utilities/valueUnits'; | ||
|
||
type CPUFieldProps = { | ||
onChange: (newValue: string) => void; | ||
value?: string; | ||
}; | ||
|
||
const CPUField: React.FC<CPUFieldProps> = ({ onChange, value = '1' }) => { | ||
return <ValueUnitField min={1} onChange={onChange} options={CPU_UNITS} value={value} />; | ||
}; | ||
|
||
export default CPUField; |
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,14 @@ | ||
import * as React from 'react'; | ||
import ValueUnitField from './ValueUnitField'; | ||
import { MEMORY_UNITS } from '../utilities/valueUnits'; | ||
|
||
type MemoryFieldProps = { | ||
onChange: (newValue: string) => void; | ||
value?: string; | ||
}; | ||
|
||
const MemoryField: React.FC<MemoryFieldProps> = ({ onChange, value = '1Gi' }) => { | ||
return <ValueUnitField min={1} onChange={onChange} options={MEMORY_UNITS} value={value} />; | ||
}; | ||
|
||
export default MemoryField; |
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,27 @@ | ||
import * as React from 'react'; | ||
import { NumberInput } from '@patternfly/react-core'; | ||
|
||
type NumberInputWrapperProps = { | ||
onChange: (newValue: number) => void; | ||
value: number; | ||
} & Omit<React.ComponentProps<typeof NumberInput>, 'onChange' | 'value' | 'onPlus' | 'onMinus'>; | ||
|
||
const NumberInputWrapper: React.FC<NumberInputWrapperProps> = ({ | ||
onChange, | ||
value, | ||
...otherProps | ||
}) => { | ||
return ( | ||
<NumberInput | ||
{...otherProps} | ||
value={value} | ||
onChange={(e) => { | ||
onChange(parseInt(e.currentTarget.value)); | ||
}} | ||
onPlus={() => onChange(value + 1)} | ||
onMinus={() => onChange(value - 1)} | ||
/> | ||
); | ||
}; | ||
|
||
export default NumberInputWrapper; |
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,15 @@ | ||
import * as React from 'react'; | ||
|
||
const ScrollViewOnMount: React.FC = () => { | ||
return ( | ||
<div | ||
ref={(elm) => { | ||
if (elm) { | ||
elm.scrollIntoView(); | ||
} | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default ScrollViewOnMount; |
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,63 @@ | ||
import * as React from 'react'; | ||
import { Dropdown, DropdownItem, DropdownToggle, Split, SplitItem } from '@patternfly/react-core'; | ||
import NumberInputWrapper from './NumberInputWrapper'; | ||
import { splitValueUnit, UnitOption, ValueUnitString } from '../utilities/valueUnits'; | ||
|
||
type ValueUnitFieldProps = { | ||
/** @defaults to unlimited pos/neg */ | ||
min?: number; | ||
/** @defaults to unlimited pos/neg */ | ||
max?: number; | ||
onChange: (newValue: string) => void; | ||
options: UnitOption[]; | ||
value: ValueUnitString; | ||
}; | ||
|
||
const ValueUnitField: React.FC<ValueUnitFieldProps> = ({ | ||
min, | ||
max, | ||
onChange, | ||
options, | ||
value: fullValue, | ||
}) => { | ||
const [open, setOpen] = React.useState(false); | ||
const [currentValue, currentUnitOption] = splitValueUnit(fullValue, options); | ||
|
||
return ( | ||
<Split hasGutter> | ||
<SplitItem> | ||
<NumberInputWrapper | ||
min={min} | ||
max={max} | ||
value={currentValue} | ||
onChange={(value) => { | ||
onChange(`${value || min}${currentUnitOption.unit}`); | ||
}} | ||
/> | ||
</SplitItem> | ||
<SplitItem> | ||
<Dropdown | ||
toggle={ | ||
<DropdownToggle id="toggle-basic" onToggle={() => setOpen(!open)}> | ||
{currentUnitOption.name} | ||
</DropdownToggle> | ||
} | ||
isOpen={open} | ||
dropdownItems={options.map((option) => ( | ||
<DropdownItem | ||
key={option.unit} | ||
onClick={() => { | ||
onChange(`${currentValue}${option.unit}`); | ||
setOpen(false); | ||
}} | ||
> | ||
{option.name} | ||
</DropdownItem> | ||
))} | ||
/> | ||
</SplitItem> | ||
</Split> | ||
); | ||
}; | ||
|
||
export default ValueUnitField; |
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
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
Oops, something went wrong.