Commit 2bdb2f79 by Carl Bergquist Committed by Torkel Ödegaard

fix(table): renderes empty date column as '-' (#6736)

* fix(table): renderes empty date column as '-'

closes #6728

* docs(changelog): add note about closing 6728
parent 2bdeb788
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* **Alerts out of sync**: Saving dashboards with broken alerts causes sync problem[#6576](https://github.com/grafana/grafana/issues/6576) * **Alerts out of sync**: Saving dashboards with broken alerts causes sync problem[#6576](https://github.com/grafana/grafana/issues/6576)
* **Alerting**: Saving an alert with condition "HAS NO DATA" throws an error[#6701](https://github.com/grafana/grafana/issues/6701) * **Alerting**: Saving an alert with condition "HAS NO DATA" throws an error[#6701](https://github.com/grafana/grafana/issues/6701)
* **Config**: Improve error message when parsing broken config file [#6731](https://github.com/grafana/grafana/issues/6731) * **Config**: Improve error message when parsing broken config file [#6731](https://github.com/grafana/grafana/issues/6731)
* **Table**: Render empty dates as - instead of current date [#6728](https://github.com/grafana/grafana/issues/6728)
# 4.0-beta2 (2016-11-21) # 4.0-beta2 (2016-11-21)
......
...@@ -47,6 +47,10 @@ export class TableRenderer { ...@@ -47,6 +47,10 @@ export class TableRenderer {
if (style.type === 'date') { if (style.type === 'date') {
return v => { return v => {
if (v === undefined || v === null) {
return '-';
}
if (_.isArray(v)) { v = v[0]; } if (_.isArray(v)) { v = v[0]; }
var date = moment(v); var date = moment(v);
if (this.isUtc) { if (this.isUtc) {
......
...@@ -68,6 +68,16 @@ describe('when rendering table', () => { ...@@ -68,6 +68,16 @@ describe('when rendering table', () => {
expect(html).to.be('<td>2014-01-01T06:06:06Z</td>'); expect(html).to.be('<td>2014-01-01T06:06:06Z</td>');
}); });
it('undefined time column should be rendered as -', () => {
var html = renderer.renderCell(0, undefined);
expect(html).to.be('<td>-</td>');
});
it('null time column should be rendered as -', () => {
var html = renderer.renderCell(0, null);
expect(html).to.be('<td>-</td>');
});
it('number column with unit specified should ignore style unit', () => { it('number column with unit specified should ignore style unit', () => {
var html = renderer.renderCell(5, 1230); var html = renderer.renderCell(5, 1230);
expect(html).to.be('<td>1.23 kbps</td>'); expect(html).to.be('<td>1.23 kbps</td>');
......
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