Use ternary conditionals instead of && (#12406)

feature/default_network_editable
David Walsh 3 years ago committed by GitHub
parent 5fea5fac8c
commit 3f687ff45f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      ui/components/app/account-list-item/account-list-item.js
  2. 4
      ui/components/app/account-menu/account-menu.component.js
  3. 6
      ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js
  4. 2
      ui/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js
  5. 6
      ui/components/app/contact-list/contact-list.component.js
  6. 2
      ui/components/app/modal/modal-content/modal-content.component.js
  7. 2
      ui/components/app/signature-request/signature-request-header/signature-request-header.component.js
  8. 2
      ui/components/app/transaction-activity-log/transaction-activity-log-icon/transaction-activity-log-icon.component.js
  9. 2
      ui/components/ui/actionable-message/actionable-message.js
  10. 2
      ui/components/ui/button/button.component.js
  11. 4
      ui/components/ui/chip/chip.js
  12. 2
      ui/components/ui/icon-with-label/icon-with-label.js
  13. 16
      ui/components/ui/list-item/list-item.component.js
  14. 6
      ui/components/ui/page-container/page-container-header/page-container-header.component.js
  15. 8
      ui/components/ui/qr-code/qr-code.js
  16. 2
      ui/components/ui/unit-input/unit-input.component.js
  17. 2
      ui/pages/create-account/connect-hardware/account-list.js
  18. 2
      ui/pages/create-account/connect-hardware/select-hardware.js
  19. 4
      ui/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
  20. 4
      ui/pages/routes/routes.component.js
  21. 19
      ui/pages/send/send-content/send-content.component.js
  22. 4
      ui/pages/send/send-content/send-row-wrapper/send-row-wrapper.component.js
  23. 2
      ui/pages/settings/advanced-tab/advanced-tab.component.js
  24. 4
      ui/pages/settings/contact-list-tab/contact-list-tab.component.js
  25. 2
      ui/pages/settings/networks-tab/networks-tab.component.js
  26. 2
      ui/pages/settings/security-tab/security-tab.component.js
  27. 2
      ui/pages/settings/settings-tab/settings-tab.component.js
  28. 2
      ui/pages/swaps/awaiting-swap/awaiting-swap.js
  29. 55
      ui/pages/swaps/searchable-item-list/item-list/item-list.component.js

@ -24,11 +24,8 @@ export default function AccountListItem({
className="account-list-item__identicon" className="account-list-item__identicon"
diameter={18} diameter={18}
/> />
<div className="account-list-item__account-name">{name || address}</div> <div className="account-list-item__account-name">{name || address}</div>
{icon ? <div className="account-list-item__icon">{icon}</div> : null}
{icon && <div className="account-list-item__icon">{icon}</div>}
<AccountMismatchWarning address={address} /> <AccountMismatchWarning address={address} />
</div> </div>

@ -196,7 +196,9 @@ export default class AccountMenu extends Component {
key={identity.address} key={identity.address}
> >
<div className="account-menu__check-mark"> <div className="account-menu__check-mark">
{isSelected && <div className="account-menu__check-mark-icon" />} {isSelected ? (
<div className="account-menu__check-mark-icon" />
) : null}
</div> </div>
<Identicon address={identity.address} diameter={24} /> <Identicon address={identity.address} diameter={24} />
<div className="account-menu__account-info"> <div className="account-menu__account-info">

@ -93,7 +93,7 @@ export default class ConfirmPageContainerContent extends Component {
return ( return (
<div className="confirm-page-container-content"> <div className="confirm-page-container-content">
{warning && <ConfirmPageContainerWarning warning={warning} />} {warning ? <ConfirmPageContainerWarning warning={warning} /> : null}
{ethGasPriceWarning && ( {ethGasPriceWarning && (
<ConfirmPageContainerWarning warning={ethGasPriceWarning} /> <ConfirmPageContainerWarning warning={ethGasPriceWarning} />
)} )}
@ -124,7 +124,9 @@ export default class ConfirmPageContainerContent extends Component {
submitText={submitText} submitText={submitText}
disabled={disabled} disabled={disabled}
> >
{unapprovedTxCount > 1 && <a onClick={onCancelAll}>{rejectNText}</a>} {unapprovedTxCount > 1 ? (
<a onClick={onCancelAll}>{rejectNText}</a>
) : null}
</PageContainerFooter> </PageContainerFooter>
</div> </div>
); );

@ -56,7 +56,7 @@ export default function ConfirmPageContainerHeader({
</span> </span>
</div> </div>
)} )}
{!isFullScreen && <NetworkDisplay />} {isFullScreen ? null : <NetworkDisplay />}
</div> </div>
{children} {children}
</div> </div>

@ -106,9 +106,9 @@ export default class ContactList extends PureComponent {
return ( return (
<div className="send__select-recipient-wrapper__list"> <div className="send__select-recipient-wrapper__list">
{children || null} {children || null}
{searchForRecents && this.renderRecents()} {searchForRecents ? this.renderRecents() : null}
{searchForContacts && this.renderAddressBook()} {searchForContacts ? this.renderAddressBook() : null}
{searchForMyAccounts && this.renderMyAccounts()} {searchForMyAccounts ? this.renderMyAccounts() : null}
</div> </div>
); );
} }

@ -12,7 +12,7 @@ export default class ModalContent extends PureComponent {
return ( return (
<div className="modal-content"> <div className="modal-content">
{title && <div className="modal-content__title">{title}</div>} {title ? <div className="modal-content__title">{title}</div> : null}
{description && ( {description && (
<div className="modal-content__description">{description}</div> <div className="modal-content__description">{description}</div>
)} )}

@ -14,7 +14,7 @@ export default class SignatureRequestHeader extends PureComponent {
return ( return (
<div className="signature-request-header"> <div className="signature-request-header">
<div className="signature-request-header--account"> <div className="signature-request-header--account">
{fromAccount && <AccountListItem account={fromAccount} />} {fromAccount ? <AccountListItem account={fromAccount} /> : null}
</div> </div>
<div className="signature-request-header--network"> <div className="signature-request-header--network">
<NetworkDisplay colored={false} /> <NetworkDisplay colored={false} />

@ -40,7 +40,7 @@ export default class TransactionActivityLogIcon extends PureComponent {
return ( return (
<div className={classnames('transaction-activity-log-icon', className)}> <div className={classnames('transaction-activity-log-icon', className)}>
{imagePath && <img src={imagePath} height="9" width="9" alt="" />} {imagePath ? <img src={imagePath} height="9" width="9" alt="" /> : null}
</div> </div>
); );
} }

@ -35,7 +35,7 @@ export default function ActionableMessage({
return ( return (
<div className={actionableMessageClassName}> <div className={actionableMessageClassName}>
{useIcon && <InfoTooltipIcon fillColor={iconFillColor} />} {useIcon ? <InfoTooltipIcon fillColor={iconFillColor} /> : null}
{infoTooltipText && ( {infoTooltipText && (
<InfoTooltip <InfoTooltip
position="left" position="left"

@ -66,7 +66,7 @@ const Button = ({
)} )}
{...buttonProps} {...buttonProps}
> >
{icon && <span className="button__icon">{icon}</span>} {icon ? <span className="button__icon">{icon}</span> : null}
{children} {children}
</Tag> </Tag>
); );

@ -35,7 +35,7 @@ export default function Chip({
role={isInteractive ? 'button' : undefined} role={isInteractive ? 'button' : undefined}
tabIndex={isInteractive ? 0 : undefined} tabIndex={isInteractive ? 0 : undefined}
> >
{leftIcon && <div className="chip__left-icon">{leftIcon}</div>} {leftIcon ? <div className="chip__left-icon">{leftIcon}</div> : null}
{children ?? ( {children ?? (
<Typography <Typography
className="chip__label" className="chip__label"
@ -47,7 +47,7 @@ export default function Chip({
{label} {label}
</Typography> </Typography>
)} )}
{rightIcon && <div className="chip__right-icon">{rightIcon}</div>} {rightIcon ? <div className="chip__right-icon">{rightIcon}</div> : null}
</div> </div>
); );
} }

@ -6,7 +6,7 @@ export default function IconWithLabel({ icon, label, className }) {
return ( return (
<div className={classnames('icon-with-label', className)}> <div className={classnames('icon-with-label', className)}>
{icon} {icon}
{label && <span className="icon-with-label__label">{label}</span>} {label ? <span className="icon-with-label__label">{label}</span> : null}
</div> </div>
); );
} }

@ -33,7 +33,7 @@ export default function ListItem({
} }
}} }}
> >
{icon && <div className="list-item__icon">{icon}</div>} {icon ? <div className="list-item__icon">{icon}</div> : null}
<div className="list-item__heading"> <div className="list-item__heading">
{React.isValidElement(title) ? ( {React.isValidElement(title) ? (
title title
@ -44,12 +44,16 @@ export default function ListItem({
<div className="list-item__heading-wrap">{titleIcon}</div> <div className="list-item__heading-wrap">{titleIcon}</div>
)} )}
</div> </div>
{subtitle && <div className="list-item__subheading">{subtitle}</div>} {subtitle ? (
{children && <div className="list-item__actions">{children}</div>} <div className="list-item__subheading">{subtitle}</div>
{midContent && <div className="list-item__mid-content">{midContent}</div>} ) : null}
{rightContent && ( {children ? <div className="list-item__actions">{children}</div> : null}
{midContent ? (
<div className="list-item__mid-content">{midContent}</div>
) : null}
{rightContent ? (
<div className="list-item__right-content">{rightContent}</div> <div className="list-item__right-content">{rightContent}</div>
)} ) : null}
</div> </div>
); );
} }

@ -21,7 +21,7 @@ export default class PageContainerHeader extends Component {
renderTabs() { renderTabs() {
const { tabs } = this.props; const { tabs } = this.props;
return tabs && <ul className="page-container__tabs">{tabs}</ul>; return tabs ? <ul className="page-container__tabs">{tabs}</ul> : null;
} }
renderCloseAction() { renderCloseAction() {
@ -99,7 +99,9 @@ export default class PageContainerHeader extends Component {
{title} {title}
</div> </div>
)} )}
{subtitle && <div className="page-container__subtitle">{subtitle}</div>} {subtitle ? (
<div className="page-container__subtitle">{subtitle}</div>
) : null}
{this.renderCloseAction()} {this.renderCloseAction()}

@ -26,6 +26,10 @@ function QrCodeView(props) {
qrImage.addData(address); qrImage.addData(address);
qrImage.make(); qrImage.make();
const header = message ? (
<div className="qr-code__header">{message}</div>
) : null;
return ( return (
<div className="qr-code"> <div className="qr-code">
{Array.isArray(message) ? ( {Array.isArray(message) ? (
@ -37,9 +41,9 @@ function QrCodeView(props) {
))} ))}
</div> </div>
) : ( ) : (
message && <div className="qr-code__header">{message}</div> header
)} )}
{warning && <span className="qr_code__error">{warning}</span>} {warning ? <span className="qr_code__error">{warning}</span> : null}
<div <div
className="qr-code__wrapper" className="qr-code__wrapper"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{

@ -108,7 +108,7 @@ export default class UnitInput extends PureComponent {
}} }}
autoFocus autoFocus
/> />
{suffix && <div className="unit-input__suffix">{suffix}</div>} {suffix ? <div className="unit-input__suffix">{suffix}</div> : null}
</div> </div>
{children} {children}
</div> </div>

@ -273,7 +273,7 @@ class AccountList extends Component {
{this.renderPagination()} {this.renderPagination()}
{this.renderButtons()} {this.renderButtons()}
{this.renderForgetDevice()} {this.renderForgetDevice()}
{showPopover && this.renderSelectPathPopover()} {showPopover ? this.renderSelectPathPopover() : null}
</div> </div>
); );
} }

@ -235,7 +235,7 @@ export default class SelectHardware extends Component {
<div className="new-external-account-form"> <div className="new-external-account-form">
{this.renderHeader()} {this.renderHeader()}
{this.renderButtons()} {this.renderButtons()}
{this.state.selectedDevice && this.renderTutorialsteps()} {this.state.selectedDevice ? this.renderTutorialsteps() : null}
{this.renderContinueButton()} {this.renderContinueButton()}
</div> </div>
); );

@ -258,7 +258,9 @@ export default class ImportWithSeedPhrase extends PureComponent {
autoComplete="off" autoComplete="off"
/> />
)} )}
{seedPhraseError && <span className="error">{seedPhraseError}</span>} {seedPhraseError ? (
<span className="error">{seedPhraseError}</span>
) : null}
<div <div
className="first-time-flow__checkbox-container" className="first-time-flow__checkbox-container"
onClick={this.toggleShowSeedPhrase} onClick={this.toggleShowSeedPhrase}

@ -340,8 +340,8 @@ export default class Routes extends Component {
/> />
<AccountMenu /> <AccountMenu />
<div className="main-container-wrapper"> <div className="main-container-wrapper">
{isLoading && <Loading loadingMessage={loadMessage} />} {isLoading ? <Loading loadingMessage={loadMessage} /> : null}
{!isLoading && isNetworkLoading && <LoadingNetwork />} {!isLoading && isNetworkLoading ? <LoadingNetwork /> : null}
{this.renderRoutes()} {this.renderRoutes()}
</div> </div>
{isUnlocked ? <Alerts history={this.props.history} /> : null} {isUnlocked ? <Alerts history={this.props.history} /> : null}

@ -50,17 +50,20 @@ export default class SendContent extends Component {
return ( return (
<PageContainerContent> <PageContainerContent>
<div className="send-v2__form"> <div className="send-v2__form">
{gasError && this.renderError(gasError)} {gasError ? this.renderError(gasError) : null}
{isEthGasPrice && this.renderWarning(ETH_GAS_PRICE_FETCH_WARNING_KEY)} {isEthGasPrice
{isAssetSendable === false && ? this.renderWarning(ETH_GAS_PRICE_FETCH_WARNING_KEY)
this.renderError(UNSENDABLE_ASSET_ERROR_KEY)} : null}
{error && this.renderError(error)} {isAssetSendable === false
{warning && this.renderWarning()} ? this.renderError(UNSENDABLE_ASSET_ERROR_KEY)
: null}
{error ? this.renderError(error) : null}
{warning ? this.renderWarning() : null}
{this.maybeRenderAddContact()} {this.maybeRenderAddContact()}
<SendAssetRow /> <SendAssetRow />
<SendAmountRow /> <SendAmountRow />
{networkOrAccountNotSupports1559 && <SendGasRow />} {networkOrAccountNotSupports1559 ? <SendGasRow /> : null}
{this.props.showHexData && <SendHexDataRow />} {this.props.showHexData ? <SendHexDataRow /> : null}
</div> </div>
</PageContainerContent> </PageContainerContent>
); );

@ -30,7 +30,7 @@ export default class SendRowWrapper extends Component {
<div className="send-v2__form-field-container"> <div className="send-v2__form-field-container">
<div className="send-v2__form-field">{formField}</div> <div className="send-v2__form-field">{formField}</div>
<div> <div>
{showError && <SendRowErrorMessage errorType={errorType} />} {showError ? <SendRowErrorMessage errorType={errorType} /> : null}
</div> </div>
</div> </div>
</div> </div>
@ -50,7 +50,7 @@ export default class SendRowWrapper extends Component {
<div className="send-v2__form-row"> <div className="send-v2__form-row">
<div className="send-v2__form-label"> <div className="send-v2__form-label">
{label} {label}
{showError && <SendRowErrorMessage errorType={errorType} />} {showError ? <SendRowErrorMessage errorType={errorType} /> : null}
{customLabelContent} {customLabelContent}
</div> </div>
<div className="send-v2__form-field">{formField}</div> <div className="send-v2__form-field">{formField}</div>

@ -533,7 +533,7 @@ export default class AdvancedTab extends PureComponent {
return ( return (
<div className="settings-page__body"> <div className="settings-page__body">
{warning && <div className="settings-tab__error">{warning}</div>} {warning ? <div className="settings-tab__error">{warning}</div> : null}
{this.renderStateLogs()} {this.renderStateLogs()}
{this.renderMobileSync()} {this.renderMobileSync()}
{this.renderResetAccount()} {this.renderResetAccount()}

@ -136,7 +136,9 @@ export default class ContactListTab extends Component {
<div className="address-book-wrapper"> <div className="address-book-wrapper">
{this.renderAddressBookContent()} {this.renderAddressBookContent()}
{this.renderContactContent()} {this.renderContactContent()}
{!addingContact && addressBook.length > 0 && this.renderAddButton()} {!addingContact && addressBook.length > 0
? this.renderAddButton()
: null}
</div> </div>
); );
} }

@ -244,7 +244,7 @@ export default class NetworksTab extends PureComponent {
return ( return (
<div className="networks-tab__body"> <div className="networks-tab__body">
{isFullScreen && this.renderSubHeader()} {isFullScreen ? this.renderSubHeader() : null}
<div className="networks-tab__content"> <div className="networks-tab__content">
{this.renderNetworksTabContent()} {this.renderNetworksTabContent()}
{!isFullScreen && !shouldRenderNetworkForm ? ( {!isFullScreen && !shouldRenderNetworkForm ? (

@ -146,7 +146,7 @@ export default class SecurityTab extends PureComponent {
return ( return (
<div className="settings-page__body"> <div className="settings-page__body">
{warning && <div className="settings-tab__error">{warning}</div>} {warning ? <div className="settings-tab__error">{warning}</div> : null}
{this.renderSeedWords()} {this.renderSeedWords()}
{this.renderIncomingTransactionsOptIn()} {this.renderIncomingTransactionsOptIn()}
{this.renderPhishingDetectionToggle()} {this.renderPhishingDetectionToggle()}

@ -212,7 +212,7 @@ export default class SettingsTab extends PureComponent {
return ( return (
<div className="settings-page__body"> <div className="settings-page__body">
{warning && <div className="settings-tab__error">{warning}</div>} {warning ? <div className="settings-tab__error">{warning}</div> : null}
{this.renderCurrentConversion()} {this.renderCurrentConversion()}
{this.renderUsePrimaryCurrencyOptions()} {this.renderUsePrimaryCurrencyOptions()}
{this.renderCurrentLocale()} {this.renderCurrentLocale()}

@ -272,7 +272,7 @@ export default function AwaitingSwap({
<div className="awaiting-swap__main-descrption">{descriptionText}</div> <div className="awaiting-swap__main-descrption">{descriptionText}</div>
{content} {content}
</div> </div>
{!errorKey && swapComplete && <MakeAnotherSwap />} {!errorKey && swapComplete ? <MakeAnotherSwap /> : null}
<SwapsFooter <SwapsFooter
onSubmit={async () => { onSubmit={async () => {
if (errorKey === OFFLINE_FOR_MAINTENANCE) { if (errorKey === OFFLINE_FOR_MAINTENANCE) {

@ -52,13 +52,16 @@ export default function ItemList({
// If there is a token for import based on a contract address, it's the only one in the list. // If there is a token for import based on a contract address, it's the only one in the list.
const hasTokenForImport = results.length === 1 && results[0].notImported; const hasTokenForImport = results.length === 1 && results[0].notImported;
const placeholder = Placeholder ? (
<Placeholder searchQuery={searchQuery} />
) : null;
return results.length === 0 ? ( return results.length === 0 ? (
Placeholder && <Placeholder searchQuery={searchQuery} /> placeholder
) : ( ) : (
<div className="searchable-item-list"> <div className="searchable-item-list">
{listTitle && ( {listTitle ? (
<div className="searchable-item-list__title">{listTitle}</div> <div className="searchable-item-list__title">{listTitle}</div>
)} ) : null}
<div <div
className={classnames( className={classnames(
'searchable-item-list__list-container', 'searchable-item-list__list-container',
@ -100,43 +103,43 @@ export default function ItemList({
onKeyUp={(e) => e.key === 'Enter' && onClick()} onKeyUp={(e) => e.key === 'Enter' && onClick()}
key={`searchable-item-list-item-${i}`} key={`searchable-item-list-item-${i}`}
> >
{(iconUrl || primaryLabel) && ( {iconUrl || primaryLabel ? (
<UrlIcon url={iconUrl} name={primaryLabel} /> <UrlIcon url={iconUrl} name={primaryLabel} />
)} ) : null}
{!(iconUrl || primaryLabel) && identiconAddress && ( {!(iconUrl || primaryLabel) && identiconAddress ? (
<div className="searchable-item-list__identicon"> <div className="searchable-item-list__identicon">
<Identicon address={identiconAddress} diameter={24} /> <Identicon address={identiconAddress} diameter={24} />
</div> </div>
)} ) : null}
{IconComponent && <IconComponent />} {IconComponent ? <IconComponent /> : null}
<div className="searchable-item-list__labels"> <div className="searchable-item-list__labels">
<div className="searchable-item-list__item-labels"> <div className="searchable-item-list__item-labels">
{primaryLabel && ( {primaryLabel ? (
<span className="searchable-item-list__primary-label"> <span className="searchable-item-list__primary-label">
{primaryLabel} {primaryLabel}
</span> </span>
)} ) : null}
{secondaryLabel && ( {secondaryLabel ? (
<span className="searchable-item-list__secondary-label"> <span className="searchable-item-list__secondary-label">
{secondaryLabel} {secondaryLabel}
</span> </span>
)} ) : null}
</div> </div>
{!hideRightLabels && {!hideRightLabels &&
(rightPrimaryLabel || rightSecondaryLabel) && ( (rightPrimaryLabel || rightSecondaryLabel) ? (
<div className="searchable-item-list__right-labels"> <div className="searchable-item-list__right-labels">
{rightPrimaryLabel && ( {rightPrimaryLabel ? (
<span className="searchable-item-list__right-primary-label"> <span className="searchable-item-list__right-primary-label">
{rightPrimaryLabel} {rightPrimaryLabel}
</span> </span>
)} ) : null}
{rightSecondaryLabel && ( {rightSecondaryLabel ? (
<span className="searchable-item-list__right-secondary-label"> <span className="searchable-item-list__right-secondary-label">
{rightSecondaryLabel} {rightSecondaryLabel}
</span> </span>
)} ) : null}
</div> </div>
)} ) : null}
</div> </div>
{result.notImported && ( {result.notImported && (
<Button type="confirm" onClick={onClick}> <Button type="confirm" onClick={onClick}>

Loading…
Cancel
Save