fix search.ux: While searching, show the search term in place of breadcrumb (resolve #8)

fix search: Navigating to search result's folders should exit search mode
This commit is contained in:
Mahdi Dibaiee 2015-09-26 20:53:34 +03:30
parent 92b5fa2fee
commit cb30112c40
4 changed files with 101 additions and 66 deletions

View File

@ -30215,8 +30215,6 @@ 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);
@ -30229,12 +30227,28 @@ var Breadcrumb = (function (_Component) {
_createClass(Breadcrumb, [{ _createClass(Breadcrumb, [{
key: 'render', key: 'render',
value: function render() { value: function render() {
var directories = this.props.cwd.split('/').filter(function (a) { var _this = this;
var els = [];
if (this.props.search) {
console.log('search');
els = [_react2['default'].createElement(
'span',
{ key: '000' },
'Search: ',
this.props.search
)];
} else {
(function () {
els.unshift(_react2['default'].createElement('span', { onClick: _this.goUp, className: 'icon-up', key: '000' }));
var directories = _this.props.cwd.split('/').filter(function (a) {
return a; return a;
}); });
directories.unshift('sdcard'); directories.unshift('sdcard');
var els = directories.map(function (dir, index, arr) { els = els.concat(directories.map(function (dir, index, arr) {
var path = arr.slice(1, index + 1).join('/'); var path = arr.slice(1, index + 1).join('/');
return _react2['default'].createElement( return _react2['default'].createElement(
@ -30247,9 +30261,9 @@ var Breadcrumb = (function (_Component) {
), ),
dir dir
); );
}); }));
var lastDirectories = this.props.lwd.split('/').filter(function (a) { var lastDirectories = _this.props.lwd.split('/').filter(function (a) {
return a; return a;
}); });
if (lastDirectories.length > directories.length - 1) { if (lastDirectories.length > directories.length - 1) {
@ -30273,6 +30287,8 @@ var Breadcrumb = (function (_Component) {
els = els.concat(_history); els = els.concat(_history);
} }
})();
}
return _react2['default'].createElement( return _react2['default'].createElement(
'div', 'div',
@ -30280,7 +30296,6 @@ var Breadcrumb = (function (_Component) {
_react2['default'].createElement( _react2['default'].createElement(
'div', 'div',
null, null,
_react2['default'].createElement('span', { onClick: this.goUp, className: 'icon-up' }),
els els
) )
); );
@ -30307,7 +30322,8 @@ exports['default'] = Breadcrumb;
function props(state) { function props(state) {
return { return {
lwd: state.get('lwd'), // last working directory lwd: state.get('lwd'), // last working directory
cwd: state.get('cwd') cwd: state.get('cwd'),
search: state.get('search')
}; };
} }
module.exports = exports['default']; module.exports = exports['default'];
@ -32389,6 +32405,10 @@ exports['default'] = function (state, action) {
return action.keywords; return action.keywords;
} }
if (action.type === _actionsTypes.CHANGE_DIRECTORY || action.type === _actionsTypes.REFRESH) {
return '';
}
return state; return state;
}; };
@ -32407,7 +32427,7 @@ function search(keywords) {
// We don't want to show all the currently visible files from the // We don't want to show all the currently visible files from the
// first iteration // first iteration
var once = true; var once = true;
(0, _apiFiles.children)('/', true).then(function showResults(files) { (0, _apiFiles.children)('', true).then(function showResults(files) {
if (!_store2['default'].getState().get('search')) return; if (!_store2['default'].getState().get('search')) return;
var current = once ? [] : _store2['default'].getState().get('files'); var current = once ? [] : _store2['default'].getState().get('files');

Binary file not shown.

View File

@ -3,14 +3,24 @@ 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() {
let els = [];
if (this.props.search) {
console.log('search');
els = [
<span key='000'>Search: {this.props.search}</span>
]
} else {
els.unshift(<span onClick={this.goUp} className='icon-up' key='000'></span>);
let directories = this.props.cwd.split('/').filter(a => a); let directories = this.props.cwd.split('/').filter(a => a);
directories.unshift('sdcard'); directories.unshift('sdcard');
let els = directories.map((dir, index, arr) => { els = els.concat(directories.map((dir, index, arr) => {
let path = arr.slice(1, index + 1).join('/'); let path = arr.slice(1, index + 1).join('/');
return ( return (
@ -18,7 +28,7 @@ export default class Breadcrumb extends Component {
<i>/</i>{dir} <i>/</i>{dir}
</span> </span>
); );
}); }));
let lastDirectories = this.props.lwd.split('/').filter(a => a); let lastDirectories = this.props.lwd.split('/').filter(a => a);
if (lastDirectories.length > directories.length - 1) { if (lastDirectories.length > directories.length - 1) {
@ -37,11 +47,11 @@ export default class Breadcrumb extends Component {
els = els.concat(history); els = els.concat(history);
} }
}
return ( return (
<div className='breadcrumb'> <div className='breadcrumb'>
<div> <div>
<span onClick={this.goUp} className='icon-up'></span>
{els} {els}
</div> </div>
</div> </div>
@ -61,6 +71,7 @@ export default class Breadcrumb extends Component {
function props(state) { function props(state) {
return { return {
lwd: state.get('lwd'), // last working directory lwd: state.get('lwd'), // last working directory
cwd: state.get('cwd') cwd: state.get('cwd'),
search: state.get('search')
} }
} }

View File

@ -1,4 +1,4 @@
import { SEARCH } from 'actions/types'; import { SEARCH, CHANGE_DIRECTORY, REFRESH } from 'actions/types';
import store from 'store'; import store from 'store';
import { reportError } from 'utils'; import { reportError } from 'utils';
import { listFiles } from 'actions/files-view'; import { listFiles } from 'actions/files-view';
@ -12,6 +12,10 @@ export default function(state = '', action) {
return action.keywords; return action.keywords;
} }
if (action.type === CHANGE_DIRECTORY || action.type === REFRESH) {
return '';
}
return state; return state;
} }
@ -28,7 +32,7 @@ function search(keywords) {
// We don't want to show all the currently visible files from the // We don't want to show all the currently visible files from the
// first iteration // first iteration
let once = true; let once = true;
children('/', true).then(function showResults(files) { children('', true).then(function showResults(files) {
if (!store.getState().get('search')) return; if (!store.getState().get('search')) return;
let current = once ? [] : store.getState().get('files'); let current = once ? [] : store.getState().get('files');