Skip to content

Commit 2ce692c

Browse files
committed
removed custom modal, to reduce scope of changes
1 parent 7901c66 commit 2ce692c

File tree

8 files changed

+39
-149
lines changed

8 files changed

+39
-149
lines changed

src/components/gui/gui.jsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import Alerts from '../../containers/alerts.jsx';
3030
import DragLayer from '../../containers/drag-layer.jsx';
3131
import ConnectionModal from '../../containers/connection-modal.jsx';
3232
import TelemetryModal from '../telemetry-modal/telemetry-modal.jsx';
33-
import Confirm from '../prompt/confirm.jsx';
3433

3534
import layout, {STAGE_SIZE_MODES} from '../../lib/layout-constants';
3635
import {resolveStageSize} from '../../lib/screen-utils';
@@ -40,7 +39,6 @@ import addExtensionIcon from './icon--extensions.svg';
4039
import codeIcon from './icon--code.svg';
4140
import costumesIcon from './icon--costumes.svg';
4241
import soundsIcon from './icon--sounds.svg';
43-
import fileUploadIcon from '../../lib/assets/icon--file-upload-blue.svg';
4442

4543
import sharedMessages from '../../lib/shared-messages';
4644
const messages = defineMessages({
@@ -81,7 +79,6 @@ const GUIComponent = props => {
8179
costumeLibraryVisible,
8280
costumesTabVisible,
8381
enableCommunity,
84-
fileUploadConfirmVisible,
8582
intl,
8683
isCreating,
8784
isFullScreen,
@@ -90,10 +87,8 @@ const GUIComponent = props => {
9087
isShared,
9188
loading,
9289
renderLogin,
93-
onCancelFileUpload,
9490
onClickAccountNav,
9591
onCloseAccountNav,
96-
onConfirmFileUpload,
9792
onLogOut,
9893
onOpenRegistration,
9994
onToggleLoginOpen,
@@ -204,15 +199,6 @@ const GUIComponent = props => {
204199
onRequestClose={onRequestCloseBackdropLibrary}
205200
/>
206201
) : null}
207-
{fileUploadConfirmVisible ? (
208-
<Confirm
209-
iconSrc={fileUploadIcon}
210-
label={intl.formatMessage(sharedMessages.replaceProjectWarning)}
211-
title={intl.formatMessage(sharedMessages.loadFromComputerTitle)}
212-
onCancel={onCancelFileUpload}
213-
onOk={onConfirmFileUpload}
214-
/>
215-
) : null}
216202
<MenuBar
217203
accountNavOpen={accountNavOpen}
218204
authorId={authorId}
@@ -388,7 +374,6 @@ GUIComponent.propTypes = {
388374
costumeLibraryVisible: PropTypes.bool,
389375
costumesTabVisible: PropTypes.bool,
390376
enableCommunity: PropTypes.bool,
391-
fileUploadConfirmVisible: PropTypes.bool,
392377
intl: intlShape.isRequired,
393378
isCreating: PropTypes.bool,
394379
isFullScreen: PropTypes.bool,
@@ -399,11 +384,9 @@ GUIComponent.propTypes = {
399384
onActivateCostumesTab: PropTypes.func,
400385
onActivateSoundsTab: PropTypes.func,
401386
onActivateTab: PropTypes.func,
402-
onCancelFileUpload: PropTypes.func.isRequired,
403387
onClickAccountNav: PropTypes.func,
404388
onClickLogo: PropTypes.func,
405389
onCloseAccountNav: PropTypes.func,
406-
onConfirmFileUpload: PropTypes.func.isRequired,
407390
onExtensionButtonClick: PropTypes.func,
408391
onLogOut: PropTypes.func,
409392
onOpenRegistration: PropTypes.func,
@@ -443,8 +426,6 @@ GUIComponent.defaultProps = {
443426
isCreating: false,
444427
isShared: false,
445428
loading: false,
446-
onCancelFileUpload: () => {},
447-
onConfirmFileUpload: () => {},
448429
onUpdateProjectTitle: () => {},
449430
showComingSoon: false,
450431
stageSizeMode: STAGE_SIZE_MODES.large

src/components/prompt/confirm.jsx

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

src/components/prompt/prompt.css

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717

1818
.label {
1919
font-weight: 500;
20+
margin: 0 0 0.75rem;
2021
}
2122

2223
.disabled-label {
2324
opacity: 0.5;
2425
}
2526

26-
.icon {
27-
margin: .5rem 1rem .5rem .75rem;
28-
width: 4.125rem;
29-
}
30-
3127
.variable-name-text-input {
3228
margin-bottom: 1.5rem;
3329
width: 100%;
@@ -46,13 +42,6 @@
4642
text-align: center;
4743
}
4844

49-
.label-row {
50-
display: flex;
51-
justify-content: space-between;
52-
align-items: center;
53-
margin: 0 0 0.75rem;
54-
}
55-
5645
.options-row {
5746
display: flex;
5847
font-weight: normal;
@@ -65,11 +54,6 @@
6554
text-align: right;
6655
}
6756

68-
.button-row.center {
69-
text-align: center;
70-
margin: 0 auto;
71-
}
72-
7357
.button-row button {
7458
padding: 0.75rem 1rem;
7559
border-radius: 0.25rem;

src/components/prompt/prompt.jsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import classNames from 'classnames';
2-
import {defineMessages, FormattedMessage, injectIntl, intlShape} from 'react-intl';
2+
import {defineMessages, FormattedMessage} from 'react-intl';
33
import PropTypes from 'prop-types';
44
import React from 'react';
55

66
import Box from '../box/box.jsx';
77
import Modal from '../../containers/modal.jsx';
8-
import sharedMessages from '../../lib/shared-messages';
98

109
import styles from './prompt.css';
1110

@@ -41,10 +40,8 @@ const PromptComponent = props => (
4140
onRequestClose={props.onCancel}
4241
>
4342
<Box className={styles.body}>
44-
<Box className={styles.labelRow}>
45-
<Box className={styles.label}>
46-
{props.label}
47-
</Box>
43+
<Box className={styles.label}>
44+
{props.label}
4845
</Box>
4946
<Box>
5047
<input
@@ -117,13 +114,21 @@ const PromptComponent = props => (
117114
className={styles.cancelButton}
118115
onClick={props.onCancel}
119116
>
120-
{props.intl.formatMessage(sharedMessages.cancel)}
117+
<FormattedMessage
118+
defaultMessage="Cancel"
119+
description="Button in prompt for cancelling the dialog"
120+
id="gui.prompt.cancel"
121+
/>
121122
</button>
122123
<button
123124
className={styles.okButton}
124125
onClick={props.onOk}
125126
>
126-
{props.intl.formatMessage(sharedMessages.ok)}
127+
<FormattedMessage
128+
defaultMessage="OK"
129+
description="Button in prompt for confirming the dialog"
130+
id="gui.prompt.ok"
131+
/>
127132
</button>
128133
</Box>
129134
</Box>
@@ -135,7 +140,6 @@ PromptComponent.propTypes = {
135140
cloudSelected: PropTypes.bool.isRequired,
136141
defaultValue: PropTypes.string,
137142
globalSelected: PropTypes.bool.isRequired,
138-
intl: intlShape.isRequired,
139143
isStage: PropTypes.bool.isRequired,
140144
label: PropTypes.string.isRequired,
141145
onCancel: PropTypes.func.isRequired,
@@ -150,4 +154,4 @@ PromptComponent.propTypes = {
150154
title: PropTypes.string.isRequired
151155
};
152156

153-
export default injectIntl(PromptComponent);
157+
export default PromptComponent;

src/lib/assets/icon--file-upload-blue.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/lib/sb-file-uploader-hoc.jsx

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import bindAll from 'lodash.bindall';
22
import React from 'react';
33
import PropTypes from 'prop-types';
4+
import {defineMessages, intlShape, injectIntl} from 'react-intl';
45
import {connect} from 'react-redux';
56
import log from '../lib/log';
7+
import sharedMessages from './shared-messages';
68

79
import {
810
LoadingStates,
@@ -19,13 +21,13 @@ import {
1921
closeFileMenu
2022
} from '../reducers/menus';
2123

22-
// const messages = defineMessages({
23-
// loadError: {
24-
// id: 'gui.projectLoader.loadError',
25-
// defaultMessage: 'The project file that was selected failed to load.',
26-
// description: 'An error that displays when a local project file fails to load.'
27-
// }
28-
// });
24+
const messages = defineMessages({
25+
loadError: {
26+
id: 'gui.projectLoader.loadError',
27+
defaultMessage: 'The project file that was selected failed to load.',
28+
description: 'An error that displays when a local project file fails to load.'
29+
}
30+
});
2931

3032
/**
3133
* Higher Order Component to provide behavior for loading local project files into editor.
@@ -45,15 +47,9 @@ const SBFileUploaderHOC = function (WrappedComponent) {
4547
'handleStartSelectingFileUpload',
4648
'setFileInput',
4749
'handleChange',
48-
'handleConfirmClickedCancel',
49-
'handleConfirmClickedOK',
50-
'handleConfirmClose',
5150
'onload',
5251
'resetFileInput'
5352
]);
54-
this.state = {
55-
showingConfirm: false
56-
};
5753
}
5854
componentWillMount () {
5955
this.reader = new FileReader();
@@ -90,6 +86,7 @@ const SBFileUploaderHOC = function (WrappedComponent) {
9086
// called when user has finished selecting a file to upload
9187
handleChange (e) {
9288
const {
89+
intl,
9390
isShowingWithoutId,
9491
loadingState,
9592
projectChanged,
@@ -103,25 +100,20 @@ const SBFileUploaderHOC = function (WrappedComponent) {
103100
// If user owns the project, or user has changed the project,
104101
// we must confirm with the user that they really intend to replace it.
105102
// (If they don't own the project and haven't changed it, no need to confirm.)
103+
let uploadAllowed = true;
106104
if (userOwnsProject || (projectChanged && isShowingWithoutId)) {
107-
this.setState({showingConfirm: true});
108-
} else {
105+
uploadAllowed = confirm( // eslint-disable-line no-alert
106+
intl.formatMessage(sharedMessages.replaceProjectWarning)
107+
);
108+
}
109+
if (uploadAllowed) {
109110
this.props.requestProjectUpload(loadingState);
111+
} else {
112+
this.resetFileInput();
110113
}
114+
this.props.closeFileMenu();
111115
}
112116
}
113-
handleConfirmClickedCancel () {
114-
this.resetFileInput();
115-
this.handleConfirmClose();
116-
}
117-
handleConfirmClickedOK () {
118-
this.props.requestProjectUpload(this.props.loadingState);
119-
this.handleConfirmClose();
120-
}
121-
handleConfirmClose () {
122-
this.setState({showingConfirm: false});
123-
this.props.closeFileMenu();
124-
}
125117
// called when file upload raw data is available in the reader
126118
onload () {
127119
if (this.reader) {
@@ -140,8 +132,7 @@ const SBFileUploaderHOC = function (WrappedComponent) {
140132
})
141133
.catch(error => {
142134
log.warn(error);
143-
// NOTE: revise this
144-
alert('this.props.intl.formatMessage(messages.loadError)'); // eslint-disable-line no-alert
135+
this.props.intl.formatMessage(messages.loadError); // eslint-disable-line no-alert
145136
this.props.onLoadingFinished(this.props.loadingState, false);
146137
// Reset the file input after project is loaded
147138
// This is necessary in case the user wants to reload a project
@@ -183,9 +174,6 @@ const SBFileUploaderHOC = function (WrappedComponent) {
183174
return (
184175
<React.Fragment>
185176
<WrappedComponent
186-
fileUploadConfirmVisible={this.state.showingConfirm}
187-
onCancelFileUpload={this.handleConfirmClickedCancel}
188-
onConfirmFileUpload={this.handleConfirmClickedOK}
189177
onStartSelectingFileUpload={this.handleStartSelectingFileUpload}
190178
{...componentProps}
191179
/>
@@ -199,6 +187,7 @@ const SBFileUploaderHOC = function (WrappedComponent) {
199187
canSave: PropTypes.bool,
200188
cancelFileUpload: PropTypes.func,
201189
closeFileMenu: PropTypes.func,
190+
intl: intlShape.isRequired,
202191
isLoadingUpload: PropTypes.bool,
203192
isShowingWithoutId: PropTypes.bool,
204193
loadingState: PropTypes.oneOf(LoadingStates),
@@ -240,11 +229,11 @@ const SBFileUploaderHOC = function (WrappedComponent) {
240229
const mergeProps = (stateProps, dispatchProps, ownProps) => Object.assign(
241230
{}, stateProps, dispatchProps, ownProps
242231
);
243-
return connect(
232+
return injectIntl(connect(
244233
mapStateToProps,
245234
mapDispatchToProps,
246235
mergeProps
247-
)(SBFileUploaderComponent);
236+
)(SBFileUploaderComponent));
248237
};
249238

250239
export {

src/lib/shared-messages.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,5 @@ export default defineMessages({
3030
id: 'gui.sharedMessages.loadFromComputerTitle',
3131
defaultMessage: 'Load from your computer',
3232
description: 'Title for uploading a project from your computer'
33-
},
34-
cancel: {
35-
id: 'gui.sharedMessages.cancel',
36-
defaultMessage: 'Cancel',
37-
description: 'Label for button to indicate user wants to cancel'
38-
},
39-
ok: {
40-
id: 'gui.sharedMessages.ok',
41-
defaultMessage: 'OK',
42-
description: 'Label for button to indicate user is OK with continuing'
4333
}
4434
});

0 commit comments

Comments
 (0)