show find in console
This commit is contained in:
parent
cb4b26e03f
commit
be37c42d28
11 changed files with 45 additions and 9 deletions
|
@ -65,6 +65,10 @@ const exec = (operation, tab) => {
|
||||||
return sendConsoleShowCommand(tab, 'winopen ');
|
return sendConsoleShowCommand(tab, 'winopen ');
|
||||||
case operations.COMMAND_SHOW_BUFFER:
|
case operations.COMMAND_SHOW_BUFFER:
|
||||||
return sendConsoleShowCommand(tab, 'buffer ');
|
return sendConsoleShowCommand(tab, 'buffer ');
|
||||||
|
case operations.FIND_START:
|
||||||
|
return browser.tabs.sendMessage(tab.id, {
|
||||||
|
type: messages.CONSOLE_SHOW_FIND
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,12 @@ const showCommand = (text) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showFind = () => {
|
||||||
|
return {
|
||||||
|
type: actions.CONSOLE_SHOW_FIND,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const showError = (text) => {
|
const showError = (text) => {
|
||||||
return {
|
return {
|
||||||
type: actions.CONSOLE_SHOW_ERROR,
|
type: actions.CONSOLE_SHOW_ERROR,
|
||||||
|
@ -47,6 +53,6 @@ const completionPrev = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
showCommand, showError, showInfo, hideCommand,
|
showCommand, showFind, showError, showInfo, hideCommand,
|
||||||
setCompletions, completionNext, completionPrev
|
setCompletions, completionNext, completionPrev
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,4 +7,5 @@ export default {
|
||||||
CONSOLE_SET_COMPLETIONS: 'console.set.completions',
|
CONSOLE_SET_COMPLETIONS: 'console.set.completions',
|
||||||
CONSOLE_COMPLETION_NEXT: 'console.completion.next',
|
CONSOLE_COMPLETION_NEXT: 'console.completion.next',
|
||||||
CONSOLE_COMPLETION_PREV: 'console.completion.prev',
|
CONSOLE_COMPLETION_PREV: 'console.completion.prev',
|
||||||
|
CONSOLE_SHOW_FIND: 'console.show.find',
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,8 +68,10 @@ export default class ConsoleComponent {
|
||||||
update() {
|
update() {
|
||||||
let state = this.store.getState();
|
let state = this.store.getState();
|
||||||
if (this.prevState.mode !== 'command' && state.mode === 'command') {
|
if (this.prevState.mode !== 'command' && state.mode === 'command') {
|
||||||
this.showCommand(state.commandText);
|
this.showCommand(state.consoleText);
|
||||||
} else if (state.mode !== 'command') {
|
} else if (this.prevState.mode !== 'find' && state.mode === 'find') {
|
||||||
|
this.showFind();
|
||||||
|
} else if (state.mode !== 'command' && state.mode !== 'find') {
|
||||||
this.hideCommand();
|
this.hideCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ const onMessage = (message) => {
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case messages.CONSOLE_SHOW_COMMAND:
|
case messages.CONSOLE_SHOW_COMMAND:
|
||||||
return store.dispatch(consoleActions.showCommand(message.command));
|
return store.dispatch(consoleActions.showCommand(message.command));
|
||||||
|
case messages.CONSOLE_SHOW_FIND:
|
||||||
|
return store.dispatch(consoleActions.showFind());
|
||||||
case messages.CONSOLE_SHOW_ERROR:
|
case messages.CONSOLE_SHOW_ERROR:
|
||||||
return store.dispatch(consoleActions.showError(message.text));
|
return store.dispatch(consoleActions.showError(message.text));
|
||||||
case messages.CONSOLE_SHOW_INFO:
|
case messages.CONSOLE_SHOW_INFO:
|
||||||
|
|
|
@ -3,7 +3,7 @@ import actions from 'console/actions';
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
mode: '',
|
mode: '',
|
||||||
messageText: '',
|
messageText: '',
|
||||||
commandText: '',
|
consoleText: '',
|
||||||
completions: [],
|
completions: [],
|
||||||
groupSelection: -1,
|
groupSelection: -1,
|
||||||
itemSelection: -1,
|
itemSelection: -1,
|
||||||
|
@ -48,8 +48,13 @@ export default function reducer(state = defaultState, action = {}) {
|
||||||
case actions.CONSOLE_SHOW_COMMAND:
|
case actions.CONSOLE_SHOW_COMMAND:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
mode: 'command',
|
mode: 'command',
|
||||||
commandText: action.text,
|
consoleText: action.text,
|
||||||
errorShown: false,
|
completions: []
|
||||||
|
});
|
||||||
|
case actions.CONSOLE_SHOW_FIND:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
mode: 'find',
|
||||||
|
consoleText: '',
|
||||||
completions: []
|
completions: []
|
||||||
});
|
});
|
||||||
case actions.CONSOLE_SHOW_ERROR:
|
case actions.CONSOLE_SHOW_ERROR:
|
||||||
|
@ -64,7 +69,7 @@ export default function reducer(state = defaultState, action = {}) {
|
||||||
});
|
});
|
||||||
case actions.CONSOLE_HIDE_COMMAND:
|
case actions.CONSOLE_HIDE_COMMAND:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
mode: state.mode === 'command' ? '' : state.mode,
|
mode: state.mode === 'command' || state.mode === 'find' ? '' : state.mode,
|
||||||
});
|
});
|
||||||
case actions.CONSOLE_SET_COMPLETIONS:
|
case actions.CONSOLE_SET_COMPLETIONS:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
|
|
|
@ -46,6 +46,9 @@ export default {
|
||||||
"gu": { "type": "navigate.parent" },
|
"gu": { "type": "navigate.parent" },
|
||||||
"gU": { "type": "navigate.root" },
|
"gU": { "type": "navigate.root" },
|
||||||
"y": { "type": "urls.yank" },
|
"y": { "type": "urls.yank" },
|
||||||
|
"/": { "type": "find.start" },
|
||||||
|
"n": { "type": "find.next" },
|
||||||
|
"N": { "type": "find.prev" },
|
||||||
"<S-Esc>": { "type": "addon.toggle.enabled" }
|
"<S-Esc>": { "type": "addon.toggle.enabled" }
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
|
|
|
@ -31,6 +31,7 @@ export default {
|
||||||
CONSOLE_SHOW_ERROR: 'console.show.error',
|
CONSOLE_SHOW_ERROR: 'console.show.error',
|
||||||
CONSOLE_SHOW_INFO: 'console.show.info',
|
CONSOLE_SHOW_INFO: 'console.show.info',
|
||||||
CONSOLE_HIDE_COMMAND: 'console.hide.command',
|
CONSOLE_HIDE_COMMAND: 'console.hide.command',
|
||||||
|
CONSOLE_SHOW_FIND: 'console.show.find',
|
||||||
|
|
||||||
FOLLOW_START: 'follow.start',
|
FOLLOW_START: 'follow.start',
|
||||||
FOLLOW_REQUEST_COUNT_TARGETS: 'follow.request.count.targets',
|
FOLLOW_REQUEST_COUNT_TARGETS: 'follow.request.count.targets',
|
||||||
|
|
|
@ -51,4 +51,9 @@ export default {
|
||||||
|
|
||||||
// Url yank
|
// Url yank
|
||||||
URLS_YANK: 'urls.yank',
|
URLS_YANK: 'urls.yank',
|
||||||
|
|
||||||
|
// Find
|
||||||
|
FIND_START: 'find.start',
|
||||||
|
FIND_NEXT: 'find.next',
|
||||||
|
FIND_PREV: 'find.prev',
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,6 +11,13 @@ describe("console actions", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("showFind", () => {
|
||||||
|
it('create CONSOLE_SHOW_FIND action', () => {
|
||||||
|
let action = consoleActions.showFind();
|
||||||
|
expect(action.type).to.equal(actions.CONSOLE_SHOW_FIND);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("showInfo", () => {
|
describe("showInfo", () => {
|
||||||
it('create CONSOLE_SHOW_INFO action', () => {
|
it('create CONSOLE_SHOW_INFO action', () => {
|
||||||
let action = consoleActions.showInfo('an info');
|
let action = consoleActions.showInfo('an info');
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe("console reducer", () => {
|
||||||
let state = reducer(undefined, {});
|
let state = reducer(undefined, {});
|
||||||
expect(state).to.have.property('mode', '');
|
expect(state).to.have.property('mode', '');
|
||||||
expect(state).to.have.property('messageText', '');
|
expect(state).to.have.property('messageText', '');
|
||||||
expect(state).to.have.property('commandText', '');
|
expect(state).to.have.property('consoleText', '');
|
||||||
expect(state).to.have.deep.property('completions', []);
|
expect(state).to.have.deep.property('completions', []);
|
||||||
expect(state).to.have.property('groupSelection', -1);
|
expect(state).to.have.property('groupSelection', -1);
|
||||||
expect(state).to.have.property('itemSelection', -1);
|
expect(state).to.have.property('itemSelection', -1);
|
||||||
|
@ -17,7 +17,7 @@ describe("console reducer", () => {
|
||||||
let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' };
|
let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' };
|
||||||
let state = reducer({}, action);
|
let state = reducer({}, action);
|
||||||
expect(state).to.have.property('mode', 'command');
|
expect(state).to.have.property('mode', 'command');
|
||||||
expect(state).to.have.property('commandText', 'open ');
|
expect(state).to.have.property('consoleText', 'open ');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return next state for CONSOLE_SHOW_INFO', () => {
|
it('return next state for CONSOLE_SHOW_INFO', () => {
|
||||||
|
|
Reference in a new issue