From 735aa75f81715e96ed4e3cbca6af2aee1ecfab53 Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Thu, 17 Mar 2022 17:41:33 +0400 Subject: [PATCH] ALM: reorder warnings --- alm/src/components/ExecutionConfirmation.tsx | 9 ++++++++- alm/src/components/MainPage.tsx | 6 +----- alm/src/components/ManualExecutionButton.tsx | 6 ++++-- alm/src/components/commons/ErrorAlert.tsx | 2 +- alm/src/components/commons/WarningAlert.tsx | 2 +- alm/src/state/StateProvider.tsx | 20 +++----------------- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/alm/src/components/ExecutionConfirmation.tsx b/alm/src/components/ExecutionConfirmation.tsx index f86334a7b..38cde65a5 100644 --- a/alm/src/components/ExecutionConfirmation.tsx +++ b/alm/src/components/ExecutionConfirmation.tsx @@ -11,6 +11,8 @@ import { Thead, AgeTd, StatusTd } from './commons/Table' import { ManualExecutionButton } from './ManualExecutionButton' import { useStateProvider } from '../state/StateProvider' import { matchesRule, MessageObject, WarnRule } from '../utils/web3' +import { WarningAlert } from './commons/WarningAlert' +import { ErrorAlert } from './commons/ErrorAlert' const StyledExecutionConfirmation = styled.div` margin-top: 30px; @@ -35,8 +37,10 @@ export const ExecutionConfirmation = ({ executionEventsFetched, setPendingExecution }: ExecutionConfirmationParams) => { - const { foreign, setWarning } = useStateProvider() + const { foreign } = useStateProvider() const [safeExecutionAvailable, setSafeExecutionAvailable] = useState(false) + const [error, setError] = useState('') + const [warning, setWarning] = useState('') const availableManualExecution = !isHome && (executionData.status === VALIDATOR_CONFIRMATION_STATUS.WAITING || @@ -106,6 +110,8 @@ export const ExecutionConfirmation = ({ return ( + {error && setError('')} error={error} />} + {warning && setWarning('')} error={warning} />} @@ -148,6 +154,7 @@ export const ExecutionConfirmation = ({ setExecutionData={setExecutionData} signatureCollected={signatureCollected as string[]} setPendingExecution={setPendingExecution} + setError={setError} /> )} diff --git a/alm/src/components/MainPage.tsx b/alm/src/components/MainPage.tsx index e5055208c..88ced8153 100644 --- a/alm/src/components/MainPage.tsx +++ b/alm/src/components/MainPage.tsx @@ -8,8 +8,6 @@ import { TransactionReceipt } from 'web3-eth' import { InfoAlert } from './commons/InfoAlert' import { ExplorerTxLink } from './commons/ExplorerTxLink' import { FOREIGN_NETWORK_NAME, HOME_NETWORK_NAME } from '../config/constants' -import { ErrorAlert } from './commons/ErrorAlert' -import { WarningAlert } from './commons/WarningAlert' const StyledMainPage = styled.div` text-align: center; @@ -53,7 +51,7 @@ export interface FormSubmitParams { export const MainPage = () => { const history = useHistory() - const { home, foreign, error, setError, warning, setWarning } = useStateProvider() + const { home, foreign } = useStateProvider() const [networkName, setNetworkName] = useState('') const [receipt, setReceipt] = useState>(null) const [showInfoAlert, setShowInfoAlert] = useState(false) @@ -133,8 +131,6 @@ export const MainPage = () => { )} - {error && setError('')} error={error} />} - {warning && setWarning('')} error={warning} />} } /> { - const { foreign, setError } = useStateProvider() + const { foreign } = useStateProvider() const { library, activate, account, active } = useWeb3React() const [manualExecution, setManualExecution] = useState(false) const [allowFailures, setAllowFailures] = useState(false) diff --git a/alm/src/components/commons/ErrorAlert.tsx b/alm/src/components/commons/ErrorAlert.tsx index 236353b00..28eed2af1 100644 --- a/alm/src/components/commons/ErrorAlert.tsx +++ b/alm/src/components/commons/ErrorAlert.tsx @@ -33,7 +33,7 @@ export const ErrorAlert = ({ onClick, error }: { onClick: () => void; error: str } return (
- + {text} diff --git a/alm/src/components/commons/WarningAlert.tsx b/alm/src/components/commons/WarningAlert.tsx index 8705b8f81..160147758 100644 --- a/alm/src/components/commons/WarningAlert.tsx +++ b/alm/src/components/commons/WarningAlert.tsx @@ -22,7 +22,7 @@ const TextContainer = styled.div` export const WarningAlert = ({ onClick, error }: { onClick: () => void; error: string }) => { return (
- + {error} diff --git a/alm/src/state/StateProvider.tsx b/alm/src/state/StateProvider.tsx index f753a91d5..c495ef65f 100644 --- a/alm/src/state/StateProvider.tsx +++ b/alm/src/state/StateProvider.tsx @@ -1,4 +1,4 @@ -import React, { createContext, ReactNode, useState } from 'react' +import React, { createContext, ReactNode } from 'react' import { useNetwork } from '../hooks/useNetwork' import { HOME_RPC_URL, @@ -25,10 +25,6 @@ export interface StateContext { home: BaseNetworkParams foreign: BaseNetworkParams loading: boolean - error: string - setError: Function - warning: string - setWarning: Function } const initialState = { @@ -46,11 +42,7 @@ const initialState = { bridgeAddress: FOREIGN_BRIDGE_ADDRESS, bridgeContract: null }, - loading: true, - error: '', - setError: () => {}, - warning: '', - setWarning: () => {} + loading: true } const StateContext = createContext(initialState) @@ -62,8 +54,6 @@ export const StateProvider = ({ children }: { children: ReactNode }) => { homeWeb3: homeNetwork.web3, foreignWeb3: foreignNetwork.web3 }) - const [error, setError] = useState('') - const [warning, setWarning] = useState('') const value = { home: { @@ -78,11 +68,7 @@ export const StateProvider = ({ children }: { children: ReactNode }) => { bridgeContract: foreignBridge, ...foreignNetwork }, - loading: homeNetwork.loading || foreignNetwork.loading, - error, - setError, - warning, - setWarning + loading: homeNetwork.loading || foreignNetwork.loading } return {children}