Skip to content

Commit ade7d2b

Browse files
committed
Connect ShareModal to Redux.
1 parent 59326e8 commit ade7d2b

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

client/modules/IDE/components/ShareModal.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import { useTranslation } from 'react-i18next';
3+
import { useSelector } from 'react-redux';
44
import CopyableInput from './CopyableInput';
55
// import getConfig from '../../../utils/getConfig';
66

7-
const ShareModal = ({ projectId, ownerUsername, projectName }) => {
7+
const ShareModal = () => {
88
const { t } = useTranslation();
9+
10+
// TODO: store these as nested properties instead of top-level
11+
const projectId = useSelector((state) => state.ide.shareModalProjectId);
12+
const projectName = useSelector((state) => state.ide.shareModalProjectName);
13+
const ownerUsername = useSelector(
14+
(state) => state.ide.shareModalProjectUsername
15+
);
16+
917
const hostname = window.location.origin;
1018
// const previewUrl = getConfig('PREVIEW_URL');
1119
return (
@@ -35,10 +43,4 @@ const ShareModal = ({ projectId, ownerUsername, projectName }) => {
3543
);
3644
};
3745

38-
ShareModal.propTypes = {
39-
projectId: PropTypes.string.isRequired,
40-
ownerUsername: PropTypes.string.isRequired,
41-
projectName: PropTypes.string.isRequired
42-
};
43-
4446
export default ShareModal;

client/modules/IDE/pages/IDEView.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,7 @@ class IDEView extends React.Component {
406406
ariaLabel={this.props.t('IDEView.ShareARIA')}
407407
closeOverlay={this.props.closeShareModal}
408408
>
409-
<ShareModal
410-
projectId={this.props.ide.shareModalProjectId}
411-
projectName={this.props.ide.shareModalProjectName}
412-
ownerUsername={this.props.ide.shareModalProjectUsername}
413-
/>
409+
<ShareModal />
414410
</Overlay>
415411
)}
416412
{this.props.ide.keyboardShortcutVisible && (
@@ -459,9 +455,6 @@ IDEView.propTypes = {
459455
errorType: PropTypes.string,
460456
keyboardShortcutVisible: PropTypes.bool.isRequired,
461457
shareModalVisible: PropTypes.bool.isRequired,
462-
shareModalProjectId: PropTypes.string.isRequired,
463-
shareModalProjectName: PropTypes.string.isRequired,
464-
shareModalProjectUsername: PropTypes.string.isRequired,
465458
previousPath: PropTypes.string.isRequired,
466459
previewIsRefreshing: PropTypes.bool.isRequired,
467460
isPlaying: PropTypes.bool.isRequired,

0 commit comments

Comments
 (0)