Skip to content

Commit

Permalink
feat: add plain text renderer (elastic#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson authored May 10, 2018
1 parent 4b94d2e commit 7111c07
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
8 changes: 3 additions & 5 deletions common/types/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ export const boolean = () => ({
to: {
string: n => String(n),
number: n => Number(n),
render: input => {
render: value => {
return {
type: 'render',
as: 'markdown',
value: {
content: input,
},
as: 'text',
value: `${value}`,
};
},
},
Expand Down
8 changes: 3 additions & 5 deletions common/types/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ export const number = () => ({
},
to: {
string: n => String(n),
render: input => {
render: value => {
return {
type: 'render',
as: 'markdown',
value: {
content: String(input),
},
as: 'text',
value: `${value}`,
};
},
datatable: value => {
Expand Down
8 changes: 3 additions & 5 deletions common/types/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ export const string = () => ({
},
to: {
number: n => Number(n),
render: input => {
render: value => {
return {
type: 'render',
as: 'markdown',
value: {
content: input,
},
as: 'text',
value,
};
},
},
Expand Down
2 changes: 2 additions & 0 deletions public/render_functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { pie } from './pie';
import { plot } from './plot';
import { table } from './table';
import { timeFilter } from './time_filter';
import { text } from './text';

export const renderFunctions = [
advancedFilter,
Expand All @@ -26,4 +27,5 @@ export const renderFunctions = [
plot,
table,
timeFilter,
text,
];
13 changes: 13 additions & 0 deletions public/render_functions/text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ReactDOM from 'react-dom';
import React from 'react';

export const text = () => ({
name: 'text',
displayName: 'Plain Text',
help: 'Render output as plain text',
reuseDomNode: true,
render(domNode, config, handlers) {
ReactDOM.render(<div>{config}</div>, domNode, () => handlers.done());
handlers.onDestroy(() => ReactDOM.unmountComponentAtNode(domNode));
},
});

0 comments on commit 7111c07

Please sign in to comment.