Merge pull request #258 from mattermost/experiment/search-box

CTRL/CMD+F on Desktop app puts cursor in Mattermost search box filtered to channel

Close #229
This commit is contained in:
Yuya Ochiai
2016-08-22 20:27:37 +09:00
committed by GitHub
5 changed files with 34 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ Release date: TBD
- Reload only the selected tab and keep its URL on "Reload" and "Clear Cache and Reload". - Reload only the selected tab and keep its URL on "Reload" and "Clear Cache and Reload".
- Disabled `eval()` function for security improvements. - Disabled `eval()` function for security improvements.
- Invalidate cache before load, to make server upgrades easy - Invalidate cache before load, to make server upgrades easy
- Ctrl/Command+F puts cursor in search box to search in current channel.
#### Windows #### Windows
- Update Mattermost icon for desktop notifications in Windows 10. - Update Mattermost icon for desktop notifications in Windows 10.

View File

@@ -149,6 +149,7 @@ Below lists menu options (shortcut keys are listed in brackets, `Ctrl` becomes `
- **Copy** (Ctrl+C) - Copies selected text - **Copy** (Ctrl+C) - Copies selected text
- **Paste** (Ctrl+V) - Pastes text from clipboard - **Paste** (Ctrl+V) - Pastes text from clipboard
- **Select All** (Ctrl+A) - Select all text in input box - **Select All** (Ctrl+A) - Select all text in input box
- **Search in Channel** (Ctrl+F) - Puts cursor in search box to search in current channel
- **View** - **View**
- **Reload** (Ctrl+R) - Reload page from the server - **Reload** (Ctrl+R) - Reload page from the server
- **Clear Cache and Reload** (Ctrl+Shift+R) - Clear cached content in application and reload page - **Clear Cache and Reload** (Ctrl+Shift+R) - Clear cached content in application and reload page

View File

@@ -75,6 +75,12 @@ var MainPage = React.createClass({
this.refs[`mattermostView${this.state.key}`].clearCacheAndReload(); this.refs[`mattermostView${this.state.key}`].clearCacheAndReload();
}); });
// activate search box in current tab
ipcRenderer.on('activate-search-box', (event) => {
let webview = document.getElementById('mattermostView' + thisObj.state.key);
webview.send('activate-search-box');
});
var focusListener = function() { var focusListener = function() {
var webview = document.getElementById('mattermostView' + thisObj.state.key); var webview = document.getElementById('mattermostView' + thisObj.state.key);
webview.focus(); webview.focus();

View File

@@ -127,3 +127,20 @@ notification.override({
ipc.sendToHost('onNotificationClick'); ipc.sendToHost('onNotificationClick');
} }
}); });
// get the last of href for the current channel in the sidebar.
function getCurrentChannelString() {
const active_channel_link = document.querySelector('.active a.sidebar-channel');
const url_elements = active_channel_link.href.split('/');
return url_elements[url_elements.length - 1];
}
ipc.on('activate-search-box', (event) => {
const search_boxes = document.getElementsByClassName('search-bar'); // should use id
if (search_boxes.length === 0) {
return;
}
const search_box = search_boxes[0];
search_box.focus();
search_box.value = `in:${getCurrentChannelString()} `;
});

View File

@@ -69,7 +69,15 @@ var createTemplate = function(mainWindow, config) {
role: 'paste' role: 'paste'
}, { }, {
role: 'selectall' role: 'selectall'
}, ] }, separatorItem, {
label: 'Search in Channel',
accelerator: 'CmdOrCtrl+F',
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.send('activate-search-box');
}
}
}]
}); });
template.push({ template.push({
label: '&View', label: '&View',