Skip to content

Commit 2235602

Browse files
committed
Merge branch 'release-2.14.4' into release
2 parents d6ae940 + 5e65e80 commit 2235602

18 files changed

+420
-90
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import EditorAccessibility from './EditorAccessibility';
66

77
describe('<EditorAccessibility />', () => {
88
it('renders empty message with no lines', () => {
9-
render(<EditorAccessibility lintMessages={[]} />);
9+
render(<EditorAccessibility lintMessages={[]} currentLine={0} />);
1010

1111
expect(
1212
screen.getByRole('listitem', {
@@ -21,11 +21,12 @@ describe('<EditorAccessibility />', () => {
2121
lintMessages={[
2222
{
2323
severity: 'info',
24-
line: '1',
24+
line: 1,
2525
message: 'foo',
26-
id: '1a2b3c'
26+
id: 123
2727
}
2828
]}
29+
currentLine={0}
2930
/>
3031
);
3132

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,30 @@ jest.mock('../../../i18n');
88

99
describe('<ErrorModal />', () => {
1010
it('renders type forceAuthentication', () => {
11-
render(<ErrorModal type="forceAuthentication" closeModal={jest.fn()} />);
11+
render(
12+
<ErrorModal
13+
type="forceAuthentication"
14+
closeModal={jest.fn()}
15+
service="google"
16+
/>
17+
);
1218

1319
expect(screen.getByText('Login')).toBeVisible();
1420
expect(screen.getByText('Sign Up')).toBeVisible();
1521
});
1622

1723
it('renders type staleSession', () => {
18-
render(<ErrorModal type="staleSession" closeModal={jest.fn()} />);
24+
render(
25+
<ErrorModal type="staleSession" closeModal={jest.fn()} service="google" />
26+
);
1927

2028
expect(screen.getByText('log in')).toBeVisible();
2129
});
2230

2331
it('renders type staleProject', () => {
24-
render(<ErrorModal type="staleProject" closeModal={jest.fn()} />);
32+
render(
33+
<ErrorModal type="staleProject" closeModal={jest.fn()} service="google" />
34+
);
2535

2636
expect(
2737
screen.getByText(

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ describe('<FileNode />', () => {
8383
});
8484

8585
it('can change to a different extension', async () => {
86+
const mockConfirm = jest.fn(() => true);
87+
window.confirm = mockConfirm;
88+
8689
const newName = 'newname.gif';
8790
const props = renderFileNode('file');
8891

8992
changeName(newName);
9093

91-
await waitFor(() => expect(props.updateFileName).not.toHaveBeenCalled());
94+
expect(mockConfirm).toHaveBeenCalled();
95+
await waitFor(() =>
96+
expect(props.updateFileName).toHaveBeenCalledWith(props.id, newName)
97+
);
9298
await expectFileNameToBe(props.name);
9399
});
94100

client/modules/IDE/components/QuickAddList/QuickAddList.jsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,21 @@ const Item = ({ isAdded, onSelect, name, url }) => {
1010
const buttonLabel = isAdded
1111
? t('QuickAddList.ButtonRemoveARIA')
1212
: t('QuickAddList.ButtonAddToCollectionARIA');
13+
14+
const handleKeyDown = (event) => {
15+
if (event.key === 'Enter' || event.key === ' ') {
16+
onSelect(event);
17+
}
18+
};
19+
1320
return (
14-
<li className="quick-add__item" onClick={onSelect}> { /* eslint-disable-line */ }
21+
<div
22+
role="button"
23+
className="quick-add__item"
24+
onClick={onSelect}
25+
onKeyDown={handleKeyDown}
26+
tabIndex={0}
27+
>
1528
<button
1629
className="quick-add__item-toggle"
1730
onClick={onSelect}
@@ -28,7 +41,7 @@ const Item = ({ isAdded, onSelect, name, url }) => {
2841
>
2942
{t('QuickAddList.View')}
3043
</Link>
31-
</li>
44+
</div>
3245
);
3346
};
3447

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
import { bindActionCreators } from 'redux';
2-
import { connect } from 'react-redux';
1+
import React from 'react';
2+
import { useDispatch, useSelector } from 'react-redux';
33
import i18next from 'i18next';
44
import * as SortingActions from '../../actions/sorting';
55

66
import Searchbar from './Searchbar';
77

88
const scope = 'collection';
99

10-
function mapStateToProps(state) {
11-
return {
12-
searchLabel: i18next.t('Searchbar.SearchCollection'),
13-
searchTerm: state.search[`${scope}SearchTerm`]
10+
const SearchbarContainer = () => {
11+
const dispatch = useDispatch();
12+
const searchLabel = i18next.t('Searchbar.SearchCollection');
13+
const searchTerm = useSelector((state) => state.search[`${scope}SearchTerm`]);
14+
15+
const setSearchTerm = (term) => {
16+
dispatch(SortingActions.setSearchTerm(scope, term));
1417
};
15-
}
1618

17-
function mapDispatchToProps(dispatch) {
18-
const actions = {
19-
setSearchTerm: (term) => SortingActions.setSearchTerm(scope, term),
20-
resetSearchTerm: () => SortingActions.resetSearchTerm(scope)
19+
const resetSearchTerm = () => {
20+
dispatch(SortingActions.resetSearchTerm(scope));
2121
};
22-
return bindActionCreators(Object.assign({}, actions), dispatch);
23-
}
2422

25-
export default connect(mapStateToProps, mapDispatchToProps)(Searchbar);
23+
return (
24+
<Searchbar
25+
searchLabel={searchLabel}
26+
searchTerm={searchTerm}
27+
setSearchTerm={setSearchTerm}
28+
resetSearchTerm={resetSearchTerm}
29+
/>
30+
);
31+
};
32+
33+
export default SearchbarContainer;

client/modules/IDE/components/Searchbar/Searchbar.jsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import React, { useState, useCallback, useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { throttle } from 'lodash';
4-
import { withTranslation } from 'react-i18next';
4+
import { useTranslation } from 'react-i18next';
55
import i18next from 'i18next';
66
import SearchIcon from '../../../../images/magnifyingglass.svg';
77

88
const Searchbar = ({
99
searchTerm,
1010
setSearchTerm,
1111
resetSearchTerm,
12-
searchLabel,
13-
t
12+
searchLabel
1413
}) => {
14+
const { t } = useTranslation();
1515
const [searchValue, setSearchValue] = useState(searchTerm);
1616

1717
const throttledSearchChange = useCallback(
1818
throttle((value) => {
1919
setSearchTerm(value.trim());
2020
}, 500),
21-
[]
21+
[setSearchTerm]
2222
);
2323

2424
const handleResetSearch = () => {
@@ -65,12 +65,11 @@ Searchbar.propTypes = {
6565
searchTerm: PropTypes.string.isRequired,
6666
setSearchTerm: PropTypes.func.isRequired,
6767
resetSearchTerm: PropTypes.func.isRequired,
68-
searchLabel: PropTypes.string,
69-
t: PropTypes.func.isRequired
68+
searchLabel: PropTypes.string
7069
};
7170

7271
Searchbar.defaultProps = {
7372
searchLabel: i18next.t('Searchbar.SearchSketch')
7473
};
7574

76-
export default withTranslation()(Searchbar);
75+
export default Searchbar;
Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
import { bindActionCreators } from 'redux';
2-
import { connect } from 'react-redux';
1+
import React from 'react';
2+
import { useDispatch, useSelector } from 'react-redux';
33
import i18next from 'i18next';
44
import * as SortingActions from '../../actions/sorting';
5-
65
import Searchbar from './Searchbar';
76

87
const scope = 'sketch';
98

10-
function mapStateToProps(state) {
11-
return {
12-
searchLabel: i18next.t('Searchbar.SearchSketch'),
13-
searchTerm: state.search[`${scope}SearchTerm`]
9+
const SearchbarContainer = () => {
10+
const dispatch = useDispatch();
11+
const searchLabel = i18next.t('Searchbar.SearchSketch');
12+
const searchTerm = useSelector((state) => state.search[`${scope}SearchTerm`]);
13+
14+
const setSearchTerm = (term) => {
15+
dispatch(SortingActions.setSearchTerm(scope, term));
1416
};
15-
}
1617

17-
function mapDispatchToProps(dispatch) {
18-
const actions = {
19-
setSearchTerm: (term) => SortingActions.setSearchTerm(scope, term),
20-
resetSearchTerm: () => SortingActions.resetSearchTerm(scope)
18+
const resetSearchTerm = () => {
19+
dispatch(SortingActions.resetSearchTerm(scope));
2120
};
22-
return bindActionCreators(Object.assign({}, actions), dispatch);
23-
}
2421

25-
export default connect(mapStateToProps, mapDispatchToProps)(Searchbar);
22+
return (
23+
<Searchbar
24+
searchLabel={searchLabel}
25+
searchTerm={searchTerm}
26+
setSearchTerm={setSearchTerm}
27+
resetSearchTerm={resetSearchTerm}
28+
/>
29+
);
30+
};
31+
32+
export default SearchbarContainer;

client/modules/IDE/components/Sidebar.jsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useState } from 'react';
1+
import React, { useRef } from 'react';
22
import classNames from 'classnames';
33
import { useTranslation } from 'react-i18next';
44
import { useDispatch, useSelector } from 'react-redux';
@@ -33,21 +33,10 @@ export default function SideBar() {
3333

3434
const sidebarOptionsRef = useRef(null);
3535

36-
const [isFocused, setIsFocused] = useState(false);
37-
3836
const isAuthenticated = useSelector(getAuthenticated);
3937

4038
const onBlurComponent = () => {
41-
setIsFocused(false);
42-
setTimeout(() => {
43-
if (!isFocused) {
44-
dispatch(closeProjectOptions());
45-
}
46-
}, 200);
47-
};
48-
49-
const onFocusComponent = () => {
50-
setIsFocused(true);
39+
setTimeout(() => dispatch(closeProjectOptions()), 200);
5140
};
5241

5342
const toggleProjectOptions = (e) => {
@@ -96,7 +85,6 @@ export default function SideBar() {
9685
ref={sidebarOptionsRef}
9786
onClick={toggleProjectOptions}
9887
onBlur={onBlurComponent}
99-
onFocus={onFocusComponent}
10088
>
10189
<PlusIcon focusable="false" aria-hidden="true" />
10290
</button>
@@ -109,7 +97,6 @@ export default function SideBar() {
10997
setTimeout(() => dispatch(closeProjectOptions()), 0);
11098
}}
11199
onBlur={onBlurComponent}
112-
onFocus={onFocusComponent}
113100
>
114101
{t('Sidebar.AddFolder')}
115102
</button>
@@ -122,7 +109,6 @@ export default function SideBar() {
122109
setTimeout(() => dispatch(closeProjectOptions()), 0);
123110
}}
124111
onBlur={onBlurComponent}
125-
onFocus={onFocusComponent}
126112
>
127113
{t('Sidebar.AddFile')}
128114
</button>
@@ -136,7 +122,6 @@ export default function SideBar() {
136122
setTimeout(() => dispatch(closeProjectOptions()), 0);
137123
}}
138124
onBlur={onBlurComponent}
139-
onFocus={onFocusComponent}
140125
>
141126
{t('Sidebar.UploadFile')}
142127
</button>

0 commit comments

Comments
 (0)