Skip to content

Commit fd50239

Browse files
authored
Merge branch 'develop' into cleanup/cb
2 parents 6b27ea1 + a36830b commit fd50239

File tree

18 files changed

+300
-385
lines changed

18 files changed

+300
-385
lines changed

client/constants.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ export const SET_SORT_PARAMS = 'SET_SORT_PARAMS';
137137
export const SET_SEARCH_TERM = 'SET_SEARCH_TERM';
138138
export const CLOSE_SKETCHLIST_MODAL = 'CLOSE_SKETCHLIST_MODAL';
139139

140-
export const START_LOADING = 'START_LOADING';
141-
export const STOP_LOADING = 'STOP_LOADING';
142-
143140
export const START_SAVING_PROJECT = 'START_SAVING_PROJECT';
144141
export const END_SAVING_PROJECT = 'END_SAVING_PROJECT';
145142

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { connect } from 'react-redux';
3+
import { useSelector } from 'react-redux';
44
import { ThemeProvider } from 'styled-components';
5+
import theme from '../../../theme';
56

6-
import theme, { Theme } from '../../../theme';
7-
8-
const Provider = ({ children, currentTheme }) => (
9-
<ThemeProvider theme={{ ...theme[currentTheme] }}>{children}</ThemeProvider>
10-
);
7+
const Provider = ({ children }) => {
8+
const currentTheme = useSelector((state) => state.preferences.theme);
9+
return (
10+
<ThemeProvider theme={{ ...theme[currentTheme] }}>{children}</ThemeProvider>
11+
);
12+
};
1113

1214
Provider.propTypes = {
13-
children: PropTypes.node.isRequired,
14-
currentTheme: PropTypes.oneOf(Object.keys(Theme)).isRequired
15+
children: PropTypes.node.isRequired
1516
};
1617

17-
function mapStateToProps(state) {
18-
return {
19-
currentTheme: state.preferences.theme
20-
};
21-
}
22-
23-
export default connect(mapStateToProps)(Provider);
18+
export default Provider;

client/modules/IDE/actions/assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import apiClient from '../../../utils/apiClient';
22
import * as ActionTypes from '../../../constants';
3-
import { startLoader, stopLoader } from './loader';
3+
import { startLoader, stopLoader } from '../reducers/loading';
44
import { assetsActions } from '../reducers/assets';
55

66
const { setAssets, deleteAsset } = assetsActions;

client/modules/IDE/actions/collections.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import browserHistory from '../../../browserHistory';
22
import apiClient from '../../../utils/apiClient';
33
import * as ActionTypes from '../../../constants';
4-
import { startLoader, stopLoader } from './loader';
4+
import { startLoader, stopLoader } from '../reducers/loading';
55
import { setToastText, showToast } from './toast';
66

77
const TOAST_DISPLAY_TIME_MS = 1500;
@@ -80,7 +80,7 @@ export function addToCollection(collectionId, projectId) {
8080

8181
const collectionName = response.data.name;
8282

83-
dispatch(setToastText(`Added to "${collectionName}`));
83+
dispatch(setToastText(`Added to "${collectionName}"`));
8484
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
8585

8686
return response.data;
@@ -110,7 +110,7 @@ export function removeFromCollection(collectionId, projectId) {
110110

111111
const collectionName = response.data.name;
112112

113-
dispatch(setToastText(`Removed from "${collectionName}`));
113+
dispatch(setToastText(`Removed from "${collectionName}"`));
114114
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
115115

116116
return response.data;

client/modules/IDE/actions/loader.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

client/modules/IDE/actions/projects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import apiClient from '../../../utils/apiClient';
22
import * as ActionTypes from '../../../constants';
3-
import { startLoader, stopLoader } from './loader';
3+
import { startLoader, stopLoader } from '../reducers/loading';
44

55
// eslint-disable-next-line
66
export function getProjects(username) {

client/modules/IDE/actions/projects.unit.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { rest } from 'msw';
55

66
import * as ProjectActions from './projects';
77
import * as ActionTypes from '../../../constants';
8+
import { startLoader, stopLoader } from '../reducers/loading';
89
import {
910
initialTestState,
1011
mockProjects
@@ -33,9 +34,9 @@ describe('projects action creator tests', () => {
3334
store = mockStore(initialTestState);
3435

3536
const expectedActions = [
36-
{ type: ActionTypes.START_LOADING },
37+
{ type: startLoader.type },
3738
{ type: ActionTypes.SET_PROJECTS, projects: mockProjects },
38-
{ type: ActionTypes.STOP_LOADING }
39+
{ type: stopLoader.type }
3940
];
4041

4142
return store

client/modules/IDE/components/Preferences/Preferences.unit.test.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { act, fireEvent, reduxRender, screen } from '../../../../test-utils';
3+
import { initialState } from '../../reducers/preferences';
34
import Preferences from './index';
45
import * as PreferencesActions from '../../actions/preferences';
56

@@ -15,7 +16,10 @@ describe('<Preferences />', () => {
1516
const subject = (initialPreferences = {}) =>
1617
reduxRender(<Preferences />, {
1718
initialState: {
18-
preferences: initialPreferences
19+
preferences: {
20+
...initialState,
21+
...initialPreferences
22+
}
1923
}
2024
});
2125

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import * as ActionTypes from '../../../constants';
1+
import { createSlice } from '@reduxjs/toolkit';
22

3-
const loading = (state = false, action) => {
4-
switch (action.type) {
5-
case ActionTypes.START_LOADING:
6-
return true;
7-
case ActionTypes.STOP_LOADING:
8-
return false;
9-
default:
10-
return state;
3+
const loadingSlice = createSlice({
4+
name: 'loading',
5+
initialState: false,
6+
reducers: {
7+
startLoader: () => true,
8+
stopLoader: () => false
119
}
12-
};
10+
});
1311

14-
export default loading;
12+
export const { startLoader, stopLoader } = loadingSlice.actions;
13+
export default loadingSlice.reducer;

client/modules/IDE/reducers/preferences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as ActionTypes from '../../../constants';
22

3-
const initialState = {
3+
export const initialState = {
44
fontSize: 18,
55
autosave: true,
66
linewrap: true,

client/styles/components/_editor.scss

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pre.CodeMirror-line {
9191
position: fixed;
9292
top: 0;
9393
left: 50%;
94-
margin-left: math.div(552 * 0.5, $base-font-size);
94+
margin-left: #{math.div(-552 * 0.5, $base-font-size)}rem;
9595

9696
@media (max-width: 770px) {
9797
left: 0;
@@ -100,7 +100,7 @@ pre.CodeMirror-line {
100100
margin-left: 0;
101101
}
102102

103-
z-index: 1;
103+
z-index: 10;
104104

105105
width: 580px;
106106
font-family: Montserrat, sans-serif;
@@ -139,8 +139,11 @@ pre.CodeMirror-line {
139139
}
140140

141141
.CodeMirror-find-controls {
142+
width: 100%;
142143
display: flex;
143144
align-items: center;
145+
justify-content: space-between;
146+
height: #{math.div(35, $base-font-size)}rem;
144147
}
145148
.CodeMirror-search-inputs {
146149
width: 30%;
@@ -152,9 +155,11 @@ pre.CodeMirror-line {
152155
align-items: center;
153156
}
154157
.CodeMirror-search-controls {
158+
width: 60%;
155159
display: flex;
156-
align-items: center;
157-
justify-content: end;
160+
flex-wrap: wrap-reverse;
161+
justify-content: flex-start;
162+
align-items: flex-end;
158163
}
159164
.CodeMirror-replace-controls {
160165
display: flex;

client/testData/testReduxStore.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { initialState as initialFilesState } from '../modules/IDE/reducers/files';
2+
import { initialState as initialPrefState } from '../modules/IDE/reducers/preferences';
23

34
const mockProjects = [
45
{
@@ -46,20 +47,7 @@ const initialTestState = {
4647
parentId: undefined
4748
},
4849
files: initialFilesState(),
49-
preferences: {
50-
fontSize: 18,
51-
autosave: true,
52-
linewrap: true,
53-
lineNumbers: true,
54-
lintWarning: false,
55-
textOutput: false,
56-
gridOutput: false,
57-
theme: 'light',
58-
autorefresh: false,
59-
language: 'en-US',
60-
autocloseBracketsQuotes: true,
61-
autocompleteHinter: false
62-
},
50+
preferences: initialPrefState,
6351
user: {
6452
email: 'happydog@example.com',
6553
username: 'happydog',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p5.js-web-editor",
3-
"version": "2.11.0",
3+
"version": "2.12.1",
44
"description": "The web editor for p5.js.",
55
"scripts": {
66
"clean": "rimraf dist",

server/config/passport.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ passport.use(
4545
done(null, false, { msg: accountSuspensionMessage });
4646
return;
4747
}
48-
user.comparePassword(password, (innerErr, isMatch) => {
48+
user.comparePassword(password).then((isMatch) => {
4949
if (isMatch) {
5050
done(null, user);
51-
return;
51+
} else {
52+
done(null, false, { msg: 'Invalid email or password.' });
5253
}
53-
done(null, false, { msg: 'Invalid email or password.' });
5454
});
5555
})
5656
.catch((err) => done(null, false, { msg: err }));
@@ -123,12 +123,12 @@ passport.use(
123123
User.findOne({ github: profile.id }, (findByGithubErr, existingUser) => {
124124
if (existingUser) {
125125
if (req.user && req.user.email !== existingUser.email) {
126-
done(
127-
new Error('GitHub account is already linked to another account.')
128-
);
126+
done(null, false, {
127+
msg: 'GitHub account is already linked to another account.'
128+
});
129129
return;
130130
} else if (existingUser.banned) {
131-
done(new Error(accountSuspensionMessage));
131+
done(null, false, { msg: accountSuspensionMessage });
132132
return;
133133
}
134134
done(null, existingUser);
@@ -159,7 +159,7 @@ passport.use(
159159
[existingEmailUser] = existingEmailUsers;
160160
}
161161
if (existingEmailUser.banned) {
162-
done(new Error(accountSuspensionMessage));
162+
done(null, false, { msg: accountSuspensionMessage });
163163
return;
164164
}
165165
existingEmailUser.email = existingEmailUser.email || primaryEmail;
@@ -218,14 +218,12 @@ passport.use(
218218
(findByGoogleErr, existingUser) => {
219219
if (existingUser) {
220220
if (req.user && req.user.email !== existingUser.email) {
221-
done(
222-
new Error(
223-
'Google account is already linked to another account.'
224-
)
225-
);
221+
done(null, false, {
222+
msg: 'Google account is already linked to another account.'
223+
});
226224
return;
227225
} else if (existingUser.banned) {
228-
done(new Error(accountSuspensionMessage));
226+
done(null, false, { msg: accountSuspensionMessage });
229227
return;
230228
}
231229
done(null, existingUser);
@@ -256,7 +254,7 @@ passport.use(
256254
// then, append a random friendly word?
257255
if (existingEmailUser) {
258256
if (existingEmailUser.banned) {
259-
done(new Error(accountSuspensionMessage));
257+
done(null, false, { msg: accountSuspensionMessage });
260258
return;
261259
}
262260
existingEmailUser.email =

0 commit comments

Comments
 (0)