Skip to content

Commit

Permalink
[ML] Data Frames: Adds support for transform description (#40153)
Browse files Browse the repository at this point in the history
- Adds an optional input field for a transform description to the wizard's details page.
- Adds a column Description to the transform list.
  • Loading branch information
walterra authored Jul 3, 2019
1 parent c3b8142 commit 2fd04d4
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/ml/public/data_frame/common/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type IndexPattern = string;
export type JobId = string;

export interface DataFrameJob {
description?: string;
dest: {
index: IndexName;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('Data Frame: Common', () => {
createIndexPattern: false,
isContinuousModeEnabled: false,
jobId: 'the-job-id',
jobDescription: 'the-job-description',
destinationIndex: 'the-destination-index',
touched: true,
valid: true,
Expand All @@ -114,6 +115,7 @@ describe('Data Frame: Common', () => {
const request = getDataFrameRequest('the-index-pattern-title', pivotState, jobDetailsState);

expect(request).toEqual({
description: 'the-job-description',
dest: { index: 'the-destination-index' },
pivot: {
aggregations: { 'the-agg-agg-name': { avg: { field: 'the-agg-field' } } },
Expand Down
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/ml/public/data_frame/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export function getDataFrameRequest(
dictionaryToArray(pivotState.groupByList),
dictionaryToArray(pivotState.aggList)
),
// conditionally add optional description
...(jobDetailsState.jobDescription !== ''
? { description: jobDetailsState.jobDescription }
: {}),
dest: {
index: jobDetailsState.destinationIndex,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface JobDetailsExposedState {
createIndexPattern: boolean;
isContinuousModeEnabled: boolean;
jobId: JobId;
jobDescription: string;
destinationIndex: EsIndexName;
touched: boolean;
valid: boolean;
Expand All @@ -34,6 +35,7 @@ export function getDefaultJobDetailsState(): JobDetailsExposedState {
createIndexPattern: true,
isContinuousModeEnabled: false,
jobId: '',
jobDescription: '',
destinationIndex: '',
touched: false,
valid: false,
Expand All @@ -55,6 +57,7 @@ export const JobDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChange
const defaults = { ...getDefaultJobDetailsState(), ...overrides };

const [jobId, setJobId] = useState<JobId>(defaults.jobId);
const [jobDescription, setJobDescription] = useState<string>(defaults.jobDescription);
const [destinationIndex, setDestinationIndex] = useState<EsIndexName>(defaults.destinationIndex);
const [jobIds, setJobIds] = useState<JobId[]>([]);
const [indexNames, setIndexNames] = useState<EsIndexName[]>([]);
Expand Down Expand Up @@ -139,6 +142,7 @@ export const JobDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChange
createIndexPattern,
isContinuousModeEnabled,
jobId,
jobDescription,
destinationIndex,
touched: true,
valid,
Expand All @@ -150,6 +154,7 @@ export const JobDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChange
createIndexPattern,
isContinuousModeEnabled,
jobId,
jobDescription,
destinationIndex,
valid,
]
Expand Down Expand Up @@ -180,6 +185,23 @@ export const JobDetailsForm: SFC<Props> = React.memo(({ overrides = {}, onChange
isInvalid={jobIdExists}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('xpack.ml.dataframe.jobDetailsForm.jobDescriptionLabel', {
defaultMessage: 'Job description',
})}
>
<EuiFieldText
placeholder="job description"
value={jobDescription}
onChange={e => setJobDescription(e.target.value)}
aria-label={i18n.translate(
'xpack.ml.dataframe.jobDetailsForm.jobDescriptionInputAriaLabel',
{
defaultMessage: 'Choose an optional job description.',
}
)}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('xpack.ml.dataframe.jobDetailsForm.destinationIndexLabel', {
defaultMessage: 'Destination index',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ describe('Data Frame: Job List Columns', () => {
test('getColumns()', () => {
const columns = getColumns(() => {}, [], () => {});

expect(columns).toHaveLength(8);
expect(columns).toHaveLength(9);
expect(columns[0].isExpander).toBeTruthy();
expect(columns[1].name).toBe('ID');
expect(columns[2].name).toBe('Source index');
expect(columns[3].name).toBe('Destination index');
expect(columns[4].name).toBe('Status');
expect(columns[5].name).toBe('Mode');
expect(columns[6].name).toBe('Progress');
expect(columns[7].name).toBe('Actions');
expect(columns[2].name).toBe('Description');
expect(columns[3].name).toBe('Source index');
expect(columns[4].name).toBe('Destination index');
expect(columns[5].name).toBe('Status');
expect(columns[6].name).toBe('Mode');
expect(columns[7].name).toBe('Progress');
expect(columns[8].name).toBe('Actions');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ export const getColumns = (
sortable: true,
truncateText: true,
},
{
field: DataFrameJobListColumn.description,
name: i18n.translate('xpack.ml.dataframe.description', { defaultMessage: 'Description' }),
sortable: true,
truncateText: true,
},
{
field: DataFrameJobListColumn.configSourceIndex,
name: i18n.translate('xpack.ml.dataframe.sourceIndex', { defaultMessage: 'Source index' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface DataFrameJobListRow {
export enum DataFrameJobListColumn {
configDestIndex = 'config.dest.index',
configSourceIndex = 'config.source.index',
description = 'config.description',
id = 'id',
}

Expand Down

0 comments on commit 2fd04d4

Please sign in to comment.