From 89a4a04e8f40ae77e861998ec37207877b791d1e Mon Sep 17 00:00:00 2001 From: veado <61792675+veado@users.noreply.github.com> Date: Sat, 4 Sep 2021 09:46:12 +0200 Subject: [PATCH] PoolDetails: Disable `Manage` button (#1732) based on `disablePoolActions` --- src/renderer/components/pool/PoolDetails.stories.tsx | 1 + src/renderer/components/pool/PoolDetails.tsx | 3 +++ src/renderer/components/pool/PoolTitle.tsx | 6 ++++-- src/renderer/views/pool/PoolDetailsView.tsx | 10 ++++++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/pool/PoolDetails.stories.tsx b/src/renderer/components/pool/PoolDetails.stories.tsx index 212576a01..c9ce4f705 100644 --- a/src/renderer/components/pool/PoolDetails.stories.tsx +++ b/src/renderer/components/pool/PoolDetails.stories.tsx @@ -22,6 +22,7 @@ export const PoolDetailsStory = () => { ChartView={() => <>Pool Chart Here} disableTradingPoolAction={false} disableAllPoolActions={false} + disablePoolActions={false} /> ) } diff --git a/src/renderer/components/pool/PoolDetails.tsx b/src/renderer/components/pool/PoolDetails.tsx index 345a5b773..5c2010291 100644 --- a/src/renderer/components/pool/PoolDetails.tsx +++ b/src/renderer/components/pool/PoolDetails.tsx @@ -24,6 +24,7 @@ export type Props = { ChartView: React.ComponentType<{ isLoading?: boolean; priceRatio: BigNumber }> disableTradingPoolAction: boolean disableAllPoolActions: boolean + disablePoolActions: boolean network: Network } @@ -38,6 +39,7 @@ export const PoolDetails: React.FC = ({ ChartView, disableTradingPoolAction, disableAllPoolActions, + disablePoolActions, network }) => { const price = useMemo(() => H.getPrice(poolDetail, priceRatio), [poolDetail, priceRatio]) @@ -48,6 +50,7 @@ export const PoolDetails: React.FC = ({ network={network} disableAllPoolActions={disableAllPoolActions} disableTradingPoolAction={disableTradingPoolAction} + disablePoolActions={disablePoolActions} asset={O.some(asset)} price={price} priceSymbol={priceSymbol} diff --git a/src/renderer/components/pool/PoolTitle.tsx b/src/renderer/components/pool/PoolTitle.tsx index c323b21e1..c86f39828 100644 --- a/src/renderer/components/pool/PoolTitle.tsx +++ b/src/renderer/components/pool/PoolTitle.tsx @@ -25,6 +25,7 @@ export type Props = { isLoading?: boolean disableTradingPoolAction: boolean disableAllPoolActions: boolean + disablePoolActions: boolean network: Network status: GetPoolsStatusEnum } @@ -35,6 +36,7 @@ export const PoolTitle: React.FC = ({ priceSymbol, disableTradingPoolAction, disableAllPoolActions, + disablePoolActions, network, isLoading, status @@ -103,7 +105,7 @@ export const PoolTitle: React.FC = ({ return ( = ({ } ) ), - [oAsset, disableAllPoolActions, isDesktopView, status, disableTradingPoolAction, intl, history] + [oAsset, disableAllPoolActions, disablePoolActions, isDesktopView, status, disableTradingPoolAction, intl, history] ) return ( diff --git a/src/renderer/views/pool/PoolDetailsView.tsx b/src/renderer/views/pool/PoolDetailsView.tsx index 4844b1d44..328829931 100644 --- a/src/renderer/views/pool/PoolDetailsView.tsx +++ b/src/renderer/views/pool/PoolDetailsView.tsx @@ -36,7 +36,8 @@ const defaultDetailsProps: TargetPoolDetailProps = { earningsHistory: O.none, network: DEFAULT_NETWORK, disableAllPoolActions: false, - disableTradingPoolAction: false + disableTradingPoolAction: false, + disablePoolActions: false } export const PoolDetailsView: React.FC = () => { @@ -74,6 +75,10 @@ export const PoolDetailsView: React.FC = () => { (chain: Chain) => PoolHelpers.disableTradingActions({ chain, haltedChains, mimirHalt }), [haltedChains, mimirHalt] ) + const getDisablePoolActions = useCallback( + (chain: Chain) => PoolHelpers.disablePoolActions({ chain, haltedChains, mimirHalt }), + [haltedChains, mimirHalt] + ) const oRouteAsset = useMemo(() => O.fromNullable(assetFromString(asset.toUpperCase())), [asset]) @@ -139,7 +144,8 @@ export const PoolDetailsView: React.FC = () => { HistoryView: PoolHistory, ChartView: PoolChartView, disableAllPoolActions: getDisableAllPoolActions(asset.chain), - disableTradingPoolAction: getDisableTradingPoolAction(asset.chain) + disableTradingPoolAction: getDisableTradingPoolAction(asset.chain), + disablePoolActions: getDisablePoolActions(asset.chain) } return