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 thumbnailUrl = require('../../lib/user-thumbnail');
const FormsyProjectUpdater = require('./formsy-project-updater.jsx');
const EmailConfirmationModal = require('../../components/modal/emailConfirmation/modal.jsx').default;
const projectShape = require('./projectshape.jsx').projectShape;
require('./preview.scss');
@ -62,6 +63,7 @@ const PreviewPresentation = ({
canRestoreComments,
canSave,
canShare,
canSeeShare,
canToggleComments,
canUseBackpack,
cloudHost,
@ -109,6 +111,7 @@ const PreviewPresentation = ({
onSeeInside,
onSetProjectThumbnailer,
onShare,
onShareAttempt,
onSocialClicked,
onSocialClosed,
onToggleComments,
@ -129,6 +132,7 @@ const PreviewPresentation = ({
reportOpen,
showAdminPanel,
showModInfo,
showEmailConfirmationModal,
singleCommentId,
socialOpen,
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 (isNewScratcher) {
banner = (<Banner
@ -184,11 +188,20 @@ const PreviewPresentation = ({
/>);
}
} else if (!isShared) {
banner = (<Banner
actionMessage={<FormattedMessage id="project.share.shareButton" />}
message={<FormattedMessage id="project.share.notShared" />}
onAction={onShare}
/>);
if (canShare){
banner = (<Banner
actionMessage={<FormattedMessage id="project.share.shareButton" />}
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 (
<div className="preview">
{showEmailConfirmationModal && <EmailConfirmationModal />}
{showAdminPanel && (
<AdminPanel
className={classNames('project-admin-panel', {

View file

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

View file

@ -375,35 +375,12 @@ class SplashPresentation extends React.Component { // eslint-disable-line react/
return (
<div className="splash">
{this.props.shouldShowEmailConfirmation ? [
<DropdownBanner
className="warning"
key="confirmedEmail"
onRequestDismiss={() => { // eslint-disable-line react/jsx-no-bind
{(this.props.shouldShowEmailConfirmation &&
<EmailConfirmationBanner
onRequestDismis={() => { // eslint-disable-line react/jsx-no-bind
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 ? [
<TeacherBanner
key="teacherbanner"