copy for buttons and modals for livestream

redirect on success to dashboard
This commit is contained in:
zeppi 2021-03-24 01:22:02 -04:00 committed by jessopb
parent 995f51711f
commit 81b9b0d801
5 changed files with 101 additions and 38 deletions

View file

@ -179,13 +179,26 @@ function PublishForm(props: Props) {
} }
}, [modal]); }, [modal]);
const isLivestream = mode === PUBLISH_MODES.LIVESTREAM;
let submitLabel; let submitLabel;
if (isStillEditing) { if (publishing) {
submitLabel = !publishing ? __('Save') : __('Saving...'); if (isStillEditing) {
submitLabel = __('Saving...');
} else if (isLivestream) {
submitLabel = __('Creating...');
} else {
submitLabel = __('Uploading...');
}
} else if (previewing) { } else if (previewing) {
submitLabel = __('Preparing...'); submitLabel = __('Preparing...');
} else { } else {
submitLabel = !publishing ? __('Upload') : __('Uploading...'); if (isStillEditing) {
submitLabel = __('Save');
} else if (isLivestream) {
submitLabel = __('Create');
} else {
submitLabel = __('Upload');
}
} }
useEffect(() => { useEffect(() => {
@ -239,7 +252,7 @@ function PublishForm(props: Props) {
useEffect(() => { useEffect(() => {
updatePublishForm({ updatePublishForm({
isMarkdownPost: mode === PUBLISH_MODES.POST, isMarkdownPost: mode === PUBLISH_MODES.POST,
isLivestreamPublish: mode === PUBLISH_MODES.LIVESTREAM, isLivestreamPublish: isLivestream,
}); });
}, [mode, updatePublishForm]); }, [mode, updatePublishForm]);
@ -248,7 +261,7 @@ function PublishForm(props: Props) {
updatePublishForm({ channel: undefined }); updatePublishForm({ channel: undefined });
// Anonymous livestreams aren't supported // Anonymous livestreams aren't supported
if (mode === PUBLISH_MODES.LIVESTREAM) { if (isLivestream) {
setMode(PUBLISH_MODES.FILE); setMode(PUBLISH_MODES.FILE);
} }
} else if (activeChannelName) { } else if (activeChannelName) {
@ -357,7 +370,7 @@ function PublishForm(props: Props) {
} }
} }
// Publish file // Publish file
if (mode === PUBLISH_MODES.FILE || mode === PUBLISH_MODES.LIVESTREAM) { if (mode === PUBLISH_MODES.FILE || isLivestream) {
runPublish = true; runPublish = true;
} }
@ -386,7 +399,7 @@ function PublishForm(props: Props) {
// Editing claim uri // Editing claim uri
return ( return (
<div className="card-stack"> <div className="card-stack">
<ChannelSelect hideAnon={mode === PUBLISH_MODES.LIVESTREAM} disabled={disabled} /> <ChannelSelect hideAnon={isLivestream} disabled={disabled} />
<PublishFile <PublishFile
uri={uri} uri={uri}

View file

@ -1,16 +1,17 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideModal } from 'redux/actions/app';
import ModalPublishSuccess from './view'; import ModalPublishSuccess from './view';
import { doClearPublish } from 'lbry-redux'; import { doClearPublish, makeSelectClaimForUri } from 'lbry-redux';
import { push } from 'connected-react-router'; import { push } from 'connected-react-router';
const perform = dispatch => ({ const select = (state, props) => ({
closeModal: () => dispatch(doHideModal()), claim: makeSelectClaimForUri(props.uri)(state),
clearPublish: () => dispatch(doClearPublish()),
navigate: path => dispatch(push(path)),
}); });
export default connect( const perform = (dispatch) => ({
null, closeModal: () => dispatch(doHideModal()),
perform clearPublish: () => dispatch(doClearPublish()),
)(ModalPublishSuccess); navigate: (path) => dispatch(push(path)),
});
export default connect(select, perform)(ModalPublishSuccess);

View file

@ -10,20 +10,38 @@ import Nag from 'component/common/nag';
type Props = { type Props = {
closeModal: () => void, closeModal: () => void,
clearPublish: () => void, clearPublish: () => void,
navigate: string => void, navigate: (string) => void,
uri: string, uri: string,
isEdit: boolean, isEdit: boolean,
filePath: ?string, filePath: ?string,
lbryFirstError: ?string, lbryFirstError: ?string,
claim: Claim,
}; };
class ModalPublishSuccess extends React.PureComponent<Props> { class ModalPublishSuccess extends React.PureComponent<Props> {
render() { render() {
const { closeModal, clearPublish, navigate, uri, isEdit, filePath, lbryFirstError } = this.props; const { closeModal, clearPublish, navigate, uri, isEdit, filePath, lbryFirstError, claim } = this.props;
const contentLabel = isEdit ? __('Update published') : __('File published'); // $FlowFixMe
const publishMessage = isEdit const livestream = claim && claim.value && claim.value_type === 'stream' && !claim.value.source;
? __('Your update is now pending on LBRY. It will take a few minutes to appear for other users.') let contentLabel;
: __('Your file is now pending on LBRY. It will take a few minutes to appear for other users.'); if (livestream) {
contentLabel = __('Livestream Created');
} else if (isEdit) {
contentLabel = __('Update published');
} else {
contentLabel = __('File published');
}
let publishMessage;
if (isEdit) {
publishMessage = __('Your update is now pending. It will take a few minutes to appear for other users.');
} else if (livestream) {
publishMessage = __(
'Your livestream is now pending. You will be able to start shortly at the streaming dashboard.'
);
} else {
publishMessage = __('Your file is now pending on LBRY. It will take a few minutes to appear for other users.');
}
function handleClose() { function handleClose() {
clearPublish(); clearPublish();
@ -54,15 +72,28 @@ class ModalPublishSuccess extends React.PureComponent<Props> {
} }
actions={ actions={
<div className="section__actions"> <div className="section__actions">
<Button {!livestream && (
button="primary" <Button
label={__('View My Uploads')} button="primary"
onClick={() => { label={__('View My Uploads')}
clearPublish(); onClick={() => {
navigate(`/$/${PAGES.UPLOADS}`); clearPublish();
closeModal(); navigate(`/$/${PAGES.UPLOADS}`);
}} closeModal();
/> }}
/>
)}
{livestream && (
<Button
button="primary"
label={__('View My Dashboard')}
onClick={() => {
clearPublish();
navigate(`/$/${PAGES.LIVESTREAM}`);
closeModal();
}}
/>
)}
<Button button="link" label={__('Close')} onClick={handleClose} /> <Button button="link" label={__('Close')} onClick={handleClose} />
</div> </div>
} }

View file

@ -103,11 +103,29 @@ class ModalPublishPreview extends React.PureComponent<Props> {
myChannels, myChannels,
} = this.props; } = this.props;
const modalTitle = isStillEditing ? __('Confirm Edit') : __('Confirm Upload');
const confirmBtnText = isStillEditing ? __('Save') : __('Upload');
const txFee = previewResponse ? previewResponse['total_fee'] : null; const txFee = previewResponse ? previewResponse['total_fee'] : null;
// $FlowFixMe add outputs[0] etc to PublishResponse type
const livestream =
// $FlowFixMe
previewResponse.outputs[0] && previewResponse.outputs[0].value && !previewResponse.outputs[0].value.source;
const isOptimizeAvail = filePath && filePath !== '' && isVid && ffmpegStatus.available; const isOptimizeAvail = filePath && filePath !== '' && isVid && ffmpegStatus.available;
let modalTitle;
if (isStillEditing) {
modalTitle = __('Confirm Edit');
} else if (livestream) {
modalTitle = __('Create Livestream');
} else {
modalTitle = __('Confirm Upload');
}
let confirmBtnText;
if (isStillEditing) {
confirmBtnText = __('Save');
} else if (livestream) {
confirmBtnText = __('Create');
} else {
confirmBtnText = __('Upload');
}
const descriptionValue = description ? ( const descriptionValue = description ? (
<div className="media__info-text-preview"> <div className="media__info-text-preview">
<MarkdownPreview content={description} simpleLinks /> <MarkdownPreview content={description} simpleLinks />
@ -167,7 +185,7 @@ class ModalPublishPreview extends React.PureComponent<Props> {
<div className="section"> <div className="section">
<table className="table table--condensed table--publish-preview"> <table className="table table--condensed table--publish-preview">
<tbody> <tbody>
{!isMarkdownPost && this.createRow(__('File'), this.resolveFilePathName(filePath))} {!livestream && !isMarkdownPost && this.createRow(__('File'), this.resolveFilePathName(filePath))}
{isOptimizeAvail && this.createRow(__('Transcode'), optimize ? __('Yes') : __('No'))} {isOptimizeAvail && this.createRow(__('Transcode'), optimize ? __('Yes') : __('No'))}
{this.createRow(__('Title'), title)} {this.createRow(__('Title'), title)}
{this.createRow(__('Description'), descriptionValue)} {this.createRow(__('Description'), descriptionValue)}

View file

@ -16,7 +16,7 @@ import analytics from 'analytics';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';
export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispatch: Dispatch, getState: () => {}) => { export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispatch: Dispatch, getState: () => {}) => {
const publishPreview = previewResponse => { const publishPreview = (previewResponse) => {
dispatch( dispatch(
doOpenModal(MODALS.PUBLISH_PREVIEW, { doOpenModal(MODALS.PUBLISH_PREVIEW, {
previewResponse, previewResponse,
@ -42,7 +42,7 @@ export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispat
// We have to fake a temp claim until the new pending one is returned by claim_list_mine // We have to fake a temp claim until the new pending one is returned by claim_list_mine
// We can't rely on claim_list_mine because there might be some delay before the new claims are returned // We can't rely on claim_list_mine because there might be some delay before the new claims are returned
// Doing this allows us to show the pending claim immediately, it will get overwritten by the real one // Doing this allows us to show the pending claim immediately, it will get overwritten by the real one
const isMatch = claim => claim.claim_id === pendingClaim.claim_id; const isMatch = (claim) => claim.claim_id === pendingClaim.claim_id;
const isEdit = myClaims.some(isMatch); const isEdit = myClaims.some(isMatch);
actions.push({ actions.push({
@ -73,7 +73,7 @@ export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispat
// @endif // @endif
}; };
const publishFail = error => { const publishFail = (error) => {
const actions = []; const actions = [];
actions.push({ actions.push({
type: ACTIONS.PUBLISH_FAIL, type: ACTIONS.PUBLISH_FAIL,
@ -91,7 +91,7 @@ export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispat
// on the publishes page. This doesn't exist on desktop so wait until we get a response // on the publishes page. This doesn't exist on desktop so wait until we get a response
// from the SDK // from the SDK
// @if TARGET='web' // @if TARGET='web'
dispatch(push(`/$/${PAGES.UPLOADS}`)); dispatch(push(filePath ? `/$/${PAGES.UPLOADS}` : `/$/${PAGES.LIVESTREAM}`));
// @endif // @endif
dispatch(doPublish(publishSuccess, publishFail)); dispatch(doPublish(publishSuccess, publishFail));