Skip to content

Commit

Permalink
Deleting sandboxes (#11)
Browse files Browse the repository at this point in the history
* Possible to delete sandboxes

* Int

* Fix lint errors

* Styling tweaks
  • Loading branch information
CompuIves authored Apr 27, 2017
1 parent 67dd9dd commit c094cf8
Show file tree
Hide file tree
Showing 38 changed files with 319 additions and 113 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"react/jsx-filename-extension": 0,
"react/sort-comp": 0,
"import/no-extraneous-dependencies": 0,
"arrow-parens": 0
"arrow-parens": 0,
"import/prefer-default-export": 0
},
"settings": {
"import/resolver": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
"build": "NODE_ENV=production node scripts/build.js && gulp",
"test": "jest --env=jsdom",
"test:watch": "jest --watch --env=jsdom",
"lint": "eslint src"
"lint:app": "eslint src/app",
"lint:embed": "eslint src/embed"
},
"jest": {
"rootDir": "src",
Expand Down
17 changes: 10 additions & 7 deletions src/app/components/Logo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';

export default ({ width = 35, height = 35, className }) => (
export default ({
width = 35,
height = 35,
className,
}: { width: number, height: number, className: ?string }) => (
<svg
x="0px"
y="0px"
Expand All @@ -12,15 +16,15 @@ export default ({ width = 35, height = 35, className }) => (
<g id="Layer_1">
<polyline
fill="#FFFFFF"
points="719.001,851 719.001,639.848 902,533.802 902,745.267 719.001,851 "
points="719.001,851 719.001,639.848 902,533.802 902,745.267 719.001,851"
/>
<polyline
fill="#FFFFFF"
points="302.082,643.438 122.167,539.135 122.167,747.741 302.082,852.573 302.082,643.438 "
points="302.082,643.438 122.167,539.135 122.167,747.741 302.082,852.573 302.082,643.438"
/>
<polyline
fill="#FFFFFF"
points="511.982,275.795 694.939,169.633 512.06,63 328.436,169.987 511.982,275.795 "
points="511.982,275.795 694.939,169.633 512.06,63 328.436,169.987 511.982,275.795"
/>
</g>
<g id="Layer_2">
Expand All @@ -29,7 +33,7 @@ export default ({ width = 35, height = 35, className }) => (
stroke="#FFFFFF"
strokeWidth="50"
strokeMiterlimit="10"
points="899,287.833 509,513 509,963 "
points="899,287.833 509,513 509,963"
/>
<line
fill="none"
Expand All @@ -53,8 +57,7 @@ export default ({ width = 35, height = 35, className }) => (
stroke="#FFFFFF"
strokeWidth="50"
strokeMiterlimit="10"
points="121,739.083 510.917,963.042 901,738.333
901,288 511,62 121,289 "
points="121,739.083 510.917,963.042 901,738.333 901,288 511,62 121,289"
/>
</g>
</svg>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const CloseIconHandler = styled.div`

type Props = {
title: string,
body: string,
body: string, // eslint-disable-line
type: string,
buttons: Array<NotificationButton>,
close: () => void,
Expand Down
5 changes: 4 additions & 1 deletion src/app/components/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ const Container = styled.div`
}
`;

const getSize = ({ small }) =>
(small ? 'calc(1.5rem + 2px)' : 'calc(2rem + 2px)');

const Dot = styled.div`
transition: inherit;
position: absolute;
height: ${props => (props.small ? 14 : 20)}px;
width: 1rem;
left: 0.1rem;
border-radius: 4px;
transform: translateX(${props => (props.right ? props.small ? 'calc(1.5rem + 2px)' : 'calc(2rem + 2px)' : '0')});
transform: translateX(${props => (props.right ? getSize(props) : '0')});
top: ${({ small }) => (small ? `calc(0.1rem + 1px)` : `calc(0.1rem)`)};
background-color: white;
box-shadow: 0 0 4px rgba(0,0,0,0.2);
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/Tooltip.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import styled from 'styled-components';

// eslint-disable-next-line
const getDirectionTransforms = ({ offset = 0, left, right, bottom, top }) => {
if (left) {
return `
Expand Down Expand Up @@ -29,6 +30,7 @@ const getDirectionTransforms = ({ offset = 0, left, right, bottom, top }) => {
`;
};

// eslint-disable-next-line
const getDirectionArrow = ({ theme, left, right, bottom, top }) => {
if (left) {
return `
Expand Down Expand Up @@ -115,7 +117,7 @@ const Tooltip = styled.div`
`;

type Props = {
className: ?tring,
className: ?string,
offset: ?number,
children: React.CElement,
message: string,
Expand Down
8 changes: 7 additions & 1 deletion src/app/components/buttons/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ const LinkButton = styled(Link)`${styles}`;
const AButton = styled.a`${styles}`;
const Button = styled.button`${styles}`;

export default props => {
type Props = {
[key: any]: any,
to: ?string,
href: ?string,
};

export default (props: Props) => {
// Link
if (props.to) {
return <LinkButton {...props} />;
Expand Down
30 changes: 30 additions & 0 deletions src/app/components/buttons/Button.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import testRender from 'app/utils/test/render';
import { MemoryRouter } from 'react-router-dom';
import Button from './Button';

describe('Button', () => {
it('renders', () => {
testRender(<Button>Test</Button>);
});

it('renders onClick', () => {
testRender(<Button onClick={() => {}}>Test</Button>);
});

it('renders hrefs', () => {
testRender(
<MemoryRouter>
<Button to="https://ivesvh.com">Test</Button>
</MemoryRouter>,
);
});

it('renders properties', () => {
testRender(<Button small>Test</Button>);
});

it('renders disabled', () => {
testRender(<Button disabled>Test</Button>);
});
});
12 changes: 12 additions & 0 deletions src/app/components/buttons/LinkButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import styled from 'styled-components';
import theme from 'common/theme';

export default styled.button`
display: inline-block;
background-color: transparent;
color: ${() => theme.secondary()};
border: none;
outline: none;
cursor: pointer;
text-decoration: underline;
`;
13 changes: 13 additions & 0 deletions src/app/components/buttons/LinkButton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import testRender from 'app/utils/test/render';
import LinkButton from './LinkButton';

describe('LinkButton', () => {
it('renders', () => {
testRender(<LinkButton>Test</LinkButton>);
});

it('renders onClick', () => {
testRender(<LinkButton onClick={() => {}}>Test</LinkButton>);
});
});
45 changes: 45 additions & 0 deletions src/app/components/buttons/__snapshots__/Button.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button renders 1`] = `
<button
className="gSpDoI"
>
Test
</button>
`;

exports[`Button renders disabled 1`] = `
<button
className="dEOCIp"
disabled={true}
>
Test
</button>
`;

exports[`Button renders hrefs 1`] = `
<a
className="gSpDoI"
href="https://ivesvh.com"
onClick={[Function]}
>
Test
</a>
`;

exports[`Button renders onClick 1`] = `
<button
className="gSpDoI"
onClick={[Function]}
>
Test
</button>
`;

exports[`Button renders properties 1`] = `
<button
className="eDPTas"
>
Test
</button>
`;
18 changes: 18 additions & 0 deletions src/app/components/buttons/__snapshots__/LinkButton.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LinkButton renders 1`] = `
<button
className="lnvNEu"
>
Test
</button>
`;

exports[`LinkButton renders onClick 1`] = `
<button
className="lnvNEu"
onClick={[Function]}
>
Test
</button>
`;
2 changes: 1 addition & 1 deletion src/app/components/sandbox/CodeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default class CodeEditor extends React.PureComponent {

const showAutoComplete = cm => {
if (this.server) {
const filter = new RegExp('[\.a-z_$]', 'i');
const filter = new RegExp('[.a-z_$]', 'i');
if (cm.display.input.textarea.value.slice(-1).match(filter)) {
cm.showHint({ hint: this.server.getHint, completeSingle: false });
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/sandbox/Preview/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ type Props = {
url: string,
onChange: (text: string) => void,
onConfirm: () => void,
onBack?: () => void,
onForward?: () => void,
onRefresh?: () => void,
onBack: ?() => void,
onForward: ?() => void,
onRefresh: ?() => void,
isProjectView: boolean,
toggleProjectView: () => void,
};
Expand Down
1 change: 1 addition & 0 deletions src/app/containers/Notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type State = {
hovering: boolean,
};

// eslint-disable-next-line
injectGlobal`
.notifications-leave {
opacity: 1;
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/Sandbox/Editor/Content/Header/HoverMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
type Props = {
HeaderComponent: React.Component<any, any>,
headerProps: ?Object,
children: Function,
};

type State = {
Expand All @@ -23,7 +24,7 @@ export default class HoverMenu extends React.PureComponent {
}
};

handleViewClick = e => {
handleViewClick = () => {
// Prevent element from closing itself when you click on it
this.setState({ clicked: true });

Expand Down
2 changes: 0 additions & 2 deletions src/app/pages/Sandbox/Editor/Content/Header/User.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import styled from 'styled-components';
import type { User } from 'app/store/user/reducer';
import type { Sandbox } from 'app/store/entities/sandboxes/entity';
import Tooltip from 'app/components/Tooltip';

import DownIcon from 'react-icons/lib/go/chevron-down';
Expand Down Expand Up @@ -79,7 +78,6 @@ const Sandboxes = styled.div`

type Props = {
user: User,
sandbox: Sandbox,
signOut: () => void,
loadUserSandboxes: () => void,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Props = {
setCurrentModule: (id: string) => any,
root: ?boolean,
isMainModule: boolean,
isInProjectView: boolean,
isInProjectView: boolean, // eslint-disable-line
moduleHasError: boolean,
};

Expand Down Expand Up @@ -161,7 +161,7 @@ class Entry extends React.PureComponent {
type,
active,
setCurrentModule,
connectDragSource,
connectDragSource, // eslint-disable-line
onCreateModuleClick,
onCreateDirectoryClick,
deleteEntry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type Props = {
root: ?boolean,
siblings: Array<Module | Directory>,
depth: ?number,
openModuleTab: (id: string) => void,
openMenu: (e: Event) => void,
sandboxActions: typeof sandboxActionCreators,
currentModuleId: ?string,
Expand Down Expand Up @@ -176,8 +175,8 @@ class DirectoryEntry extends React.PureComponent {
title,
openMenu,
currentModuleId,
connectDropTarget,
isOver,
connectDropTarget, // eslint-disable-line
isOver, // eslint-disable-line
errors,
isInProjectView,
depth = 0,
Expand Down Expand Up @@ -283,11 +282,11 @@ const entryTarget = {
},
};

function collectTarget(connect, monitor) {
function collectTarget(connectMonitor, monitor) {
return {
// Call this function inside render()
// to let React DnD handle the drag events:
connectDropTarget: connect.dropTarget(),
connectDropTarget: connectMonitor.dropTarget(),
// You can ask the monitor about the current drag state:
isOver: monitor.isOver({ shallow: true }),
canDrop: monitor.canDrop(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Props = {
title: string,
enabled: boolean,
onClick: (on: boolean) => void,
tooltip: ?string,
offset: ?number,
};

export default class Preference extends React.Component {
Expand Down
Loading

0 comments on commit c094cf8

Please sign in to comment.