From 3e26431e8f4f42bd30462a0b24cda80535c0e557 Mon Sep 17 00:00:00 2001 From: Sam Keen Date: Fri, 25 Aug 2023 10:58:01 +0100 Subject: [PATCH] feat(governance): small UX improvements to successor market panels (#4562) --- .../proposal-market-data.tsx | 290 +++++++++--------- .../market-info/info-key-value-table.tsx | 2 +- .../market-info/market-info-panels.tsx | 249 ++++++--------- .../oracle-basic-profile.tsx | 9 - 4 files changed, 233 insertions(+), 317 deletions(-) diff --git a/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx b/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx index bf491b2b3..453bf41f5 100644 --- a/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx @@ -15,8 +15,6 @@ import { SettlementAssetInfoPanel, } from '@vegaprotocol/markets'; import { - Accordion, - AccordionItem, Button, CopyWithTooltip, Dialog, @@ -43,6 +41,9 @@ export const useMarketDataDialogStore = create( }) ); +const marketDataHeaderStyles = + 'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2'; + export const ProposalMarketData = ({ marketData, parentMarketData, @@ -76,6 +77,14 @@ export const ProposalMarketData = ({ parentTerminationData !== undefined && isEqual(terminationData, parentTerminationData); + const showParentPriceMonitoringBounds = + parentMarketData?.priceMonitoringSettings?.parameters?.triggers !== + undefined && + !isEqual( + marketData.priceMonitoringSettings?.parameters?.triggers, + parentMarketData?.priceMonitoringSettings?.parameters?.triggers + ); + const getSigners = (data: DataSourceDefinition) => { if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { const signers = data.sourceType.sourceType.signers || []; @@ -108,164 +117,141 @@ export const ProposalMarketData = ({
- - - } - /> - - } - /> - {isEqual( - getSigners(settlementData), - getSigners(terminationData) - ) ? ( - +

{t('Key details')}

+ + +

{t('Instrument')}

+ + + {isEqual( + getSigners(settlementData), + getSigners(terminationData) + ) ? ( + <> +

{t('Oracle')}

+ + + + ) : ( + <> +

+ {t('Settlement Oracle')} +

+ - ) : ( - <> - - } - /> - - } - /> - - )} - {/*Note: successor markets will not differ in their settlement*/} - {/*assets, so no need to pass in parent market data for comparison.*/} - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - {( - marketData.priceMonitoringSettings?.parameters?.triggers || [] +

+ {t('Termination Oracle')} +

+ + + )} + + {/*Note: successor markets will not differ in their settlement*/} + {/*assets, so no need to pass in parent market data for comparison.*/} + +

{t('Settlement assets')}

+ + +

{t('Metadata')}

+ + +

{t('Risk model')}

+ + +

{t('Risk parameters')}

+ + +

{t('Risk factors')}

+ + + {showParentPriceMonitoringBounds && + ( + parentMarketData?.priceMonitoringSettings?.parameters + ?.triggers || [] ).map((_, triggerIndex) => ( - +

+ {t(`Parent price monitoring bounds ${triggerIndex + 1}`)} +

+ +
- } - /> +
+ ))} - - } - /> - - } - /> -
+ + {( + marketData.priceMonitoringSettings?.parameters?.triggers || [] + ).map((_, triggerIndex) => ( + <> +

+ {t(`Price monitoring bounds ${triggerIndex + 1}`)} +

+ + + + ))} + +

+ {t('Liquidity monitoring parameters')} +

+ + +

+ {t('Liquidity price range')} +

+
)} diff --git a/libs/markets/src/lib/components/market-info/info-key-value-table.tsx b/libs/markets/src/lib/components/market-info/info-key-value-table.tsx index e717453bb..483b0aaa9 100644 --- a/libs/markets/src/lib/components/market-info/info-key-value-table.tsx +++ b/libs/markets/src/lib/components/market-info/info-key-value-table.tsx @@ -98,7 +98,7 @@ export const Row = ({
{valueDiffersFromParentMarket ? (
- + {getFormattedValue(parentValue)} {formattedValue} diff --git a/libs/markets/src/lib/components/market-info/market-info-panels.tsx b/libs/markets/src/lib/components/market-info/market-info-panels.tsx index 1c84223d3..a1acca924 100644 --- a/libs/markets/src/lib/components/market-info/market-info-panels.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-panels.tsx @@ -1,13 +1,14 @@ import isEqual from 'lodash/isEqual'; import type { ReactNode } from 'react'; -import { Fragment, useState } from 'react'; -import { useMemo } from 'react'; +import { Fragment, useMemo, useState } from 'react'; import { AssetDetailsTable, useAssetDataProvider } from '@vegaprotocol/assets'; import { t } from '@vegaprotocol/i18n'; import { marketDataProvider } from '../../market-data-provider'; import { totalFeesPercentage } from '../../market-utils'; import { ExternalLink, + Intent, + Lozenge, Splash, Tooltip, VegaIcon, @@ -27,9 +28,15 @@ import type { } from './market-info-data-provider'; import { Last24hVolume } from '../last-24h-volume'; import BigNumber from 'bignumber.js'; -import type { DataSourceDefinition, SignerKind } from '@vegaprotocol/types'; -import { ConditionOperatorMapping } from '@vegaprotocol/types'; -import { MarketTradingModeMapping } from '@vegaprotocol/types'; +import type { + DataSourceDefinition, + MarketTradingMode, + SignerKind, +} from '@vegaprotocol/types'; +import { + ConditionOperatorMapping, + MarketTradingModeMapping, +} from '@vegaprotocol/types'; import { DApp, FLAGS, @@ -48,8 +55,6 @@ import { useSuccessorMarketQuery, } from '../../__generated__'; import { useSuccessorMarketProposalDetailsQuery } from '@vegaprotocol/proposals'; -import type { MarketTradingMode } from '@vegaprotocol/types'; -import type { Signer } from '@vegaprotocol/types'; import classNames from 'classnames'; import compact from 'lodash/compact'; @@ -575,7 +580,6 @@ export const RiskFactorsInfoPanel = ({ export const PriceMonitoringBoundsInfoPanel = ({ market, triggerIndex, - parentMarket, }: MarketInfoProps & { triggerIndex: number; }) => { @@ -584,33 +588,13 @@ export const PriceMonitoringBoundsInfoPanel = ({ variables: { marketId: market.id }, }); - const { data: parentData } = useDataProvider({ - dataProvider: marketDataProvider, - variables: { marketId: parentMarket?.id || '' }, - skip: - !parentMarket || - !parentMarket?.priceMonitoringSettings?.parameters?.triggers?.[ - triggerIndex - ], - }); - const quoteUnit = market?.tradableInstrument.instrument.product?.quoteName || ''; - const parentQuoteUnit = - parentMarket?.tradableInstrument.instrument.product?.quoteName || ''; - const isParentQuoteUnitEqual = quoteUnit === parentQuoteUnit; const trigger = market.priceMonitoringSettings?.parameters?.triggers?.[triggerIndex]; - const parentTrigger = - parentMarket?.priceMonitoringSettings?.parameters?.triggers?.[triggerIndex]; - const isParentTriggerEqual = isEqual(trigger, parentTrigger); const bounds = data?.priceMonitoringBounds?.[triggerIndex]; - const parentBounds = parentData?.priceMonitoringBounds?.[triggerIndex]; - - const shouldShowParentData = - isParentQuoteUnitEqual && isParentTriggerEqual && !!parentBounds; if (!trigger) { console.error( @@ -638,14 +622,6 @@ export const PriceMonitoringBoundsInfoPanel = ({ highestPrice: bounds.maxValidPrice, lowestPrice: bounds.minValidPrice, }} - parentData={ - shouldShowParentData - ? { - highestPrice: parentBounds.maxValidPrice, - lowestPrice: parentBounds.minValidPrice, - } - : undefined - } decimalPlaces={market.decimalPlaces} assetSymbol={quoteUnit} /> @@ -839,45 +815,76 @@ export const OracleInfoPanel = ({ : (parentProduct?.dataSourceSpecForTradingTermination ?.data as DataSourceDefinition); - const isParentDataSourceSpecEqual = - parentDataSourceSpec !== undefined && - dataSourceSpec === parentDataSourceSpec; - const isParentDataSourceSpecIdEqual = + const shouldShowParentData = + parentMarket !== undefined && parentDataSourceSpecId !== undefined && - dataSourceSpecId === parentDataSourceSpecId; + !isEqual(dataSourceSpec, parentDataSourceSpec); + + const wrapperClasses = classNames('mb-4', { + 'flex items-center gap-6': shouldShowParentData, + }); - // We'll only provide successor parent data (if it differs) to the - // DataSourceProof component. Having an old external link struck through - // is unlikely to be useful. return ( -
- + <> + {shouldShowParentData && ( + + {t('Updated')} + + )} - - {type === 'settlementData' - ? t('View settlement data specification') - : t('View termination specification')} - -
+
+ {shouldShowParentData && + parentDataSourceSpec && + parentDataSourceSpecId && + parentProduct && ( +
+ + + + {type === 'settlementData' + ? t('View settlement data specification') + : t('View termination specification')} + +
+ )} + +
+ + + + {type === 'settlementData' + ? t('View settlement data specification') + : t('View termination specification')} + +
+
+ ); }; @@ -886,28 +893,14 @@ export const DataSourceProof = ({ providers, type, dataSourceSpecId, - parentData, - parentDataSourceSpecId, }: { data: DataSourceDefinition; providers: Provider[] | undefined; type: 'settlementData' | 'termination'; dataSourceSpecId: string; - parentData?: DataSourceDefinition; - parentDataSourceSpecId?: string; }) => { - // If this is a successor market, we'll only pass parent data to child - // components for comparison if the data differs from the parent market. if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { const signers = data.sourceType.sourceType.signers || []; - let parentSigners: Signer[]; - - if ( - parentData && - parentData.sourceType.__typename === 'DataSourceDefinitionExternal' - ) { - parentSigners = parentData.sourceType.sourceType?.signers || []; - } if (!providers?.length) { return ; @@ -915,34 +908,15 @@ export const DataSourceProof = ({ return (
- {signers.map(({ signer }, i) => { - const parentSigner = parentSigners?.find( - ({ signer: ParentSigner }) => - ParentSigner.__typename === signer.__typename - )?.signer; - - const isParentSignerEqual = isEqual(signer, parentSigner); - - return isParentSignerEqual ? ( - - ) : ( - - ); - })} + {signers.map(({ signer }, i) => ( + + ))}
); } @@ -1002,22 +976,13 @@ const OracleLink = ({ signer, type, dataSourceSpecId, - parentSigner, - parentDataSourceSpecId, }: { providers: Provider[]; signer: SignerKind; type: 'settlementData' | 'termination'; dataSourceSpecId: string; - parentSigner?: SignerKind; - parentDataSourceSpecId?: string; }) => { - // If this is a successor market, the parent market data will only have been passed - // in if it differs from the current data. const signerProviders = getSignerProviders(signer, providers); - const parentSignerProviders = parentSigner - ? getSignerProviders(parentSigner, providers) - : []; if (!signerProviders.length) { return ; @@ -1025,34 +990,13 @@ const OracleLink = ({ return (
- {signerProviders.map((provider) => { - // Making the assumption here that if the provider name is the same, - // that it is the same provider that the parent market used. - const parentProvider = parentSignerProviders.find( - (p) => p.name === provider.name - ); - - const isParentProviderEqual = - parentProvider !== undefined && isEqual(provider, parentProvider); - - // We only want to pass the parent data to the child component if the - // data differs from the parent market. - return isParentProviderEqual ? ( - - ) : ( - - ); - })} + {signerProviders.map((provider) => ( + + ))}
); }; @@ -1075,18 +1019,13 @@ const NoOracleProof = ({ const OracleProfile = (props: { provider: Provider; dataSourceSpecId: string; - parentProvider?: Provider; - parentDataSourceSpecId?: string; }) => { - // If this is a successor market, the parent market data will only have been passed - // in if it differs from the current data. const [open, onChange] = useState(false); return (
onChange(!open)} - parentProvider={props.parentProvider} />
diff --git a/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx b/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx index b9243ffc7..a8afd2966 100644 --- a/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx +++ b/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx @@ -5,7 +5,6 @@ import { ExternalLink, Icon, Intent, - Lozenge, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; @@ -60,12 +59,10 @@ export const OracleBasicProfile = ({ provider, onClick, markets: oracleMarkets, - parentProvider, }: { provider: Provider; markets?: OracleMarketSpecFieldsFragment[] | undefined; onClick?: (value?: boolean) => void; - parentProvider?: Provider; }) => { const { icon, message, intent } = getVerifiedStatusIcon(provider); @@ -81,14 +78,8 @@ export const OracleBasicProfile = ({ icon: getLinkIcon(proof.type), })); - // If this is a successor market and there's a different parent provider, - // we'll just show that there's been a change, rather than add old data - // in alongside the new provider. return ( <> - {parentProvider && ( - {t('Updated')} - )} {provider.url && (