Skip to content

Commit 9f23c93

Browse files
authored
Merge branch 'develop' into refactor/prefer-use-translation
2 parents 6c35e01 + 42ecd5d commit 9f23c93

File tree

5 files changed

+14
-64
lines changed

5 files changed

+14
-64
lines changed
Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
3-
import { bindActionCreators } from 'redux';
4-
import { connect } from 'react-redux';
2+
import { useDispatch, useSelector } from 'react-redux';
53
import { useTranslation } from 'react-i18next';
6-
import * as ToastActions from '../actions/toast';
4+
import { hideToast } from '../actions/toast';
75

86
import ExitIcon from '../../../images/exit.svg';
97

10-
function Toast(props) {
8+
export default function Toast() {
9+
const { text, isVisible } = useSelector((state) => state.toast);
10+
const dispatch = useDispatch();
1111
const { t } = useTranslation();
12+
if (!isVisible) {
13+
return null;
14+
}
1215
return (
1316
<section className="toast">
14-
<p>{t(props.text)}</p>
17+
<p>{t(text)}</p>
1518
<button
1619
className="toast__close"
17-
onClick={props.hideToast}
20+
onClick={() => dispatch(hideToast())}
1821
aria-label="Close Alert"
1922
>
2023
<ExitIcon focusable="false" aria-hidden="true" />
2124
</button>
2225
</section>
2326
);
2427
}
25-
26-
Toast.propTypes = {
27-
text: PropTypes.string.isRequired,
28-
hideToast: PropTypes.func.isRequired
29-
};
30-
31-
function mapStateToProps(state) {
32-
return state.toast;
33-
}
34-
35-
function mapDispatchToProps(dispatch) {
36-
return bindActionCreators(ToastActions, dispatch);
37-
}
38-
39-
export default connect(mapStateToProps, mapDispatchToProps)(Toast);

client/modules/IDE/pages/IDEView.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import * as ProjectActions from '../actions/project';
2626
import * as EditorAccessibilityActions from '../actions/editorAccessibility';
2727
import * as PreferencesActions from '../actions/preferences';
2828
import * as UserActions from '../../User/actions';
29-
import * as ToastActions from '../actions/toast';
3029
import * as ConsoleActions from '../actions/console';
3130
import { getHTMLFile } from '../reducers/files';
3231
import Overlay from '../../App/components/Overlay';
@@ -255,7 +254,7 @@ class IDEView extends React.Component {
255254
<Helmet>
256255
<title>{getTitle(this.props)}</title>
257256
</Helmet>
258-
{this.props.toast.isVisible && <Toast />}
257+
<Toast />
259258
<Nav
260259
warnIfUnsavedChanges={this.handleUnsavedChanges}
261260
cmController={this.cmController}
@@ -561,9 +560,6 @@ IDEView.propTypes = {
561560
closeNewFileModal: PropTypes.func.isRequired,
562561
closeShareModal: PropTypes.func.isRequired,
563562
closeKeyboardShortcutModal: PropTypes.func.isRequired,
564-
toast: PropTypes.shape({
565-
isVisible: PropTypes.bool.isRequired
566-
}).isRequired,
567563
autosaveProject: PropTypes.func.isRequired,
568564
router: PropTypes.shape({
569565
setRouteLeaveHook: PropTypes.func
@@ -594,7 +590,6 @@ function mapStateToProps(state) {
594590
editorAccessibility: state.editorAccessibility,
595591
user: state.user,
596592
project: state.project,
597-
toast: state.toast,
598593
console: state.console,
599594
isUserOwner: getIsUserOwner(state)
600595
};
@@ -610,7 +605,6 @@ function mapDispatchToProps(dispatch) {
610605
IDEActions,
611606
PreferencesActions,
612607
UserActions,
613-
ToastActions,
614608
ConsoleActions
615609
),
616610
dispatch

client/modules/IDE/pages/MobileIDEView.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ const MobileIDEView = (props) => {
278278
files,
279279
toggleForceDesktop,
280280
logoutUser,
281-
toast,
282281
isUserOwner
283282
} = props;
284283

@@ -383,7 +382,7 @@ const MobileIDEView = (props) => {
383382
/>
384383
</li>
385384
</Header>
386-
{toast.isVisible && <Toast />}
385+
<Toast />
387386

388387
<IDEWrapper>
389388
<Editor provideController={setCmController} />
@@ -456,10 +455,6 @@ MobileIDEView.propTypes = {
456455
username: PropTypes.string
457456
}).isRequired,
458457

459-
toast: PropTypes.shape({
460-
isVisible: PropTypes.bool
461-
}).isRequired,
462-
463458
logoutUser: PropTypes.func.isRequired,
464459

465460
getProject: PropTypes.func.isRequired,
@@ -490,7 +485,6 @@ function mapStateToProps(state) {
490485
preferences: state.preferences,
491486
user: state.user,
492487
project: state.project,
493-
toast: state.toast,
494488
console: state.console,
495489
isUserOwner: getIsUserOwner(state)
496490
};

client/modules/User/pages/AccountView.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class AccountView extends React.Component {
6161
<Helmet>
6262
<title>{this.props.t('AccountView.Title')}</title>
6363
</Helmet>
64-
{this.props.toast.isVisible && <Toast />}
64+
<Toast />
6565

6666
<Nav layout="dashboard" />
6767

@@ -122,8 +122,7 @@ function mapStateToProps(state) {
122122
previousPath: state.ide.previousPath,
123123
user: state.user,
124124
apiKeys: state.user.apiKeys,
125-
theme: state.preferences.theme,
126-
toast: state.toast
125+
theme: state.preferences.theme
127126
};
128127
}
129128

@@ -144,9 +143,6 @@ AccountView.propTypes = {
144143
location: PropTypes.shape({
145144
search: PropTypes.string.isRequired,
146145
pathname: PropTypes.string.isRequired
147-
}).isRequired,
148-
toast: PropTypes.shape({
149-
isVisible: PropTypes.bool.isRequired
150146
}).isRequired
151147
};
152148

contributor_docs/installation.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ _Note_: The installation steps assume you are using a Unix-like shell. If you ar
2525
7. Install MongoDB and make sure it is running
2626
* For Mac OSX with [homebrew](http://brew.sh/): `brew tap mongodb/brew` then `brew install mongodb-community` and finally start the server with `brew services start mongodb-community` or you can visit the installation guide here [Installation Guide For MacOS](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/)
2727
* For Windows and Linux: [MongoDB Installation](https://docs.mongodb.com/manual/installation/)
28-
<<<<<<< HEAD:contributor_docs/installation.md
2928
8. `$ cp .env.example .env`
3029
9. (Optional) Update `.env` with necessary keys to enable certain app behaviors, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
3130
10. Run `$ npm run fetch-examples` to download the example sketches into a user called 'p5'. Note that you need to configure your GitHub Credentials, which you can do by following the [Github API Configuration](#github-api-configuration) section.
@@ -34,16 +33,6 @@ _Note_: The installation steps assume you are using a Unix-like shell. If you ar
3433
13. Navigate to [http://localhost:8000](http://localhost:8000) in your browser
3534
14. Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
3635
15. Open and close the Redux DevTools using `ctrl+h`, and move them with `ctrl+w`
37-
=======
38-
7. `$ cp .env.example .env`
39-
8. (Optional) Update `.env` with necessary keys to enable certain app behaviours, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
40-
9. Run `$ npm run fetch-examples` to download the example sketches into a user called 'p5'. Note that you need to configure your GitHub Credentials, which you can do by following the [Github API Configuration](#github-api-configuration) section.
41-
10. Enable Prettier in your text editor by following [this guide](https://prettier.io/docs/en/editors.html).
42-
11. `$ npm start`
43-
12. Navigate to [http://localhost:8000](http://localhost:8000) in your browser
44-
13. Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
45-
14. Open and close the Redux DevTools using `ctrl+h`, and move them with `ctrl+w`
46-
>>>>>>> 1129cb97b545e7fa0a7d463fcf3f1c596e1fbf49:developer_docs/installation.md
4736

4837
## Docker Installation
4938

@@ -54,7 +43,6 @@ Using Docker, you can have a complete, consistent development environment withou
5443
Note that this takes up a significant amount of space on your machine. Make sure you have at least 5GB free.
5544

5645
1. Install Docker for your operating system
57-
<<<<<<< HEAD:contributor_docs/installation.md
5846
* [Mac](https://www.docker.com/docker-mac)
5947
* [Windows](https://www.docker.com/docker-windows)
6048
2. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
@@ -64,16 +52,6 @@ Note that this takes up a significant amount of space on your machine. Make sure
6452
6. (Optional) Update `.env` with necessary keys to enable certain app behavoirs, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
6553
7. `$ docker-compose -f docker-compose-development.yml run --rm app npm run fetch-examples` - note that you need to configure your GitHub Credentials, which you can do by following the [Github API Configuration](#github-api-configuration) section.
6654
8. Enable Prettier in your text editor by following [this guide](https://prettier.io/docs/en/editors.html).
67-
=======
68-
* Mac: https://www.docker.com/docker-mac
69-
* Windows: https://www.docker.com/docker-windows
70-
2. Clone this repository and cd into it
71-
3. `$ docker-compose -f docker-compose-development.yml build`
72-
4. `$ cp .env.example .env`
73-
5. (Optional) Update `.env` with necessary keys to enable certain app behaviours, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
74-
6. `$ docker-compose -f docker-compose-development.yml run --rm app npm run fetch-examples` - note that you need to configure your GitHub Credentials, which you can do by following the [Github API Configuration](#github-api-configuration) section.
75-
7. Enable Prettier in your text editor by following [this guide](https://prettier.io/docs/en/editors.html).
76-
>>>>>>> 1129cb97b545e7fa0a7d463fcf3f1c596e1fbf49:developer_docs/installation.md
7755

7856
Now, anytime you wish to start the server with its dependencies, you can run:
7957

0 commit comments

Comments
 (0)