Skip to content

Commit 2f62cd7

Browse files
committed
Merge branch 'release-2.14.2' into release
2 parents 7ecebed + d8d6d82 commit 2f62cd7

File tree

32 files changed

+248
-156
lines changed

32 files changed

+248
-156
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"import/named": 0,
1515
"import/namespace": 0,
1616
"import/no-unresolved": 0,
17-
"import/no-named-as-default": 2,
17+
"import/no-named-as-default": 0,
18+
"import/no-named-as-default-member": 0,
1819
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
1920
"indent": 0,
2021
"no-console": 0,

client/common/useKeyDownHandlers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default function useKeyDownHandlers(keyHandlers) {
3838
/^\d+$/.test(e.code.at(-1)) ? e.code.at(-1) : e.key.toLowerCase()
3939
}`
4040
]?.(e);
41+
} else if (isCtrl && e.altKey && e.code === 'KeyN') {
42+
// specifically for creating a new file
43+
handlers.current[`ctrl-alt-n`]?.(e);
4144
} else if (isCtrl) {
4245
handlers.current[`ctrl-${e.key.toLowerCase()}`]?.(e);
4346
}

client/components/RootPage.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ const RootPage = styled.div`
1414
height: 100%;
1515
overflow: hidden;
1616
}
17+
@media print {
18+
@page {
19+
page-orientation: landscape;
20+
}
21+
}
1722
`;
1823

1924
export default RootPage;

client/constants.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export const COLLAPSE_SIDEBAR = 'COLLAPSE_SIDEBAR';
5555
export const EXPAND_CONSOLE = 'EXPAND_CONSOLE';
5656
export const COLLAPSE_CONSOLE = 'COLLAPSE_CONSOLE';
5757

58-
export const UPDATE_LINT_MESSAGE = 'UPDATE_LINT_MESSAGE';
59-
export const CLEAR_LINT_MESSAGE = 'CLEAR_LINT_MESSAGE';
6058
export const TOGGLE_FORCE_DESKTOP = 'TOGGLE_FORCE_DESKTOP';
6159

6260
export const UPDATE_FILE_NAME = 'UPDATE_FILE_NAME';

client/index.jsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ const initialState = window.__INITIAL_STATE__;
2121
const store = configureStore(initialState);
2222

2323
const App = () => (
24-
<Provider store={store}>
25-
<ThemeProvider>
26-
<Router history={browserHistory}>
27-
<SkipLink targetId="play-sketch" text="PlaySketch" />
28-
<Routing />
29-
</Router>
30-
</ThemeProvider>
31-
</Provider>
24+
<>
25+
<Router history={browserHistory}>
26+
<SkipLink targetId="play-sketch" text="PlaySketch" />
27+
<Routing />
28+
</Router>
29+
</>
3230
);
3331

3432
render(
35-
<Suspense fallback={<Loader />}>
36-
<App />
37-
</Suspense>,
33+
<Provider store={store}>
34+
<ThemeProvider>
35+
<Suspense fallback={<Loader />}>
36+
<App />
37+
</Suspense>
38+
</ThemeProvider>
39+
</Provider>,
3840
document.getElementById('root')
3941
);
Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,55 @@
11
import React from 'react';
2+
import styled, { keyframes } from 'styled-components';
3+
import { prop, remSize } from '../../../theme';
4+
5+
const skBounce = keyframes`
6+
0%, 100% {
7+
transform: scale(0.0);
8+
}
9+
50% {
10+
transform: scale(1.0);
11+
}
12+
`;
13+
const Container = styled.div`
14+
&&& {
15+
width: 100%;
16+
height: 100%;
17+
display: flex;
18+
justify-content: center;
19+
align-items: center;
20+
background-color: ${prop('backgroundColor')};
21+
}
22+
`;
23+
const LoaderWrapper = styled.div`
24+
&&& {
25+
width: ${remSize(80)};
26+
height: ${remSize(80)};
27+
position: relative;
28+
}
29+
`;
30+
const LoaderCircle = styled.div`
31+
&&& {
32+
width: 100%;
33+
height: 100%;
34+
border-radius: 80%;
35+
background-color: ${prop('logoColor')};
36+
opacity: 0.6;
37+
position: absolute;
38+
top: 0;
39+
left: 0;
40+
animation: ${skBounce} 2s infinite ease-in-out;
41+
&:nth-child(2) {
42+
animation-delay: -1s;
43+
}
44+
}
45+
`;
246

347
const Loader = () => (
4-
<div className="loader-container">
5-
<div className="loader">
6-
<div className="loader__circle1" />
7-
<div className="loader__circle2" />
8-
</div>
9-
</div>
48+
<Container>
49+
<LoaderWrapper>
50+
<LoaderCircle />
51+
<LoaderCircle />
52+
</LoaderWrapper>
53+
</Container>
1054
);
1155
export default Loader;
Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
import * as ActionTypes from '../../../constants';
2-
3-
export function updateLintMessage(severity, line, message) {
4-
return {
5-
type: ActionTypes.UPDATE_LINT_MESSAGE,
6-
severity,
7-
line,
8-
message
9-
};
10-
}
11-
12-
export function clearLintMessage() {
13-
return {
14-
type: ActionTypes.CLEAR_LINT_MESSAGE
15-
};
16-
}
17-
18-
export function toggleForceDesktop() {
19-
return {
20-
type: ActionTypes.TOGGLE_FORCE_DESKTOP
21-
};
22-
}
1+
export {
2+
updateLintMessage,
3+
clearLintMessage,
4+
toggleForceDesktop
5+
} from '../reducers/editorAccessibility';

client/modules/IDE/components/CollectionList/CollectionListRow.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ const CollectionListRowBase = (props) => {
129129
closeAll();
130130
setRenameOpen(true);
131131
setRenameValue(props.collection.name);
132-
if (renameInput.current) {
133-
renameInput.current.focus();
134-
}
135132
};
136133

137134
const handleRenameChange = (e) => {
@@ -146,6 +143,12 @@ const CollectionListRowBase = (props) => {
146143
}
147144
};
148145

146+
const handleRenameFocus = () => {
147+
if (renameInput.current) {
148+
renameInput.current.focus();
149+
}
150+
};
151+
149152
const handleRenameBlur = () => {
150153
updateName();
151154
closeAll();
@@ -191,7 +194,10 @@ const CollectionListRowBase = (props) => {
191194
onKeyDown={handleRenameEnter}
192195
onBlur={handleRenameBlur}
193196
onClick={(e) => e.stopPropagation()}
194-
ref={renameInput}
197+
ref={(node) => {
198+
renameInput.current = node;
199+
handleRenameFocus();
200+
}}
195201
/>
196202
)}
197203
</>

client/modules/IDE/components/Header/Nav.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ const ProjectMenu = () => {
133133

134134
const replaceCommand =
135135
metaKey === 'Ctrl' ? `${metaKeyName}+H` : `${metaKeyName}+⌥+F`;
136+
const newFileCommand =
137+
metaKey === 'Ctrl' ? `${metaKeyName}+Alt+N` : `${metaKeyName}+⌥+N`;
136138

137139
return (
138140
<ul className="nav__items-left" role="menubar">
@@ -220,6 +222,7 @@ const ProjectMenu = () => {
220222
<NavDropdownMenu id="sketch" title={t('Nav.Sketch.Title')}>
221223
<NavMenuItem onClick={() => dispatch(newFile(rootFile.id))}>
222224
{t('Nav.Sketch.AddFile')}
225+
<span className="nav__keyboard-shortcut">{newFileCommand}</span>
223226
</NavMenuItem>
224227
<NavMenuItem onClick={() => dispatch(newFolder(rootFile.id))}>
225228
{t('Nav.Sketch.AddFolder')}

client/modules/IDE/components/Header/__snapshots__/Nav.unit.test.jsx.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ exports[`Nav renders editor version for desktop 1`] = `
637637
role="menuitem"
638638
>
639639
Add File
640+
<span
641+
class="nav__keyboard-shortcut"
642+
>
643+
Ctrl+Alt+N
644+
</span>
640645
</button>
641646
</li>
642647
<li

client/modules/IDE/components/IDEKeyHandlers.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
expandSidebar,
99
showErrorModal,
1010
startSketch,
11-
stopSketch
11+
stopSketch,
12+
newFile
1213
} from '../actions/ide';
1314
import { setAllAccessibleOutput } from '../actions/preferences';
1415
import { cloneProject, saveProject } from '../actions/project';
@@ -25,6 +26,10 @@ export const useIDEKeyHandlers = ({ getContent }) => {
2526
const sidebarIsExpanded = useSelector((state) => state.ide.sidebarIsExpanded);
2627
const consoleIsExpanded = useSelector((state) => state.ide.consoleIsExpanded);
2728

29+
const rootFile = useSelector(
30+
(state) => state.files.filter((file) => file.name === 'root')[0]
31+
);
32+
2833
const isUserOwner = useSelector(getIsUserOwner);
2934
const isAuthenticated = useSelector(getAuthenticated);
3035
const sketchOwner = useSelector(getSketchOwner);
@@ -72,6 +77,11 @@ export const useIDEKeyHandlers = ({ getContent }) => {
7277
sidebarIsExpanded ? collapseSidebar() : expandSidebar()
7378
);
7479
},
80+
'ctrl-alt-n': (e) => {
81+
e.preventDefault();
82+
e.stopPropagation();
83+
dispatch(newFile(rootFile.id));
84+
},
7585
'ctrl-`': (e) => {
7686
e.preventDefault();
7787
dispatch(consoleIsExpanded ? collapseConsole() : expandConsole());

client/modules/IDE/components/KeyboardShortcutModal.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ function KeyboardShortcutModal() {
66
const { t } = useTranslation();
77
const replaceCommand =
88
metaKey === 'Ctrl' ? `${metaKeyName} + H` : `${metaKeyName} + ⌥ + F`;
9+
const newFileCommand =
10+
metaKey === 'Ctrl' ? `${metaKeyName} + Alt + N` : `${metaKeyName} + ⌥ + N`;
911
return (
1012
<div className="keyboard-shortcuts">
1113
<h3 className="keyboard-shortcuts__title">
@@ -69,6 +71,10 @@ function KeyboardShortcutModal() {
6971
<span className="keyboard-shortcut__command">{metaKeyName} + K</span>
7072
<span>{t('KeyboardShortcuts.CodeEditing.ColorPicker')}</span>
7173
</li>
74+
<li className="keyboard-shortcut-item">
75+
<span className="keyboard-shortcut__command">{newFileCommand}</span>
76+
<span>{t('KeyboardShortcuts.CodeEditing.CreateNewFile')}</span>
77+
</li>
7278
</ul>
7379
<h3 className="keyboard-shortcuts__title">General</h3>
7480
<ul className="keyboard-shortcuts__list">

client/modules/IDE/components/show-hint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283
<span class="hint-hidden">, </span>\
284284
${
285285
p5
286-
? `<a href="https://p5js.org/reference/#/p5/${
286+
? `<a href="https://p5js.org/reference/p5/${
287287
typeof p5 === 'string' ? p5 : name
288288
}" role="link" onclick="event.stopPropagation()" target="_blank">\
289289
<span class="hint-hidden">open ${name} reference</span>\
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1-
import * as ActionTypes from '../../../constants';
1+
import { createSlice } from '@reduxjs/toolkit';
22

33
const initialState = {
44
lintMessages: [],
55
forceDesktop: false
66
};
7+
78
let messageId = 0;
89

9-
const editorAccessibility = (state = initialState, action) => {
10-
switch (action.type) {
11-
case ActionTypes.UPDATE_LINT_MESSAGE:
10+
const editorAccessibilitySlice = createSlice({
11+
name: 'editorAccessibility',
12+
initialState,
13+
reducers: {
14+
updateLintMessage: (state, action) => {
1215
messageId += 1;
13-
return Object.assign({}, state, {
14-
lintMessages: state.lintMessages.concat({
15-
severity: action.severity,
16-
line: action.line,
17-
message: action.message,
18-
id: messageId
19-
})
16+
state.lintMessages.push({
17+
severity: action.payload.severity,
18+
line: action.payload.line,
19+
message: action.payload.message,
20+
id: messageId
2021
});
21-
case ActionTypes.CLEAR_LINT_MESSAGE:
22-
return Object.assign({}, state, { lintMessages: [] });
23-
case ActionTypes.TOGGLE_FORCE_DESKTOP:
24-
return Object.assign({}, state, { forceDesktop: !state.forceDesktop });
25-
default:
26-
return state;
22+
},
23+
clearLintMessage: (state) => {
24+
state.lintMessages = [];
25+
},
26+
toggleForceDesktop: (state) => {
27+
state.forceDesktop = !state.forceDesktop;
28+
}
2729
}
28-
};
30+
});
31+
32+
export const {
33+
updateLintMessage,
34+
clearLintMessage,
35+
toggleForceDesktop
36+
} = editorAccessibilitySlice.actions;
2937

30-
export default editorAccessibility;
38+
export default editorAccessibilitySlice.reducer;

client/modules/User/actions.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,41 @@ export function submitSettings(formValues) {
276276

277277
export function updateSettings(formValues) {
278278
return (dispatch) =>
279-
new Promise((resolve) =>
279+
new Promise((resolve) => {
280+
if (!formValues.currentPassword && formValues.newPassword) {
281+
dispatch(showToast(5500));
282+
dispatch(setToastText('Toast.EmptyCurrentPass'));
283+
resolve();
284+
return;
285+
}
280286
submitSettings(formValues)
281287
.then((response) => {
282288
dispatch(updateSettingsSuccess(response.data));
283289
dispatch(showToast(5500));
284290
dispatch(setToastText('Toast.SettingsSaved'));
285291
resolve();
286292
})
287-
.catch((error) => resolve({ error }))
288-
);
293+
.catch((error) => {
294+
if (error.response) {
295+
switch (error.response.status) {
296+
case 401:
297+
dispatch(showToast(5500));
298+
dispatch(setToastText('Toast.IncorrectCurrentPass'));
299+
break;
300+
case 404:
301+
dispatch(showToast(5500));
302+
dispatch(setToastText('Toast.UserNotFound'));
303+
break;
304+
default:
305+
dispatch(showToast(5500));
306+
dispatch(setToastText('Toast.DefaultError'));
307+
}
308+
} else {
309+
dispatch(showToast(5500));
310+
dispatch(setToastText('Toast.NetworkError'));
311+
}
312+
});
313+
});
289314
}
290315

291316
export function createApiKeySuccess(user) {

0 commit comments

Comments
 (0)