Skip to content

Commit 7088ded

Browse files
committed
Open 'My Sandboxes' by default if there are no folders
1 parent 7c907df commit 7088ded

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

packages/app/src/app/components/ContextMenu/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ class ContextMenu extends React.PureComponent {
102102
return null;
103103
}
104104

105-
const { children, childFunction, items, ...props } = this.props;
105+
// remove isDraggingItem from the list of props as it's generating warnings.
106+
const {
107+
children,
108+
childFunction,
109+
items,
110+
isDraggingItem,
111+
...props
112+
} = this.props;
106113
const { show, x, y, down, left } = this.state;
107114

108115
const mapFunction = (item, i) => {

packages/app/src/app/pages/Dashboard/Sidebar/Item/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ const getContainer = contextItems => {
2323

2424
export default class Item extends React.Component {
2525
state = {
26-
open: undefined,
26+
open: this.props.openByDefault,
2727
};
2828

2929
toggleOpen = e => {
3030
e.preventDefault();
3131
this.setState(state => ({ open: !state.open }));
3232
};
3333

34+
componentWillReceiveProps(nextProps) {
35+
if (nextProps.openByDefault === true && !this.props.openByDefault) {
36+
this.setState({ open: true });
37+
}
38+
}
39+
3440
render() {
3541
const { name, contextItems, Icon, path, children, style } = this.props;
3642

packages/app/src/app/pages/Dashboard/Sidebar/SandboxesItem/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ class SandboxesItem extends React.Component {
2626
};
2727

2828
render() {
29-
const { isOver, canDrop, teamId, connectDropTarget } = this.props;
29+
const {
30+
isOver,
31+
canDrop,
32+
teamId,
33+
connectDropTarget,
34+
openByDefault,
35+
} = this.props;
3036

3137
const basePath = teamId
3238
? `/dashboard/teams/${teamId}/sandboxes`
@@ -35,6 +41,7 @@ class SandboxesItem extends React.Component {
3541
return connectDropTarget(
3642
<div>
3743
<Item
44+
openByDefault={openByDefault}
3845
path={basePath}
3946
Icon={InfoIcon}
4047
name={teamId ? 'Our Sandboxes' : 'My Sandboxes'}

packages/app/src/app/pages/Dashboard/Sidebar/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Item from './Item';
1313
import SandboxesItem from './SandboxesItem';
1414
import TrashItem from './TrashItem';
1515
import { Items, CategoryHeader, SidebarStyled, InputWrapper } from './elements';
16-
import { TEAMS_QUERY } from '../queries';
16+
import { TEAMS_QUERY, PATHED_SANDBOXES_FOLDER_QUERY } from '../queries';
1717

1818
class Sidebar extends React.Component {
1919
shouldComponentUpdate() {
@@ -47,7 +47,18 @@ class Sidebar extends React.Component {
4747

4848
<Items style={{ marginBottom: '1rem' }}>
4949
<Item Icon={TimeIcon} path="/dashboard/recent" name="Recent" />
50-
<SandboxesItem />
50+
<Query
51+
variables={{ teamId: undefined }}
52+
query={PATHED_SANDBOXES_FOLDER_QUERY}
53+
>
54+
{({ data }) => {
55+
// We open this by default if there are no folders yet, to let the user know
56+
// that they can create folders.
57+
const openByDefault =
58+
data && data.me && data.me.collections.length === 1;
59+
return <SandboxesItem openByDefault={openByDefault} />;
60+
}}
61+
</Query>
5162
<TrashItem />
5263
</Items>
5364

0 commit comments

Comments
 (0)