Skip to content

Commit

Permalink
[Uptime] Add explicit alignments to table columns (elastic#40680)
Browse files Browse the repository at this point in the history
* Add explicit alignments to table columns.

* Fix broken prop and snapshots.

* Fix pagination item count and update snapshot to match changes.
  • Loading branch information
justinkambic committed Jul 17, 2019
1 parent 91f581d commit 570e6f8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const MonitorListComponent = (props: Props) => {
// sorting={sorting}
columns={[
{
align: 'left',
field: 'monitor_id',
name: '',
sortable: true,
Expand Down Expand Up @@ -165,6 +166,7 @@ export const MonitorListComponent = (props: Props) => {
},
},
{
align: 'left',
field: 'state.monitor.status',
name: i18n.translate('xpack.uptime.monitorList.statusColumnLabel', {
defaultMessage: 'Status',
Expand All @@ -174,6 +176,7 @@ export const MonitorListComponent = (props: Props) => {
},
},
{
align: 'left',
field: 'state.monitor.name',
name: i18n.translate('xpack.uptime.monitorList.nameColumnLabel', {
defaultMessage: 'Name',
Expand All @@ -190,6 +193,7 @@ export const MonitorListComponent = (props: Props) => {
sortable: true,
},
{
align: 'left',
field: 'state.url.full',
name: i18n.translate('xpack.uptime.monitorList.urlColumnLabel', {
defaultMessage: 'URL',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export interface ExpandedRowMap {
}

export interface Pagination {
hidePerPageOptions?: boolean;
initialPageSize: number;
pageIndex: number;
pageSize: number;
totalItemCount: number;
pageSizeOptions: number[];
hidePerPageOptions: boolean;
totalItemCount: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { convertMicrosecondsToMilliseconds as microsToMillis } from '../../lib/h
import { UptimeGraphQLQueryProps, withUptimeGraphQL } from '../higher_order';
import { pingsQuery } from '../../queries';
import { LocationName } from './location_name';
import { Criteria } from './monitor_list';
import { Criteria, Pagination } from './monitor_list';

interface PingListQueryResult {
allPings?: PingResults;
Expand Down Expand Up @@ -117,34 +117,43 @@ export const PingListComponent = ({
),
},
{
field: 'observer.geo.name',
align: 'left',
dataType: 'number',
field: 'observer.geo.name',
name: i18n.translate('xpack.uptime.pingList.locationNameColumnLabel', {
defaultMessage: 'Location',
}),
render: (location: string) => <LocationName location={location} />,
},
{
field: 'monitor.ip',
align: 'left',
dataType: 'number',
field: 'monitor.ip',
name: i18n.translate('xpack.uptime.pingList.ipAddressColumnLabel', {
defaultMessage: 'IP',
}),
},
{
align: 'right',
field: 'monitor.duration.us',
name: i18n.translate('xpack.uptime.pingList.durationMsColumnLabel', {
defaultMessage: 'Duration',
}),
render: (duration: number) => microsToMillis(duration),
render: (duration: number) =>
i18n.translate('xpack.uptime.pingList.durationMsColumnFormatting', {
values: { millis: microsToMillis(duration) },
defaultMessage: '{millis} ms',
}),
},
{
align: 'left',
field: 'error.type',
name: i18n.translate('xpack.uptime.pingList.errorTypeColumnLabel', {
defaultMessage: 'Error type',
}),
},
{
align: 'left',
field: 'error.message',
name: i18n.translate('xpack.uptime.pingList.errorMessageColumnLabel', {
defaultMessage: 'Error message',
Expand Down Expand Up @@ -192,6 +201,17 @@ export const PingListComponent = ({
});
}
}
const pagination: Pagination = {
initialPageSize: 20,
pageIndex: 0,
pageSize,
pageSizeOptions: [5, 10, 20, 50, 100],
/**
* we're not currently supporting pagination in this component
* so the first page is the only page
*/
totalItemCount: pageSize,
};

return (
<Fragment>
Expand Down Expand Up @@ -278,12 +298,7 @@ export const PingListComponent = ({
loading={loading}
columns={columns}
items={pings}
pagination={{
initialPageSize: 20,
pageIndex: 0,
pageSize,
pageSizeOptions: [5, 10, 20, 50, 100],
}}
pagination={pagination}
onChange={({ page: { size } }: Criteria) => onPageCountChange(size)}
/>
</EuiPanel>
Expand Down

0 comments on commit 570e6f8

Please sign in to comment.