diff --git a/public/app/features/plugins/all.ts b/public/app/features/plugins/all.ts
index a0d4e61962c..fd19ea963b6 100644
--- a/public/app/features/plugins/all.ts
+++ b/public/app/features/plugins/all.ts
@@ -3,6 +3,7 @@ import './plugin_page_ctrl';
import './plugin_list_ctrl';
import './import_list/import_list';
import './ds_edit_ctrl';
+import './ds_dashboards_ctrl';
import './ds_list_ctrl';
import './datasource_srv';
import './plugin_component';
diff --git a/public/app/features/plugins/ds_dashboards_ctrl.ts b/public/app/features/plugins/ds_dashboards_ctrl.ts
new file mode 100644
index 00000000000..950fe2a04bd
--- /dev/null
+++ b/public/app/features/plugins/ds_dashboards_ctrl.ts
@@ -0,0 +1,39 @@
+import { toJS } from 'mobx';
+import { coreModule } from 'app/core/core';
+import { store } from 'app/stores/store';
+
+export class DataSourceDashboardsCtrl {
+ datasourceMeta: any;
+ navModel: any;
+ current: any;
+
+ /** @ngInject */
+ constructor(private backendSrv, private $routeParams) {
+ if (this.$routeParams.id) {
+ this.getDatasourceById(this.$routeParams.id);
+ }
+ }
+
+ getDatasourceById(id) {
+ this.backendSrv
+ .get('/api/datasources/' + id)
+ .then(ds => {
+ this.current = ds;
+ })
+ .then(this.getPluginInfo.bind(this));
+ }
+
+ updateNav() {
+ store.nav.initDatasourceEditNav(this.current, this.datasourceMeta, 'datasource-dashboards');
+ this.navModel = toJS(store.nav);
+ }
+
+ getPluginInfo() {
+ return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => {
+ this.datasourceMeta = pluginInfo;
+ this.updateNav();
+ });
+ }
+}
+
+coreModule.controller('DataSourceDashboardsCtrl', DataSourceDashboardsCtrl);
diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts
index 5a48ba74dbc..2f5ad470dc0 100644
--- a/public/app/features/plugins/ds_edit_ctrl.ts
+++ b/public/app/features/plugins/ds_edit_ctrl.ts
@@ -1,7 +1,8 @@
import _ from 'lodash';
-
+import { toJS } from 'mobx';
import config from 'app/core/config';
import { coreModule, appEvents } from 'app/core/core';
+import { store } from 'app/stores/store';
var datasourceTypes = [];
@@ -23,8 +24,6 @@ export class DataSourceEditCtrl {
types: any;
testing: any;
datasourceMeta: any;
- tabIndex: number;
- hasDashboards: boolean;
editForm: any;
gettingStarted: boolean;
navModel: any;
@@ -39,8 +38,8 @@ export class DataSourceEditCtrl {
navModelSrv
) {
this.navModel = navModelSrv.getNav('cfg', 'datasources', 0);
+ this.navModel = thi;
this.datasources = [];
- this.tabIndex = 0;
this.loadDatasourceTypes().then(() => {
if (this.$routeParams.id) {
@@ -55,8 +54,6 @@ export class DataSourceEditCtrl {
this.isNew = true;
this.current = _.cloneDeep(defaults);
- this.navModel.breadcrumbs.push({ text: 'New' });
-
// We are coming from getting started
if (this.$location.search().gettingstarted) {
this.gettingStarted = true;
@@ -82,12 +79,6 @@ export class DataSourceEditCtrl {
this.backendSrv.get('/api/datasources/' + id).then(ds => {
this.isNew = false;
this.current = ds;
- this.navModel.node = {
- text: ds.name,
- icon: 'icon-gf icon-gf-fw icon-gf-datasources',
- id: 'ds-new',
- };
- this.navModel.breadcrumbs.push(this.navModel.node);
if (datasourceCreated) {
datasourceCreated = false;
@@ -112,11 +103,15 @@ export class DataSourceEditCtrl {
this.typeChanged();
}
+ updateNav() {
+ store.nav.initDatasourceEditNav(this.current, this.datasourceMeta, 'datasource-settings');
+ this.navModel = toJS(store.nav);
+ }
+
typeChanged() {
- this.hasDashboards = false;
return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => {
this.datasourceMeta = pluginInfo;
- this.hasDashboards = _.find(pluginInfo.includes, { type: 'dashboard' }) !== undefined;
+ this.updateNav();
});
}
@@ -171,6 +166,7 @@ export class DataSourceEditCtrl {
if (this.current.id) {
return this.backendSrv.put('/api/datasources/' + this.current.id, this.current).then(result => {
this.current = result.datasource;
+ this.updateNav();
this.updateFrontendSettings().then(() => {
this.testDatasource();
});
diff --git a/public/app/features/plugins/partials/ds_dashboards.html b/public/app/features/plugins/partials/ds_dashboards.html
new file mode 100644
index 00000000000..50be10819b5
--- /dev/null
+++ b/public/app/features/plugins/partials/ds_dashboards.html
@@ -0,0 +1,10 @@
+