Skip to content

Commit 26644b6

Browse files
committed
history: fix misaligned columns on history page
1 parent c6b3806 commit 26644b6

File tree

8 files changed

+55
-44
lines changed

8 files changed

+55
-44
lines changed

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@improbable-eng/grpc-web": "0.12.0",
2323
"big.js": "5.2.2",
2424
"bootstrap": "4.5.0",
25+
"date-fns": "2.14.0",
2526
"debug": "4.1.1",
2627
"emotion-theming": "10.0.27",
2728
"file-saver": "2.0.2",

app/src/__tests__/components/history/HistoryPage.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ describe('HistoryPage', () => {
3939
it('should display the table headers', () => {
4040
const { getByText } = render();
4141
expect(getByText('Status')).toBeInTheDocument();
42-
expect(getByText('Loop Type')).toBeInTheDocument();
43-
expect(getByText('Amount (sats)')).toBeInTheDocument();
42+
expect(getByText('Type')).toBeInTheDocument();
43+
expect(getByText('Amount')).toBeInTheDocument();
4444
expect(getByText('Created')).toBeInTheDocument();
4545
expect(getByText('Updated')).toBeInTheDocument();
4646
});

app/src/__tests__/timezone.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Timezone', () => {
1616

1717
it('should format the swap timestamps correctly', () => {
1818
const swap = new Swap(loopListSwaps.swapsList[0]);
19-
expect(swap.createdOnLabel).toEqual('4/8/2020 11:59:13 PM');
20-
expect(swap.updatedOnLabel).toEqual('4/9/2020 2:12:49 AM');
19+
expect(swap.createdOnLabel).toEqual('Apr 8, 11:59 PM');
20+
expect(swap.updatedOnLabel).toEqual('Apr 9, 2:12 AM');
2121
});
2222
});

app/src/__tests__/util/csv.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('csv Util', () => {
1616
const actual = csv.convert(Swap.csvColumns, swaps);
1717
const expected = [
1818
'"Swap ID","Type","Amount","Status","Created On","Updated On"',
19-
'"f4eb118383c2b09d8c7289ce21c25900cfb4545d46c47ed23a31ad2aa57ce830","Loop Out","500000","Failed","4/8/2020 11:59:13 PM","4/9/2020 2:12:49 AM"',
19+
'"f4eb118383c2b09d8c7289ce21c25900cfb4545d46c47ed23a31ad2aa57ce830","Loop Out","500000","Failed","Apr 8, 11:59 PM","Apr 9, 2:12 AM"',
2020
].join('\n');
2121
expect(actual).toEqual(expected);
2222
});

app/src/components/history/HistoryRow.tsx

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,50 @@ const Styled = {
2121
border-bottom-width: 0;
2222
}
2323
`,
24-
Column: styled(Column)`
24+
HeaderRow: styled(Row)`
25+
margin-right: 0;
26+
`,
27+
HeaderColumn: styled(Column)`
2528
white-space: nowrap;
26-
line-height: ${ROW_HEIGHT}px;
29+
padding: 0 5px;
30+
31+
&:last-child {
32+
padding-right: 0;
33+
}
2734
`,
28-
StatusHeader: styled(HeaderFour)`
29-
margin-left: 35px;
35+
Column: styled(Column)`
36+
line-height: ${ROW_HEIGHT}px;
37+
padding: 0 5px;
3038
`,
31-
StatusIcon: styled.span`
32-
display: inline-block;
33-
margin-right: 20px;
39+
ActionColumn: styled(Column)`
40+
max-width: 50px;
41+
padding: 0 20px;
42+
line-height: ${ROW_HEIGHT}px;
3443
`,
3544
};
3645

3746
export const HistoryRowHeader: React.FC = () => {
3847
const { l } = usePrefixedTranslation('cmps.history.HistoryRowHeader');
39-
const { StatusHeader } = Styled;
48+
const { HeaderRow, ActionColumn, HeaderColumn } = Styled;
4049
return (
41-
<Row>
42-
<Column>
43-
<StatusHeader>{l('status')}</StatusHeader>
44-
</Column>
45-
<Column>
50+
<HeaderRow>
51+
<ActionColumn />
52+
<HeaderColumn cols={3}>
53+
<HeaderFour>{l('status')}</HeaderFour>
54+
</HeaderColumn>
55+
<HeaderColumn>
4656
<HeaderFour>{l('type')}</HeaderFour>
47-
</Column>
48-
<Column>
49-
<HeaderFour>{l('amount')} (sats)</HeaderFour>
50-
</Column>
51-
<Column right cols={3}>
57+
</HeaderColumn>
58+
<HeaderColumn right>
59+
<HeaderFour>{l('amount')}</HeaderFour>
60+
</HeaderColumn>
61+
<HeaderColumn right>
5262
<HeaderFour>{l('created')}</HeaderFour>
53-
</Column>
54-
<Column right cols={3}>
63+
</HeaderColumn>
64+
<HeaderColumn right>
5565
<HeaderFour>{l('updated')}</HeaderFour>
56-
</Column>
57-
</Row>
66+
</HeaderColumn>
67+
</HeaderRow>
5868
);
5969
};
6070

@@ -64,25 +74,19 @@ interface Props {
6474
}
6575

6676
const HistoryRow: React.FC<Props> = ({ swap, style }) => {
67-
const { Row, Column, StatusIcon } = Styled;
77+
const { Row, Column, ActionColumn } = Styled;
6878
return (
6979
<Row style={style}>
70-
<Column>
71-
<StatusIcon>
72-
<SwapDot swap={swap} />
73-
</StatusIcon>
74-
{swap.stateLabel}
75-
</Column>
80+
<ActionColumn>
81+
<SwapDot swap={swap} />
82+
</ActionColumn>
83+
<Column cols={3}>{swap.stateLabel}</Column>
7684
<Column>{swap.typeName}</Column>
77-
<Column>
85+
<Column right>
7886
<Unit sats={swap.amount} suffix={false} />
7987
</Column>
80-
<Column right cols={3}>
81-
{swap.createdOnLabel}
82-
</Column>
83-
<Column right cols={3}>
84-
{swap.updatedOnLabel}
85-
</Column>
88+
<Column right>{swap.createdOnLabel}</Column>
89+
<Column right>{swap.updatedOnLabel}</Column>
8690
</Row>
8791
);
8892
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cmps.history.HistoryPage.pageTitle": "Loop History",
1616
"cmps.history.HistoryRowHeader.status": "Status",
1717
"cmps.history.HistoryRowHeader.amount": "Amount",
18-
"cmps.history.HistoryRowHeader.type": "Loop Type",
18+
"cmps.history.HistoryRowHeader.type": "Type",
1919
"cmps.history.HistoryRowHeader.created": "Created",
2020
"cmps.history.HistoryRowHeader.updated": "Updated",
2121
"cmps.loop.ChannelIcon.processing.in": "Loop In currently in progress",

app/src/store/models/swap.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { action, computed, observable } from 'mobx';
22
import { now } from 'mobx-utils';
33
import * as LOOP from 'types/generated/loop_pb';
44
import Big from 'big.js';
5+
import formatDate from 'date-fns/format';
56
import { CsvColumns } from 'util/csv';
67
import { ellipseInside } from 'util/strings';
78

@@ -84,7 +85,7 @@ export default class Swap {
8485

8586
/** The date this swap was created as formatted string */
8687
@computed get createdOnLabel() {
87-
return `${this.createdOn.toLocaleDateString()} ${this.createdOn.toLocaleTimeString()}`;
88+
return formatDate(this.createdOn, 'MMM d, h:mm a');
8889
}
8990

9091
/** The date this swap was last updated as a JS Date object */
@@ -94,7 +95,7 @@ export default class Swap {
9495

9596
/** The date this swap was last updated as formatted string */
9697
@computed get updatedOnLabel() {
97-
return `${this.updatedOn.toLocaleDateString()} ${this.updatedOn.toLocaleTimeString()}`;
98+
return formatDate(this.updatedOn, 'MMM d, h:mm a');
9899
}
99100

100101
/**

app/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5391,6 +5391,11 @@ data-urls@^2.0.0:
53915391
whatwg-mimetype "^2.3.0"
53925392
whatwg-url "^8.0.0"
53935393

5394+
date-fns@2.14.0:
5395+
version "2.14.0"
5396+
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
5397+
integrity sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw==
5398+
53945399
de-indent@^1.0.2:
53955400
version "1.0.2"
53965401
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"

0 commit comments

Comments
 (0)