Skip to content

Commit e78a120

Browse files
author
Ives van Hoorne
committed
Cleanup
1 parent d43cebf commit e78a120

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

src/app/components/spacing/Margin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import getSpacing from './get-spacing';
33

44
export default styled.div`
55
margin: ${getSpacing};
6+
box-sizing: border-box;
67
`;
File renamed without changes.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import styled, { injectGlobal } from 'styled-components';
55
import { connect } from 'react-redux';
66
import { spring, Motion } from 'react-motion';
77
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
8+
import notificationActionCreators from 'app/store/notifications/actions';
9+
import Portal from 'app/components/Portal';
10+
811
import type { Notification } from 'common/types';
9-
import notificationActionCreators from '../store/notifications/actions';
10-
import NotificationComponent from '../components/Notification';
11-
import Portal from '../components/Portal';
12+
13+
import NotificationComponent from './Notification';
1214

1315
type Props = {
1416
notifications: Array<Notification>,

src/app/store/entities/sandboxes/modules/validator.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// @flow
2-
32
import type { Module, Directory } from 'common/types';
43

54
export const validateTitle = (
65
id: string,
76
title: string,
87
siblings: Array<Module | Directory>, // eslint-disable-line
98
) => {
10-
if (title.length === 0) return 'title cannot be empty';
9+
if (title.length === 0) return 'Title cannot be empty';
1110
if (/^[09azAZ_.]+$/.test(title)) {
1211
// It has whitespaces
1312
return 'Title cannot have whitespaces or special characters';

src/embed/components/Sidebar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ export default ({ sandbox, setCurrentModule, currentModule }: Props) => (
104104

105105
<Item>
106106
<Title>Dependencies</Title>
107+
107108
<Subtitle>NPM Dependencies</Subtitle>
108109
{Object.keys(sandbox.npmDependencies).map(dep => (
109110
<EntryContainer key={dep}>
110111
{dep}
111112
<Version>{sandbox.npmDependencies[dep]}</Version>
112113
</EntryContainer>
113114
))}
115+
114116
<Subtitle>External Resources</Subtitle>
115117
{sandbox.externalResources.map(dep => (
116118
<EntryContainer key={dep}>
@@ -120,6 +122,7 @@ export default ({ sandbox, setCurrentModule, currentModule }: Props) => (
120122
</EntryContainer>
121123
))}
122124
</Item>
125+
123126
<Item hover>
124127
<Padding margin={1}>
125128
<EditorLink id={sandbox.id} />

src/sandbox/utils/resolve-module.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const compareTitle = (original: string, test: string) => {
88
return false;
99
};
1010

11+
const throwError = (path: string) => {
12+
throw new Error(`Cannot find module in ${path}`);
13+
};
14+
1115
/**
1216
* Convert the module path to a module
1317
*/
@@ -19,40 +23,38 @@ export default (
1923
) => {
2024
// Split path
2125
const splitPath = path.replace(/^.\//, '').split('/');
22-
const founddirectoryShortid = splitPath.reduce(
26+
const foundDirectoryShortid = splitPath.reduce(
2327
(dirId: ?string, pathPart: string, i: number) => {
2428
// Meaning this is the last argument, so the file
2529
if (i === splitPath.length - 1) return dirId;
2630

2731
if (pathPart === '..') {
2832
// Find the parent
2933
const dir = directories.find(d => d.shortid === dirId);
30-
if (dir == null) throw new Error(`Cannot find module in ${path}`);
34+
if (dir == null) throwError(path);
3135

3236
return dir.directoryShortid;
3337
}
3438

35-
// For == check on null
36-
// eslint-disable-next-line eqeqeq
3739
const directoriesInDirectory = directories.filter(
40+
// eslint-disable-next-line eqeqeq
3841
m => m.directoryShortid == dirId,
3942
);
4043
const nextDirectory = directoriesInDirectory.find(d =>
4144
compareTitle(d.title, pathPart),
4245
);
4346

44-
if (nextDirectory == null)
45-
throw new Error(`Cannot find module in ${path}`);
47+
if (nextDirectory == null) throwError(path);
4648

4749
return nextDirectory.shortid;
4850
},
4951
startdirectoryShortid,
5052
);
5153

5254
const lastPath = splitPath[splitPath.length - 1];
53-
// eslint-disable-next-line eqeqeq
5455
const modulesInFoundDirectory = modules.filter(
55-
m => m.directoryShortid == founddirectoryShortid,
56+
// eslint-disable-next-line eqeqeq
57+
m => m.directoryShortid == foundDirectoryShortid,
5658
);
5759

5860
// Find module with same name
@@ -61,22 +63,25 @@ export default (
6163
);
6264
if (foundModule) return foundModule;
6365

64-
// eslint-disable-next-line eqeqeq
66+
// Check all directories in said directory for same name
6567
const directoriesInFoundDirectory = directories.filter(
66-
m => m.directoryShortid == founddirectoryShortid,
68+
// eslint-disable-next-line eqeqeq
69+
m => m.directoryShortid == foundDirectoryShortid,
6770
);
6871
const foundDirectory = directoriesInFoundDirectory.find(m =>
6972
compareTitle(m.title, lastPath),
7073
);
7174

75+
// If it refers to a directory
7276
if (foundDirectory) {
73-
// eslint-disable-next-line eqeqeq
77+
// Find module named index
7478
const indexModule = modules.find(
7579
m =>
80+
// eslint-disable-next-line eqeqeq
7681
m.directoryShortid == foundDirectory.shortid &&
7782
compareTitle(m.title, 'index'),
7883
);
79-
if (indexModule == null) throw new Error(`Cannot find module in ${path}`);
84+
if (indexModule == null) throwError(path);
8085
return indexModule;
8186
}
8287

@@ -87,5 +92,6 @@ export default (
8792
);
8893
if (indexModule) return indexModule;
8994
}
90-
throw new Error(`Cannot find module in ${path}`);
95+
96+
throwError(path);
9197
};

0 commit comments

Comments
 (0)