Unify header actions
This commit is contained in:
14
src/components/DropdownMenu/components/MoreIcon/MoreIcon.js
Normal file
14
src/components/DropdownMenu/components/MoreIcon/MoreIcon.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
|
||||
import styles from './MoreIcon.scss';
|
||||
|
||||
const MoreIcon = (props) => {
|
||||
return (
|
||||
<img
|
||||
src={ require("./assets/more.svg") }
|
||||
className={ styles.icon }
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default MoreIcon;
|
||||
@@ -0,0 +1,4 @@
|
||||
.icon {
|
||||
width: 21px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
2
src/components/DropdownMenu/components/MoreIcon/index.js
Normal file
2
src/components/DropdownMenu/components/MoreIcon/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import MoreIcon from './MoreIcon';
|
||||
export default MoreIcon;
|
||||
@@ -1,5 +1,7 @@
|
||||
import DropdownMenu, { MenuItem } from './DropdownMenu';
|
||||
import MoreIcon from './components/MoreIcon';
|
||||
export default DropdownMenu;
|
||||
export {
|
||||
MenuItem,
|
||||
MoreIcon,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import Link from 'react-router/lib/Link';
|
||||
import History from 'utils/History';
|
||||
import { Link, browserHistory } from 'react-router';
|
||||
|
||||
import store from './AtlasStore';
|
||||
|
||||
@@ -10,6 +9,8 @@ import AtlasPreviewLoading from 'components/AtlasPreviewLoading';
|
||||
import CenteredContent from 'components/CenteredContent';
|
||||
import DocumentList from 'components/DocumentList';
|
||||
import Divider from 'components/Divider';
|
||||
import DropdownMenu, { MenuItem, MoreIcon } from 'components/DropdownMenu';
|
||||
import Flex from 'components/Flex';
|
||||
|
||||
import styles from './Atlas.scss';
|
||||
|
||||
@@ -21,11 +22,16 @@ class Atlas extends React.Component {
|
||||
|
||||
// Forward directly to root document
|
||||
if (data.type === 'atlas') {
|
||||
History.replace(data.navigationTree.url);
|
||||
browserHistory.replace(data.navigationTree.url);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onClickCreate = (event) => {
|
||||
event.preventDefault();
|
||||
browserHistory.push(`/atlas/${store.atlas.id}/new`);
|
||||
}
|
||||
|
||||
render() {
|
||||
const atlas = store.atlas;
|
||||
|
||||
@@ -34,9 +40,15 @@ class Atlas extends React.Component {
|
||||
let titleText;
|
||||
|
||||
if (atlas) {
|
||||
actions = <HeaderAction>
|
||||
<Link to={ `/atlas/${atlas.id}/new` }>New document</Link>
|
||||
</HeaderAction>;
|
||||
actions = (
|
||||
<Flex direction="row">
|
||||
<DropdownMenu label={ <MoreIcon /> } >
|
||||
<MenuItem onClick={ this.onClickCreate }>
|
||||
New document
|
||||
</MenuItem>
|
||||
</DropdownMenu>
|
||||
</Flex>
|
||||
);
|
||||
title = <Title>{ atlas.name }</Title>;
|
||||
titleText = atlas.name;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import Layout from 'components/Layout';
|
||||
import AtlasPreview from 'components/AtlasPreview';
|
||||
import AtlasPreviewLoading from 'components/AtlasPreviewLoading';
|
||||
import CenteredContent from 'components/CenteredContent';
|
||||
import DropdownMenu, { MenuItem } from 'components/DropdownMenu';
|
||||
import DropdownMenu, { MenuItem, MoreIcon } from 'components/DropdownMenu';
|
||||
import FullscreenField from 'components/FullscreenField';
|
||||
|
||||
import styles from './Dashboard.scss';
|
||||
@@ -36,12 +36,7 @@ class Dashboard extends React.Component {
|
||||
render() {
|
||||
const actions = (
|
||||
<Flex direction="row">
|
||||
<DropdownMenu label={
|
||||
<img
|
||||
src={ require("../../assets/icons/more.svg") }
|
||||
className={ styles.moreIcon }
|
||||
/>
|
||||
} >
|
||||
<DropdownMenu label={ <MoreIcon /> } >
|
||||
<MenuItem onClick={ this.onClickNewAtlas }>
|
||||
New Atlas
|
||||
</MenuItem>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
.moreIcon {
|
||||
width: 21px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import Layout, { HeaderAction } from 'components/Layout';
|
||||
import AtlasPreviewLoading from 'components/AtlasPreviewLoading';
|
||||
import CenteredContent from 'components/CenteredContent';
|
||||
import Document from 'components/Document';
|
||||
import DropdownMenu, { MenuItem } from 'components/DropdownMenu';
|
||||
import DropdownMenu, { MenuItem, MoreIcon } from 'components/DropdownMenu';
|
||||
import Flex from 'components/Flex';
|
||||
import Tree from 'components/Tree';
|
||||
|
||||
@@ -65,6 +65,11 @@ class DocumentScene extends React.Component {
|
||||
browserHistory.push(url);
|
||||
}
|
||||
|
||||
onCreate = () => {
|
||||
const url = `/documents/${this.store.document.id}/new`;
|
||||
browserHistory.push(url);
|
||||
}
|
||||
|
||||
onDelete = () => {
|
||||
let msg;
|
||||
if (this.store.document.atlas.type === 'atlas') {
|
||||
@@ -96,12 +101,8 @@ class DocumentScene extends React.Component {
|
||||
if (doc) {
|
||||
actions = (
|
||||
<div className={ styles.actions }>
|
||||
{ this.store.isAtlas ? (
|
||||
<HeaderAction>
|
||||
<Link to={ `/documents/${doc.id}/new` }>New document</Link>
|
||||
</HeaderAction>
|
||||
) : null }
|
||||
<DropdownMenu label="More">
|
||||
<DropdownMenu label={ <MoreIcon /> }>
|
||||
{ this.store.isAtlas && <MenuItem onClick={ this.onCreate }>New document</MenuItem> }
|
||||
<MenuItem onClick={ this.onEdit }>Edit</MenuItem>
|
||||
{ allowDelete && <MenuItem onClick={ this.onDelete }>Delete</MenuItem> }
|
||||
</DropdownMenu>
|
||||
|
||||
Reference in New Issue
Block a user