Commit 56dc892e authored by seotts's avatar seotts

Muted user can’t add proj to studio via proj page

parent dfbce650
...@@ -46,5 +46,6 @@ ...@@ -46,5 +46,6 @@
"project.cloudVariables": "Cloud Variables", "project.cloudVariables": "Cloud Variables",
"project.cloudDataLink": "See Data", "project.cloudDataLink": "See Data",
"project.usernameBlockAlert": "This project can detect who is using it, through the \"username\" block. To hide your identity, sign out before using the project.", "project.usernameBlockAlert": "This project can detect who is using it, through the \"username\" block. To hide your identity, sign out before using the project.",
"project.inappropriateUpdate": "Hmm...the bad word detector thinks there is a problem with your text. Please change it and remember to be respectful." "project.inappropriateUpdate": "Hmm...the bad word detector thinks there is a problem with your text. Please change it and remember to be respectful.",
"project.mutedAddToStudio": "You will be able to add to studios again {inDuration}."
} }
...@@ -160,7 +160,6 @@ $stage-width: 480px; ...@@ -160,7 +160,6 @@ $stage-width: 480px;
margin-top: $arrow-border-width; margin-top: $arrow-border-width;
border: 1px solid $active-gray; border: 1px solid $active-gray;
border-radius: 5px; border-radius: 5px;
background-color: $ui-orange;
padding: 1rem; padding: 1rem;
max-width: 18.75rem; max-width: 18.75rem;
min-height: 1rem; min-height: 1rem;
...@@ -185,7 +184,6 @@ $stage-width: 480px; ...@@ -185,7 +184,6 @@ $stage-width: 480px;
border-left: 1px solid $active-gray; border-left: 1px solid $active-gray;
border-radius: 5px; border-radius: 5px;
background-color: $ui-orange;
width: $arrow-border-width; width: $arrow-border-width;
height: $arrow-border-width; height: $arrow-border-width;
......
...@@ -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 {selectShowProjectMuteError} = require('../../redux/studio-permissions.js');
const {useState} = require('react');
const projectShape = require('./projectshape.jsx').projectShape; const projectShape = require('./projectshape.jsx').projectShape;
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 && 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: selectShowProjectMuteError(state)
})
)(Subactions);
...@@ -109,3 +109,10 @@ ...@@ -109,3 +109,10 @@
} }
} }
} }
.studio-button-error {
top: auto;
transform: none;
width: 100%;
margin-left: 0;
}
...@@ -9,12 +9,15 @@ import {selectMuteStatus} from '../../redux/session'; ...@@ -9,12 +9,15 @@ import {selectMuteStatus} from '../../redux/session';
import {formatRelativeTime} from '../../lib/format-time.js'; import {formatRelativeTime} from '../../lib/format-time.js';
const StudioMuteEditMessage = ({ const StudioMuteEditMessage = ({
className,
messageId,
muteExpiresAtMs muteExpiresAtMs
}) => ( }) => (
<ValidationMessage <ValidationMessage
className={className}
mode="info" mode="info"
message={<FormattedMessage message={<FormattedMessage
id="studios.mutedEdit" id={messageId}
values={{ values={{
inDuration: formatRelativeTime(muteExpiresAtMs, window._locale) inDuration: formatRelativeTime(muteExpiresAtMs, window._locale)
}} }}
...@@ -24,9 +27,15 @@ const StudioMuteEditMessage = ({ ...@@ -24,9 +27,15 @@ const StudioMuteEditMessage = ({
StudioMuteEditMessage.propTypes = { StudioMuteEditMessage.propTypes = {
className: PropTypes.string,
messageId: PropTypes.string,
muteExpiresAtMs: PropTypes.number muteExpiresAtMs: PropTypes.number
}; };
StudioMuteEditMessage.defaultProps = {
messageId: 'studio.mutedEdit'
};
export default connect( export default connect(
state => ({ state => ({
muteExpiresAtMs: (selectMuteStatus(state).muteExpiresAt * 1000 || 0) muteExpiresAtMs: (selectMuteStatus(state).muteExpiresAt * 1000 || 0)
......
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