Dropdown menu refactors
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observable } from 'mobx';
|
import { observable } from 'mobx';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
|
import keydown from 'react-keydown';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import Flex from 'components/Flex';
|
import Flex from 'components/Flex';
|
||||||
import { color } from 'styles/constants';
|
import { color } from 'styles/constants';
|
||||||
@ -15,22 +16,30 @@ type DropdownMenuProps = {
|
|||||||
|
|
||||||
@observer class DropdownMenu extends React.Component {
|
@observer class DropdownMenu extends React.Component {
|
||||||
props: DropdownMenuProps;
|
props: DropdownMenuProps;
|
||||||
@observable menuOpen: boolean = false;
|
@observable open: boolean = false;
|
||||||
|
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
this.menuOpen = !this.menuOpen;
|
this.open = !this.open;
|
||||||
|
};
|
||||||
|
|
||||||
|
@keydown('esc')
|
||||||
|
handleEscape() {
|
||||||
|
this.open = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClickOutside = (ev: SyntheticEvent) => {
|
||||||
|
ev.stopPropagation();
|
||||||
|
this.open = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<MenuContainer onClick={this.handleClick}>
|
<MenuContainer onClick={this.handleClick}>
|
||||||
{this.menuOpen && <Backdrop />}
|
{this.open && <Backdrop onClick={this.handleClickOutside} />}
|
||||||
|
|
||||||
<Label>
|
<Label>
|
||||||
{this.props.label}
|
{this.props.label}
|
||||||
</Label>
|
</Label>
|
||||||
|
{this.open &&
|
||||||
{this.menuOpen &&
|
|
||||||
<Menu style={this.props.style}>
|
<Menu style={this.props.style}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</Menu>}
|
</Menu>}
|
||||||
|
@ -22,6 +22,7 @@ const MenuItem = styled.div`
|
|||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
|
|
||||||
|
color: ${color.slateDark};
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -1,31 +1,26 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link, withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { observer, inject } from 'mobx-react';
|
import { observer, inject } from 'mobx-react';
|
||||||
import { observable } from 'mobx';
|
|
||||||
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 { documentEditUrl, homeUrl, searchUrl } from 'utils/routeHelpers';
|
||||||
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
|
||||||
|
|
||||||
import Avatar from 'components/Avatar';
|
import Avatar from 'components/Avatar';
|
||||||
import { LoadingIndicatorBar } from 'components/LoadingIndicator';
|
import { LoadingIndicatorBar } from 'components/LoadingIndicator';
|
||||||
import Scrollable from 'components/Scrollable';
|
import Scrollable from 'components/Scrollable';
|
||||||
import Modal from 'components/Modal';
|
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import CollectionNew from 'scenes/CollectionNew';
|
import CollectionMenu from 'menus/CollectionMenu';
|
||||||
import CollectionEdit from 'scenes/CollectionEdit';
|
import AccountMenu from 'menus/AccountMenu';
|
||||||
import KeyboardShortcuts from 'scenes/KeyboardShortcuts';
|
|
||||||
import Settings from 'scenes/Settings';
|
|
||||||
|
|
||||||
import SidebarCollection from './components/SidebarCollection';
|
import SidebarCollection from './components/SidebarCollection';
|
||||||
import SidebarCollectionList from './components/SidebarCollectionList';
|
import SidebarCollectionList from './components/SidebarCollectionList';
|
||||||
import SidebarLink from './components/SidebarLink';
|
import SidebarLink from './components/SidebarLink';
|
||||||
import HeaderBlock from './components/HeaderBlock';
|
import HeaderBlock from './components/HeaderBlock';
|
||||||
|
import Modals from './components/Modals';
|
||||||
|
|
||||||
import AuthStore from 'stores/AuthStore';
|
import AuthStore from 'stores/AuthStore';
|
||||||
import UiStore from 'stores/UiStore';
|
import UiStore from 'stores/UiStore';
|
||||||
@ -52,8 +47,6 @@ type Props = {
|
|||||||
search: true,
|
search: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@observable modal = null;
|
|
||||||
|
|
||||||
@keydown(['/', 't'])
|
@keydown(['/', 't'])
|
||||||
goToSearch(ev) {
|
goToSearch(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
@ -76,37 +69,21 @@ type Props = {
|
|||||||
this.props.history.push(documentEditUrl(activeDocument));
|
this.props.history.push(documentEditUrl(activeDocument));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLogout = () => {
|
|
||||||
this.props.auth.logout(() => this.props.history.push('/'));
|
|
||||||
};
|
|
||||||
|
|
||||||
@keydown('shift+/')
|
@keydown('shift+/')
|
||||||
goToOpenKeyboardShortcuts() {
|
goToOpenKeyboardShortcuts() {
|
||||||
this.modal = 'keyboard-shortcuts';
|
this.props.ui.setActiveModal('keyboard-shortcuts');
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOpenKeyboardShortcuts = () => {
|
|
||||||
this.goToOpenKeyboardShortcuts();
|
|
||||||
};
|
|
||||||
|
|
||||||
handleOpenSettings = () => {
|
|
||||||
this.modal = 'settings';
|
|
||||||
};
|
|
||||||
|
|
||||||
handleCreateCollection = () => {
|
handleCreateCollection = () => {
|
||||||
this.modal = 'create-collection';
|
this.props.ui.setActiveModal('create-collection');
|
||||||
};
|
};
|
||||||
|
|
||||||
handleEditCollection = () => {
|
handleEditCollection = () => {
|
||||||
this.modal = 'edit-collection';
|
this.props.ui.setActiveModal('edit-collection');
|
||||||
};
|
|
||||||
|
|
||||||
handleCloseModal = () => {
|
|
||||||
this.modal = null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { auth, documents, collections, history, ui } = this.props;
|
const { auth, documents, collections, ui } = this.props;
|
||||||
const { user, team } = auth;
|
const { user, team } = auth;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -130,27 +107,13 @@ type Props = {
|
|||||||
user &&
|
user &&
|
||||||
team &&
|
team &&
|
||||||
<Sidebar column editMode={ui.editMode}>
|
<Sidebar column editMode={ui.editMode}>
|
||||||
<DropdownMenu
|
<AccountMenu
|
||||||
style={{ marginRight: 10, marginTop: -10 }}
|
|
||||||
label={
|
label={
|
||||||
<HeaderBlock user={user} team={team}>
|
<HeaderBlock user={user} team={team}>
|
||||||
<Avatar src={user.avatarUrl} />
|
<Avatar src={user.avatarUrl} />
|
||||||
</HeaderBlock>
|
</HeaderBlock>
|
||||||
}
|
}
|
||||||
>
|
/>
|
||||||
<DropdownMenuItem onClick={this.handleOpenSettings}>
|
|
||||||
Settings
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={this.handleOpenKeyboardShortcuts}>
|
|
||||||
Keyboard shortcuts
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<MenuLink to="/developers">
|
|
||||||
<DropdownMenuItem>API</DropdownMenuItem>
|
|
||||||
</MenuLink>
|
|
||||||
<DropdownMenuItem onClick={this.handleLogout}>
|
|
||||||
Logout
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
<Flex column>
|
<Flex column>
|
||||||
<Scrollable>
|
<Scrollable>
|
||||||
@ -167,8 +130,8 @@ type Props = {
|
|||||||
</LinkSection>
|
</LinkSection>
|
||||||
<LinkSection>
|
<LinkSection>
|
||||||
{collections.active
|
{collections.active
|
||||||
? <CollectionAction onClick={this.handleEditCollection}>
|
? <CollectionAction>
|
||||||
<Icon type="MoreHorizontal" />
|
<CollectionMenu collection={collections.active} />
|
||||||
</CollectionAction>
|
</CollectionAction>
|
||||||
: <CollectionAction onClick={this.handleCreateCollection}>
|
: <CollectionAction onClick={this.handleCreateCollection}>
|
||||||
<Icon type="PlusCircle" />
|
<Icon type="PlusCircle" />
|
||||||
@ -189,44 +152,7 @@ type Props = {
|
|||||||
{this.props.children}
|
{this.props.children}
|
||||||
</Content>
|
</Content>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Modal
|
<Modals ui={ui} />
|
||||||
isOpen={this.modal === 'create-collection'}
|
|
||||||
onRequestClose={this.handleCloseModal}
|
|
||||||
title="Create a collection"
|
|
||||||
>
|
|
||||||
<CollectionNew
|
|
||||||
collections={collections}
|
|
||||||
history={history}
|
|
||||||
onSubmit={this.handleCloseModal}
|
|
||||||
/>
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
isOpen={this.modal === 'edit-collection'}
|
|
||||||
onRequestClose={this.handleCloseModal}
|
|
||||||
title="Edit collection"
|
|
||||||
>
|
|
||||||
{collections.active &&
|
|
||||||
<CollectionEdit
|
|
||||||
collection={collections.active}
|
|
||||||
collections={collections}
|
|
||||||
history={history}
|
|
||||||
onSubmit={this.handleCloseModal}
|
|
||||||
/>}
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
isOpen={this.modal === 'keyboard-shortcuts'}
|
|
||||||
onRequestClose={this.handleCloseModal}
|
|
||||||
title="Keyboard shortcuts"
|
|
||||||
>
|
|
||||||
<KeyboardShortcuts />
|
|
||||||
</Modal>
|
|
||||||
<Modal
|
|
||||||
isOpen={this.modal === 'settings'}
|
|
||||||
onRequestClose={this.handleCloseModal}
|
|
||||||
title="Settings"
|
|
||||||
>
|
|
||||||
<Settings />
|
|
||||||
</Modal>
|
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -255,10 +181,6 @@ const Content = styled(Flex)`
|
|||||||
transition: margin-left 200ms ease-in-out;
|
transition: margin-left 200ms ease-in-out;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const MenuLink = styled(Link)`
|
|
||||||
color: ${color.text};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Sidebar = styled(Flex)`
|
const Sidebar = styled(Flex)`
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
58
frontend/components/Layout/components/Modals.js
Normal file
58
frontend/components/Layout/components/Modals.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// @flow
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
import Modal from 'components/Modal';
|
||||||
|
import UiStore from 'stores/UiStore';
|
||||||
|
import CollectionNew from 'scenes/CollectionNew';
|
||||||
|
import CollectionEdit from 'scenes/CollectionEdit';
|
||||||
|
import KeyboardShortcuts from 'scenes/KeyboardShortcuts';
|
||||||
|
import Settings from 'scenes/Settings';
|
||||||
|
|
||||||
|
@observer class Modals extends Component {
|
||||||
|
props: {
|
||||||
|
ui: UiStore,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClose = () => {
|
||||||
|
this.props.ui.clearActiveModal();
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { activeModalName, activeModalProps } = this.props.ui;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
<Modal
|
||||||
|
isOpen={activeModalName === 'create-collection'}
|
||||||
|
onRequestClose={this.handleClose}
|
||||||
|
title="Create a collection"
|
||||||
|
>
|
||||||
|
<CollectionNew onSubmit={this.handleClose} {...activeModalProps} />
|
||||||
|
</Modal>
|
||||||
|
<Modal
|
||||||
|
isOpen={activeModalName === 'edit-collection'}
|
||||||
|
onRequestClose={this.handleClose}
|
||||||
|
title="Edit collection"
|
||||||
|
>
|
||||||
|
<CollectionEdit onSubmit={this.handleClose} {...activeModalProps} />
|
||||||
|
</Modal>
|
||||||
|
<Modal
|
||||||
|
isOpen={activeModalName === 'keyboard-shortcuts'}
|
||||||
|
onRequestClose={this.handleClose}
|
||||||
|
title="Keyboard shortcuts"
|
||||||
|
>
|
||||||
|
<KeyboardShortcuts />
|
||||||
|
</Modal>
|
||||||
|
<Modal
|
||||||
|
isOpen={activeModalName === 'settings'}
|
||||||
|
onRequestClose={this.handleClose}
|
||||||
|
title="Settings"
|
||||||
|
>
|
||||||
|
<Settings />
|
||||||
|
</Modal>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Modals;
|
@ -6,7 +6,6 @@ const Scroll = styled.div`
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
transform: translateZ(0);
|
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
53
frontend/menus/AccountMenu.js
Normal file
53
frontend/menus/AccountMenu.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// @flow
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { Link, withRouter } from 'react-router-dom';
|
||||||
|
import { inject, observer } from 'mobx-react';
|
||||||
|
import UiStore from 'stores/UiStore';
|
||||||
|
import AuthStore from 'stores/AuthStore';
|
||||||
|
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
||||||
|
|
||||||
|
@observer class AccountMenu extends Component {
|
||||||
|
props: {
|
||||||
|
label?: React$Element<any>,
|
||||||
|
history: Object,
|
||||||
|
ui: UiStore,
|
||||||
|
auth: AuthStore,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleOpenKeyboardShortcuts = () => {
|
||||||
|
this.props.ui.setActiveModal('keyboard-shortcuts');
|
||||||
|
};
|
||||||
|
|
||||||
|
handleOpenSettings = () => {
|
||||||
|
this.props.ui.setActiveModal('settings');
|
||||||
|
};
|
||||||
|
|
||||||
|
handleLogout = () => {
|
||||||
|
this.props.auth.logout();
|
||||||
|
this.props.history.push('/');
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<DropdownMenu
|
||||||
|
style={{ marginRight: 10, marginTop: -10 }}
|
||||||
|
label={this.props.label}
|
||||||
|
>
|
||||||
|
<DropdownMenuItem onClick={this.handleOpenSettings}>
|
||||||
|
Settings
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={this.handleOpenKeyboardShortcuts}>
|
||||||
|
Keyboard shortcuts
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<Link to="/developers">
|
||||||
|
<DropdownMenuItem>API documentation</DropdownMenuItem>
|
||||||
|
</Link>
|
||||||
|
<DropdownMenuItem onClick={this.handleLogout}>
|
||||||
|
Logout
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(inject('ui', 'auth')(AccountMenu));
|
43
frontend/menus/CollectionMenu.js
Normal file
43
frontend/menus/CollectionMenu.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// @flow
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
|
import { inject, observer } from 'mobx-react';
|
||||||
|
import Collection from 'models/Collection';
|
||||||
|
import UiStore from 'stores/UiStore';
|
||||||
|
import Icon from 'components/Icon';
|
||||||
|
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
||||||
|
|
||||||
|
@observer class CollectionMenu extends Component {
|
||||||
|
props: {
|
||||||
|
label?: React$Element<any>,
|
||||||
|
history: Object,
|
||||||
|
ui: UiStore,
|
||||||
|
collection: Collection,
|
||||||
|
};
|
||||||
|
|
||||||
|
onEdit = () => {
|
||||||
|
const { collection } = this.props;
|
||||||
|
this.props.ui.setActiveModal('edit-collection', { collection });
|
||||||
|
};
|
||||||
|
|
||||||
|
onDelete = () => {
|
||||||
|
const { collection } = this.props;
|
||||||
|
this.props.ui.setActiveModal('delete-collection', { collection });
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { collection, label } = this.props;
|
||||||
|
const { allowDelete } = collection;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownMenu label={label || <Icon type="MoreHorizontal" />}>
|
||||||
|
{collection &&
|
||||||
|
<DropdownMenuItem onClick={this.onEdit}>Edit</DropdownMenuItem>}
|
||||||
|
{allowDelete &&
|
||||||
|
<DropdownMenuItem onClick={this.onDelete}>Delete</DropdownMenuItem>}
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(inject('ui')(CollectionMenu));
|
@ -1,19 +1,19 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import get from 'lodash/get';
|
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
import { observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import Document from 'models/Document';
|
import Document from 'models/Document';
|
||||||
|
import UiStore from 'stores/UiStore';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
||||||
|
|
||||||
type Props = {
|
@observer class DocumentMenu extends Component {
|
||||||
history: Object,
|
props: {
|
||||||
document: Document,
|
ui: UiStore,
|
||||||
};
|
label?: React$Element<any>,
|
||||||
|
history: Object,
|
||||||
@observer class Menu extends Component {
|
document: Document,
|
||||||
props: Props;
|
};
|
||||||
|
|
||||||
onCreateDocument = () => {
|
onCreateDocument = () => {
|
||||||
this.props.history.push(`${this.props.document.collection.url}/new`);
|
this.props.history.push(`${this.props.document.collection.url}/new`);
|
||||||
@ -23,19 +23,9 @@ type Props = {
|
|||||||
this.props.history.push(`${this.props.document.url}/new`);
|
this.props.history.push(`${this.props.document.url}/new`);
|
||||||
};
|
};
|
||||||
|
|
||||||
onDelete = async () => {
|
onDelete = () => {
|
||||||
let msg;
|
const { document } = this.props;
|
||||||
if (get(this.props, 'document.collection.type') === 'atlas') {
|
this.props.ui.setActiveModal('delete-document', { document });
|
||||||
msg =
|
|
||||||
"Are you sure you want to delete this document and all it's child documents (if any)?";
|
|
||||||
} else {
|
|
||||||
msg = 'Are you sure you want to delete this document?';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (confirm(msg)) {
|
|
||||||
await this.props.document.delete();
|
|
||||||
this.props.history.push(this.props.document.collection.url);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onExport = () => {
|
onExport = () => {
|
||||||
@ -43,11 +33,11 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const collection = this.props.document.collection;
|
const { document, label } = this.props;
|
||||||
const allowDelete = this.props.document.allowDelete;
|
const { collection, allowDelete } = document;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu label={<Icon type="MoreHorizontal" />} top right>
|
<DropdownMenu label={label || <Icon type="MoreHorizontal" />}>
|
||||||
{collection &&
|
{collection &&
|
||||||
<DropdownMenuItem onClick={this.onCreateDocument}>
|
<DropdownMenuItem onClick={this.onCreateDocument}>
|
||||||
New document
|
New document
|
||||||
@ -60,4 +50,4 @@ type Props = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(Menu);
|
export default withRouter(inject('ui')(DocumentMenu));
|
@ -32,6 +32,10 @@ class Collection extends BaseModel {
|
|||||||
: this.url;
|
: this.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed get allowDelete(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
|
||||||
@action fetch = async () => {
|
@action fetch = async () => {
|
||||||
|
@ -10,7 +10,7 @@ import { color, layout } from 'styles/constants';
|
|||||||
import Document from 'models/Document';
|
import Document from 'models/Document';
|
||||||
import UiStore from 'stores/UiStore';
|
import UiStore from 'stores/UiStore';
|
||||||
import DocumentsStore from 'stores/DocumentsStore';
|
import DocumentsStore from 'stores/DocumentsStore';
|
||||||
import Menu from './components/Menu';
|
import DocumentMenu from 'menus/DocumentMenu';
|
||||||
import SaveAction from './components/SaveAction';
|
import SaveAction from './components/SaveAction';
|
||||||
import LoadingPlaceholder from 'components/LoadingPlaceholder';
|
import LoadingPlaceholder from 'components/LoadingPlaceholder';
|
||||||
import Editor from 'components/Editor';
|
import Editor from 'components/Editor';
|
||||||
@ -222,10 +222,12 @@ type Props = {
|
|||||||
Edit
|
Edit
|
||||||
</a>}
|
</a>}
|
||||||
</HeaderAction>
|
</HeaderAction>
|
||||||
|
{isEditing &&
|
||||||
|
<HeaderAction>
|
||||||
|
<a onClick={this.onCancel}>Cancel</a>
|
||||||
|
</HeaderAction>}
|
||||||
<HeaderAction>
|
<HeaderAction>
|
||||||
{isEditing
|
<DocumentMenu document={document} />
|
||||||
? <a onClick={this.onCancel}>Cancel</a>
|
|
||||||
: <Menu document={document} />}
|
|
||||||
</HeaderAction>
|
</HeaderAction>
|
||||||
{!isEditing && <Separator />}
|
{!isEditing && <Separator />}
|
||||||
<HeaderAction>
|
<HeaderAction>
|
||||||
|
@ -30,10 +30,9 @@ class AuthStore {
|
|||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
|
||||||
@action logout = (cb: Function) => {
|
@action logout = () => {
|
||||||
this.user = null;
|
this.user = null;
|
||||||
this.token = null;
|
this.token = null;
|
||||||
cb();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@action getOauthState = () => {
|
@action getOauthState = () => {
|
||||||
|
@ -3,12 +3,23 @@ import { observable, action } from 'mobx';
|
|||||||
import Document from 'models/Document';
|
import Document from 'models/Document';
|
||||||
|
|
||||||
class UiStore {
|
class UiStore {
|
||||||
|
@observable activeModalName: ?string;
|
||||||
|
@observable activeModalProps: ?Object;
|
||||||
@observable activeDocumentId: ?string;
|
@observable activeDocumentId: ?string;
|
||||||
@observable activeCollectionId: ?string;
|
@observable activeCollectionId: ?string;
|
||||||
@observable progressBarVisible: boolean = false;
|
@observable progressBarVisible: boolean = false;
|
||||||
@observable editMode: boolean = false;
|
@observable editMode: boolean = false;
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
@action setActiveModal = (name: string, props: ?Object): void => {
|
||||||
|
this.activeModalName = name;
|
||||||
|
this.activeModalProps = props;
|
||||||
|
};
|
||||||
|
|
||||||
|
@action clearActiveModal = (): void => {
|
||||||
|
this.activeModalName = undefined;
|
||||||
|
this.activeModalProps = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
@action setActiveDocument = (document: Document): void => {
|
@action setActiveDocument = (document: Document): void => {
|
||||||
this.activeDocumentId = document.id;
|
this.activeDocumentId = document.id;
|
||||||
|
Reference in New Issue
Block a user