-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,446 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
...gent_policy/create_package_policy_page/components/steps/components/order_datasets.test.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...ons/agent_policy/create_package_policy_page/components/steps/components/order_datasets.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...nt_policy/create_package_policy_page/components/steps/components/sort_datastreams.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { DataStream } from '../../../../../../../../../common/types'; | ||
|
||
import { sortDatastreamsByDataset } from './sort_datastreams'; | ||
|
||
const ds = (dataset: string) => ({ dataset } as DataStream); | ||
describe('orderDatasets', () => { | ||
it('should move datasets up that match package name', () => { | ||
const datasets = sortDatastreamsByDataset( | ||
[ds('system.memory'), ds('elastic_agent'), ds('elastic_agent.filebeat'), ds('system.cpu')], | ||
'elastic_agent' | ||
); | ||
|
||
expect(datasets).toEqual([ | ||
ds('elastic_agent'), | ||
ds('elastic_agent.filebeat'), | ||
ds('system.cpu'), | ||
ds('system.memory'), | ||
]); | ||
}); | ||
|
||
it('should order alphabetically if name does not match', () => { | ||
const datasets = sortDatastreamsByDataset([ds('system.memory'), ds('elastic_agent')], 'nginx'); | ||
|
||
expect(datasets).toEqual([ds('elastic_agent'), ds('system.memory')]); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
...s/agent_policy/create_package_policy_page/components/steps/components/sort_datastreams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { partition, sortBy } from 'lodash'; | ||
|
||
import type { DataStream } from '../../../../../../../../../common/types'; | ||
|
||
// sort data streams by dataset name, but promote datastreams that are from this package to the start | ||
export function sortDatastreamsByDataset(datasetList: DataStream[], name: string): DataStream[] { | ||
const [relevantDatasets, otherDatasets] = partition(sortBy(datasetList, 'dataset'), (record) => | ||
record.dataset.startsWith(name) | ||
); | ||
const datasets = relevantDatasets.concat(otherDatasets); | ||
return datasets; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.