Move modals types constants to lbry-redux repository. #1438

Merged
dan1d merged 1 commit from move-modal-types into master 2018-05-08 06:56:01 +02:00
15 changed files with 47 additions and 75 deletions

View file

@ -2,7 +2,7 @@
import React from 'react'; import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import FileDownloadLink from 'component/fileDownloadLink'; import FileDownloadLink from 'component/fileDownloadLink';
import * as modals from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import classnames from 'classnames'; import classnames from 'classnames';
import * as icons from 'constants/icons'; import * as icons from 'constants/icons';
@ -33,7 +33,7 @@ class FileActions extends React.PureComponent<Props> {
className="btn--file-actions" className="btn--file-actions"
icon={icons.TRASH} icon={icons.TRASH}
description={__('Delete')} description={__('Delete')}
onClick={() => openModal({ id: modals.CONFIRM_FILE_REMOVE }, { uri })} onClick={() => openModal({ id: MODALS.CONFIRM_FILE_REMOVE }, { uri })}
/> />
)} )}
{!claimIsMine && ( {!claimIsMine && (

View file

@ -1,10 +1,9 @@
import * as React from 'react'; import * as React from 'react';
import { Lbry } from 'lbry-redux'; import { Lbry, MODALS } from 'lbry-redux';
import LoadScreen from './internal/load-screen'; import LoadScreen from './internal/load-screen';
import ModalIncompatibleDaemon from 'modal/modalIncompatibleDaemon'; import ModalIncompatibleDaemon from 'modal/modalIncompatibleDaemon';
import ModalUpgrade from 'modal/modalUpgrade'; import ModalUpgrade from 'modal/modalUpgrade';
import ModalDownloading from 'modal/modalDownloading'; import ModalDownloading from 'modal/modalDownloading';
import * as modals from 'constants/modal_types';
type Props = { type Props = {
checkDaemonVersion: () => Promise<any>, checkDaemonVersion: () => Promise<any>,
@ -115,9 +114,9 @@ export class SplashScreen extends React.PureComponent<Props, State> {
in the modals won't work. */} in the modals won't work. */}
{isRunning && ( {isRunning && (
<React.Fragment> <React.Fragment>
{notificationId === modals.INCOMPATIBLE_DAEMON && <ModalIncompatibleDaemon />} {notificationId === MODALS.INCOMPATIBLE_DAEMON && <ModalIncompatibleDaemon />}
{notificationId === modals.UPGRADE && <ModalUpgrade />} {notificationId === MODALS.UPGRADE && <ModalUpgrade />}
{notificationId === modals.DOWNLOADING && <ModalDownloading />} {notificationId === MODALS.DOWNLOADING && <ModalDownloading />}
</React.Fragment> </React.Fragment>
)} )}
</React.Fragment> </React.Fragment>

View file

@ -1,6 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import * as modals from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import * as icons from 'constants/icons'; import * as icons from 'constants/icons';
import Button from 'component/button'; import Button from 'component/button';
import type { Subscription } from 'redux/reducers/subscriptions'; import type { Subscription } from 'redux/reducers/subscriptions';
@ -42,7 +42,7 @@ export default (props: Props) => {
label={subscriptionLabel} label={subscriptionLabel}
onClick={() => { onClick={() => {
if (!subscriptions.length) { if (!subscriptions.length) {
doNotify({ id: modals.FIRST_SUBSCRIPTION }); doNotify({ id: MODALS.FIRST_SUBSCRIPTION });
} }
subscriptionHandler({ subscriptionHandler({
channelName, channelName,

View file

@ -4,7 +4,7 @@ import { FormField } from 'component/common/form';
import Button from 'component/button'; import Button from 'component/button';
import FileExporter from 'component/common/file-exporter'; import FileExporter from 'component/common/file-exporter';
import * as icons from 'constants/icons'; import * as icons from 'constants/icons';
import * as modals from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import TransactionListItem from './internal/transaction-list-item'; import TransactionListItem from './internal/transaction-list-item';
export type Transaction = { export type Transaction = {
@ -65,7 +65,7 @@ class TransactionList extends React.PureComponent<Props, State> {
} }
revokeClaim(txid: string, nout: number) { revokeClaim(txid: string, nout: number) {
this.props.openModal({ id: modals.CONFIRM_CLAIM_REVOKE }, { txid, nout }); this.props.openModal({ id: MODALS.CONFIRM_CLAIM_REVOKE }, { txid, nout });
} }
render() { render() {

View file

@ -8,8 +8,7 @@ import {
selectIdentityVerifyErrorMessage, selectIdentityVerifyErrorMessage,
} from 'redux/selectors/user'; } from 'redux/selectors/user';
import UserVerify from './view'; import UserVerify from './view';
import { doNotify } from 'lbry-redux'; import { doNotify, MODALS } from 'lbry-redux';
import { PHONE_COLLECTION } from 'constants/modal_types';
const select = (state, props) => { const select = (state, props) => {
const selectReward = makeSelectRewardByType(); const selectReward = makeSelectRewardByType();
@ -24,7 +23,7 @@ const select = (state, props) => {
const perform = dispatch => ({ const perform = dispatch => ({
navigate: uri => dispatch(doNavigate(uri)), navigate: uri => dispatch(doNavigate(uri)),
verifyUserIdentity: token => dispatch(doUserIdentityVerify(token)), verifyUserIdentity: token => dispatch(doUserIdentityVerify(token)),
verifyPhone: () => dispatch(doNotify({ id: PHONE_COLLECTION })), verifyPhone: () => dispatch(doNotify({ id: MODALS.PHONE_COLLECTION })),
}); });
export default connect(select, perform)(UserVerify); export default connect(select, perform)(UserVerify);

View file

@ -1,11 +1,10 @@
import * as MODALS from 'constants/modal_types';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { normalizeURI } from 'lbry-redux';
import { import {
selectSearchState as selectSearch, selectSearchState as selectSearch,
selectWunderBarAddress, selectWunderBarAddress,
doUpdateSearchQuery, doUpdateSearchQuery,
doNotify, doNotify,
MODALS,
} from 'lbry-redux'; } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import Wunderbar from './view'; import Wunderbar from './view';

View file

@ -1,22 +0,0 @@
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';

View file

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { MODALS } from 'lbry-redux';
import ModalError from 'modal/modalError'; import ModalError from 'modal/modalError';
import ModalAuthFailure from 'modal/modalAuthFailure'; import ModalAuthFailure from 'modal/modalAuthFailure';
import ModalDownloading from 'modal/modalDownloading'; import ModalDownloading from 'modal/modalDownloading';
@ -20,7 +21,6 @@ import ModalFirstSubscription from 'modal/modalFirstSubscription';
import ModalSendTip from '../modalSendTip'; import ModalSendTip from '../modalSendTip';
import ModalPublish from '../modalPublish'; import ModalPublish from '../modalPublish';
import ModalSearch from '../modalSearch'; import ModalSearch from '../modalSearch';
import * as modals from 'constants/modal_types';
class ModalRouter extends React.PureComponent { class ModalRouter extends React.PureComponent {
constructor(props) { constructor(props) {
@ -68,7 +68,7 @@ class ModalRouter extends React.PureComponent {
checkShowWelcome(props) { checkShowWelcome(props) {
const { isWelcomeAcknowledged, user } = props; const { isWelcomeAcknowledged, user } = props;
if (!isWelcomeAcknowledged && user && !user.is_reward_approved && !user.is_identity_verified) { if (!isWelcomeAcknowledged && user && !user.is_reward_approved && !user.is_identity_verified) {
return modals.WELCOME; return MODALS.WELCOME;
} }
} }
@ -80,7 +80,7 @@ class ModalRouter extends React.PureComponent {
user && user &&
!user.has_verified_email !user.has_verified_email
) { ) {
return modals.EMAIL_COLLECTION; return MODALS.EMAIL_COLLECTION;
} }
} }
@ -92,7 +92,7 @@ class ModalRouter extends React.PureComponent {
!isCreditIntroAcknowledged && !isCreditIntroAcknowledged &&
(['send', 'publish'].includes(page) || this.isPaidShowPage(props)) (['send', 'publish'].includes(page) || this.isPaidShowPage(props))
) { ) {
return modals.INSUFFICIENT_CREDITS; return MODALS.INSUFFICIENT_CREDITS;
} }
} }
@ -113,47 +113,47 @@ class ModalRouter extends React.PureComponent {
} }
switch (notification.id) { switch (notification.id) {
case modals.UPGRADE: case MODALS.UPGRADE:
return <ModalUpgrade {...notificationProps} />; return <ModalUpgrade {...notificationProps} />;
case modals.DOWNLOADING: case MODALS.DOWNLOADING:
return <ModalDownloading {...notificationProps} />; return <ModalDownloading {...notificationProps} />;
case modals.AUTO_UPDATE_DOWNLOADED: case MODALS.AUTO_UPDATE_DOWNLOADED:
return <ModalAutoUpdateDownloaded {...notificationProps} />; return <ModalAutoUpdateDownloaded {...notificationProps} />;
case modals.AUTO_UPDATE_CONFIRM: case MODALS.AUTO_UPDATE_CONFIRM:
return <ModalAutoUpdateConfirm {...notificationProps} />; return <ModalAutoUpdateConfirm {...notificationProps} />;
case modals.ERROR: case MODALS.ERROR:
return <ModalError {...notificationProps} />; return <ModalError {...notificationProps} />;
case modals.FILE_TIMEOUT: case MODALS.FILE_TIMEOUT:
return <ModalFileTimeout {...notificationProps} />; return <ModalFileTimeout {...notificationProps} />;
case modals.INSUFFICIENT_CREDITS: case MODALS.INSUFFICIENT_CREDITS:
return <ModalCreditIntro {...notificationProps} />; return <ModalCreditIntro {...notificationProps} />;
case modals.WELCOME: case MODALS.WELCOME:
return <ModalWelcome {...notificationProps} />; return <ModalWelcome {...notificationProps} />;
case modals.FIRST_REWARD: case MODALS.FIRST_REWARD:
return <ModalFirstReward {...notificationProps} />; return <ModalFirstReward {...notificationProps} />;
case modals.AUTHENTICATION_FAILURE: case MODALS.AUTHENTICATION_FAILURE:
return <ModalAuthFailure {...notificationProps} />; return <ModalAuthFailure {...notificationProps} />;
case modals.TRANSACTION_FAILED: case MODALS.TRANSACTION_FAILED:
return <ModalTransactionFailed {...notificationProps} />; return <ModalTransactionFailed {...notificationProps} />;
case modals.REWARD_APPROVAL_REQUIRED: case MODALS.REWARD_APPROVAL_REQUIRED:
return <ModalRewardApprovalRequired {...notificationProps} />; return <ModalRewardApprovalRequired {...notificationProps} />;
case modals.CONFIRM_FILE_REMOVE: case MODALS.CONFIRM_FILE_REMOVE:
return <ModalRemoveFile {...notificationProps} />; return <ModalRemoveFile {...notificationProps} />;
case modals.AFFIRM_PURCHASE: case MODALS.AFFIRM_PURCHASE:
return <ModalAffirmPurchase {...notificationProps} />; return <ModalAffirmPurchase {...notificationProps} />;
case modals.CONFIRM_CLAIM_REVOKE: case MODALS.CONFIRM_CLAIM_REVOKE:
return <ModalRevokeClaim {...notificationProps} />; return <ModalRevokeClaim {...notificationProps} />;
case modals.PHONE_COLLECTION: case MODALS.PHONE_COLLECTION:
return <ModalPhoneCollection {...notificationProps} />; return <ModalPhoneCollection {...notificationProps} />;
case modals.EMAIL_COLLECTION: case MODALS.EMAIL_COLLECTION:
return <ModalEmailCollection {...notificationProps} />; return <ModalEmailCollection {...notificationProps} />;
case modals.FIRST_SUBSCRIPTION: case MODALS.FIRST_SUBSCRIPTION:
return <ModalFirstSubscription {...notificationProps} />; return <ModalFirstSubscription {...notificationProps} />;
case modals.SEND_TIP: case MODALS.SEND_TIP:
return <ModalSendTip {...notificationProps} />; return <ModalSendTip {...notificationProps} />;
case modals.PUBLISH: case MODALS.PUBLISH:
return <ModalPublish {...notificationProps} />; return <ModalPublish {...notificationProps} />;
case modals.SEARCH: case MODALS.SEARCH:
return <ModalSearch {...notificationProps} />; return <ModalSearch {...notificationProps} />;
default: default:
return null; return null;

View file

@ -1,6 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import { Lbry, buildURI, normalizeURI } from 'lbry-redux'; import { Lbry, buildURI, normalizeURI, MODALS } from 'lbry-redux';
import Video from 'component/video'; import Video from 'component/video';
import Thumbnail from 'component/common/thumbnail'; import Thumbnail from 'component/common/thumbnail';
import FilePrice from 'component/filePrice'; import FilePrice from 'component/filePrice';
@ -14,7 +14,6 @@ import Button from 'component/button';
import SubscribeButton from 'component/subscribeButton'; import SubscribeButton from 'component/subscribeButton';
import Page from 'component/page'; import Page from 'component/page';
import player from 'render-media'; import player from 'render-media';
import * as modals from 'constants/modal_types';
type Props = { type Props = {
claim: { claim: {
@ -171,7 +170,7 @@ class FilePage extends React.Component<Props> {
button="alt" button="alt"
iconRight="Send" iconRight="Send"
label={__('Enjoy this? Send a tip')} label={__('Enjoy this? Send a tip')}
onClick={() => openModal({ id: modals.SEND_TIP }, { uri })} onClick={() => openModal({ id: MODALS.SEND_TIP }, { uri })}
/> />
<SubscribeButton uri={subscriptionUri} channelName={channelName} /> <SubscribeButton uri={subscriptionUri} channelName={channelName} />
</React.Fragment> </React.Fragment>

View file

@ -1,7 +1,6 @@
import { execSync } from 'child_process'; import { execSync } from 'child_process';
import isDev from 'electron-is-dev'; import isDev from 'electron-is-dev';
import path from 'path'; import path from 'path';
import * as MODALS from 'constants/modal_types';
import { ipcRenderer, remote } from 'electron'; import { ipcRenderer, remote } from 'electron';
import { import {
ACTIONS, ACTIONS,
@ -10,6 +9,7 @@ import {
doFetchFileInfosAndPublishedClaims, doFetchFileInfosAndPublishedClaims,
doNotify, doNotify,
selectNotification, selectNotification,
MODALS,
} from 'lbry-redux'; } from 'lbry-redux';
import Native from 'native'; import Native from 'native';
import { doFetchRewardedContent } from 'redux/actions/content'; import { doFetchRewardedContent } from 'redux/actions/content';

View file

@ -1,8 +1,6 @@
import * as MODALS from 'constants/modal_types';
import * as NOTIFICATION_TYPES from 'constants/notification_types'; import * as NOTIFICATION_TYPES from 'constants/notification_types';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import Lbryio from 'lbryio'; import Lbryio from 'lbryio';
import { doNotify } from 'lbry-redux';
import { doAlertError } from 'redux/actions/app'; import { doAlertError } from 'redux/actions/app';
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards'; import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
@ -27,6 +25,8 @@ import {
selectDownloadingByOutpoint, selectDownloadingByOutpoint,
selectTotalDownloadProgress, selectTotalDownloadProgress,
selectBalance, selectBalance,
MODALS,
doNotify,
} from 'lbry-redux'; } from 'lbry-redux';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import setBadge from 'util/setBadge'; import setBadge from 'util/setBadge';

View file

@ -1,6 +1,5 @@
// @flow // @flow
import * as MODALS from 'constants/modal_types'; import { ACTIONS, Lbry, selectMyClaimsWithoutChannels, doNotify, MODALS } from 'lbry-redux';
import { ACTIONS, Lbry, selectMyClaimsWithoutChannels, doNotify } from 'lbry-redux';
import { selectPendingPublishes } from 'redux/selectors/publish'; import { selectPendingPublishes } from 'redux/selectors/publish';
import type { import type {
UpdatePublishFormData, UpdatePublishFormData,

View file

@ -1,5 +1,5 @@
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import Lbryio from 'lbryio'; import Lbryio from 'lbryio';
import { selectUnclaimedRewardsByType } from 'redux/selectors/rewards'; import { selectUnclaimedRewardsByType } from 'redux/selectors/rewards';
import { selectUserIsRewardApproved } from 'redux/selectors/user'; import { selectUserIsRewardApproved } from 'redux/selectors/user';

View file

@ -1,7 +1,6 @@
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types';
import Lbryio from 'lbryio'; import Lbryio from 'lbryio';
import { doNotify } from 'lbry-redux'; import { doNotify, MODALS } from 'lbry-redux';
import { doClaimRewardType, doRewardList } from 'redux/actions/rewards'; import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
import { import {
selectEmailToVerify, selectEmailToVerify,

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types'; import { MODALS } from 'lbry-redux';
import { remote } from 'electron'; import { remote } from 'electron';