Commit 60b98908 authored by seotts's avatar seotts

use selectIsMuted to determine whether to show error

parent 2cc413f8
...@@ -8,19 +8,47 @@ const Button = require('../../components/forms/button.jsx'); ...@@ -8,19 +8,47 @@ const Button = require('../../components/forms/button.jsx');
const AddToStudioModal = require('./add-to-studio.jsx'); const AddToStudioModal = require('./add-to-studio.jsx');
const SocialModal = require('../../components/modal/social/container.jsx'); const SocialModal = require('../../components/modal/social/container.jsx');
const ReportModal = require('../../components/modal/report/modal.jsx'); const ReportModal = require('../../components/modal/report/modal.jsx');
const {connect} = require('react-redux');
const {useState} = require('react');
const projectShape = require('./projectshape.jsx').projectShape; const projectShape = require('./projectshape.jsx').projectShape;
import {selectIsMuted, selectNewStudiosLaunched} from '../../redux/session.js';
import StudioMuteEditMessage from '../studio/studio-mute-edit-message.jsx';
require('./subactions.scss'); require('./subactions.scss');
const Subactions = props => ( const Subactions = ({
addToStudioOpen,
canAddToStudio,
canReport,
isAdmin,
isShared,
onAddToStudioClicked,
onAddToStudioClosed,
onReportClicked,
onReportClose,
onReportSubmit,
onSocialClicked,
onSocialClosed,
onToggleStudio,
projectInfo,
reportOpen,
shareDate,
showAddToStudioMuteError,
socialOpen,
userOwnsProject
}) => {
const [showMuteMessage, setShowMuteMessage] = useState(false);
return (
<FlexRow className="subactions"> <FlexRow className="subactions">
<div className="share-date"> <div className="share-date">
<div className="copyleft">&copy;</div> <div className="copyleft">&copy;</div>
{' '} {' '}
{/* eslint-disable react/jsx-sort-props */} {/* eslint-disable react/jsx-sort-props */}
{props.shareDate ? ( {shareDate ? (
<FormattedDate <FormattedDate
value={Date.parse(props.shareDate)} value={Date.parse(shareDate)}
day="2-digit" day="2-digit"
month="short" month="short"
year="numeric" year="numeric"
...@@ -29,69 +57,83 @@ const Subactions = props => ( ...@@ -29,69 +57,83 @@ const Subactions = props => (
{/* eslint-enable react/jsx-sort-props */} {/* eslint-enable react/jsx-sort-props */}
</div> </div>
<FlexRow className="action-buttons"> <FlexRow className="action-buttons">
{(props.canReport) && {(canReport) &&
<React.Fragment> <React.Fragment>
<Button <Button
className="action-button report-button" className="action-button report-button"
key="report-button" key="report-button"
onClick={props.onReportClicked} onClick={onReportClicked}
> >
<FormattedMessage id="general.report" /> <FormattedMessage id="general.report" />
</Button> </Button>
{props.reportOpen && ( {reportOpen && (
<ReportModal <ReportModal
isOpen isOpen
key="report-modal" key="report-modal"
type="project" type="project"
onReport={props.onReportSubmit} onReport={onReportSubmit}
onRequestClose={props.onReportClose} onRequestClose={onReportClose}
/> />
)} )}
</React.Fragment> </React.Fragment>
} }
{props.canAddToStudio && {canAddToStudio &&
<React.Fragment> <React.Fragment>
<div
style={{position: 'relative'}}
/* eslint-disable react/jsx-no-bind */
onMouseEnter={() => showAddToStudioMuteError && setShowMuteMessage(true)}
onMouseLeave={() => showAddToStudioMuteError && setShowMuteMessage(false)}
/* eslint-enable react/jsx-no-bind */
>
<Button <Button
className="action-button studio-button" className="action-button studio-button"
disabled={showAddToStudioMuteError}
key="add-to-studio-button" key="add-to-studio-button"
onClick={props.onAddToStudioClicked} onClick={showMuteMessage ? null : onAddToStudioClicked}
> >
<FormattedMessage id="addToStudio.title" /> <FormattedMessage id="addToStudio.title" />
</Button> </Button>
{props.addToStudioOpen && ( {showMuteMessage && <StudioMuteEditMessage
className="studio-button-error"
messageId="project.mutedAddToStudio"
/>}
</div>
{addToStudioOpen && (
<AddToStudioModal <AddToStudioModal
isOpen isOpen
isAdmin={props.isAdmin} isAdmin={isAdmin}
key="add-to-studio-modal" key="add-to-studio-modal"
userOwnsProject={props.userOwnsProject} userOwnsProject={userOwnsProject}
onRequestClose={props.onAddToStudioClosed} onRequestClose={onAddToStudioClosed}
onToggleStudio={props.onToggleStudio} onToggleStudio={onToggleStudio}
/> />
)} )}
</React.Fragment> </React.Fragment>
} }
{/* only show copy link button, modal if project is shared */} {/* only show copy link button, modal if project is shared */}
{props.isShared && props.projectInfo && props.projectInfo.id && ( {isShared && projectInfo && projectInfo.id && (
<React.Fragment> <React.Fragment>
<Button <Button
className="action-button copy-link-button" className="action-button copy-link-button"
onClick={props.onSocialClicked} onClick={onSocialClicked}
> >
<FormattedMessage id="general.copyLink" /> <FormattedMessage id="general.copyLink" />
</Button> </Button>
{props.socialOpen && ( {socialOpen && (
<SocialModal <SocialModal
isOpen isOpen
key="social-modal" key="social-modal"
projectId={props.projectInfo && props.projectInfo.id} projectId={projectInfo && projectInfo.id}
onRequestClose={props.onSocialClosed} onRequestClose={onSocialClosed}
/> />
)} )}
</React.Fragment> </React.Fragment>
)} )}
</FlexRow> </FlexRow>
</FlexRow> </FlexRow>
); );
};
Subactions.propTypes = { Subactions.propTypes = {
addToStudioOpen: PropTypes.bool, addToStudioOpen: PropTypes.bool,
...@@ -110,8 +152,13 @@ Subactions.propTypes = { ...@@ -110,8 +152,13 @@ Subactions.propTypes = {
projectInfo: projectShape, projectInfo: projectShape,
reportOpen: PropTypes.bool, reportOpen: PropTypes.bool,
shareDate: PropTypes.string, shareDate: PropTypes.string,
showAddToStudioMuteError: PropTypes.bool,
socialOpen: PropTypes.bool, socialOpen: PropTypes.bool,
userOwnsProject: PropTypes.bool userOwnsProject: PropTypes.bool
}; };
module.exports = Subactions; module.exports = connect(
state => ({
showAddToStudioMuteError: selectNewStudiosLaunched(state) && selectIsMuted(state)
})
)(Subactions);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment