Skip to content
This repository was archived by the owner on Mar 31, 2024. It is now read-only.

Commit 25ea38d

Browse files
authored
[Uptime] Add explicit alignments to table columns (elastic#40680) (elastic#41414)
* Add explicit alignments to table columns. * Fix broken prop and snapshots. * Fix pagination item count and update snapshot to match changes.
1 parent 3da6c2c commit 25ea38d

5 files changed

Lines changed: 46 additions & 12 deletions

File tree

x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/ping_list.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export const MonitorListComponent = (props: Props) => {
134134
// sorting={sorting}
135135
columns={[
136136
{
137+
align: 'left',
137138
field: 'monitor_id',
138139
name: '',
139140
sortable: true,
@@ -165,6 +166,7 @@ export const MonitorListComponent = (props: Props) => {
165166
},
166167
},
167168
{
169+
align: 'left',
168170
field: 'state.monitor.status',
169171
name: i18n.translate('xpack.uptime.monitorList.statusColumnLabel', {
170172
defaultMessage: 'Status',
@@ -174,6 +176,7 @@ export const MonitorListComponent = (props: Props) => {
174176
},
175177
},
176178
{
179+
align: 'left',
177180
field: 'state.monitor.name',
178181
name: i18n.translate('xpack.uptime.monitorList.nameColumnLabel', {
179182
defaultMessage: 'Name',
@@ -190,6 +193,7 @@ export const MonitorListComponent = (props: Props) => {
190193
sortable: true,
191194
},
192195
{
196+
align: 'left',
193197
field: 'state.url.full',
194198
name: i18n.translate('xpack.uptime.monitorList.urlColumnLabel', {
195199
defaultMessage: 'URL',

x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ export interface ExpandedRowMap {
3333
}
3434

3535
export interface Pagination {
36+
hidePerPageOptions?: boolean;
37+
initialPageSize: number;
3638
pageIndex: number;
3739
pageSize: number;
38-
totalItemCount: number;
3940
pageSizeOptions: number[];
40-
hidePerPageOptions: boolean;
41+
totalItemCount: number;
4142
}

x-pack/legacy/plugins/uptime/public/components/functional/ping_list.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { convertMicrosecondsToMilliseconds as microsToMillis } from '../../lib/h
2828
import { UptimeGraphQLQueryProps, withUptimeGraphQL } from '../higher_order';
2929
import { pingsQuery } from '../../queries';
3030
import { LocationName } from './location_name';
31-
import { Criteria } from './monitor_list';
31+
import { Criteria, Pagination } from './monitor_list';
3232

3333
interface PingListQueryResult {
3434
allPings?: PingResults;
@@ -117,34 +117,43 @@ export const PingListComponent = ({
117117
),
118118
},
119119
{
120-
field: 'observer.geo.name',
120+
align: 'left',
121121
dataType: 'number',
122+
field: 'observer.geo.name',
122123
name: i18n.translate('xpack.uptime.pingList.locationNameColumnLabel', {
123124
defaultMessage: 'Location',
124125
}),
125126
render: (location: string) => <LocationName location={location} />,
126127
},
127128
{
128-
field: 'monitor.ip',
129+
align: 'left',
129130
dataType: 'number',
131+
field: 'monitor.ip',
130132
name: i18n.translate('xpack.uptime.pingList.ipAddressColumnLabel', {
131133
defaultMessage: 'IP',
132134
}),
133135
},
134136
{
137+
align: 'right',
135138
field: 'monitor.duration.us',
136139
name: i18n.translate('xpack.uptime.pingList.durationMsColumnLabel', {
137140
defaultMessage: 'Duration',
138141
}),
139-
render: (duration: number) => microsToMillis(duration),
142+
render: (duration: number) =>
143+
i18n.translate('xpack.uptime.pingList.durationMsColumnFormatting', {
144+
values: { millis: microsToMillis(duration) },
145+
defaultMessage: '{millis} ms',
146+
}),
140147
},
141148
{
149+
align: 'left',
142150
field: 'error.type',
143151
name: i18n.translate('xpack.uptime.pingList.errorTypeColumnLabel', {
144152
defaultMessage: 'Error type',
145153
}),
146154
},
147155
{
156+
align: 'left',
148157
field: 'error.message',
149158
name: i18n.translate('xpack.uptime.pingList.errorMessageColumnLabel', {
150159
defaultMessage: 'Error message',
@@ -192,6 +201,17 @@ export const PingListComponent = ({
192201
});
193202
}
194203
}
204+
const pagination: Pagination = {
205+
initialPageSize: 20,
206+
pageIndex: 0,
207+
pageSize,
208+
pageSizeOptions: [5, 10, 20, 50, 100],
209+
/**
210+
* we're not currently supporting pagination in this component
211+
* so the first page is the only page
212+
*/
213+
totalItemCount: pageSize,
214+
};
195215

196216
return (
197217
<Fragment>
@@ -278,12 +298,7 @@ export const PingListComponent = ({
278298
loading={loading}
279299
columns={columns}
280300
items={pings}
281-
pagination={{
282-
initialPageSize: 20,
283-
pageIndex: 0,
284-
pageSize,
285-
pageSizeOptions: [5, 10, 20, 50, 100],
286-
}}
301+
pagination={pagination}
287302
onChange={({ page: { size } }: Criteria) => onPageCountChange(size)}
288303
/>
289304
</EuiPanel>

0 commit comments

Comments
 (0)