Browse Source

feat(export): added grafana version to requires array, #5084

Torkel Ödegaard 9 years ago
parent
commit
fb74d10573

+ 8 - 0
public/app/features/dashboard/export/exporter.ts

@@ -78,6 +78,14 @@ export class DashboardExporter {
       templateizeDatasourceUsage(annotationDef);
       templateizeDatasourceUsage(annotationDef);
     }
     }
 
 
+    // add grafana version
+    requires['grafana'] = {
+      type: 'grafana',
+      id: 'grafana',
+      name: 'Grafana',
+      version: config.buildInfo.version
+    };
+
     return Promise.all(promises).then(() => {
     return Promise.all(promises).then(() => {
       _.each(datasources, (value, key) => {
       _.each(datasources, (value, key) => {
         inputs.push(value);
         inputs.push(value);

+ 11 - 0
public/app/features/dashboard/specs/exporter_specs.ts

@@ -14,6 +14,10 @@ describe.only('given dashboard with repeated panels', function() {
       annotations: { list: [] },
       annotations: { list: [] },
     };
     };
 
 
+    config.buildInfo = {
+      version: "3.0.2"
+    };
+
     dash.templating.list.push({
     dash.templating.list.push({
       name: 'apps',
       name: 'apps',
       type: 'query',
       type: 'query',
@@ -104,5 +108,12 @@ describe.only('given dashboard with repeated panels', function() {
     expect(require.version).to.be("1.1.0");
     expect(require.version).to.be("1.1.0");
   });
   });
 
 
+  it('should add grafana version', function() {
+    var require = _.findWhere(exported.__requires, {name: 'Grafana'});
+    expect(require.type).to.be("grafana");
+    expect(require.id).to.be("grafana");
+    expect(require.version).to.be("3.0.2");
+  });
+
 });
 });