From e2068541fd6fa9c3b1778043e33c038f2beb444a Mon Sep 17 00:00:00 2001 From: Travis Person Date: Sat, 2 Jan 2016 17:15:42 -0800 Subject: [PATCH 01/14] Remove jquery from views/page.js Removes the use of jquery to get the value of the dag path input box. Addresses part of #133 --- app/scripts/views/page.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/scripts/views/page.js b/app/scripts/views/page.js index 9d1dad1df..0ae469523 100644 --- a/app/scripts/views/page.js +++ b/app/scripts/views/page.js @@ -1,9 +1,6 @@ import React from 'react' -import ReactDOM from 'react-dom' import Nav from './nav' import {Link} from 'react-router' -import $ from 'jquery' - import i18n from '../utils/i18n.js' import {parse} from '../utils/path' @@ -59,7 +56,7 @@ export default React.createClass({ }, showDAG: function () { - var path = $(ReactDOM.findDOMNode(this)).find('.dag-path').val() + var path = this.refs.dagPath.value this.context.router.push(`/objects/${parse(path).urlify()}`) }, @@ -105,7 +102,7 @@ export default React.createClass({
- +
From 13652366a567de0013bf101cf9fd39e51e5c10b9 Mon Sep 17 00:00:00 2001 From: Travis Person Date: Sat, 2 Jan 2016 19:11:43 -0800 Subject: [PATCH 02/14] Remove jquery from views/filelist.js Removes the use of jquery to get the files hash from the elements attrs. Instead we will create a callback for the click that will handle each files unpin. Also cleaned up things a bit, more will be required. Addresses part of #133 --- app/scripts/views/filelist.js | 118 +++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/app/scripts/views/filelist.js b/app/scripts/views/filelist.js index 288d3afee..4220723dd 100644 --- a/app/scripts/views/filelist.js +++ b/app/scripts/views/filelist.js @@ -1,34 +1,28 @@ -import React from 'react' -import $ from 'jquery' +import React, { Component } from 'react' import i18n from '../utils/i18n.js' import {Table, Tooltip, OverlayTrigger} from 'react-bootstrap' -export default React.createClass({ - displayName: 'FileList', - propTypes: { - ipfs: React.PropTypes.object, - files: React.PropTypes.array, - namesHidden: React.PropTypes.bool - }, - - unpin: function (e) { - e.preventDefault() - e.stopPropagation() +function getExtention (name, defaultExt = '?') { + if (!name) { + return defaultExt + } - var el = $(e.target) - var hash = el.attr('data-hash') - if (!hash) hash = el.parent().attr('data-hash') + const ext = name.split('.').pop() - this.props.ipfs.pin.remove(hash, {r: true}, function (err, res) { - console.log(err, res) - }) - }, + if (ext === name) { + return defaultExt + } else { + return ext.toUpperCase() + } +} - render: function () { - var t = this +export default class FileList extends Component { + render () { var files = this.props.files var className = 'table-hover filelist' - if (this.props.namesHidden) className += ' filelist-names-hidden' + if (this.props.namesHidden) { + className += ' filelist-names-hidden' + } return ( @@ -41,43 +35,61 @@ export default React.createClass({ - {files ? files.map(function (file) { - if (typeof file === 'string') file = { id: file } - - var type = '?' - if (file.name) { - var lastDot = file.name.lastIndexOf('.') - if (lastDot !== -1) type = file.name.substr(lastDot + 1, 4).toUpperCase() + {files ? files.map(file => { + if (typeof file === 'string') { + file = { id: file } } - var gatewayPath = t.props.gateway + '/ipfs/' + file.id - var dagPath = '#/objects/' + file.id - - var tooltip = ( - {i18n.t('Remove')} - ) + var dagPath = `#/objects/${file.id}` + var gatewayPath = `${this.props.gateway}/ipfs/${file.id}` + var unpin = (e) => { + e.preventDefault() + this.props.ipfs.pin.remove(file.id, {r: true}, function (err, res) { + console.log(err, res) + }) + } return ( - - - - - - + ) }) : void 0}
{type}{file.name}{file.id} - {i18n.t('RAW')} - | - {i18n.t('DAG')} - | - - - - - -
) } -}) +} + +FileList.propTypes = { + ipfs: React.PropTypes.object, + files: React.PropTypes.array, + namesHidden: React.PropTypes.bool, + gateway: React.PropTypes.string +} + +const FileItem = ({gatewayPath, dagPath, file, unpin}) => { + var type = getExtention(file.name) + var tooltip = ( + {i18n.t('Remove')} + ) + + return ( + + {type} + {file.name} + {file.id} + + {i18n.t('RAW')} + | + {i18n.t('DAG')} + | + + + {/* The block element is required otherwise the overlay is *over* the icon */} +
+
+
+ + + ) +} + From c7d517e374fbca07797d395fe3e62fdee80f992c Mon Sep 17 00:00:00 2001 From: Travis Person Date: Sat, 2 Jan 2016 19:16:54 -0800 Subject: [PATCH 03/14] Editable is no longer used Removed editable as it's not used anywhere in the code. Addresses part of #133 --- app/scripts/views/editable.js | 75 ----------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 app/scripts/views/editable.js diff --git a/app/scripts/views/editable.js b/app/scripts/views/editable.js deleted file mode 100644 index b32327f9a..000000000 --- a/app/scripts/views/editable.js +++ /dev/null @@ -1,75 +0,0 @@ -import React from 'react' -import $ from 'jquery' - -function format (value) { - value = value.trim() - if (value.length > 600) value = value.substr(0, 597) + '...' - return value -} - -export default React.createClass({ - displayName: 'Editable', - propTypes: { - ipfs: React.PropTypes.object, - key: React.PropTypes.any, - value: React.PropTypes.string - }, - getInitialState: function () { - this.props.value = JSON.stringify(this.props.value).trim() - return {} - }, - - convertToInput: function (e) { - var target = $(e.target) - if (target.hasClass('webui-editable-input')) return - - var text = this.props.value - var input = $('') - if (text.length > 110) input = $('