adds modal progress and new logic for showing share button on project page

This commit is contained in:
tomlum 2021-10-26 13:11:26 -04:00 committed by seotts
parent f8218a9888
commit 058edef86a
5 changed files with 106 additions and 33 deletions

View file

@ -0,0 +1,46 @@
import React, {useState} from 'react';
import DropdownBanner from '../banner.jsx';
/* <IframeModal
componentRef={iframe => { // eslint-disable-line react/jsx-no-bind
this.emailConfirmationiFrame = iframe;
}}
isOpen={this.props.emailConfirmationModalOpen}
key="iframe-modal"
src="/accounts/email_resend_standalone/"
onRequestClose={this.props.onHideEmailConfirmationModal}
/> */
const EmailConfirmationBanner = onRequestDismiss => {
const [showEmailConfirmationModal, setShowEmailConfirmationModal] = useState(false);
return (
<React.Fragment>
{(showEmailConfirmationModal && <h1>test</h1>)}
<DropdownBanner
className="warning"
key="confirmedEmail"
onRequestDismiss={onRequestDismiss}
>
<a
href="#"
onClick={setShowEmailConfirmationModal(true)}
>
Confirm your email
</a>{' '}to enable sharing.{' '}
<a href="/faq/#accounts">
Having trouble?
</a>
</DropdownBanner>
</React.Fragment>);
};
EmailConfirmationBanner.propTypes = {
};
module.exports = EmailConfirmationBanner;

View file

@ -0,0 +1,26 @@
import React from 'react';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import Modal from '../base/modal.jsx';
import ModalTitle from '../base/modal-title.jsx';
// import ModalInnerContent from '../../../components/modal/base/modal-inner-content.jsx';
// import './manager-limit-modal.scss';
// import {STUDIO_MANAGER_LIMIT} from '../../../redux/studio.js';
const EmailConfirmationModal = () => (
<Modal
isOpen
>
<ModalTitle />
test 1234
</Modal>
);
EmailConfirmationModal.propTypes = {
handleClose: PropTypes.func
};
export default EmailConfirmationModal;

View file

@ -32,6 +32,7 @@ const ComposeComment = require('./comment/compose-comment.jsx');
const ExtensionChip = require('./extension-chip.jsx'); const ExtensionChip = require('./extension-chip.jsx');
const thumbnailUrl = require('../../lib/user-thumbnail'); const thumbnailUrl = require('../../lib/user-thumbnail');
const FormsyProjectUpdater = require('./formsy-project-updater.jsx'); const FormsyProjectUpdater = require('./formsy-project-updater.jsx');
const EmailConfirmationModal = require('../../components/modal/emailConfirmation/modal.jsx').default;
const projectShape = require('./projectshape.jsx').projectShape; const projectShape = require('./projectshape.jsx').projectShape;
require('./preview.scss'); require('./preview.scss');
@ -62,6 +63,7 @@ const PreviewPresentation = ({
canRestoreComments, canRestoreComments,
canSave, canSave,
canShare, canShare,
canSeeShare,
canToggleComments, canToggleComments,
canUseBackpack, canUseBackpack,
cloudHost, cloudHost,
@ -109,6 +111,7 @@ const PreviewPresentation = ({
onSeeInside, onSeeInside,
onSetProjectThumbnailer, onSetProjectThumbnailer,
onShare, onShare,
onShareAttempt,
onSocialClicked, onSocialClicked,
onSocialClosed, onSocialClosed,
onToggleComments, onToggleComments,
@ -129,6 +132,7 @@ const PreviewPresentation = ({
reportOpen, reportOpen,
showAdminPanel, showAdminPanel,
showModInfo, showModInfo,
showEmailConfirmationModal,
singleCommentId, singleCommentId,
socialOpen, socialOpen,
userOwnsProject, userOwnsProject,
@ -170,7 +174,7 @@ const PreviewPresentation = ({
} }
/> />
); );
} else if (canShare) { } else if (canSeeShare) {
if (isShared && justShared) { // if was shared a while ago, don't show any share banner if (isShared && justShared) { // if was shared a while ago, don't show any share banner
if (isNewScratcher) { if (isNewScratcher) {
banner = (<Banner banner = (<Banner
@ -184,11 +188,20 @@ const PreviewPresentation = ({
/>); />);
} }
} else if (!isShared) { } else if (!isShared) {
banner = (<Banner if (canShare){
actionMessage={<FormattedMessage id="project.share.shareButton" />} banner = (<Banner
message={<FormattedMessage id="project.share.notShared" />} actionMessage={<FormattedMessage id="project.share.shareButton" />}
onAction={onShare} message={<FormattedMessage id="project.share.notShared" />}
/>); onAction={onShare}
/>);
} else {
banner = (<Banner
actionMessage={<FormattedMessage id="project.share.shareButton" />}
message={<FormattedMessage id="project.share.notShared" />}
onAction={onShareAttempt}
/>
);
}
} }
} }
@ -208,6 +221,7 @@ const PreviewPresentation = ({
); );
return ( return (
<div className="preview"> <div className="preview">
{showEmailConfirmationModal && <EmailConfirmationModal />}
{showAdminPanel && ( {showAdminPanel && (
<AdminPanel <AdminPanel
className={classNames('project-admin-panel', { className={classNames('project-admin-panel', {

View file

@ -78,6 +78,7 @@ class Preview extends React.Component {
'handleSeeInside', 'handleSeeInside',
'handleSetProjectThumbnailer', 'handleSetProjectThumbnailer',
'handleShare', 'handleShare',
'handleShareAttempt',
'handleUpdateProjectData', 'handleUpdateProjectData',
'handleUpdateProjectId', 'handleUpdateProjectId',
'handleUpdateProjectTitle', 'handleUpdateProjectTitle',
@ -121,6 +122,7 @@ class Preview extends React.Component {
}, },
showCloudDataAlert: false, showCloudDataAlert: false,
showUsernameBlockAlert: false, showUsernameBlockAlert: false,
showEmailConfirmationModal: false,
projectId: parts[1] === 'editor' ? '0' : parts[1], projectId: parts[1] === 'editor' ? '0' : parts[1],
reportOpen: false, reportOpen: false,
singleCommentId: singleCommentId, singleCommentId: singleCommentId,
@ -619,6 +621,11 @@ class Preview extends React.Component {
justShared: true justShared: true
}); });
} }
handleShareAttempt () {
this.setState({
showEmailConfirmationModal: true
});
}
handleUpdateProjectTitle (title) { handleUpdateProjectTitle (title) {
this.props.updateProject( this.props.updateProject(
this.props.projectInfo.id, this.props.projectInfo.id,
@ -727,6 +734,7 @@ class Preview extends React.Component {
canRestoreComments={this.props.isAdmin} canRestoreComments={this.props.isAdmin}
canSave={this.props.canSave} canSave={this.props.canSave}
canShare={this.props.canShare || this.props.isAdmin} canShare={this.props.canShare || this.props.isAdmin}
canSeeShare={this.props.userOwnsProject || this.props.isAdmin}
canToggleComments={this.props.canToggleComments} canToggleComments={this.props.canToggleComments}
canUseBackpack={this.props.canUseBackpack} canUseBackpack={this.props.canUseBackpack}
cloudHost={this.props.cloudHost} cloudHost={this.props.cloudHost}
@ -762,6 +770,7 @@ class Preview extends React.Component {
showAdminPanel={this.props.isAdmin} showAdminPanel={this.props.isAdmin}
showCloudDataAlert={this.state.showCloudDataAlert} showCloudDataAlert={this.state.showCloudDataAlert}
showModInfo={this.props.isAdmin} showModInfo={this.props.isAdmin}
showEmailConfirmationModal={this.state.showEmailConfirmationModal}
showUsernameBlockAlert={this.state.showUsernameBlockAlert} showUsernameBlockAlert={this.state.showUsernameBlockAlert}
singleCommentId={this.state.singleCommentId} singleCommentId={this.state.singleCommentId}
socialOpen={this.state.socialOpen} socialOpen={this.state.socialOpen}
@ -790,6 +799,7 @@ class Preview extends React.Component {
onSeeInside={this.handleSeeInside} onSeeInside={this.handleSeeInside}
onSetProjectThumbnailer={this.handleSetProjectThumbnailer} onSetProjectThumbnailer={this.handleSetProjectThumbnailer}
onShare={this.handleShare} onShare={this.handleShare}
onShareAttempt={this.handleShareAttempt}
onSocialClicked={this.handleSocialClick} onSocialClicked={this.handleSocialClick}
onSocialClosed={this.handleSocialClose} onSocialClosed={this.handleSocialClose}
onToggleComments={this.handleToggleComments} onToggleComments={this.handleToggleComments}

View file

@ -375,35 +375,12 @@ class SplashPresentation extends React.Component { // eslint-disable-line react/
return ( return (
<div className="splash"> <div className="splash">
{this.props.shouldShowEmailConfirmation ? [ {(this.props.shouldShowEmailConfirmation &&
<DropdownBanner <EmailConfirmationBanner
className="warning" onRequestDismis={() => { // eslint-disable-line react/jsx-no-bind
key="confirmedEmail"
onRequestDismiss={() => { // eslint-disable-line react/jsx-no-bind
this.props.onDismiss('confirmed_email'); this.props.onDismiss('confirmed_email');
}} }}
> />)}
<a
href="#"
onClick={this.props.onShowEmailConfirmationModal}
>
Confirm your email
</a>{' '}to enable sharing.{' '}
<a href="/faq/#accounts">
Having trouble?
</a>
</DropdownBanner>,
<IframeModal
className="mod-confirmation"
componentRef={iframe => { // eslint-disable-line react/jsx-no-bind
this.emailConfirmationiFrame = iframe;
}}
isOpen={this.props.emailConfirmationModalOpen}
key="iframe-modal"
src="/accounts/email_resend_standalone/"
onRequestClose={this.props.onHideEmailConfirmationModal}
/>
] : []}
{this.props.isEducator ? [ {this.props.isEducator ? [
<TeacherBanner <TeacherBanner
key="teacherbanner" key="teacherbanner"