mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
* ShareModal: refactor dashboard export modal * Modal: show react modals with appEvents * ShareModal: embed panel tab * ShareModal: bind to shortcut (p s) * grafana-ui: ClipboardButton component * ShareModal: use ClipboardButton component * ClipboardButton: add to storybook * ShareModal: use event-based approach for dashboard share * ShareModal: remove unused * ModalReact: pass theme to the component * ShareModal: styles clean up * DashboardExporter: fix tests * fixed whitespace betwen icon and link * ShareModal: use theme from config * Modal: tab header refactor * ShareModal: tests * ShareModal: fix share url rendering * ShareModal: remove unused angular files * Chore: fix strictNullChecks errors * Modal: provide theme for event-based modal usage * ShareModal: use ModalsController for opening modal Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import {
|
|
DataSourceApi,
|
|
DataQueryRequest,
|
|
DataQueryResponse,
|
|
DataSourceInstanceSettings,
|
|
DataSourcePluginMeta,
|
|
} from '@grafana/data';
|
|
|
|
export class DatasourceSrvMock {
|
|
constructor(private defaultDS: DataSourceApi, private datasources: { [name: string]: DataSourceApi }) {
|
|
//
|
|
}
|
|
|
|
get(name?: string): Promise<DataSourceApi> {
|
|
if (!name) {
|
|
return Promise.resolve(this.defaultDS);
|
|
}
|
|
const ds = this.datasources[name];
|
|
if (ds) {
|
|
return Promise.resolve(ds);
|
|
}
|
|
return Promise.reject('Unknown Datasource: ' + name);
|
|
}
|
|
}
|
|
|
|
export class MockDataSourceApi extends DataSourceApi {
|
|
result: DataQueryResponse = { data: [] };
|
|
queryResolver: Promise<DataQueryResponse>;
|
|
|
|
constructor(name?: string, result?: DataQueryResponse, meta?: any) {
|
|
super({ name: name ? name : 'MockDataSourceApi' } as DataSourceInstanceSettings);
|
|
if (result) {
|
|
this.result = result;
|
|
}
|
|
|
|
this.meta = meta || ({} as DataSourcePluginMeta);
|
|
}
|
|
|
|
query(request: DataQueryRequest): Promise<DataQueryResponse> {
|
|
if (this.queryResolver) {
|
|
return this.queryResolver;
|
|
}
|
|
return new Promise(resolver => {
|
|
setTimeout(() => {
|
|
resolver(this.result);
|
|
});
|
|
});
|
|
}
|
|
|
|
testDatasource() {
|
|
return Promise.resolve();
|
|
}
|
|
}
|