diff --git a/README.md b/README.md index 81ec096..11f0e6d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,27 @@ # Hawk The missing Firefox OS file manager + +This app is under heavy development, things may change and break, but don't hesitate to test and fill issues in case you find bugs. + +Please read the Features section below and issues to make sure your issue is not already reported. + +# Features + +- [ ] Breadcrumb +- [x] Delete Files +- [ ] Rename Files +- [ ] Create new files and directories +- [ ] Share Files +- [ ] Search +- [ ] FTP Browser +- [ ] File Preview +- [ ] File Type Icons +- [ ] File Size +- [ ] Directory Child Count +- [ ] Filter Filtes +- [ ] Show / Hide hidden files +- [ ] Show directories first +- [ ] Share files +- [ ] Wi-Fi File Transfer (is this possible?) +- [ ] Preferences +- [ ] Swipe Gestures diff --git a/build/main.js b/build/main.js index fa953d2..a563eda 100644 --- a/build/main.js +++ b/build/main.js @@ -21251,7 +21251,6 @@ var createDirectory = _asyncToGenerator(function* () { exports.createDirectory = createDirectory; var rename = _asyncToGenerator(function* (file, newName) { - console.log(file); var path = (file.path || '').slice(1); // remove starting slash var oldPath = path + file.name; var newPath = path + newName; @@ -21346,6 +21345,8 @@ var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir); var _store = require('store'); +// TODO: Fix history not working when clicking on sdcard + var Breadcrumb = (function (_Component) { _inherits(Breadcrumb, _Component); @@ -21443,6 +21444,8 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _utils = require('utils'); + var Dialog = (function (_Component) { _inherits(Dialog, _Component); @@ -21457,7 +21460,14 @@ var Dialog = (function (_Component) { value: function render() { var _this = this; - var conditionalInput = this.props.input ? _react2['default'].createElement('input', { ref: 'input' }) : ''; + var _props = this.props; + var input = _props.input; + var title = _props.title; + var description = _props.description; + var active = _props.active; + + var conditionalInput = input ? _react2['default'].createElement('input', { ref: 'input' }) : ''; + var buttons = this.props.buttons.map(function (button, i) { return _react2['default'].createElement( 'button', @@ -21467,7 +21477,7 @@ var Dialog = (function (_Component) { ); }); - var className = this.props.active ? 'dialog active' : 'dialog'; + var className = active ? 'dialog active' : 'dialog'; return _react2['default'].createElement( 'div', @@ -21475,12 +21485,12 @@ var Dialog = (function (_Component) { _react2['default'].createElement( 'p', { className: 'regular-medium' }, - this.props.title + title ), _react2['default'].createElement( 'p', { className: 'light-medium' }, - this.props.description + description ), conditionalInput, _react2['default'].createElement( @@ -21498,7 +21508,7 @@ var Dialog = (function (_Component) { exports['default'] = Dialog; module.exports = exports['default']; -},{"react":165}],186:[function(require,module,exports){ +},{"react":165,"utils":"utils"}],186:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22097,6 +22107,9 @@ var DirectoryMenu = (0, _reactRedux.connect)(function (state) { var RenameDialog = (0, _reactRedux.connect)(function (state) { return state.get('renameDialog'); })(_componentsDialog2['default']); +var DeleteDialog = (0, _reactRedux.connect)(function (state) { + return state.get('deleteDialog'); +})(_componentsDialog2['default']); var Root = (function (_Component) { _inherits(Root, _Component); @@ -22120,7 +22133,8 @@ var Root = (function (_Component) { _react2['default'].createElement(_componentsToolbar2['default'], null), _react2['default'].createElement(FileMenu, null), _react2['default'].createElement(DirectoryMenu, null), - _react2['default'].createElement(RenameDialog, null) + _react2['default'].createElement(RenameDialog, null), + _react2['default'].createElement(DeleteDialog, null) ); } }, { @@ -22244,7 +22258,7 @@ exports['default'] = { }, deleteDialog: { title: 'Delete', - description: 'Are you sure you want to remove @activeFile.name?', + description: 'Are you sure you want to remove this file?', buttons: [{ text: 'No', action: (0, _store.bind)((0, _actionsDialog.hideAll)()) @@ -27590,15 +27604,45 @@ function bind(action) { exports['default'] = store; },{"./dialogs":194,"./menus":196,"actions/changedir":175,"immutable":205,"reducers/all":198,"redux":167}],"utils":[function(require,module,exports){ -"use strict"; +'use strict'; -Object.defineProperty(exports, "__esModule", { +Object.defineProperty(exports, '__esModule', { value: true }); exports.type = type; +exports.template = template; +exports.getKey = getKey; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _store = require('store'); + +var _store2 = _interopRequireDefault(_store); function type(obj) { return Object.prototype.toString.call(obj).slice(8, -1); } -},{}]},{},[175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,"store","utils"]); +function template(string, props) { + return string.replace(/@(\S+)/g, function (all, match) { + return getKey(props, match); + }); +} + +function getKey(object, key) { + if (object === undefined) object = _store2['default'].getState().toJS(); + + var parent = object; + + do { + var dot = key.indexOf('.'); + if (dot === -1) dot = key.length; + parent = parent[key.slice(0, dot)]; + + key = key.slice(dot + 1); + } while (key); + + return parent; +} + +},{"store":"store"}]},{},[175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,"store","utils"]); diff --git a/src/js/api/files.js b/src/js/api/files.js index b5fbf3c..c3cf5cc 100644 --- a/src/js/api/files.js +++ b/src/js/api/files.js @@ -57,7 +57,6 @@ export async function createDirectory(...args) { } export async function rename(file, newName) { - console.log(file); let path = (file.path || '').slice(1); // remove starting slash let oldPath = (path + file.name); let newPath = path + newName; diff --git a/src/js/components/breadcrumb.js b/src/js/components/breadcrumb.js index 4e7683e..44b0184 100644 --- a/src/js/components/breadcrumb.js +++ b/src/js/components/breadcrumb.js @@ -3,6 +3,7 @@ import { connect } from 'react-redux'; import changedir from 'actions/changedir'; import { bind } from 'store'; +// TODO: Fix history not working when clicking on sdcard @connect(props) export default class Breadcrumb extends Component { render() { diff --git a/src/js/components/dialog.js b/src/js/components/dialog.js index 6eb1b21..719e35a 100644 --- a/src/js/components/dialog.js +++ b/src/js/components/dialog.js @@ -1,8 +1,11 @@ import React, { Component } from 'react'; +import { template } from 'utils'; export default class Dialog extends Component { render() { - let conditionalInput = this.props.input ? : ''; + let { input, title, description, active } = this.props; + let conditionalInput = input ? : ''; + let buttons = this.props.buttons.map((button, i) => { return ; }); - let className = this.props.active ? 'dialog active' : 'dialog'; + let className = active ? 'dialog active' : 'dialog'; return (
-

{this.props.title}

-

{this.props.description}

+

{title}

+

{description}

{conditionalInput} diff --git a/src/js/components/root.js b/src/js/components/root.js index b422a42..d42a291 100644 --- a/src/js/components/root.js +++ b/src/js/components/root.js @@ -19,6 +19,7 @@ let FileMenu = connect(state => state.get('fileMenu'))(Menu); let DirectoryMenu = connect(state => state.get('directoryMenu'))(Menu); let RenameDialog = connect(state => state.get('renameDialog'))(Dialog); +let DeleteDialog = connect(state => state.get('deleteDialog'))(Dialog); export default class Root extends Component { render() { @@ -34,6 +35,7 @@ export default class Root extends Component { +
); } diff --git a/src/js/dialogs.js b/src/js/dialogs.js index 4e409f7..e7ba0bc 100644 --- a/src/js/dialogs.js +++ b/src/js/dialogs.js @@ -28,7 +28,7 @@ export default { }, deleteDialog: { title: 'Delete', - description: 'Are you sure you want to remove @activeFile.name?', + description: 'Are you sure you want to remove this file?', buttons: [ { text: 'No', diff --git a/src/js/utils.js b/src/js/utils.js index 8338fb8..4c6a9d0 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -1,3 +1,25 @@ +import store from 'store'; + export function type(obj) { return Object.prototype.toString.call(obj).slice(8, -1); } + +export function template(string, props) { + return string.replace(/@(\S+)/g, (all, match) => { + return getKey(props, match); + }); +} + +export function getKey(object = store.getState().toJS(), key) { + let parent = object; + + do { + let dot = key.indexOf('.'); + if (dot === -1) dot = key.length; + parent = parent[key.slice(0, dot)]; + + key = key.slice(dot + 1); + } while (key) + + return parent; +}