Skip to content

Commit 7174ce5

Browse files
committed
Share modal can now display different projects
1 parent 57d181a commit 7174ce5

File tree

6 files changed

+29
-16
lines changed

6 files changed

+29
-16
lines changed

client/modules/App/components/Overlay.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class Overlay extends React.Component {
3737
}
3838

3939
handleClickOutside() {
40-
console.log(this.node);
4140
this.close();
4241
}
4342

client/modules/IDE/actions/ide.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,17 @@ export function closeNewFolderModal() {
134134
};
135135
}
136136

137-
export function showShareModal() {
138-
return {
139-
type: ActionTypes.SHOW_SHARE_MODAL
137+
export function showShareModal(projectId, projectName, ownerUsername) {
138+
return (dispatch, getState) => {
139+
const { project, user } = getState();
140+
dispatch({
141+
type: ActionTypes.SHOW_SHARE_MODAL,
142+
payload: {
143+
shareModalProjectId: projectId || project.id,
144+
shareModalProjectName: projectName || project.name,
145+
shareModalOwnerUsername: ownerUsername || user.username
146+
}
147+
});
140148
};
141149
}
142150

client/modules/IDE/actions/project.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ export function cloneProject(id) {
223223
if (!id) {
224224
resolve(getState());
225225
} else {
226-
console.log(id);
227226
fetch(`${ROOT_URL}/projects/${id}`)
228227
.then(res => res.json())
229228
.then(data => resolve({
@@ -234,8 +233,6 @@ export function cloneProject(id) {
234233
}));
235234
}
236235
}).then((state) => {
237-
console.log('Huuray');
238-
console.log(state);
239236
const newFiles = state.files.map((file) => { // eslint-disable-line
240237
return { ...file };
241238
});

client/modules/IDE/components/SketchList.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import { browserHistory, Link } from 'react-router';
88
import { bindActionCreators } from 'redux';
99
import * as ProjectActions from '../actions/project';
1010
import * as SketchActions from '../actions/projects';
11-
import * as ToastActions from '../actions/toast';
1211
import * as IdeActions from '../actions/ide';
12+
import * as ToastActions from '../actions/toast';
1313

14-
// const trashCan = require('../../../images/trash-can.svg');
1514
const downFilledTriangle = require('../../../images/down-filled-triangle.svg');
1615
const btnUpTriangleDivot = require('../../../images/btn-up-triangle-divot.svg');
1716

@@ -220,16 +219,15 @@ class SketchList extends React.Component {
220219
>
221220
Duplicate
222221
</div> }
223-
{ this.props.project.id &&
224222
<div
225223
role="presentation"
226224
className="sketch-list__action-option"
227225
onClick={() => {
228-
this.props.showShareModal();
226+
this.props.showShareModal(sketch.id, sketch.name);
229227
}}
230228
>
231229
Share
232-
</div> }
230+
</div>
233231
<div
234232
role="presentation"
235233
className="sketch-list__action-option"

client/modules/IDE/pages/IDEView.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ class IDEView extends React.Component {
434434
closeOverlay={this.props.closeShareModal}
435435
>
436436
<ShareModal
437-
projectId={this.props.project.id}
438-
projectName={this.props.project.name}
439-
ownerUsername={this.props.project.owner.username}
437+
projectId={this.props.ide.shareModalProjectId}
438+
projectName={this.props.ide.shareModalProjectName}
439+
ownerUsername={this.props.ide.shareModalProjectUsername}
440440
/>
441441
</Overlay>
442442
}
@@ -501,6 +501,9 @@ IDEView.propTypes = {
501501
projectOptionsVisible: PropTypes.bool.isRequired,
502502
newFolderModalVisible: PropTypes.bool.isRequired,
503503
shareModalVisible: PropTypes.bool.isRequired,
504+
shareModalProjectId: PropTypes.string.isRequired,
505+
shareModalProjectName: PropTypes.string.isRequired,
506+
shareModalProjectUsername: PropTypes.string.isRequired,
504507
editorOptionsVisible: PropTypes.bool.isRequired,
505508
keyboardShortcutVisible: PropTypes.bool.isRequired,
506509
unsavedChanges: PropTypes.bool.isRequired,

client/modules/IDE/reducers/ide.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const initialState = {
1010
projectOptionsVisible: false,
1111
newFolderModalVisible: false,
1212
shareModalVisible: false,
13+
shareModalProjectId: null,
14+
shareModalProjectName: null,
15+
shareModalOwnerUsername: null,
1316
editorOptionsVisible: false,
1417
keyboardShortcutVisible: false,
1518
unsavedChanges: false,
@@ -61,7 +64,12 @@ const ide = (state = initialState, action) => {
6164
case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
6265
return Object.assign({}, state, { newFolderModalVisible: false });
6366
case ActionTypes.SHOW_SHARE_MODAL:
64-
return Object.assign({}, state, { shareModalVisible: true });
67+
return Object.assign({}, state, {
68+
shareModalVisible: true,
69+
shareModalProjectId: action.payload.shareModalProjectId,
70+
shareModalProjectName: action.payload.shareModalProjectName,
71+
shareModalOwnerUsername: action.payload.shareModalOwnerUsername,
72+
});
6573
case ActionTypes.CLOSE_SHARE_MODAL:
6674
return Object.assign({}, state, { shareModalVisible: false });
6775
case ActionTypes.SHOW_EDITOR_OPTIONS:

0 commit comments

Comments
 (0)