Skip to content

Commit 616cfb5

Browse files
committed
ui+pages: Integrate SubServerStatus component into loop and pool pages
1 parent 4255780 commit 616cfb5

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

app/src/components/history/HistoryPage.tsx

Lines changed: 13 additions & 1 deletion
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 SubServerStatus from 'components/common/SubServerStatus';
78
import HistoryList from './HistoryList';
89

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

1516
const HistoryPage: React.FC = () => {
1617
const { l } = usePrefixedTranslation('cmps.history.HistoryPage');
17-
const { swapStore } = useStore();
18+
const { swapStore, subServerStore } = useStore();
19+
20+
if (subServerStore.subServers.loop?.disabled) {
21+
return <SubServerStatus isDisabled={true} />;
22+
} else if (subServerStore.subServers.loop?.error) {
23+
return (
24+
<SubServerStatus
25+
isDisabled={false}
26+
errorMessage={subServerStore.subServers.loop.error}
27+
/>
28+
);
29+
}
1830

1931
const { Wrapper } = Styled;
2032
return (

app/src/components/loop/LoopPage.tsx

Lines changed: 13 additions & 0 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 SubServerStatus from 'components/common/SubServerStatus';
89
import ChannelList from './ChannelList';
910
import LoopActions from './LoopActions';
1011
import LoopTiles from './LoopTiles';
@@ -26,8 +27,20 @@ const LoopPage: React.FC = () => {
2627
registerSidecarView,
2728
channelStore,
2829
nodeStore,
30+
subServerStore,
2931
} = useStore();
3032

33+
if (subServerStore.subServers.loop?.disabled) {
34+
return <SubServerStatus isDisabled={true} />;
35+
} else if (subServerStore.subServers.loop?.error) {
36+
return (
37+
<SubServerStatus
38+
isDisabled={false}
39+
errorMessage={subServerStore.subServers.loop.error}
40+
/>
41+
);
42+
}
43+
3144
const title = (
3245
<>
3346
{l('pageTitle')}

app/src/components/pool/PoolPage.tsx

Lines changed: 28 additions & 10 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 SubServerStatus from 'components/common/SubServerStatus';
89
import AccountSection from './AccountSection';
910
import BatchSection from './BatchSection';
1011
import OrderFormSection from './OrderFormSection';
@@ -34,23 +35,40 @@ 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();
5259
};
53-
}, [accountStore, orderStore, batchStore]);
60+
}, [accountStore, orderStore, batchStore, subServerStore.subServers.pool]);
61+
62+
if (subServerStore.subServers.pool?.disabled) {
63+
return <SubServerStatus isDisabled={true} />;
64+
} else if (subServerStore.subServers.pool?.error) {
65+
return (
66+
<SubServerStatus
67+
isDisabled={false}
68+
errorMessage={subServerStore.subServers.pool.error}
69+
/>
70+
);
71+
}
5472

5573
const title = (
5674
<>

0 commit comments

Comments
 (0)