chore(trading): remove floating buttons (#4512)

This commit is contained in:
Matthew Russell 2023-08-10 16:02:46 +01:00 committed by GitHub
parent 7e49836875
commit 70c3bc8128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 247 additions and 281 deletions

View File

@ -10,7 +10,6 @@ import { TradeGrid } from './trade-grid';
import { TradePanels } from './trade-panels'; import { TradePanels } from './trade-panels';
import { useNavigate, useParams } from 'react-router-dom'; import { useNavigate, useParams } from 'react-router-dom';
import { Links, Routes } from '../../pages/client-router'; import { Links, Routes } from '../../pages/client-router';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
import { ViewType, useSidebar } from '../../components/sidebar'; import { ViewType, useSidebar } from '../../components/sidebar';
const calculatePrice = (markPrice?: string, decimalPlaces?: number) => { const calculatePrice = (markPrice?: string, decimalPlaces?: number) => {
@ -65,8 +64,6 @@ export const MarketPage = () => {
const update = useGlobalStore((store) => store.update); const update = useGlobalStore((store) => store.update);
const lastMarketId = useGlobalStore((store) => store.marketId); const lastMarketId = useGlobalStore((store) => store.marketId);
const onSelect = useMarketClickHandler();
const { data, error, loading } = useMarket(marketId); const { data, error, loading } = useMarket(marketId);
useEffect(() => { useEffect(() => {
@ -87,7 +84,6 @@ export const MarketPage = () => {
return ( return (
<TradeGrid <TradeGrid
market={data} market={data}
onSelect={onSelect}
pinnedAsset={ pinnedAsset={
data?.tradableInstrument.instrument.product.settlementAsset data?.tradableInstrument.instrument.product.settlementAsset
} }
@ -97,11 +93,12 @@ export const MarketPage = () => {
return ( return (
<TradePanels <TradePanels
market={data} market={data}
onSelect={onSelect} pinnedAsset={
onClickCollateral={() => navigate('/portfolio')} data?.tradableInstrument.instrument.product.settlementAsset
}
/> />
); );
}, [largeScreen, data, onSelect, navigate]); }, [largeScreen, data]);
if (!data && marketId) { if (!data && marketId) {
return ( return (

View File

@ -9,7 +9,6 @@ import { OracleBanner } from '@vegaprotocol/markets';
import type { Market } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets';
import { Filter } from '@vegaprotocol/orders'; import { Filter } from '@vegaprotocol/orders';
import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit'; import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
import { import {
ResizableGrid, ResizableGrid,
ResizableGridPanel, ResizableGridPanel,
@ -24,7 +23,6 @@ import { FLAGS } from '@vegaprotocol/environment';
interface TradeGridProps { interface TradeGridProps {
market: Market | null; market: Market | null;
onSelect: (marketId: string, metaKey?: boolean) => void;
pinnedAsset?: PinnedAsset; pinnedAsset?: PinnedAsset;
} }
@ -40,7 +38,6 @@ const MainGrid = memo(
const [sizesMiddle, handleOnMiddleLayoutChange] = usePaneLayout({ const [sizesMiddle, handleOnMiddleLayoutChange] = usePaneLayout({
id: 'middle-1', id: 'middle-1',
}); });
const onMarketClick = useMarketClickHandler(true);
return ( return (
<ResizableGrid vertical onChange={handleOnLayoutChange}> <ResizableGrid vertical onChange={handleOnLayoutChange}>
@ -98,30 +95,27 @@ const MainGrid = memo(
<TradeGridChild> <TradeGridChild>
<Tabs storageKey="console-trade-grid-bottom"> <Tabs storageKey="console-trade-grid-bottom">
<Tab id="positions" name={t('Positions')}> <Tab id="positions" name={t('Positions')}>
<TradingViews.positions.component <TradingViews.positions.component />
onMarketClick={onMarketClick}
/>
</Tab> </Tab>
<Tab id="open-orders" name={t('Open')}> <Tab
<TradingViews.orders.component id="open-orders"
marketId={marketId} name={t('Open')}
filter={Filter.Open} menu={<TradingViews.activeOrders.menu marketId={marketId} />}
/> >
<TradingViews.orders.component filter={Filter.Open} />
</Tab> </Tab>
<Tab id="closed-orders" name={t('Closed')}> <Tab id="closed-orders" name={t('Closed')}>
<TradingViews.orders.component <TradingViews.orders.component filter={Filter.Closed} />
marketId={marketId}
filter={Filter.Closed}
/>
</Tab> </Tab>
<Tab id="rejected-orders" name={t('Rejected')}> <Tab id="rejected-orders" name={t('Rejected')}>
<TradingViews.orders.component <TradingViews.orders.component filter={Filter.Rejected} />
marketId={marketId}
filter={Filter.Rejected}
/>
</Tab> </Tab>
<Tab id="orders" name={t('All')}> <Tab
<TradingViews.orders.component marketId={marketId} /> id="orders"
name={t('All')}
menu={<TradingViews.orders.menu marketId={marketId} />}
>
<TradingViews.orders.component />
</Tab> </Tab>
{FLAGS.STOP_ORDERS ? ( {FLAGS.STOP_ORDERS ? (
<Tab id="stop-orders" name={t('Stop orders')}> <Tab id="stop-orders" name={t('Stop orders')}>
@ -129,17 +123,14 @@ const MainGrid = memo(
</Tab> </Tab>
) : null} ) : null}
<Tab id="fills" name={t('Fills')}> <Tab id="fills" name={t('Fills')}>
<TradingViews.fills.component <TradingViews.fills.component marketId={marketId} />
marketId={marketId}
onMarketClick={onMarketClick}
/>
</Tab> </Tab>
<Tab id="accounts" name={t('Collateral')}> <Tab
<TradingViews.collateral.component id="accounts"
pinnedAsset={pinnedAsset} name={t('Collateral')}
onMarketClick={onMarketClick} menu={<TradingViews.collateral.menu />}
hideButtons >
/> <TradingViews.collateral.component pinnedAsset={pinnedAsset} />
</Tab> </Tab>
</Tabs> </Tabs>
</TradeGridChild> </TradeGridChild>

View File

@ -1,13 +1,9 @@
import type { PinnedAsset } from '@vegaprotocol/accounts'; import type { PinnedAsset } from '@vegaprotocol/accounts';
import type { Market } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets';
import { OracleBanner } from '@vegaprotocol/markets'; import { OracleBanner } from '@vegaprotocol/markets';
import {
useMarketClickHandler,
useMarketLiquidityClickHandler,
} from '../../lib/hooks/use-market-click-handler';
import type { TradingView } from './trade-views'; import type { TradingView } from './trade-views';
import { TradingViews } from './trade-views'; import { TradingViews } from './trade-views';
import { memo, useState } from 'react'; import { useState } from 'react';
import { Splash } from '@vegaprotocol/ui-toolkit'; import { Splash } from '@vegaprotocol/ui-toolkit';
import { NO_MARKET } from './constants'; import { NO_MARKET } from './constants';
import AutoSizer from 'react-virtualized-auto-sizer'; import AutoSizer from 'react-virtualized-auto-sizer';
@ -20,33 +16,14 @@ import { FLAGS } from '@vegaprotocol/environment';
interface TradePanelsProps { interface TradePanelsProps {
market: Market | null; market: Market | null;
onSelect: (marketId: string, metaKey?: boolean) => void;
onMarketClick?: (marketId: string) => void;
onOrderTypeClick?: (marketId: string) => void;
onClickCollateral: () => void;
pinnedAsset?: PinnedAsset; pinnedAsset?: PinnedAsset;
} }
export const TradePanels = ({ export const TradePanels = ({ market, pinnedAsset }: TradePanelsProps) => {
market,
onSelect,
onClickCollateral,
pinnedAsset,
}: TradePanelsProps) => {
const onMarketClick = useMarketClickHandler(true);
const onOrderTypeClick = useMarketLiquidityClickHandler();
const [view, setView] = useState<TradingView>('candles'); const [view, setView] = useState<TradingView>('candles');
const renderView = () => { const renderView = () => {
const Component = memo<{ const Component = TradingViews[view].component;
marketId: string;
onSelect: (marketId: string, metaKey?: boolean) => void;
onMarketClick?: (marketId: string) => void;
onOrderTypeClick?: (marketId: string) => void;
onClickCollateral: () => void;
pinnedAsset?: PinnedAsset;
}>(TradingViews[view].component);
if (!Component) { if (!Component) {
throw new Error(`No component for view: ${view}`); throw new Error(`No component for view: ${view}`);
@ -54,16 +31,7 @@ export const TradePanels = ({
if (!market) return <Splash>{NO_MARKET}</Splash>; if (!market) return <Splash>{NO_MARKET}</Splash>;
return ( return <Component marketId={market?.id} pinnedAsset={pinnedAsset} />;
<Component
marketId={market?.id}
onSelect={onSelect}
onClickCollateral={onClickCollateral}
pinnedAsset={pinnedAsset}
onMarketClick={onMarketClick}
onOrderTypeClick={onOrderTypeClick}
/>
);
}; };
const renderMenu = () => { const renderMenu = () => {
@ -71,9 +39,10 @@ export const TradePanels = ({
if ('menu' in viewCfg) { if ('menu' in viewCfg) {
const Menu = viewCfg.menu; const Menu = viewCfg.menu;
return ( return (
<div className="flex gap-1 p-1 bg-vega-clight-800 dark:bg-vega-cdark-800 border-b border-default"> <div className="flex gap-1 p-1 bg-vega-clight-800 dark:bg-vega-cdark-800 border-b border-default">
<Menu /> <Menu marketId={market?.id || ''} />
</div> </div>
); );
} }

View File

@ -6,7 +6,7 @@ import {
CandlesChartContainer, CandlesChartContainer,
CandlesMenu, CandlesMenu,
} from '@vegaprotocol/candles-chart'; } from '@vegaprotocol/candles-chart';
import { Filter } from '@vegaprotocol/orders'; import { Filter, OpenOrdersMenu } from '@vegaprotocol/orders';
import { NO_MARKET } from './constants'; import { NO_MARKET } from './constants';
import { OrderbookContainer } from '../../components/orderbook-container'; import { OrderbookContainer } from '../../components/orderbook-container';
import { FillsContainer } from '../../components/fills-container'; import { FillsContainer } from '../../components/fills-container';
@ -16,6 +16,7 @@ import { LiquidityContainer } from '../../components/liquidity-container';
import type { OrderContainerProps } from '../../components/orders-container'; import type { OrderContainerProps } from '../../components/orders-container';
import { OrdersContainer } from '../../components/orders-container'; import { OrdersContainer } from '../../components/orders-container';
import { StopOrdersContainer } from '../../components/stop-orders-container'; import { StopOrdersContainer } from '../../components/stop-orders-container';
import { AccountsMenu } from '../../components/accounts-menu';
type MarketDependantView = type MarketDependantView =
| typeof CandlesChartContainer | typeof CandlesChartContainer
@ -62,6 +63,7 @@ export const TradingViews = {
component: (props: OrderContainerProps) => ( component: (props: OrderContainerProps) => (
<OrdersContainer {...props} filter={Filter.Open} /> <OrdersContainer {...props} filter={Filter.Open} />
), ),
menu: OpenOrdersMenu,
}, },
closedOrders: { closedOrders: {
label: 'Closed', label: 'Closed',
@ -78,11 +80,16 @@ export const TradingViews = {
orders: { orders: {
label: 'All', label: 'All',
component: OrdersContainer, component: OrdersContainer,
menu: OpenOrdersMenu,
}, },
stopOrders: { stopOrders: {
label: 'Stop', label: 'Stop',
component: StopOrdersContainer, component: StopOrdersContainer,
}, },
collateral: { label: 'Collateral', component: AccountsContainer }, collateral: {
label: 'Collateral',
component: AccountsContainer,
menu: AccountsMenu,
},
fills: { label: 'Fills', component: FillsContainer }, fills: { label: 'Fills', component: FillsContainer },
}; };

View File

@ -1,40 +0,0 @@
import { Button, Splash } from '@vegaprotocol/ui-toolkit';
import { DepositsTable } from '@vegaprotocol/deposits';
import { depositsProvider } from '@vegaprotocol/deposits';
import { t } from '@vegaprotocol/i18n';
import { useDataProvider } from '@vegaprotocol/data-provider';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { useSidebar, ViewType } from '../../components/sidebar';
export const DepositsContainer = () => {
const { pubKey, isReadOnly } = useVegaWallet();
const { data, error } = useDataProvider({
dataProvider: depositsProvider,
variables: { partyId: pubKey || '' },
skip: !pubKey,
});
const setView = useSidebar((store) => store.setView);
if (!pubKey) {
return <Splash>{t('Please connect Vega wallet')}</Splash>;
}
return (
<div className="h-full">
<DepositsTable
rowData={data}
overlayNoRowsTemplate={error ? error.message : t('No deposits')}
/>
{!isReadOnly && (
<div className="h-auto flex justify-end p-2 bottom-0 right-0 absolute dark:bg-black/75 bg-white/75 rounded">
<Button
variant="primary"
size="sm"
onClick={() => setView({ type: ViewType.Deposit })}
data-testid="deposit-button"
>
{t('Deposit')}
</Button>
</div>
)}
</div>
);
};

View File

@ -6,12 +6,11 @@ import { t } from '@vegaprotocol/i18n';
import { useIncompleteWithdrawals } from '@vegaprotocol/withdraws'; import { useIncompleteWithdrawals } from '@vegaprotocol/withdraws';
import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit'; import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit';
import { usePageTitleStore } from '../../stores'; import { usePageTitleStore } from '../../stores';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
import { AccountsContainer } from '../../components/accounts-container'; import { AccountsContainer } from '../../components/accounts-container';
import { DepositsContainer } from './deposits-container'; import { DepositsContainer } from '../../components/deposits-container';
import { FillsContainer } from '../../components/fills-container'; import { FillsContainer } from '../../components/fills-container';
import { PositionsContainer } from '../../components/positions-container'; import { PositionsContainer } from '../../components/positions-container';
import { WithdrawalsContainer } from './withdrawals-container'; import { WithdrawalsContainer } from '../../components/withdrawals-container';
import { OrdersContainer } from '../../components/orders-container'; import { OrdersContainer } from '../../components/orders-container';
import { LedgerContainer } from '../../components/ledger-container'; import { LedgerContainer } from '../../components/ledger-container';
import { AccountHistoryContainer } from './account-history-container'; import { AccountHistoryContainer } from './account-history-container';
@ -21,6 +20,9 @@ import {
usePaneLayout, usePaneLayout,
} from '../../components/resizable-grid'; } from '../../components/resizable-grid';
import { ViewType, useSidebar } from '../../components/sidebar'; import { ViewType, useSidebar } from '../../components/sidebar';
import { AccountsMenu } from '../../components/accounts-menu';
import { DepositsMenu } from '../../components/deposits-menu';
import { WithdrawalsMenu } from '../../components/withdrawals-menu';
const WithdrawalsIndicator = () => { const WithdrawalsIndicator = () => {
const { ready } = useIncompleteWithdrawals(); const { ready } = useIncompleteWithdrawals();
@ -51,7 +53,6 @@ export const Portfolio = () => {
} }
}, [init, view, setView]); }, [init, view, setView]);
const onMarketClick = useMarketClickHandler(true);
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'portfolio' }); const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'portfolio' });
const wrapperClasses = 'p-0.5 h-full max-h-full flex flex-col'; const wrapperClasses = 'p-0.5 h-full max-h-full flex flex-col';
return ( return (
@ -64,13 +65,13 @@ export const Portfolio = () => {
<AccountHistoryContainer /> <AccountHistoryContainer />
</Tab> </Tab>
<Tab id="positions" name={t('Positions')}> <Tab id="positions" name={t('Positions')}>
<PositionsContainer onMarketClick={onMarketClick} allKeys /> <PositionsContainer allKeys />
</Tab> </Tab>
<Tab id="orders" name={t('Orders')}> <Tab id="orders" name={t('Orders')}>
<OrdersContainer /> <OrdersContainer />
</Tab> </Tab>
<Tab id="fills" name={t('Fills')}> <Tab id="fills" name={t('Fills')}>
<FillsContainer onMarketClick={onMarketClick} /> <FillsContainer />
</Tab> </Tab>
<Tab id="ledger-entries" name={t('Ledger entries')}> <Tab id="ledger-entries" name={t('Ledger entries')}>
<LedgerContainer /> <LedgerContainer />
@ -85,16 +86,21 @@ export const Portfolio = () => {
> >
<PortfolioGridChild> <PortfolioGridChild>
<Tabs storageKey="console-portfolio-bottom"> <Tabs storageKey="console-portfolio-bottom">
<Tab id="collateral" name={t('Collateral')}> <Tab
id="collateral"
name={t('Collateral')}
menu={<AccountsMenu />}
>
<AccountsContainer /> <AccountsContainer />
</Tab> </Tab>
<Tab id="deposits" name={t('Deposits')}> <Tab id="deposits" name={t('Deposits')} menu={<DepositsMenu />}>
<DepositsContainer /> <DepositsContainer />
</Tab> </Tab>
<Tab <Tab
id="withdrawals" id="withdrawals"
name={t('Withdrawals')} name={t('Withdrawals')}
indicator={<WithdrawalsIndicator />} indicator={<WithdrawalsIndicator />}
menu={<WithdrawalsMenu />}
> >
<WithdrawalsContainer /> <WithdrawalsContainer />
</Tab> </Tab>

View File

@ -1,49 +0,0 @@
import { Button, Splash } from '@vegaprotocol/ui-toolkit';
import {
withdrawalProvider,
WithdrawalsTable,
useIncompleteWithdrawals,
} from '@vegaprotocol/withdraws';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { t } from '@vegaprotocol/i18n';
import { useDataProvider } from '@vegaprotocol/data-provider';
import { ViewType, useSidebar } from '../../components/sidebar';
export const WithdrawalsContainer = () => {
const { pubKey, isReadOnly } = useVegaWallet();
const { data, error } = useDataProvider({
dataProvider: withdrawalProvider,
variables: { partyId: pubKey || '' },
skip: !pubKey,
});
const setView = useSidebar((store) => store.setView);
const { ready, delayed } = useIncompleteWithdrawals();
if (!pubKey) {
return <Splash>{t('Please connect Vega wallet')}</Splash>;
}
return (
<>
<div className="h-full relative">
<WithdrawalsTable
data-testid="withdrawals-history"
rowData={data}
overlayNoRowsTemplate={error ? error.message : t('No withdrawals')}
ready={ready}
delayed={delayed}
/>
</div>
{!isReadOnly && (
<div className="h-auto flex justify-end p-2 bottom-0 right-0 absolute dark:bg-black/75 bg-white/75 rounded">
<Button
variant="primary"
size="sm"
onClick={() => setView({ type: ViewType.Withdraw })}
data-testid="withdraw-dialog-button"
>
{t('Make withdrawal')}
</Button>
</div>
)}
</>
);
};

View File

@ -1,5 +1,4 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import { Button } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { Splash } from '@vegaprotocol/ui-toolkit'; import { Splash } from '@vegaprotocol/ui-toolkit';
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
@ -12,16 +11,14 @@ import { useDataGridEvents } from '@vegaprotocol/datagrid';
import type { DataGridSlice } from '../../stores/datagrid-store-slice'; import type { DataGridSlice } from '../../stores/datagrid-store-slice';
import { createDataGridSlice } from '../../stores/datagrid-store-slice'; import { createDataGridSlice } from '../../stores/datagrid-store-slice';
import { ViewType, useSidebar } from '../sidebar'; import { ViewType, useSidebar } from '../sidebar';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
export const AccountsContainer = ({ export const AccountsContainer = ({
pinnedAsset, pinnedAsset,
hideButtons,
onMarketClick,
}: { }: {
pinnedAsset?: PinnedAsset; pinnedAsset?: PinnedAsset;
hideButtons?: boolean;
onMarketClick?: (marketId: string, metaKey?: boolean) => void;
}) => { }) => {
const onMarketClick = useMarketClickHandler(true);
const { pubKey, isReadOnly } = useVegaWallet(); const { pubKey, isReadOnly } = useVegaWallet();
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore(); const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
const setView = useSidebar((store) => store.setView); const setView = useSidebar((store) => store.setView);
@ -48,44 +45,23 @@ export const AccountsContainer = ({
} }
return ( return (
<div className="h-full relative"> <AccountManager
<AccountManager partyId={pubKey}
partyId={pubKey} onClickAsset={onClickAsset}
onClickAsset={onClickAsset} onClickWithdraw={(assetId) => {
onClickWithdraw={(assetId) => { setView({ type: ViewType.Withdraw, assetId });
setView({ type: ViewType.Withdraw, assetId }); }}
}} onClickDeposit={(assetId) => {
onClickDeposit={(assetId) => { setView({ type: ViewType.Deposit, assetId });
setView({ type: ViewType.Deposit, assetId }); }}
}} onClickTransfer={(assetId) => {
onClickTransfer={(assetId) => { setView({ type: ViewType.Transfer, assetId });
setView({ type: ViewType.Transfer, assetId }); }}
}} onMarketClick={onMarketClick}
onMarketClick={onMarketClick} isReadOnly={isReadOnly}
isReadOnly={isReadOnly} pinnedAsset={pinnedAsset}
pinnedAsset={pinnedAsset} gridProps={gridStoreCallbacks}
gridProps={gridStoreCallbacks} />
/>
{!isReadOnly && !hideButtons && (
<div className="flex gap-2 justify-end p-2 absolute bottom-0 right-0 dark:bg-black/75 bg-white/75 rounded">
<Button
variant="primary"
size="sm"
data-testid="open-transfer"
onClick={() => setView({ type: ViewType.Transfer })}
>
{t('Transfer')}
</Button>
<Button
variant="primary"
size="sm"
onClick={() => setView({ type: ViewType.Deposit })}
>
{t('Deposit')}
</Button>
</div>
)}
</div>
); );
}; };

View File

@ -0,0 +1,27 @@
import { t } from '@vegaprotocol/i18n';
import { Intent, TradingButton } from '@vegaprotocol/ui-toolkit';
import { ViewType, useSidebar } from '../sidebar';
export const AccountsMenu = () => {
const setView = useSidebar((store) => store.setView);
return (
<>
<TradingButton
intent={Intent.Primary}
size="extra-small"
data-testid="open-transfer"
onClick={() => setView({ type: ViewType.Transfer })}
>
{t('Transfer')}
</TradingButton>
<TradingButton
intent={Intent.Primary}
size="extra-small"
onClick={() => setView({ type: ViewType.Deposit })}
>
{t('Deposit')}
</TradingButton>
</>
);
};

View File

@ -0,0 +1 @@
export * from './accounts-menu';

View File

@ -0,0 +1,24 @@
import { Splash } from '@vegaprotocol/ui-toolkit';
import { DepositsTable } from '@vegaprotocol/deposits';
import { depositsProvider } from '@vegaprotocol/deposits';
import { t } from '@vegaprotocol/i18n';
import { useDataProvider } from '@vegaprotocol/data-provider';
import { useVegaWallet } from '@vegaprotocol/wallet';
export const DepositsContainer = () => {
const { pubKey } = useVegaWallet();
const { data, error } = useDataProvider({
dataProvider: depositsProvider,
variables: { partyId: pubKey || '' },
skip: !pubKey,
});
if (!pubKey) {
return <Splash>{t('Please connect Vega wallet')}</Splash>;
}
return (
<DepositsTable
rowData={data}
overlayNoRowsTemplate={error ? error.message : t('No deposits')}
/>
);
};

View File

@ -0,0 +1 @@
export * from './deposits-container';

View File

@ -0,0 +1,18 @@
import { t } from '@vegaprotocol/i18n';
import { Intent, TradingButton } from '@vegaprotocol/ui-toolkit';
import { ViewType, useSidebar } from '../sidebar';
export const DepositsMenu = () => {
const setView = useSidebar((store) => store.setView);
return (
<TradingButton
intent={Intent.Primary}
size="extra-small"
onClick={() => setView({ type: ViewType.Deposit })}
data-testid="deposit-button"
>
{t('Deposit')}
</TradingButton>
);
};

View File

@ -0,0 +1 @@
export * from './deposits-menu';

View File

@ -7,14 +7,10 @@ import { t } from '@vegaprotocol/i18n';
import { Splash } from '@vegaprotocol/ui-toolkit'; import { Splash } from '@vegaprotocol/ui-toolkit';
import type { DataGridSlice } from '../../stores/datagrid-store-slice'; import type { DataGridSlice } from '../../stores/datagrid-store-slice';
import { createDataGridSlice } from '../../stores/datagrid-store-slice'; import { createDataGridSlice } from '../../stores/datagrid-store-slice';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
export const FillsContainer = ({ export const FillsContainer = ({ marketId }: { marketId?: string }) => {
marketId, const onMarketClick = useMarketClickHandler(true);
onMarketClick,
}: {
marketId?: string;
onMarketClick?: (marketId: string, metaKey?: boolean) => void;
}) => {
const { pubKey } = useVegaWallet(); const { pubKey } = useVegaWallet();
const gridStore = useFillsStore((store) => store.gridStore); const gridStore = useFillsStore((store) => store.gridStore);

View File

@ -25,11 +25,10 @@ export const FilterStatusValue = {
}; };
export interface OrderContainerProps { export interface OrderContainerProps {
marketId?: string;
filter?: Filter; filter?: Filter;
} }
export const OrdersContainer = ({ marketId, filter }: OrderContainerProps) => { export const OrdersContainer = ({ filter }: OrderContainerProps) => {
const { pubKey, isReadOnly } = useVegaWallet(); const { pubKey, isReadOnly } = useVegaWallet();
const onMarketClick = useMarketClickHandler(true); const onMarketClick = useMarketClickHandler(true);
const onOrderTypeClick = useMarketLiquidityClickHandler(); const onOrderTypeClick = useMarketLiquidityClickHandler();
@ -45,7 +44,6 @@ export const OrdersContainer = ({ marketId, filter }: OrderContainerProps) => {
return ( return (
<OrderListManager <OrderListManager
partyId={pubKey} partyId={pubKey}
marketId={marketId}
filter={filter} filter={filter}
onMarketClick={onMarketClick} onMarketClick={onMarketClick}
onOrderTypeClick={onOrderTypeClick} onOrderTypeClick={onOrderTypeClick}

View File

@ -7,14 +7,10 @@ import type { DataGridSlice } from '../../stores/datagrid-store-slice';
import { createDataGridSlice } from '../../stores/datagrid-store-slice'; import { createDataGridSlice } from '../../stores/datagrid-store-slice';
import { create } from 'zustand'; import { create } from 'zustand';
import { persist } from 'zustand/middleware'; import { persist } from 'zustand/middleware';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
export const PositionsContainer = ({ export const PositionsContainer = ({ allKeys }: { allKeys?: boolean }) => {
onMarketClick, const onMarketClick = useMarketClickHandler(true);
allKeys,
}: {
onMarketClick?: (marketId: string) => void;
allKeys?: boolean;
}) => {
const { pubKey, pubKeys, isReadOnly } = useVegaWallet(); const { pubKey, pubKeys, isReadOnly } = useVegaWallet();
const gridStore = usePositionsStore((store) => store.gridStore); const gridStore = usePositionsStore((store) => store.gridStore);

View File

@ -0,0 +1 @@
export * from './withdrawals-container';

View File

@ -0,0 +1,31 @@
import { Splash } from '@vegaprotocol/ui-toolkit';
import {
withdrawalProvider,
WithdrawalsTable,
useIncompleteWithdrawals,
} from '@vegaprotocol/withdraws';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { t } from '@vegaprotocol/i18n';
import { useDataProvider } from '@vegaprotocol/data-provider';
export const WithdrawalsContainer = () => {
const { pubKey } = useVegaWallet();
const { data, error } = useDataProvider({
dataProvider: withdrawalProvider,
variables: { partyId: pubKey || '' },
skip: !pubKey,
});
const { ready, delayed } = useIncompleteWithdrawals();
if (!pubKey) {
return <Splash>{t('Please connect Vega wallet')}</Splash>;
}
return (
<WithdrawalsTable
data-testid="withdrawals-history"
rowData={data}
overlayNoRowsTemplate={error ? error.message : t('No withdrawals')}
ready={ready}
delayed={delayed}
/>
);
};

View File

@ -0,0 +1 @@
export * from './withdrawals-menu';

View File

@ -0,0 +1,18 @@
import { t } from '@vegaprotocol/i18n';
import { Intent, TradingButton } from '@vegaprotocol/ui-toolkit';
import { ViewType, useSidebar } from '../sidebar';
export const WithdrawalsMenu = () => {
const setView = useSidebar((store) => store.setView);
return (
<TradingButton
intent={Intent.Primary}
size="extra-small"
onClick={() => setView({ type: ViewType.Withdraw })}
data-testid="withdraw-dialog-button"
>
{t('Make withdrawal')}
</TradingButton>
);
};

View File

@ -1,4 +1,4 @@
import { Intent, Notification, Link } from '@vegaprotocol/ui-toolkit'; import { Intent, Notification } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
interface ZeroBalanceErrorProps { interface ZeroBalanceErrorProps {
@ -6,13 +6,11 @@ interface ZeroBalanceErrorProps {
id: string; id: string;
symbol: string; symbol: string;
}; };
onClickCollateral?: () => void;
onDeposit: (assetId: string) => void; onDeposit: (assetId: string) => void;
} }
export const ZeroBalanceError = ({ export const ZeroBalanceError = ({
asset, asset,
onClickCollateral,
onDeposit, onDeposit,
}: ZeroBalanceErrorProps) => { }: ZeroBalanceErrorProps) => {
return ( return (
@ -25,12 +23,6 @@ export const ZeroBalanceError = ({
'You need %s in your wallet to trade in this market. ', 'You need %s in your wallet to trade in this market. ',
asset.symbol asset.symbol
)} )}
{onClickCollateral && (
<>
{t('See all your')}{' '}
<Link onClick={onClickCollateral}>collateral</Link>.
</>
)}
</> </>
} }
buttonProps={{ buttonProps={{

View File

@ -17,7 +17,6 @@ import { FLAGS } from '@vegaprotocol/environment';
interface DealTicketContainerProps { interface DealTicketContainerProps {
marketId: string; marketId: string;
onMarketClick?: (marketId: string, metaKey?: boolean) => void; onMarketClick?: (marketId: string, metaKey?: boolean) => void;
onClickCollateral?: () => void;
onDeposit: (assetId: string) => void; onDeposit: (assetId: string) => void;
} }

View File

@ -74,7 +74,6 @@ export interface DealTicketProps {
marketPrice?: string | null; marketPrice?: string | null;
onMarketClick?: (marketId: string, metaKey?: boolean) => void; onMarketClick?: (marketId: string, metaKey?: boolean) => void;
submit: (order: OrderSubmission) => void; submit: (order: OrderSubmission) => void;
onClickCollateral?: () => void;
onDeposit: (assetId: string) => void; onDeposit: (assetId: string) => void;
} }
@ -121,7 +120,6 @@ export const DealTicket = ({
marketData, marketData,
marketPrice, marketPrice,
submit, submit,
onClickCollateral,
onDeposit, onDeposit,
}: DealTicketProps) => { }: DealTicketProps) => {
const { pubKey, isReadOnly } = useVegaWallet(); const { pubKey, isReadOnly } = useVegaWallet();
@ -530,7 +528,6 @@ export const DealTicket = ({
} }
isReadOnly={isReadOnly} isReadOnly={isReadOnly}
pubKey={pubKey} pubKey={pubKey}
onClickCollateral={onClickCollateral}
onDeposit={onDeposit} onDeposit={onDeposit}
/> />
<DealTicketButton side={side} /> <DealTicketButton side={side} />
@ -566,7 +563,6 @@ interface SummaryMessageProps {
margin: string; margin: string;
isReadOnly: boolean; isReadOnly: boolean;
pubKey: string | null; pubKey: string | null;
onClickCollateral?: () => void;
onDeposit: (assetId: string) => void; onDeposit: (assetId: string) => void;
} }
@ -596,7 +592,6 @@ const SummaryMessage = memo(
margin, margin,
isReadOnly, isReadOnly,
pubKey, pubKey,
onClickCollateral,
onDeposit, onDeposit,
}: SummaryMessageProps) => { }: SummaryMessageProps) => {
// Specific error UI for if balance is so we can // Specific error UI for if balance is so we can
@ -608,11 +603,7 @@ const SummaryMessage = memo(
if (error?.type === SummaryValidationType.NoCollateral) { if (error?.type === SummaryValidationType.NoCollateral) {
return ( return (
<div className="mb-2"> <div className="mb-2">
<ZeroBalanceError <ZeroBalanceError asset={asset} onDeposit={onDeposit} />
asset={asset}
onClickCollateral={onClickCollateral}
onDeposit={onDeposit}
/>
</div> </div>
); );
} }

View File

@ -1,3 +1,4 @@
export * from './open-orders-menu';
export * from './order-data-provider'; export * from './order-data-provider';
export * from './order-list'; export * from './order-list';
export * from './order-list-manager'; export * from './order-list-manager';

View File

@ -0,0 +1 @@
export * from './open-orders-menu';

View File

@ -0,0 +1,39 @@
import { t } from '@vegaprotocol/i18n';
import { Intent, TradingButton } from '@vegaprotocol/ui-toolkit';
import { useVegaTransactionStore, useVegaWallet } from '@vegaprotocol/wallet';
import { useHasAmendableOrder } from '../../order-hooks';
export const OpenOrdersMenu = ({ marketId }: { marketId: string }) => {
const { isReadOnly } = useVegaWallet();
const create = useVegaTransactionStore((state) => state.create);
const hasAmendableOrder = useHasAmendableOrder(marketId);
if (isReadOnly) {
return null;
}
if (!hasAmendableOrder) {
return null;
}
return (
<CancelAllOrdersButton
onClick={() => {
create({
orderCancellation: {},
});
}}
/>
);
};
const CancelAllOrdersButton = ({ onClick }: { onClick: () => void }) => (
<TradingButton
intent={Intent.Primary}
size="extra-small"
onClick={onClick}
data-testid="cancelAll"
>
{t('Cancel all')}
</TradingButton>
);

View File

@ -1,9 +1,7 @@
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { useCallback, useRef, useState } from 'react'; import { useCallback, useRef, useState } from 'react';
import { Button } from '@vegaprotocol/ui-toolkit';
import type { AgGridReact } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react';
import { OrderListTable } from '../order-list/order-list'; import { OrderListTable } from '../order-list/order-list';
import { useHasAmendableOrder } from '../../order-hooks/use-has-amendable-order';
import type { useDataGridEvents } from '@vegaprotocol/datagrid'; import type { useDataGridEvents } from '@vegaprotocol/datagrid';
import { useDataProvider } from '@vegaprotocol/data-provider'; import { useDataProvider } from '@vegaprotocol/data-provider';
import { ordersWithMarketProvider } from '../order-data-provider/order-data-provider'; import { ordersWithMarketProvider } from '../order-data-provider/order-data-provider';
@ -24,7 +22,6 @@ export enum Filter {
export interface OrderListManagerProps { export interface OrderListManagerProps {
partyId: string; partyId: string;
marketId?: string;
onMarketClick?: (marketId: string, metaKey?: boolean) => void; onMarketClick?: (marketId: string, metaKey?: boolean) => void;
onOrderTypeClick?: (marketId: string, metaKey?: boolean) => void; onOrderTypeClick?: (marketId: string, metaKey?: boolean) => void;
isReadOnly: boolean; isReadOnly: boolean;
@ -34,7 +31,6 @@ export interface OrderListManagerProps {
export const OrderListManager = ({ export const OrderListManager = ({
partyId, partyId,
marketId,
onMarketClick, onMarketClick,
onOrderTypeClick, onOrderTypeClick,
isReadOnly, isReadOnly,
@ -45,7 +41,6 @@ export const OrderListManager = ({
const [editOrder, setEditOrder] = useState<Order | null>(null); const [editOrder, setEditOrder] = useState<Order | null>(null);
const [viewOrder, setViewOrder] = useState<Order | null>(null); const [viewOrder, setViewOrder] = useState<Order | null>(null);
const create = useVegaTransactionStore((state) => state.create); const create = useVegaTransactionStore((state) => state.create);
const hasAmendableOrder = useHasAmendableOrder(marketId);
const variables = const variables =
filter === Filter.Open filter === Filter.Open
? { partyId, filter: { liveOnly: true } } ? { partyId, filter: { liveOnly: true } }
@ -76,12 +71,6 @@ export const OrderListManager = ({
[create] [create]
); );
const cancelAll = useCallback(() => {
create({
orderCancellation: {},
});
}, [create]);
return ( return (
<> <>
<div className="h-full relative"> <div className="h-full relative">
@ -100,9 +89,6 @@ export const OrderListManager = ({
{...gridProps} {...gridProps}
/> />
</div> </div>
{!isReadOnly && hasAmendableOrder && (
<CancelAllOrdersButton onClick={cancelAll} />
)}
{editOrder && ( {editOrder && (
<OrderEditDialog <OrderEditDialog
isOpen={Boolean(editOrder)} isOpen={Boolean(editOrder)}
@ -148,16 +134,3 @@ export const OrderListManager = ({
</> </>
); );
}; };
const CancelAllOrdersButton = ({ onClick }: { onClick: () => void }) => (
<div className="dark:bg-black/75 bg-white/75 h-auto flex justify-end p-2 absolute bottom-0 right-0 rounded">
<Button
variant="primary"
size="sm"
onClick={onClick}
data-testid="cancelAll"
>
{t('Cancel all')}
</Button>
</div>
);