fix dialog.delete: deleteDialog doesn't have to say the filename, for now.

docs README: updated README
This commit is contained in:
Mahdi Dibaiee 2015-09-03 15:57:48 +04:30
parent 79ae4c1a47
commit 8f37f52bec
8 changed files with 113 additions and 17 deletions

View File

@ -1,2 +1,27 @@
# Hawk # Hawk
The missing Firefox OS file manager 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

View File

@ -21251,7 +21251,6 @@ var createDirectory = _asyncToGenerator(function* () {
exports.createDirectory = createDirectory; exports.createDirectory = createDirectory;
var rename = _asyncToGenerator(function* (file, newName) { var rename = _asyncToGenerator(function* (file, newName) {
console.log(file);
var path = (file.path || '').slice(1); // remove starting slash var path = (file.path || '').slice(1); // remove starting slash
var oldPath = path + file.name; var oldPath = path + file.name;
var newPath = path + newName; var newPath = path + newName;
@ -21346,6 +21345,8 @@ var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir);
var _store = require('store'); var _store = require('store');
// TODO: Fix history not working when clicking on sdcard
var Breadcrumb = (function (_Component) { var Breadcrumb = (function (_Component) {
_inherits(Breadcrumb, _Component); _inherits(Breadcrumb, _Component);
@ -21443,6 +21444,8 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react); var _react2 = _interopRequireDefault(_react);
var _utils = require('utils');
var Dialog = (function (_Component) { var Dialog = (function (_Component) {
_inherits(Dialog, _Component); _inherits(Dialog, _Component);
@ -21457,7 +21460,14 @@ var Dialog = (function (_Component) {
value: function render() { value: function render() {
var _this = this; 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) { var buttons = this.props.buttons.map(function (button, i) {
return _react2['default'].createElement( return _react2['default'].createElement(
'button', '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( return _react2['default'].createElement(
'div', 'div',
@ -21475,12 +21485,12 @@ var Dialog = (function (_Component) {
_react2['default'].createElement( _react2['default'].createElement(
'p', 'p',
{ className: 'regular-medium' }, { className: 'regular-medium' },
this.props.title title
), ),
_react2['default'].createElement( _react2['default'].createElement(
'p', 'p',
{ className: 'light-medium' }, { className: 'light-medium' },
this.props.description description
), ),
conditionalInput, conditionalInput,
_react2['default'].createElement( _react2['default'].createElement(
@ -21498,7 +21508,7 @@ var Dialog = (function (_Component) {
exports['default'] = Dialog; exports['default'] = Dialog;
module.exports = exports['default']; module.exports = exports['default'];
},{"react":165}],186:[function(require,module,exports){ },{"react":165,"utils":"utils"}],186:[function(require,module,exports){
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { Object.defineProperty(exports, '__esModule', {
@ -22097,6 +22107,9 @@ var DirectoryMenu = (0, _reactRedux.connect)(function (state) {
var RenameDialog = (0, _reactRedux.connect)(function (state) { var RenameDialog = (0, _reactRedux.connect)(function (state) {
return state.get('renameDialog'); return state.get('renameDialog');
})(_componentsDialog2['default']); })(_componentsDialog2['default']);
var DeleteDialog = (0, _reactRedux.connect)(function (state) {
return state.get('deleteDialog');
})(_componentsDialog2['default']);
var Root = (function (_Component) { var Root = (function (_Component) {
_inherits(Root, _Component); _inherits(Root, _Component);
@ -22120,7 +22133,8 @@ var Root = (function (_Component) {
_react2['default'].createElement(_componentsToolbar2['default'], null), _react2['default'].createElement(_componentsToolbar2['default'], null),
_react2['default'].createElement(FileMenu, null), _react2['default'].createElement(FileMenu, null),
_react2['default'].createElement(DirectoryMenu, 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: { deleteDialog: {
title: 'Delete', title: 'Delete',
description: 'Are you sure you want to remove @activeFile.name?', description: 'Are you sure you want to remove this file?',
buttons: [{ buttons: [{
text: 'No', text: 'No',
action: (0, _store.bind)((0, _actionsDialog.hideAll)()) action: (0, _store.bind)((0, _actionsDialog.hideAll)())
@ -27590,15 +27604,45 @@ function bind(action) {
exports['default'] = store; exports['default'] = store;
},{"./dialogs":194,"./menus":196,"actions/changedir":175,"immutable":205,"reducers/all":198,"redux":167}],"utils":[function(require,module,exports){ },{"./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 value: true
}); });
exports.type = type; 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) { function type(obj) {
return Object.prototype.toString.call(obj).slice(8, -1); 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"]);

View File

@ -57,7 +57,6 @@ export async function createDirectory(...args) {
} }
export async function rename(file, newName) { export async function rename(file, newName) {
console.log(file);
let path = (file.path || '').slice(1); // remove starting slash let path = (file.path || '').slice(1); // remove starting slash
let oldPath = (path + file.name); let oldPath = (path + file.name);
let newPath = path + newName; let newPath = path + newName;

View File

@ -3,6 +3,7 @@ import { connect } from 'react-redux';
import changedir from 'actions/changedir'; import changedir from 'actions/changedir';
import { bind } from 'store'; import { bind } from 'store';
// TODO: Fix history not working when clicking on sdcard
@connect(props) @connect(props)
export default class Breadcrumb extends Component { export default class Breadcrumb extends Component {
render() { render() {

View File

@ -1,8 +1,11 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { template } from 'utils';
export default class Dialog extends Component { export default class Dialog extends Component {
render() { render() {
let conditionalInput = this.props.input ? <input ref='input' /> : ''; let { input, title, description, active } = this.props;
let conditionalInput = input ? <input ref='input' /> : '';
let buttons = this.props.buttons.map((button, i) => { let buttons = this.props.buttons.map((button, i) => {
return <button className={button.className + ' btn'} key={i} return <button className={button.className + ' btn'} key={i}
onClick={button.action.bind(this)}> onClick={button.action.bind(this)}>
@ -10,12 +13,12 @@ export default class Dialog extends Component {
</button>; </button>;
}); });
let className = this.props.active ? 'dialog active' : 'dialog'; let className = active ? 'dialog active' : 'dialog';
return ( return (
<div className={className}> <div className={className}>
<p className='regular-medium'>{this.props.title}</p> <p className='regular-medium'>{title}</p>
<p className='light-medium'>{this.props.description}</p> <p className='light-medium'>{description}</p>
{conditionalInput} {conditionalInput}

View File

@ -19,6 +19,7 @@ let FileMenu = connect(state => state.get('fileMenu'))(Menu);
let DirectoryMenu = connect(state => state.get('directoryMenu'))(Menu); let DirectoryMenu = connect(state => state.get('directoryMenu'))(Menu);
let RenameDialog = connect(state => state.get('renameDialog'))(Dialog); let RenameDialog = connect(state => state.get('renameDialog'))(Dialog);
let DeleteDialog = connect(state => state.get('deleteDialog'))(Dialog);
export default class Root extends Component { export default class Root extends Component {
render() { render() {
@ -34,6 +35,7 @@ export default class Root extends Component {
<DirectoryMenu /> <DirectoryMenu />
<RenameDialog /> <RenameDialog />
<DeleteDialog />
</div> </div>
); );
} }

View File

@ -28,7 +28,7 @@ export default {
}, },
deleteDialog: { deleteDialog: {
title: 'Delete', title: 'Delete',
description: 'Are you sure you want to remove @activeFile.name?', description: 'Are you sure you want to remove this file?',
buttons: [ buttons: [
{ {
text: 'No', text: 'No',

View File

@ -1,3 +1,25 @@
import store from 'store';
export function type(obj) { export function type(obj) {
return Object.prototype.toString.call(obj).slice(8, -1); 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;
}