mirror of
https://github.com/grafana/grafana.git
synced 2025-09-17 16:33:10 +08:00
SortPicker: Disable SortPicker by prop (#109083)
This commit is contained in:
@ -13,13 +13,14 @@ export interface Props {
|
||||
getSortOptions?: () => Promise<SelectableValue[]>;
|
||||
filter?: string[];
|
||||
isClearable?: boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const defaultSortOptionsGetter = (): Promise<SelectableValue[]> => {
|
||||
return getGrafanaSearcher().getSortOptions();
|
||||
};
|
||||
|
||||
export function SortPicker({ onChange, value, placeholder, filter, getSortOptions, isClearable }: Props) {
|
||||
export function SortPicker({ onChange, value, placeholder, filter, getSortOptions, isClearable, disabled }: Props) {
|
||||
// Using sync Select and manual options fetching here since we need to find the selected option by value
|
||||
const options = useAsync<() => Promise<SelectableValue[]>>(async () => {
|
||||
const vals = await (getSortOptions ?? defaultSortOptionsGetter)();
|
||||
@ -45,6 +46,7 @@ export function SortPicker({ onChange, value, placeholder, filter, getSortOption
|
||||
placeholder={placeholder ?? `Sort (Default ${DEFAULT_SORT.label})`}
|
||||
prefix={<Icon name={isDesc ? 'sort-amount-down' : 'sort-amount-up'} />}
|
||||
isClearable={isClearable}
|
||||
disabled={disabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user