Skip to content

Commit a4e3683

Browse files
committed
upload in current project id, rather than creating new project id
1 parent ce6df36 commit a4e3683

File tree

11 files changed

+196
-86
lines changed

11 files changed

+196
-86
lines changed
Lines changed: 1 addition & 12 deletions
Loading

src/components/menu-bar/menu-bar.jsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,19 +393,18 @@ class MenuBar extends React.Component {
393393
</MenuSection>
394394
)}
395395
<MenuSection>
396-
<SBFileUploader onUpdateProjectTitle={this.props.onUpdateProjectTitle}>
396+
<SBFileUploader
397+
canSave={this.props.canSave}
398+
userOwnsProject={this.props.authorUsername &&
399+
(this.props.authorUsername === this.props.username)}
400+
onUpdateProjectTitle={this.props.onUpdateProjectTitle}
401+
>
397402
{(className, renderFileInput, loadProject) => (
398403
<MenuItem
399404
className={className}
400405
onClick={loadProject}
401406
>
402-
<FormattedMessage
403-
defaultMessage="Load from your computer"
404-
description={
405-
'Menu bar item for uploading a project from your computer'
406-
}
407-
id="gui.menuBar.uploadFromComputer"
408-
/>
407+
{this.props.intl.formatMessage(sharedMessages.loadFromComputerTitle)}
409408
{renderFileInput()}
410409
</MenuItem>
411410
)}

src/components/prompt/confirm.jsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import classNames from 'classnames';
2+
import {injectIntl, intlShape} from 'react-intl';
3+
import PropTypes from 'prop-types';
4+
import React from 'react';
5+
6+
import Box from '../box/box.jsx';
7+
import Modal from '../../containers/modal.jsx';
8+
import sharedMessages from '../../lib/shared-messages';
9+
10+
import styles from './prompt.css';
11+
12+
const ConfirmComponent = props => (
13+
<Modal
14+
className={styles.modalContent}
15+
contentLabel={props.title}
16+
onRequestClose={props.onCancel}
17+
>
18+
<Box className={styles.body}>
19+
<Box className={styles.labelRow}>
20+
{props.iconSrc && (
21+
<img
22+
className={styles.icon}
23+
src={props.iconSrc}
24+
/>
25+
)}
26+
<Box className={styles.label}>
27+
{props.label}
28+
</Box>
29+
</Box>
30+
<Box className={classNames(styles.buttonRow, styles.center)}>
31+
<button
32+
className={styles.cancelButton}
33+
onClick={props.onCancel}
34+
>
35+
{props.intl.formatMessage(sharedMessages.cancel)}
36+
</button>
37+
<button
38+
className={styles.okButton}
39+
onClick={props.onOk}
40+
>
41+
{props.intl.formatMessage(sharedMessages.ok)}
42+
</button>
43+
</Box>
44+
</Box>
45+
</Modal>
46+
);
47+
48+
ConfirmComponent.propTypes = {
49+
iconSrc: PropTypes.string,
50+
intl: intlShape.isRequired,
51+
label: PropTypes.string.isRequired,
52+
onCancel: PropTypes.func.isRequired,
53+
onOk: PropTypes.func.isRequired,
54+
title: PropTypes.string.isRequired
55+
};
56+
57+
export default injectIntl(ConfirmComponent);

src/components/prompt/prompt.css

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

1818
.label {
1919
font-weight: 500;
20-
margin: 0 0 0.75rem;
2120
}
2221

2322
.disabled-label {
2423
opacity: 0.5;
2524
}
2625

26+
.icon {
27+
margin: .5rem 1rem .5rem .75rem;
28+
width: 4.125rem;
29+
}
30+
2731
.variable-name-text-input {
2832
margin-bottom: 1.5rem;
2933
width: 100%;
@@ -42,6 +46,13 @@
4246
text-align: center;
4347
}
4448

49+
.label-row {
50+
display: flex;
51+
justify-content: space-between;
52+
align-items: center;
53+
margin: 0 0 0.75rem;
54+
}
55+
4556
.options-row {
4657
display: flex;
4758
font-weight: normal;
@@ -54,6 +65,11 @@
5465
text-align: right;
5566
}
5667

68+
.button-row.center {
69+
text-align: center;
70+
margin: 0 auto;
71+
}
72+
5773
.button-row button {
5874
padding: 0.75rem 1rem;
5975
border-radius: 0.25rem;

src/components/prompt/prompt.jsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import classNames from 'classnames';
2-
import {defineMessages, FormattedMessage} from 'react-intl';
2+
import {defineMessages, FormattedMessage, injectIntl, intlShape} 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';
89

910
import styles from './prompt.css';
1011

@@ -40,8 +41,10 @@ const PromptComponent = props => (
4041
onRequestClose={props.onCancel}
4142
>
4243
<Box className={styles.body}>
43-
<Box className={styles.label}>
44-
{props.label}
44+
<Box className={styles.labelRow}>
45+
<Box className={styles.label}>
46+
{props.label}
47+
</Box>
4548
</Box>
4649
<Box>
4750
<input
@@ -114,21 +117,13 @@ const PromptComponent = props => (
114117
className={styles.cancelButton}
115118
onClick={props.onCancel}
116119
>
117-
<FormattedMessage
118-
defaultMessage="Cancel"
119-
description="Button in prompt for cancelling the dialog"
120-
id="gui.prompt.cancel"
121-
/>
120+
{props.intl.formatMessage(sharedMessages.cancel)}
122121
</button>
123122
<button
124123
className={styles.okButton}
125124
onClick={props.onOk}
126125
>
127-
<FormattedMessage
128-
defaultMessage="OK"
129-
description="Button in prompt for confirming the dialog"
130-
id="gui.prompt.ok"
131-
/>
126+
{props.intl.formatMessage(sharedMessages.ok)}
132127
</button>
133128
</Box>
134129
</Box>
@@ -140,6 +135,7 @@ PromptComponent.propTypes = {
140135
cloudSelected: PropTypes.bool.isRequired,
141136
defaultValue: PropTypes.string,
142137
globalSelected: PropTypes.bool.isRequired,
138+
intl: intlShape.isRequired,
143139
isStage: PropTypes.bool.isRequired,
144140
label: PropTypes.string.isRequired,
145141
onCancel: PropTypes.func.isRequired,
@@ -154,4 +150,4 @@ PromptComponent.propTypes = {
154150
title: PropTypes.string.isRequired
155151
};
156152

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

src/containers/confirm.jsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import PropTypes from 'prop-types';
2+
import React from 'react';
3+
import bindAll from 'lodash.bindall';
4+
import ConfirmComponent from '../components/prompt/confirm.jsx';
5+
6+
class Confirm extends React.Component {
7+
constructor (props) {
8+
super(props);
9+
bindAll(this, [
10+
'handleOk',
11+
'handleCancel'
12+
]);
13+
}
14+
handleOk () {
15+
this.props.onOk();
16+
}
17+
handleCancel () {
18+
this.props.onCancel();
19+
}
20+
render () {
21+
return (
22+
<ConfirmComponent
23+
iconSrc={this.props.iconSrc}
24+
label={this.props.label}
25+
title={this.props.title}
26+
onCancel={this.handleCancel}
27+
onOk={this.handleOk}
28+
/>
29+
);
30+
}
31+
}
32+
33+
Confirm.propTypes = {
34+
iconSrc: PropTypes.string,
35+
label: PropTypes.string.isRequired,
36+
onCancel: PropTypes.func.isRequired,
37+
onOk: PropTypes.func.isRequired,
38+
title: PropTypes.string.isRequired
39+
};
40+
41+
export default Confirm;

0 commit comments

Comments
 (0)