Commit 79933299 by Torkel Ödegaard

Merge branch 'develop' of github.com:grafana/grafana into develop

parents eb6d0e9f 569f5e8d
...@@ -158,7 +158,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> { ...@@ -158,7 +158,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
if (!datasourceSrv) { if (!datasourceSrv) {
throw new Error('No datasource service passed as props.'); throw new Error('No datasource service passed as props.');
} }
const datasources = datasourceSrv.getAll(); const datasources = datasourceSrv.getExternal();
const exploreDatasources = datasources.map(ds => ({ const exploreDatasources = datasources.map(ds => ({
value: ds.name, value: ds.name,
label: ds.name, label: ds.name,
......
...@@ -78,6 +78,11 @@ export class DatasourceSrv { ...@@ -78,6 +78,11 @@ export class DatasourceSrv {
return Object.keys(datasources).map(name => datasources[name]); return Object.keys(datasources).map(name => datasources[name]);
} }
getExternal() {
const datasources = this.getAll().filter(ds => !ds.meta.builtIn);
return _.sortBy(datasources, ['name']);
}
getAnnotationSources() { getAnnotationSources() {
const sources = []; const sources = [];
......
...@@ -18,6 +18,32 @@ const templateSrv = { ...@@ -18,6 +18,32 @@ const templateSrv = {
describe('datasource_srv', () => { describe('datasource_srv', () => {
const _datasourceSrv = new DatasourceSrv({}, {}, {}, templateSrv); const _datasourceSrv = new DatasourceSrv({}, {}, {}, templateSrv);
describe('when loading external datasources', () => {
beforeEach(() => {
config.datasources = {
buildInDs: {
name: 'buildIn',
meta: { builtIn: true },
},
nonBuildIn: {
name: 'external1',
meta: { builtIn: false },
},
nonExplore: {
name: 'external2',
meta: {},
},
};
});
it('should return list of explore sources', () => {
const externalSources = _datasourceSrv.getExternal();
expect(externalSources.length).toBe(2);
expect(externalSources[0].name).toBe('external1');
expect(externalSources[1].name).toBe('external2');
});
});
describe('when loading metric sources', () => { describe('when loading metric sources', () => {
let metricSources; let metricSources;
const unsortedDatasources = { const unsortedDatasources = {
......
...@@ -17,6 +17,7 @@ export class TemplateSrv { ...@@ -17,6 +17,7 @@ export class TemplateSrv {
constructor() { constructor() {
this.builtIns['__interval'] = { text: '1s', value: '1s' }; this.builtIns['__interval'] = { text: '1s', value: '1s' };
this.builtIns['__interval_ms'] = { text: '100', value: '100' }; this.builtIns['__interval_ms'] = { text: '100', value: '100' };
this.variables = [];
} }
init(variables) { init(variables) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment