diff options
Diffstat (limited to 'old-ui/app/components/typed-message-renderer.js')
-rw-r--r-- | old-ui/app/components/typed-message-renderer.js | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/old-ui/app/components/typed-message-renderer.js b/old-ui/app/components/typed-message-renderer.js deleted file mode 100644 index 0dc673b8a..000000000 --- a/old-ui/app/components/typed-message-renderer.js +++ /dev/null @@ -1,69 +0,0 @@ -const Component = require('react').Component -const h = require('react-hyperscript') -const inherits = require('util').inherits -const extend = require('xtend') -const { ObjectInspector } = require('react-inspector') - -module.exports = TypedMessageRenderer - -inherits(TypedMessageRenderer, Component) -function TypedMessageRenderer () { - Component.call(this) -} - -TypedMessageRenderer.prototype.render = function () { - const props = this.props - const { value, version, style } = props - let text - switch (version) { - case 'V1': - text = renderTypedData(value) - break - case 'V3': - text = renderTypedDataV3(value) - break - } - - const defaultStyle = extend({ - width: '315px', - maxHeight: '210px', - resize: 'none', - border: 'none', - background: 'white', - padding: '3px', - overflow: 'scroll', - }, style) - - return ( - h('div.font-small', { - style: defaultStyle, - }, text) - ) -} - -function renderTypedData (values) { - return values.map(function (value) { - let v = value.value - if (typeof v === 'boolean') { - v = v.toString() - } - return h('div', {}, [ - h('strong', {style: {display: 'block', fontWeight: 'bold'}}, String(value.name) + ':'), - h('div', {}, v), - ]) - }) -} - -function renderTypedDataV3 (values) { - const { domain, message } = JSON.parse(values) - return [ - domain ? h('div', [ - h('h1', 'Domain'), - h(ObjectInspector, { data: domain, expandLevel: 1, name: 'domain' }), - ]) : '', - message ? h('div', [ - h('h1', 'Message'), - h(ObjectInspector, { data: message, expandLevel: 1, name: 'message' }), - ]) : '', - ] -} |