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] Data Frames - search bar on list page #41415

Merged
merged 9 commits into from
Jul 22, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@
animation: none !important;
}
}
.mlTransformProgressBar {
margin-bottom: $euiSizeM;
}

.mlTaskStateBadge {
width: 100px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DATA_FRAME_TASK_STATE,
DataFrameTransformListColumn,
DataFrameTransformListRow,
DataFrameTransformState,
} from './common';
import { getActions } from './actions';

Expand All @@ -31,6 +32,29 @@ enum TASK_STATE_COLOR {
stopped = 'hollow',
}

export const getTaskStateBadge = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be just another React component <TaskStateBadge ... />.

state: DataFrameTransformState['task_state'],
reason?: DataFrameTransformState['reason']
) => {
const color = TASK_STATE_COLOR[state];

if (state === DATA_FRAME_TASK_STATE.FAILED && reason !== undefined) {
return (
<EuiToolTip content={reason}>
<EuiBadge className="mlTaskStateBadge" color={color}>
{state}
</EuiBadge>
</EuiToolTip>
);
}

return (
<EuiBadge className="mlTaskStateBadge" color={color}>
{state}
</EuiBadge>
);
};

export const getColumns = (
expandedRowItemIds: DataFrameTransformId[],
setExpandedRowItemIds: React.Dispatch<React.SetStateAction<DataFrameTransformId[]>>
Expand Down Expand Up @@ -104,17 +128,7 @@ export const getColumns = (
sortable: (item: DataFrameTransformListRow) => item.state.task_state,
truncateText: true,
render(item: DataFrameTransformListRow) {
const color = TASK_STATE_COLOR[item.state.task_state];

if (item.state.task_state === DATA_FRAME_TASK_STATE.FAILED) {
return (
<EuiToolTip content={item.state.reason}>
<EuiBadge color={color}>{item.state.task_state}</EuiBadge>
</EuiToolTip>
);
}

return <EuiBadge color={color}>{item.state.task_state}</EuiBadge>;
return getTaskStateBadge(item.state.task_state, item.state.reason);
},
width: '100px',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import {
useRefreshTransformList,
} from '../../../../common';
import { checkPermission } from '../../../../../privilege/check_privilege';
import { getTaskStateBadge } from './columns';

import {
DataFrameTransformListColumn,
DataFrameTransformListRow,
ItemIdToExpandedRowMap,
DATA_FRAME_TASK_STATE,
} from './common';
import { getTransformsFactory } from '../../services/transform_service';
import { getColumns } from './columns';
Expand Down Expand Up @@ -143,6 +145,25 @@ export const DataFrameTransformList: SFC = () => {
hidePerPageOptions: false,
};

const search = {
box: {
incremental: true,
},
filters: [
alvarezmelissa87 marked this conversation as resolved.
Show resolved Hide resolved
{
type: 'field_value_selection',
field: 'state.task_state',
name: i18n.translate('xpack.ml.dataframe.statusFilter', { defaultMessage: 'Status' }),
multiSelect: 'or',
options: Object.values(DATA_FRAME_TASK_STATE).map(val => ({
value: val,
name: val,
view: getTaskStateBadge(val),
})),
},
],
};

const onTableChange = ({
page = { index: 0, size: 10 },
sort = { field: DataFrameTransformListColumn.id, direction: SortDirection.ASC },
Expand Down Expand Up @@ -174,6 +195,7 @@ export const DataFrameTransformList: SFC = () => {
onChange={onTableChange}
pagination={pagination}
sorting={sorting}
search={search}
data-test-subj="mlDataFramesTableTransforms"
/>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const ProgressBar = ({ isLoading = false }) => {
return (
<Fragment>
{isLoading && <EuiProgress size="xs" color="primary" />}
{!isLoading && <EuiProgress value={0} max={100} size="xs" />}
{!isLoading && (
<EuiProgress className="mlTransformProgressBar" value={0} max={100} size="xs" />
alvarezmelissa87 marked this conversation as resolved.
Show resolved Hide resolved
)}
</Fragment>
);
};
Expand Down