From 6814c8f5b19c196185daaacd27a1bd9ce749e166 Mon Sep 17 00:00:00 2001 From: seotts Date: Wed, 17 Nov 2021 14:53:44 -0500 Subject: [PATCH] Wire up banner dismissal --- src/views/preview/presentation.jsx | 10 ++++++---- src/views/preview/project-view.jsx | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/views/preview/presentation.jsx b/src/views/preview/presentation.jsx index 86bf27b03..8f48696d3 100644 --- a/src/views/preview/presentation.jsx +++ b/src/views/preview/presentation.jsx @@ -92,6 +92,7 @@ const PreviewPresentation = ({ onAddComment, onAddToStudioClicked, onAddToStudioClosed, + onBannerDismiss, onCloseAdminPanel, onCloseEmailConfirmationModal, onDeleteComment, @@ -225,7 +226,7 @@ const PreviewPresentation = ({ return (
{showEmailConfirmationModal && } {showAdminPanel && ( @@ -249,9 +250,9 @@ const PreviewPresentation = ({ { projectInfo && projectInfo.author && projectInfo.author.id && ( {showEmailConfirmationBanner && { // eslint-disable-line react/jsx-no-bind - console.log('dismiss'); - }} + /* eslint-disable react/jsx-no-bind */ + onRequestDismiss={() => onBannerDismiss('confirmed_email')} + /* eslint-enable react/jsx-no-bind */ />} {banner}
@@ -749,6 +750,7 @@ PreviewPresentation.propTypes = { onAddComment: PropTypes.func, onAddToStudioClicked: PropTypes.func, onAddToStudioClosed: PropTypes.func, + onBannerDismiss: PropTypes.func, onCloseAdminPanel: PropTypes.func, onCloseEmailConfirmationModal: PropTypes.func, onDeleteComment: PropTypes.func, diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index 9217aa0b1..7b135b4a4 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -63,6 +63,7 @@ class Preview extends React.Component { 'handlePopState', 'handleCloseAdminPanel', 'handleCloseEmailConfirmationModal', + 'handleBannerDismiss', 'handleIsRemixing', 'handleOpenAdminPanel', 'handleReportClick', @@ -630,6 +631,17 @@ class Preview extends React.Component { handleCloseEmailConfirmationModal () { this.setState({showEmailConfirmationModal: false}); } + handleBannerDismiss (cue) { + api({ + host: '', + uri: '/site-api/users/set-template-cue/', + method: 'post', + useCsrf: true, + json: {cue: cue, value: false} + }, err => { + if (!err) this.props.refreshSession(); + }); + } handleUpdateProjectTitle (title) { this.props.updateProject( this.props.projectInfo.id, @@ -784,6 +796,7 @@ class Preview extends React.Component { onAddComment={this.handleAddComment} onAddToStudioClicked={this.handleAddToStudioClick} onAddToStudioClosed={this.handleAddToStudioClose} + onBannerDismiss={this.handleBannerDismiss} onCloseAdminPanel={this.handleCloseAdminPanel} onCloseEmailConfirmationModal={this.handleCloseEmailConfirmationModal} onDeleteComment={this.handleDeleteComment} @@ -933,6 +946,7 @@ Preview.propTypes = { projectInfo: projectShape, projectNotAvailable: PropTypes.bool, projectStudios: PropTypes.arrayOf(PropTypes.object), + refreshSession: PropTypes.func, registrationOpen: PropTypes.bool, remixProject: PropTypes.func, remixes: PropTypes.arrayOf(PropTypes.object), @@ -1164,6 +1178,9 @@ const mapDispatchToProps = dispatch => ({ dispatch(GUI.remixProject()); dispatch(projectCommentActions.resetComments()); }, + refreshSession: () => { + dispatch(sessionActions.refreshSession()); + }, setPlayer: player => { dispatch(GUI.setPlayer(player)); },