mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-19 03:05:53 +08:00
(ui): Make GroupSelect controlled input
This commit is contained in:
parent
f31f248937
commit
55de4e84eb
@ -28,15 +28,27 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
selected: GroupInfo | null;
|
||||||
|
onSelect: (newVal: GroupInfo | null) => void;
|
||||||
groups: GroupInfo[];
|
groups: GroupInfo[];
|
||||||
error: string;
|
error: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GroupSelect(props: Props) {
|
export default function GroupSelect(props: Props) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
const [inputValue, setInputValue] = React.useState("");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
id="task-group-selector"
|
id="task-group-selector"
|
||||||
|
value={props.selected}
|
||||||
|
onChange={(event: any, newValue: GroupInfo | null) => {
|
||||||
|
props.onSelect(newValue);
|
||||||
|
}}
|
||||||
|
inputValue={inputValue}
|
||||||
|
onInputChange={(event, newInputValue) => {
|
||||||
|
setInputValue(newInputValue);
|
||||||
|
}}
|
||||||
disableListWrap
|
disableListWrap
|
||||||
ListboxComponent={
|
ListboxComponent={
|
||||||
ListboxComponent as React.ComponentType<
|
ListboxComponent as React.ComponentType<
|
||||||
|
@ -5,6 +5,7 @@ import { listGroupsAsync } from "../actions/groupsActions";
|
|||||||
import GroupSelect from "./GroupSelect";
|
import GroupSelect from "./GroupSelect";
|
||||||
import { usePolling } from "../hooks";
|
import { usePolling } from "../hooks";
|
||||||
import { AppState } from "../store";
|
import { AppState } from "../store";
|
||||||
|
import { GroupInfo } from "../api";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
groupSelector: {
|
groupSelector: {
|
||||||
@ -34,6 +35,9 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function TaskGroupsTable(props: Props & ConnectedProps<typeof connector>) {
|
function TaskGroupsTable(props: Props & ConnectedProps<typeof connector>) {
|
||||||
|
const [selectedGroup, setSelectedGroup] = React.useState<GroupInfo | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
const { pollInterval, listGroupsAsync, queue } = props;
|
const { pollInterval, listGroupsAsync, queue } = props;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
@ -46,7 +50,12 @@ function TaskGroupsTable(props: Props & ConnectedProps<typeof connector>) {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={classes.groupSelector}>
|
<div className={classes.groupSelector}>
|
||||||
<GroupSelect groups={props.groups} error={props.groupsError} />
|
<GroupSelect
|
||||||
|
selected={selectedGroup}
|
||||||
|
onSelect={setSelectedGroup}
|
||||||
|
groups={props.groups}
|
||||||
|
error={props.groupsError}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user