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
102
build/main.js
102
build/main.js
@ -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,49 +30227,67 @@ var Breadcrumb = (function (_Component) {
|
||||
_createClass(Breadcrumb, [{
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var directories = this.props.cwd.split('/').filter(function (a) {
|
||||
return a;
|
||||
});
|
||||
directories.unshift('sdcard');
|
||||
var _this = this;
|
||||
|
||||
var els = directories.map(function (dir, index, arr) {
|
||||
var path = arr.slice(1, index + 1).join('/');
|
||||
var els = [];
|
||||
|
||||
return _react2['default'].createElement(
|
||||
if (this.props.search) {
|
||||
console.log('search');
|
||||
els = [_react2['default'].createElement(
|
||||
'span',
|
||||
{ key: index, onClick: (0, _store.bind)((0, _actionsChangedir2['default'])(path)) },
|
||||
_react2['default'].createElement(
|
||||
'i',
|
||||
null,
|
||||
'/'
|
||||
),
|
||||
dir
|
||||
);
|
||||
});
|
||||
{ key: '000' },
|
||||
'Search: ',
|
||||
this.props.search
|
||||
)];
|
||||
} else {
|
||||
(function () {
|
||||
els.unshift(_react2['default'].createElement('span', { onClick: _this.goUp, className: 'icon-up', key: '000' }));
|
||||
|
||||
var lastDirectories = this.props.lwd.split('/').filter(function (a) {
|
||||
return a;
|
||||
});
|
||||
if (lastDirectories.length > directories.length - 1) {
|
||||
lastDirectories.splice(0, directories.length - 1);
|
||||
var directories = _this.props.cwd.split('/').filter(function (a) {
|
||||
return a;
|
||||
});
|
||||
directories.unshift('sdcard');
|
||||
|
||||
var _history = lastDirectories.map(function (dir, index, arr) {
|
||||
var current = directories.slice(1).concat(arr.slice(0, index + 1));
|
||||
var path = current.join('/').replace(/^\//, ''); // remove starting slash
|
||||
els = els.concat(directories.map(function (dir, index, arr) {
|
||||
var path = arr.slice(1, index + 1).join('/');
|
||||
|
||||
return _react2['default'].createElement(
|
||||
'span',
|
||||
{ key: directories.length + index, className: 'history', onClick: (0, _store.bind)((0, _actionsChangedir2['default'])(path)) },
|
||||
_react2['default'].createElement(
|
||||
'i',
|
||||
null,
|
||||
'/'
|
||||
),
|
||||
dir
|
||||
);
|
||||
});
|
||||
return _react2['default'].createElement(
|
||||
'span',
|
||||
{ key: index, onClick: (0, _store.bind)((0, _actionsChangedir2['default'])(path)) },
|
||||
_react2['default'].createElement(
|
||||
'i',
|
||||
null,
|
||||
'/'
|
||||
),
|
||||
dir
|
||||
);
|
||||
}));
|
||||
|
||||
els = els.concat(_history);
|
||||
var lastDirectories = _this.props.lwd.split('/').filter(function (a) {
|
||||
return a;
|
||||
});
|
||||
if (lastDirectories.length > directories.length - 1) {
|
||||
lastDirectories.splice(0, directories.length - 1);
|
||||
|
||||
var _history = lastDirectories.map(function (dir, index, arr) {
|
||||
var current = directories.slice(1).concat(arr.slice(0, index + 1));
|
||||
var path = current.join('/').replace(/^\//, ''); // remove starting slash
|
||||
|
||||
return _react2['default'].createElement(
|
||||
'span',
|
||||
{ key: directories.length + index, className: 'history', onClick: (0, _store.bind)((0, _actionsChangedir2['default'])(path)) },
|
||||
_react2['default'].createElement(
|
||||
'i',
|
||||
null,
|
||||
'/'
|
||||
),
|
||||
dir
|
||||
);
|
||||
});
|
||||
|
||||
els = els.concat(_history);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
return _react2['default'].createElement(
|
||||
@ -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,45 +3,55 @@ 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 directories = this.props.cwd.split('/').filter(a => a);
|
||||
directories.unshift('sdcard');
|
||||
let els = [];
|
||||
|
||||
let els = directories.map((dir, index, arr) => {
|
||||
let path = arr.slice(1, index + 1).join('/');
|
||||
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>);
|
||||
|
||||
return (
|
||||
<span key={index} onClick={bind(changedir(path))}>
|
||||
<i>/</i>{dir}
|
||||
</span>
|
||||
);
|
||||
});
|
||||
|
||||
let lastDirectories = this.props.lwd.split('/').filter(a => a);
|
||||
if (lastDirectories.length > directories.length - 1) {
|
||||
lastDirectories.splice(0, directories.length - 1);
|
||||
let directories = this.props.cwd.split('/').filter(a => a);
|
||||
directories.unshift('sdcard');
|
||||
|
||||
let history = lastDirectories.map((dir, index, arr) => {
|
||||
let current = directories.slice(1).concat(arr.slice(0, index + 1));
|
||||
let path = current.join('/').replace(/^\//, ''); // remove starting slash
|
||||
els = els.concat(directories.map((dir, index, arr) => {
|
||||
let path = arr.slice(1, index + 1).join('/');
|
||||
|
||||
return (
|
||||
<span key={directories.length + index} className='history' onClick={bind(changedir(path))}>
|
||||
<span key={index} onClick={bind(changedir(path))}>
|
||||
<i>/</i>{dir}
|
||||
</span>
|
||||
)
|
||||
});
|
||||
);
|
||||
}));
|
||||
|
||||
els = els.concat(history);
|
||||
let lastDirectories = this.props.lwd.split('/').filter(a => a);
|
||||
if (lastDirectories.length > directories.length - 1) {
|
||||
lastDirectories.splice(0, directories.length - 1);
|
||||
|
||||
let history = lastDirectories.map((dir, index, arr) => {
|
||||
let current = directories.slice(1).concat(arr.slice(0, index + 1));
|
||||
let path = current.join('/').replace(/^\//, ''); // remove starting slash
|
||||
|
||||
return (
|
||||
<span key={directories.length + index} className='history' onClick={bind(changedir(path))}>
|
||||
<i>/</i>{dir}
|
||||
</span>
|
||||
)
|
||||
});
|
||||
|
||||
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