Skip to content

Commit 7c7a2c9

Browse files
committed
ui: add message in Loop History when there are no past swaps
1 parent 3b30e81 commit 7c7a2c9

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

app/src/__stories__/LoopHistory.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
2+
import { observable } from 'mobx';
3+
import { useStore } from 'store';
24
import Tile from 'components/common/Tile';
35
import LoopHistory from 'components/loop/LoopHistory';
46

@@ -19,3 +21,13 @@ export const InsideTile = () => {
1921
</Tile>
2022
);
2123
};
24+
25+
export const Empty = () => {
26+
const { swapStore } = useStore();
27+
swapStore.swaps = observable.map();
28+
return (
29+
<Tile title="Loop History" onMaximizeClick={() => null}>
30+
<LoopHistory />
31+
</Tile>
32+
);
33+
};

app/src/__tests__/components/loop/LoopHistory.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { observable } from 'mobx';
23
import * as LOOP from 'types/generated/loop_pb';
34
import { renderWithProviders } from 'util/tests';
45
import { createStore, Store } from 'store';
@@ -39,4 +40,12 @@ describe('LoopHistory component', () => {
3940
const { getByText } = render();
4041
expect(getByText('dot.svg')).toHaveClass('warn');
4142
});
43+
44+
it('should display the empty message', async () => {
45+
store.swapStore.swaps = observable.map();
46+
const { getByText } = render();
47+
expect(
48+
getByText('After performing swaps, you will see ongoing loops and history here.'),
49+
).toBeInTheDocument();
50+
});
4251
});

app/src/components/loop/LoopHistory.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { observer } from 'mobx-react-lite';
3+
import { usePrefixedTranslation } from 'hooks';
34
import { useStore } from 'store';
45
import { Column, Row } from 'components/common/grid';
56
import { Small } from 'components/common/text';
@@ -20,12 +21,14 @@ const Styled = {
2021
};
2122

2223
const LoopHistory: React.FC = () => {
23-
const store = useStore();
24+
const { l } = usePrefixedTranslation('cmps.loop.LoopHistory');
25+
const { swapStore } = useStore();
2426

2527
const { RightColumn, SmallText } = Styled;
2628
return (
2729
<>
28-
{store.swapStore.lastTwoSwaps.map(swap => (
30+
{swapStore.lastTwoSwaps.length === 0 && <Small>{l('emptyMsg')}</Small>}
31+
{swapStore.lastTwoSwaps.map(swap => (
2932
<Row key={swap.id}>
3033
<Column cols={6}>
3134
<SwapDot swap={swap} />

app/src/i18n/locales/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"cmps.loop.ChannelRowHeader.capacity": "Capacity",
2020
"cmps.loop.LoopActions.channelsSelected": "channels selected",
2121
"cmps.loop.LoopPage.pageTitle": "Lightning Loop",
22+
"cmps.loop.LoopHistory.emptyMsg": "After performing swaps, you will see ongoing loops and history here.",
2223
"cmps.loop.LoopTiles.history": "Loop History",
2324
"cmps.loop.LoopTiles.inbound": "Total Inbound Liquidity",
2425
"cmps.loop.LoopTiles.outbound": "Total Outbound Liquidity",

0 commit comments

Comments
 (0)