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