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:
parent
92b5fa2fee
commit
cb30112c40
@ -30215,8 +30215,6 @@ var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir);
|
||||
|
||||
var _store = require('store');
|
||||
|
||||
// TODO: Fix history not working when clicking on sdcard
|
||||
|
||||
var Breadcrumb = (function (_Component) {
|
||||
_inherits(Breadcrumb, _Component);
|
||||
|
||||
@ -30229,12 +30227,28 @@ var Breadcrumb = (function (_Component) {
|
||||
_createClass(Breadcrumb, [{
|
||||
key: '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;
|
||||
});
|
||||
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('/');
|
||||
|
||||
return _react2['default'].createElement(
|
||||
@ -30247,9 +30261,9 @@ var Breadcrumb = (function (_Component) {
|
||||
),
|
||||
dir
|
||||
);
|
||||
});
|
||||
}));
|
||||
|
||||
var lastDirectories = this.props.lwd.split('/').filter(function (a) {
|
||||
var lastDirectories = _this.props.lwd.split('/').filter(function (a) {
|
||||
return a;
|
||||
});
|
||||
if (lastDirectories.length > directories.length - 1) {
|
||||
@ -30273,6 +30287,8 @@ var Breadcrumb = (function (_Component) {
|
||||
|
||||
els = els.concat(_history);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
return _react2['default'].createElement(
|
||||
'div',
|
||||
@ -30280,7 +30296,6 @@ var Breadcrumb = (function (_Component) {
|
||||
_react2['default'].createElement(
|
||||
'div',
|
||||
null,
|
||||
_react2['default'].createElement('span', { onClick: this.goUp, className: 'icon-up' }),
|
||||
els
|
||||
)
|
||||
);
|
||||
@ -30307,7 +30322,8 @@ exports['default'] = Breadcrumb;
|
||||
function props(state) {
|
||||
return {
|
||||
lwd: state.get('lwd'), // last working directory
|
||||
cwd: state.get('cwd')
|
||||
cwd: state.get('cwd'),
|
||||
search: state.get('search')
|
||||
};
|
||||
}
|
||||
module.exports = exports['default'];
|
||||
@ -32389,6 +32405,10 @@ exports['default'] = function (state, action) {
|
||||
return action.keywords;
|
||||
}
|
||||
|
||||
if (action.type === _actionsTypes.CHANGE_DIRECTORY || action.type === _actionsTypes.REFRESH) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
@ -32407,7 +32427,7 @@ function search(keywords) {
|
||||
// We don't want to show all the currently visible files from the
|
||||
// first iteration
|
||||
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;
|
||||
|
||||
var current = once ? [] : _store2['default'].getState().get('files');
|
||||
|
Binary file not shown.
@ -3,14 +3,24 @@ 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() {
|
||||
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);
|
||||
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('/');
|
||||
|
||||
return (
|
||||
@ -18,7 +28,7 @@ export default class Breadcrumb extends Component {
|
||||
<i>/</i>{dir}
|
||||
</span>
|
||||
);
|
||||
});
|
||||
}));
|
||||
|
||||
let lastDirectories = this.props.lwd.split('/').filter(a => a);
|
||||
if (lastDirectories.length > directories.length - 1) {
|
||||
@ -37,11 +47,11 @@ export default class Breadcrumb extends Component {
|
||||
|
||||
els = els.concat(history);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='breadcrumb'>
|
||||
<div>
|
||||
<span onClick={this.goUp} className='icon-up'></span>
|
||||
{els}
|
||||
</div>
|
||||
</div>
|
||||
@ -61,6 +71,7 @@ export default class Breadcrumb extends Component {
|
||||
function props(state) {
|
||||
return {
|
||||
lwd: state.get('lwd'), // last working directory
|
||||
cwd: state.get('cwd')
|
||||
cwd: state.get('cwd'),
|
||||
search: state.get('search')
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { SEARCH } from 'actions/types';
|
||||
import { SEARCH, CHANGE_DIRECTORY, REFRESH } from 'actions/types';
|
||||
import store from 'store';
|
||||
import { reportError } from 'utils';
|
||||
import { listFiles } from 'actions/files-view';
|
||||
@ -12,6 +12,10 @@ export default function(state = '', action) {
|
||||
return action.keywords;
|
||||
}
|
||||
|
||||
if (action.type === CHANGE_DIRECTORY || action.type === REFRESH) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -28,7 +32,7 @@ function search(keywords) {
|
||||
// We don't want to show all the currently visible files from the
|
||||
// first iteration
|
||||
let once = true;
|
||||
children('/', true).then(function showResults(files) {
|
||||
children('', true).then(function showResults(files) {
|
||||
if (!store.getState().get('search')) return;
|
||||
|
||||
let current = once ? [] : store.getState().get('files');
|
||||
|
Loading…
Reference in New Issue
Block a user