|
@@ -1,5 +1,6 @@
|
|
|
import React, { PureComponent } from 'react';
|
|
import React, { PureComponent } from 'react';
|
|
|
import { AsyncSelect } from '@grafana/ui';
|
|
import { AsyncSelect } from '@grafana/ui';
|
|
|
|
|
+import { SelectableValue } from '@grafana/data';
|
|
|
import { debounce } from 'lodash';
|
|
import { debounce } from 'lodash';
|
|
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
|
import { getBackendSrv } from 'app/core/services/backend_srv';
|
|
|
import { DashboardSearchHit, DashboardDTO } from 'app/types';
|
|
import { DashboardSearchHit, DashboardDTO } from 'app/types';
|
|
@@ -7,6 +8,7 @@ import { DashboardSearchHit, DashboardDTO } from 'app/types';
|
|
|
export interface Props {
|
|
export interface Props {
|
|
|
className?: string;
|
|
className?: string;
|
|
|
onSelected: (dashboard: DashboardDTO) => void;
|
|
onSelected: (dashboard: DashboardDTO) => void;
|
|
|
|
|
+ currentDashboardId: SelectableValue<number>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface State {
|
|
export interface State {
|
|
@@ -36,7 +38,7 @@ export class DashboardPicker extends PureComponent<Props, State> {
|
|
|
.then((result: DashboardSearchHit[]) => {
|
|
.then((result: DashboardSearchHit[]) => {
|
|
|
const dashboards = result.map((item: DashboardSearchHit) => {
|
|
const dashboards = result.map((item: DashboardSearchHit) => {
|
|
|
return {
|
|
return {
|
|
|
- id: item.uid,
|
|
|
|
|
|
|
+ id: item.id,
|
|
|
value: item.id,
|
|
value: item.id,
|
|
|
label: `${item.folderTitle ? item.folderTitle : 'General'}/${item.title}`,
|
|
label: `${item.folderTitle ? item.folderTitle : 'General'}/${item.title}`,
|
|
|
};
|
|
};
|
|
@@ -48,7 +50,7 @@ export class DashboardPicker extends PureComponent<Props, State> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- const { className, onSelected } = this.props;
|
|
|
|
|
|
|
+ const { className, onSelected, currentDashboardId } = this.props;
|
|
|
const { isLoading } = this.state;
|
|
const { isLoading } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -63,6 +65,7 @@ export class DashboardPicker extends PureComponent<Props, State> {
|
|
|
onChange={onSelected}
|
|
onChange={onSelected}
|
|
|
placeholder="Select dashboard"
|
|
placeholder="Select dashboard"
|
|
|
noOptionsMessage={() => 'No dashboards found'}
|
|
noOptionsMessage={() => 'No dashboards found'}
|
|
|
|
|
+ value={currentDashboardId}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|