QueueSelect
A dropdown for selecting a Tracker queue. Supports a static queue list, asynchronous search/suggest, icons, loading state, and a confirmation dialog before changing the selection.
Basic usage
import {QueueSelect} from '@weavix/tracker-components';
import type {QueueInfo} from '@weavix/tracker-components';
const queues: QueueInfo[] = [
{key: 'DEV', display: 'Development'},
{key: 'DESIGN', display: 'Design'},
];
<QueueSelect
queues={queues}
defaultQueue={queues[0]}
onChange={(queue) => console.log(queue)}
/>;
Using with Tracker API (static list + async suggest)
Loads queues once on mount and switches to the suggest endpoint when the user starts typing.
import React, {useEffect, useState} from 'react';
import {CancellablePromise} from '@gravity-ui/sdk';
import {QueueSelect} from '@weavix/tracker-components';
import type {QueueInfo} from '@weavix/tracker-components';
interface Props {
trackerApi: TrackerApi;
onChange: (queue: QueueInfo) => void;
}
export const QueueSelectWithApi: React.FC<Props> = ({trackerApi, onChange}) => {
const [queues, setQueues] = useState<QueueInfo[]>([]);
const [loading, setLoading] = useState(true);
// Load all queues on mount
useEffect(() => {
trackerApi.v3
.get['/queues']()
.then((result) => setQueues(result.data))
.finally(() => setLoading(false));
}, [trackerApi]);
// Suggest on user input
const handleSearch = (text: string): CancellablePromise<QueueInfo[]> => {
const promise = trackerApi.v3
.get['/queues/_suggest']({queryParams: {input: text, fields: []}})
.then((result) => result.data);
return new CancellablePromise(promise, () => {});
};
return (
<QueueSelect
queues={queues}
loading={loading}
onSearch={handleSearch}
onChange={onChange}
placeholder="Select a queue"
/>
);
};
Main props
|
Prop |
Type |
Default |
Description |
|
|
|
`QueueInfo[] |
string[]` |
— |
List of queues to display |
|
|
`QueueInfo |
string` |
— |
Queue selected by default on mount |
|
|
|
|
Loading state |
|
|
|
|
— |
Async search on text input |
|
|
|
|
— |
Callback when the selected queue changes |
|
|
|
|
|
Don't select a queue by default on mount |
|
|
|
|
|
Disable the search field inside the dropdown |
|
|
|
|
|
Show the queue icon next to the selected value |
|
|
|
|
— |
Async check before applying the new selection |
|
|
|
`string |
boolean` |
— |
Error message or error flag |
|
|
|
— |
Placeholder when no selection is made |
|
|
|
|
|
Control size |
|
|
|
|
|
Show a border around the control |
|
|
|
|
— |
Additional CSS class |