lbry-desktop/ui/modal/modalRouter/view.jsx

108 lines
4.2 KiB
React
Raw Normal View History

2018-09-26 02:12:07 +02:00
// @flow
import React from 'react';
import * as MODALS from 'constants/modal_types';
import ModalError from 'modal/modalError';
import ModalDownloading from 'modal/modalDownloading';
2019-05-21 23:18:11 +02:00
import ModalAutoGenerateThumbnail from 'modal/modalAutoGenerateThumbnail';
import ModalAutoUpdateDownloaded from 'modal/modalAutoUpdateDownloaded';
import ModalUpgrade from 'modal/modalUpgrade';
import ModalWelcome from 'modal/modalWelcome';
import ModalFirstReward from 'modal/modalFirstReward';
import ModalRemoveFile from 'modal/modalRemoveFile';
import ModalTransactionFailed from 'modal/modalTransactionFailed';
import ModalFileTimeout from 'modal/modalFileTimeout';
import ModalAffirmPurchase from 'modal/modalAffirmPurchase';
import ModalRevokeClaim from 'modal/modalRevokeClaim';
import ModalPhoneCollection from 'modal/modalPhoneCollection';
import ModalFirstSubscription from 'modal/modalFirstSubscription';
import ModalConfirmTransaction from 'modal/modalConfirmTransaction';
2018-09-12 18:42:15 +02:00
import ModalSocialShare from 'modal/modalSocialShare';
import ModalSendTip from 'modal/modalSendTip';
import ModalPublish from 'modal/modalPublish';
import ModalOpenExternalResource from 'modal/modalOpenExternalResource';
2018-04-02 18:03:12 +02:00
import ModalConfirmThumbnailUpload from 'modal/modalConfirmThumbnailUpload';
2018-07-18 21:48:30 +02:00
import ModalWalletEncrypt from 'modal/modalWalletEncrypt';
import ModalWalletDecrypt from 'modal/modalWalletDecrypt';
import ModalWalletUnlock from 'modal/modalWalletUnlock';
2018-09-26 02:12:07 +02:00
import ModalRewardCode from 'modal/modalRewardCode';
2019-08-20 14:29:59 +02:00
import ModalPasswordUnsave from 'modal/modalPasswordUnsave';
2019-11-14 21:02:15 +01:00
import ModalCommentAcknowledgement from 'modal/modalCommentAcknowledgement';
2018-04-02 18:03:12 +02:00
type Props = {
2019-01-08 03:46:33 +01:00
modal: { id: string, modalProps: {} },
error: { message: string },
2018-04-02 18:03:12 +02:00
};
function ModalRouter(props: Props) {
const { modal, error } = props;
if (error) {
return <ModalError {...error} />;
}
if (!modal) {
return null;
2017-08-21 05:06:26 +02:00
}
const { id, modalProps } = modal;
switch (id) {
case MODALS.UPGRADE:
return <ModalUpgrade {...modalProps} />;
case MODALS.DOWNLOADING:
return <ModalDownloading {...modalProps} />;
2019-05-21 23:18:11 +02:00
case MODALS.AUTO_GENERATE_THUMBNAIL:
return <ModalAutoGenerateThumbnail {...modalProps} />;
case MODALS.AUTO_UPDATE_DOWNLOADED:
return <ModalAutoUpdateDownloaded {...modalProps} />;
case MODALS.ERROR:
return <ModalError {...modalProps} />;
case MODALS.FILE_TIMEOUT:
return <ModalFileTimeout {...modalProps} />;
case MODALS.WELCOME:
return <ModalWelcome {...modalProps} />;
case MODALS.FIRST_REWARD:
return <ModalFirstReward {...modalProps} />;
case MODALS.TRANSACTION_FAILED:
return <ModalTransactionFailed {...modalProps} />;
case MODALS.CONFIRM_FILE_REMOVE:
return <ModalRemoveFile {...modalProps} />;
case MODALS.AFFIRM_PURCHASE:
return <ModalAffirmPurchase {...modalProps} />;
case MODALS.CONFIRM_CLAIM_REVOKE:
return <ModalRevokeClaim {...modalProps} />;
case MODALS.PHONE_COLLECTION:
return <ModalPhoneCollection {...modalProps} />;
case MODALS.FIRST_SUBSCRIPTION:
return <ModalFirstSubscription {...modalProps} />;
case MODALS.SEND_TIP:
return <ModalSendTip {...modalProps} />;
case MODALS.SOCIAL_SHARE:
return <ModalSocialShare {...modalProps} />;
case MODALS.PUBLISH:
return <ModalPublish {...modalProps} />;
case MODALS.CONFIRM_EXTERNAL_RESOURCE:
return <ModalOpenExternalResource {...modalProps} />;
case MODALS.CONFIRM_TRANSACTION:
return <ModalConfirmTransaction {...modalProps} />;
case MODALS.CONFIRM_THUMBNAIL_UPLOAD:
return <ModalConfirmThumbnailUpload {...modalProps} />;
case MODALS.WALLET_ENCRYPT:
return <ModalWalletEncrypt {...modalProps} />;
case MODALS.WALLET_DECRYPT:
return <ModalWalletDecrypt {...modalProps} />;
case MODALS.WALLET_UNLOCK:
return <ModalWalletUnlock {...modalProps} />;
2019-08-20 14:29:59 +02:00
case MODALS.WALLET_PASSWORD_UNSAVE:
return <ModalPasswordUnsave {...modalProps} />;
case MODALS.REWARD_GENERATED_CODE:
return <ModalRewardCode {...modalProps} />;
2019-11-14 21:02:15 +01:00
case MODALS.COMMENT_ACKNOWEDGEMENT:
return <ModalCommentAcknowledgement {...modalProps} />;
default:
return null;
}
}
export default ModalRouter;