mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Variables: Extend option pickers to accept custom onChange callback (#30913)
* Rename DashboardPicker props * Extend variable option pickers to allow providing custom onchage callback * Update public/app/features/variables/pickers/OptionsPicker/actions.ts Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * Update public/app/features/variables/pickers/OptionsPicker/actions.ts Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * Update public/app/features/variables/pickers/OptionsPicker/actions.ts Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * Update public/app/features/variables/textbox/TextBoxVariablePicker.tsx Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * Codeformat Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
This commit is contained in:
@@ -7,8 +7,8 @@ import { DashboardSearchHit } from 'app/features/search/types';
|
||||
import { DashboardDTO } from 'app/types';
|
||||
|
||||
export interface Props {
|
||||
onSelected: (dashboard: DashboardDTO) => void;
|
||||
currentDashboard?: SelectableValue;
|
||||
onChange: (dashboard: DashboardDTO) => void;
|
||||
value?: SelectableValue;
|
||||
width?: number;
|
||||
isClearable?: boolean;
|
||||
invalid?: boolean;
|
||||
@@ -26,14 +26,7 @@ const getDashboards = (query = '') => {
|
||||
});
|
||||
};
|
||||
|
||||
export const DashboardPicker: FC<Props> = ({
|
||||
onSelected,
|
||||
currentDashboard,
|
||||
width,
|
||||
isClearable = false,
|
||||
invalid,
|
||||
disabled,
|
||||
}) => {
|
||||
export const DashboardPicker: FC<Props> = ({ onChange, value, width, isClearable = false, invalid, disabled }) => {
|
||||
const debouncedSearch = debounce(getDashboards, 300);
|
||||
|
||||
return (
|
||||
@@ -42,10 +35,10 @@ export const DashboardPicker: FC<Props> = ({
|
||||
isClearable={isClearable}
|
||||
defaultOptions={true}
|
||||
loadOptions={debouncedSearch}
|
||||
onChange={onSelected}
|
||||
onChange={onChange}
|
||||
placeholder="Select dashboard"
|
||||
noOptionsMessage="No dashboards found"
|
||||
value={currentDashboard}
|
||||
value={value}
|
||||
invalid={invalid}
|
||||
disabled={disabled}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user