Skip to content

Commit 6f27889

Browse files
itsrachelfishellemouton
authored andcommitted
ui+pages: Integrate SubServerRequired component into loop and pool pages
1 parent 1c01173 commit 6f27889

File tree

3 files changed

+67
-51
lines changed

3 files changed

+67
-51
lines changed

app/src/components/history/HistoryPage.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import styled from '@emotion/styled';
44
import { usePrefixedTranslation } from 'hooks';
55
import { useStore } from 'store';
66
import PageHeader from 'components/common/PageHeader';
7+
import SubServerRequired from 'components/common/SubServerRequired';
78
import HistoryList from './HistoryList';
89

910
const Styled = {
@@ -14,14 +15,16 @@ const Styled = {
1415

1516
const HistoryPage: React.FC = () => {
1617
const { l } = usePrefixedTranslation('cmps.history.HistoryPage');
17-
const { swapStore } = useStore();
18+
const { swapStore, subServerStore } = useStore();
1819

1920
const { Wrapper } = Styled;
2021
return (
21-
<Wrapper>
22-
<PageHeader title={l('pageTitle')} onExportClick={swapStore.exportSwaps} />
23-
<HistoryList />
24-
</Wrapper>
22+
<SubServerRequired status={subServerStore.subServers.loop}>
23+
<Wrapper>
24+
<PageHeader title={l('pageTitle')} onExportClick={swapStore.exportSwaps} />
25+
<HistoryList />
26+
</Wrapper>
27+
</SubServerRequired>
2528
);
2629
};
2730

app/src/components/loop/LoopPage.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { usePrefixedTranslation } from 'hooks';
55
import { useStore } from 'store';
66
import { Badge } from 'components/base';
77
import PageHeader from 'components/common/PageHeader';
8+
import SubServerRequired from 'components/common/SubServerRequired';
89
import ChannelList from './ChannelList';
910
import LoopActions from './LoopActions';
1011
import LoopTiles from './LoopTiles';
@@ -26,6 +27,7 @@ const LoopPage: React.FC = () => {
2627
registerSidecarView,
2728
channelStore,
2829
nodeStore,
30+
subServerStore,
2931
} = useStore();
3032

3133
const title = (
@@ -41,26 +43,28 @@ const LoopPage: React.FC = () => {
4143

4244
const { PageWrap } = Styled;
4345
return (
44-
<PageWrap>
45-
{appView.processingSwapsVisible ? (
46-
<ProcessingSwaps />
47-
) : buildSwapView.showWizard ? (
48-
<SwapWizard />
49-
) : registerSidecarView.showWizard ? (
50-
<SidecarWizard />
51-
) : (
52-
<>
53-
<PageHeader
54-
title={title}
55-
onHelpClick={appView.showTour}
56-
onExportClick={channelStore.exportChannels}
57-
/>
58-
<LoopTiles />
59-
<LoopActions />
60-
</>
61-
)}
62-
<ChannelList />
63-
</PageWrap>
46+
<SubServerRequired status={subServerStore.subServers.loop}>
47+
<PageWrap>
48+
{appView.processingSwapsVisible ? (
49+
<ProcessingSwaps />
50+
) : buildSwapView.showWizard ? (
51+
<SwapWizard />
52+
) : registerSidecarView.showWizard ? (
53+
<SidecarWizard />
54+
) : (
55+
<>
56+
<PageHeader
57+
title={title}
58+
onHelpClick={appView.showTour}
59+
onExportClick={channelStore.exportChannels}
60+
/>
61+
<LoopTiles />
62+
<LoopActions />
63+
</>
64+
)}
65+
<ChannelList />
66+
</PageWrap>
67+
</SubServerRequired>
6468
);
6569
};
6670

app/src/components/pool/PoolPage.tsx

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { usePrefixedTranslation } from 'hooks';
55
import { useStore } from 'store';
66
import { Badge, Column, Row } from 'components/base';
77
import PageHeader from 'components/common/PageHeader';
8+
import SubServerRequired from 'components/common/SubServerRequired';
89
import AccountSection from './AccountSection';
910
import BatchSection from './BatchSection';
1011
import OrderFormSection from './OrderFormSection';
@@ -34,18 +35,24 @@ const Styled = {
3435

3536
const PoolPage: React.FC = () => {
3637
const { l } = usePrefixedTranslation('cmps.pool.PoolPage');
37-
const { accountStore, orderStore, batchStore } = useStore();
38+
const { accountStore, orderStore, batchStore, subServerStore } = useStore();
3839

3940
useEffect(() => {
40-
accountStore.fetchAccounts();
41-
orderStore.fetchOrders();
42-
batchStore.fetchNextBatchInfo();
43-
if (!batchStore.batches.size) {
44-
// fetch batches if there aren't any in the store
45-
batchStore.fetchBatches();
41+
if (
42+
subServerStore.subServers.pool?.running &&
43+
!subServerStore.subServers.pool?.error
44+
) {
45+
accountStore.fetchAccounts();
46+
orderStore.fetchOrders();
47+
batchStore.fetchNextBatchInfo();
48+
if (!batchStore.batches.size) {
49+
// fetch batches if there aren't any in the store
50+
batchStore.fetchBatches();
51+
}
52+
// start polling when this component is mounted
53+
batchStore.startPolling();
4654
}
47-
// start polling when this component is mounted
48-
batchStore.startPolling();
55+
4956
// stop polling when this component is unmounted
5057
return () => {
5158
batchStore.stopPolling();
@@ -63,23 +70,25 @@ const PoolPage: React.FC = () => {
6370

6471
const { Wrapper, Row, Col } = Styled;
6572
return (
66-
<Wrapper>
67-
<PageHeader
68-
title={title}
69-
exportTip={l('exportTip')}
70-
onExportClick={orderStore.exportLeases}
71-
/>
72-
<Row>
73-
<Col cols={4} colsXl={3}>
74-
<AccountSection />
75-
<OrderFormSection />
76-
</Col>
77-
<Col>
78-
<BatchSection />
79-
<OrderListSection />
80-
</Col>
81-
</Row>
82-
</Wrapper>
73+
<SubServerRequired status={subServerStore.subServers.pool}>
74+
<Wrapper>
75+
<PageHeader
76+
title={title}
77+
exportTip={l('exportTip')}
78+
onExportClick={orderStore.exportLeases}
79+
/>
80+
<Row>
81+
<Col cols={4} colsXl={3}>
82+
<AccountSection />
83+
<OrderFormSection />
84+
</Col>
85+
<Col>
86+
<BatchSection />
87+
<OrderListSection />
88+
</Col>
89+
</Row>
90+
</Wrapper>
91+
</SubServerRequired>
8392
);
8493
};
8594

0 commit comments

Comments
 (0)