Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Fix annotations pagination & change labels from letters to numbers #72204

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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 @@ -13,7 +13,7 @@ import _ from 'lodash';
import PropTypes from 'prop-types';
import rison from 'rison-node';
import React, { Component, Fragment } from 'react';

import memoizeOne from 'memoize-one';
import {
EuiBadge,
EuiButtonIcon,
Expand Down Expand Up @@ -130,7 +130,7 @@ export class AnnotationsTable extends Component {
}
}

getAnnotationsWithExtraInfo(annotations) {
getAnnotationsWithExtraInfo = memoizeOne((annotations) => {
// if there is a specific view/chart entities that the annotations can be scoped to
// add a new column called 'current_series'
if (Array.isArray(this.props.chartDetails?.entityData?.entities)) {
Expand All @@ -147,7 +147,7 @@ export class AnnotationsTable extends Component {
// if not make it return the original annotations
return annotations;
}
}
});

getJob(jobId) {
// check if the job was supplied via props and matches the supplied jobId
Expand Down Expand Up @@ -644,15 +644,18 @@ export class AnnotationsTable extends Component {
name: CURRENT_SERIES,
dataType: 'boolean',
width: '0px',
render: () => '',
}
);

const items = this.getAnnotationsWithExtraInfo(annotations);
return (
<Fragment>
<EuiInMemoryTable
error={searchError}
className="eui-textOverflowWrap"
compressed={true}
items={this.getAnnotationsWithExtraInfo(annotations)}
items={items}
columns={columns}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Label column should sort numerically:

image

I think you can just replace sortable: true with something like sortable: (key) => +key,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the sort for numerical labels here 5e43657

pagination={{
pageSizeOptions: [5, 10, 25],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export function loadAnnotationsTableData(selectedCells, selectedJobs, interval,
return a.timestamp - b.timestamp;
})
.map((d, i) => {
d.key = String.fromCharCode(65 + i);
d.key = (i + 1).toString();
return d;
}),
aggregations: resp.aggregations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export function getFocusData(
.sort((a, b) => {
return a.timestamp - b.timestamp;
})
.map((d, i) => {
d.key = String.fromCharCode(65 + i);
.map((d, i: number) => {
d.key = (i + 1).toString();
return d;
});

Expand Down