From f5be93b6b512154fd5eb7f138152467014e8cabc Mon Sep 17 00:00:00 2001 From: Travis Eden Date: Mon, 2 Apr 2018 12:03:12 -0400 Subject: [PATCH] add confirmThumbnailUpload modal --- src/renderer/constants/modal_types.js | 23 ++++++++++ .../modalConfirmThumbnailUpload/index.js | 18 ++++++++ .../modalConfirmThumbnailUpload/view.jsx | 45 +++++++++++++++++++ src/renderer/modal/modalRouter/view.jsx | 11 ++++- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/renderer/constants/modal_types.js create mode 100644 src/renderer/modal/modalConfirmThumbnailUpload/index.js create mode 100644 src/renderer/modal/modalConfirmThumbnailUpload/view.jsx diff --git a/src/renderer/constants/modal_types.js b/src/renderer/constants/modal_types.js new file mode 100644 index 000000000..6e3bc67d6 --- /dev/null +++ b/src/renderer/constants/modal_types.js @@ -0,0 +1,23 @@ +export const CONFIRM_FILE_REMOVE = 'confirm_file_remove'; +export const INCOMPATIBLE_DAEMON = 'incompatible_daemon'; +export const FILE_TIMEOUT = 'file_timeout'; +export const DOWNLOADING = 'downloading'; +export const AUTO_UPDATE_DOWNLOADED = 'auto_update_downloaded'; +export const AUTO_UPDATE_CONFIRM = 'auto_update_confirm'; +export const ERROR = 'error'; +export const INSUFFICIENT_CREDITS = 'insufficient_credits'; +export const UPGRADE = 'upgrade'; +export const WELCOME = 'welcome'; +export const EMAIL_COLLECTION = 'email_collection'; +export const PHONE_COLLECTION = 'phone_collection'; +export const FIRST_REWARD = 'first_reward'; +export const AUTHENTICATION_FAILURE = 'auth_failure'; +export const TRANSACTION_FAILED = 'transaction_failed'; +export const REWARD_APPROVAL_REQUIRED = 'reward_approval_required'; +export const AFFIRM_PURCHASE = 'affirm_purchase'; +export const CONFIRM_CLAIM_REVOKE = 'confirm_claim_revoke'; +export const FIRST_SUBSCRIPTION = 'firstSubscription'; +export const SEND_TIP = 'send_tip'; +export const PUBLISH = 'publish'; +export const SEARCH = 'search'; +export const CONFIRM_THUMBNAIL_UPLOAD = 'confirmThumbnailUpload'; diff --git a/src/renderer/modal/modalConfirmThumbnailUpload/index.js b/src/renderer/modal/modalConfirmThumbnailUpload/index.js new file mode 100644 index 000000000..607ea27af --- /dev/null +++ b/src/renderer/modal/modalConfirmThumbnailUpload/index.js @@ -0,0 +1,18 @@ +import { connect } from 'react-redux'; +import { doCloseModal } from 'redux/actions/app'; +import { doUploadThumbnail, doUpdatePublishForm } from 'redux/actions/publish'; +import { selectPublishFormValues } from 'redux/selectors/publish'; +import ModalConfirmThumbnailUpload from './view'; + +const select = state => { + const publishState = selectPublishFormValues(state); + return { nsfw: publishState.nsfw }; +}; + +const perform = dispatch => ({ + closeModal: () => dispatch(doCloseModal()), + upload: (path, nsfw = false) => dispatch(doUploadThumbnail(path, nsfw)), + updatePublishForm: value => dispatch(doUpdatePublishForm(value)), +}); + +export default connect(select, perform)(ModalConfirmThumbnailUpload); diff --git a/src/renderer/modal/modalConfirmThumbnailUpload/view.jsx b/src/renderer/modal/modalConfirmThumbnailUpload/view.jsx new file mode 100644 index 000000000..910967fe3 --- /dev/null +++ b/src/renderer/modal/modalConfirmThumbnailUpload/view.jsx @@ -0,0 +1,45 @@ +// @flow +import React from 'react'; +import { Modal } from 'modal/modal'; +import { FormField } from 'component/common/form'; + +type Props = { + upload: (string, boolean) => void, + path: string, + nsfw: boolean, + closeModal: () => void, + updatePublishForm: any => void, +}; + +class ModalConfirmThumbnailUpload extends React.PureComponent { + upload() { + this.props.upload(this.props.path, this.props.nsfw); + this.props.closeModal(); + } + + render() { + const { closeModal, path, updatePublishForm, nsfw } = this.props; + + return ( + this.upload()} + onAborted={closeModal} + > +

{`Confirm upload: ${path}`}

+ updatePublishForm({ nsfw: event.target.checked })} + /> +
+ ); + } +} + +export default ModalConfirmThumbnailUpload; diff --git a/src/renderer/modal/modalRouter/view.jsx b/src/renderer/modal/modalRouter/view.jsx index 96597401f..a3046e725 100644 --- a/src/renderer/modal/modalRouter/view.jsx +++ b/src/renderer/modal/modalRouter/view.jsx @@ -23,8 +23,13 @@ import ModalSendTip from '../modalSendTip'; import ModalPublish from '../modalPublish'; import ModalSearch from '../modalSearch'; import ModalOpenExternalLink from '../modalOpenExternalLink'; +import ModalConfirmThumbnailUpload from 'modal/modalConfirmThumbnailUpload'; -class ModalRouter extends React.PureComponent { +type Props = { + modal: string, +}; + +class ModalRouter extends React.PureComponent { constructor(props) { super(props); @@ -57,7 +62,7 @@ class ModalRouter extends React.PureComponent { if ( transitionModal && - (transitionModal != this.state.lastTransitionModal || page != this.state.lastTransitionPage) + (transitionModal !== this.state.lastTransitionModal || page !== this.state.lastTransitionPage) ) { openModal({ id: transitionModal }); this.setState({ @@ -161,6 +166,8 @@ class ModalRouter extends React.PureComponent { return ; case MODALS.CONFIRM_TRANSACTION: return ; + case MODALS.CONFIRM_THUMBNAIL_UPLOAD: + return ; default: return null; }