mirror of
https://github.com/grafana/grafana.git
synced 2025-09-18 05:42:47 +08:00
SortPicker: Disable SortPicker by prop (#109083)
This commit is contained in:
@ -13,13 +13,14 @@ export interface Props {
|
|||||||
getSortOptions?: () => Promise<SelectableValue[]>;
|
getSortOptions?: () => Promise<SelectableValue[]>;
|
||||||
filter?: string[];
|
filter?: string[];
|
||||||
isClearable?: boolean;
|
isClearable?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultSortOptionsGetter = (): Promise<SelectableValue[]> => {
|
const defaultSortOptionsGetter = (): Promise<SelectableValue[]> => {
|
||||||
return getGrafanaSearcher().getSortOptions();
|
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
|
// 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 options = useAsync<() => Promise<SelectableValue[]>>(async () => {
|
||||||
const vals = await (getSortOptions ?? defaultSortOptionsGetter)();
|
const vals = await (getSortOptions ?? defaultSortOptionsGetter)();
|
||||||
@ -45,6 +46,7 @@ export function SortPicker({ onChange, value, placeholder, filter, getSortOption
|
|||||||
placeholder={placeholder ?? `Sort (Default ${DEFAULT_SORT.label})`}
|
placeholder={placeholder ?? `Sort (Default ${DEFAULT_SORT.label})`}
|
||||||
prefix={<Icon name={isDesc ? 'sort-amount-down' : 'sort-amount-up'} />}
|
prefix={<Icon name={isDesc ? 'sort-amount-down' : 'sort-amount-up'} />}
|
||||||
isClearable={isClearable}
|
isClearable={isClearable}
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user