Restore 'e' to edit current document

Fixed up ? to open keyboard shortcuts
This commit is contained in:
Tom Moor
2017-07-14 08:48:42 -07:00
parent 4992ceab69
commit 9f18bd2fb1
3 changed files with 26 additions and 10 deletions

View File

@ -9,6 +9,7 @@ import _ from 'lodash';
import keydown from 'react-keydown'; import keydown from 'react-keydown';
import Flex from 'components/Flex'; import Flex from 'components/Flex';
import { color, layout } from 'styles/constants'; import { color, layout } from 'styles/constants';
import { documentEditUrl, homeUrl, searchUrl } from 'utils/routeHelpers';
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
import { LoadingIndicatorBar } from 'components/LoadingIndicator'; import { LoadingIndicatorBar } from 'components/LoadingIndicator';
@ -51,15 +52,21 @@ type Props = {
@observable modal = null; @observable modal = null;
@keydown(['/', 't']) @keydown(['/', 't'])
search() { goToSearch(ev) {
if (this.props.auth.authenticated) ev.preventDefault();
_.defer(() => this.props.history.push('/search')); ev.stopPropagation();
this.props.history.push(searchUrl());
} }
@keydown('d') @keydown('d')
dashboard() { goToDashboard() {
if (this.props.auth.authenticated) this.props.history.push(homeUrl());
_.defer(() => this.props.history.push('/')); }
@keydown('e')
goToEdit() {
if (!this.props.ui.activeDocument) return;
this.props.history.push(documentEditUrl(this.props.ui.activeDocument));
} }
handleLogout = () => { handleLogout = () => {
@ -67,9 +74,9 @@ type Props = {
}; };
@keydown('shift+/') @keydown('shift+/')
handleOpenKeyboardShortcuts = () => { handleOpenKeyboardShortcuts() {
this.modal = 'keyboard-shortcuts'; this.modal = 'keyboard-shortcuts';
}; }
handleCreateCollection = () => { handleCreateCollection = () => {
this.modal = 'create-collection'; this.modal = 'create-collection';

View File

@ -1,5 +1,5 @@
- `Cmd+Enter` - Save and exit document editor - `Cmd+Enter` - Save and exit document editor
- `Cmd+s` - Save document and continue editing - `Cmd+S` - Save document and continue editing
- `Cmd+Esc` - Cancel edit - `Cmd+Esc` - Cancel edit
- `/` or `t` - Jump to search - `/` or `t` - Jump to search
- `d` - Jump to dashboard - `d` - Jump to dashboard

View File

@ -1,4 +1,5 @@
// @flow // @flow
import Document from 'models/Document';
export function homeUrl(): string { export function homeUrl(): string {
return '/dashboard'; return '/dashboard';
@ -12,7 +13,15 @@ export function newCollectionUrl(): string {
return '/collections/new'; return '/collections/new';
} }
export function searchUrl(query: string): string { export function documentUrl(doc: Document): string {
return doc.url;
}
export function documentEditUrl(doc: Document): string {
return `${doc.url}/edit`;
}
export function searchUrl(query?: string): string {
if (query) return `/search/${query}`; if (query) return `/search/${query}`;
return `/search`; return `/search`;
} }