2023-05-18 04:05:53 +00:00
|
|
|
import {
|
2023-07-31 16:08:55 +00:00
|
|
|
TradingDropdownItem,
|
|
|
|
TradingDropdownCopyItem,
|
2023-05-18 04:05:53 +00:00
|
|
|
Link,
|
|
|
|
VegaIcon,
|
|
|
|
VegaIconNames,
|
2023-07-05 11:02:02 +00:00
|
|
|
ActionsDropdown,
|
2023-05-18 04:05:53 +00:00
|
|
|
} from '@vegaprotocol/ui-toolkit';
|
|
|
|
import { DApp, EXPLORER_MARKET, useLinks } from '@vegaprotocol/environment';
|
|
|
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
2023-09-12 18:52:03 +00:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
2023-09-20 20:28:34 +00:00
|
|
|
import { Links } from '../../lib/links';
|
2023-11-16 03:10:39 +00:00
|
|
|
import { useT } from '../../lib/use-t';
|
2023-05-18 04:05:53 +00:00
|
|
|
|
2023-07-05 11:02:02 +00:00
|
|
|
export const MarketActionsDropdown = ({
|
2023-05-18 04:05:53 +00:00
|
|
|
marketId,
|
|
|
|
assetId,
|
2023-09-12 18:52:03 +00:00
|
|
|
successorMarketID,
|
|
|
|
parentMarketID,
|
2023-05-18 04:05:53 +00:00
|
|
|
}: {
|
|
|
|
marketId: string;
|
|
|
|
assetId: string;
|
2023-09-12 18:52:03 +00:00
|
|
|
successorMarketID: string | null | undefined;
|
|
|
|
parentMarketID: string | null | undefined;
|
2023-05-18 04:05:53 +00:00
|
|
|
}) => {
|
2023-11-16 03:10:39 +00:00
|
|
|
const t = useT();
|
2023-09-12 18:52:03 +00:00
|
|
|
const navigate = useNavigate();
|
2023-05-18 04:05:53 +00:00
|
|
|
const open = useAssetDetailsDialogStore((store) => store.open);
|
|
|
|
const linkCreator = useLinks(DApp.Explorer);
|
2023-07-05 11:02:02 +00:00
|
|
|
|
2023-05-18 04:05:53 +00:00
|
|
|
return (
|
2023-07-05 11:02:02 +00:00
|
|
|
<ActionsDropdown data-testid="market-actions-content">
|
2023-07-31 16:08:55 +00:00
|
|
|
<TradingDropdownCopyItem value={marketId} text={t('Copy Market ID')} />
|
|
|
|
<TradingDropdownItem>
|
2023-07-05 11:02:02 +00:00
|
|
|
<Link
|
|
|
|
href={linkCreator(EXPLORER_MARKET.replace(':id', marketId))}
|
|
|
|
target="_blank"
|
2023-05-18 04:05:53 +00:00
|
|
|
>
|
2023-07-05 11:02:02 +00:00
|
|
|
<span className="flex gap-2">
|
|
|
|
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} size={16} />
|
|
|
|
{t('View on Explorer')}
|
|
|
|
</span>
|
|
|
|
</Link>
|
2023-07-31 16:08:55 +00:00
|
|
|
</TradingDropdownItem>
|
|
|
|
<TradingDropdownItem
|
2023-07-05 11:02:02 +00:00
|
|
|
onClick={(e) => {
|
|
|
|
open(assetId, e.target as HTMLElement);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<VegaIcon name={VegaIconNames.INFO} size={16} />
|
|
|
|
{t('View settlement asset details')}
|
2023-07-31 16:08:55 +00:00
|
|
|
</TradingDropdownItem>
|
2023-09-12 18:52:03 +00:00
|
|
|
{parentMarketID && (
|
|
|
|
<TradingDropdownItem
|
|
|
|
onClick={() => {
|
2023-09-20 20:28:34 +00:00
|
|
|
navigate(Links.MARKET(parentMarketID));
|
2023-09-12 18:52:03 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<VegaIcon name={VegaIconNames.EYE} size={16} />
|
|
|
|
{t('View parent market')}
|
|
|
|
</TradingDropdownItem>
|
|
|
|
)}
|
|
|
|
{successorMarketID && (
|
|
|
|
<TradingDropdownItem
|
|
|
|
onClick={() => {
|
2023-09-20 20:28:34 +00:00
|
|
|
navigate(Links.MARKET(successorMarketID));
|
2023-09-12 18:52:03 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<VegaIcon name={VegaIconNames.EYE} size={16} />
|
|
|
|
{t('View successor market')}
|
|
|
|
</TradingDropdownItem>
|
|
|
|
)}
|
2023-07-05 11:02:02 +00:00
|
|
|
</ActionsDropdown>
|
2023-05-18 04:05:53 +00:00
|
|
|
);
|
|
|
|
};
|