Skip to content

Commit 3a15289

Browse files
committed
cleanup assets, filter assets for those currently supported
1 parent 4cbd647 commit 3a15289

6 files changed

Lines changed: 60 additions & 46 deletions

File tree

x-pack/legacy/plugins/integrations_manager/common/types.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ export { Request, ResponseToolkit, Server, ServerRoute } from 'hapi';
1010

1111
export type InstallationStatus = Installed['status'] | NotInstalled['status'];
1212

13-
export type AssetType =
14-
| 'config'
15-
| 'dashboard'
16-
| 'visualization'
17-
| 'search'
18-
| 'ingest-pipeline'
19-
| 'index-pattern'
20-
| 'timelion-sheet';
13+
export type AssetType = KibanaAssetType | ElasticsearchAssetType;
14+
15+
export type KibanaAssetType = 'dashboard' | 'visualization' | 'search' | 'index-pattern';
16+
17+
export type ElasticsearchAssetType = 'ingest-pipeline' | 'index-template' | 'ilm-policy';
2118

2219
// Registry's response types
2320
// from /search
@@ -39,7 +36,7 @@ export interface ScreenshotItem {
3936

4037
// from /package/{name}
4138
// https://github.com/elastic/integrations-registry/blob/master/docs/api/package.json
42-
export type ServiceName = 'kibana' | 'elasticsearch' | 'filebeat' | 'metricbeat';
39+
export type ServiceName = 'kibana' | 'elasticsearch';
4340
export type RequirementVersion = string;
4441

4542
export interface ServiceRequirements {
@@ -68,8 +65,8 @@ export interface AssetParts {
6865
type: AssetType;
6966
file: string;
7067
}
71-
72-
export type AssetsGroupedByServiceByType = Record<ServiceName, Record<AssetType, AssetParts[]>>;
68+
export type Assets = Record<AssetType, AssetParts[]>;
69+
export type AssetsGroupedByServiceByType = Record<ServiceName, Assets>;
7370
export interface RegistryPackage {
7471
name: string;
7572
version: string;
@@ -79,6 +76,7 @@ export interface RegistryPackage {
7976
requirement: RequirementsByServiceName;
8077
title?: string;
8178
screenshots?: ScreenshotItem[];
79+
assets: string[];
8280
}
8381

8482
// Managers public HTTP response types

x-pack/legacy/plugins/integrations_manager/public/components/assets_facet_group.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,19 @@ import {
1717
} from '@elastic/eui';
1818
import styled from 'styled-components';
1919
import { entries } from '../../common/type_utils';
20-
import { AssetIcons, AssetTitleMap, ServiceIcons, ServiceTitleMap } from '../constants';
21-
import { AssetsGroupedByServiceByType } from '../../common/types';
20+
import {
21+
DisplayedAssets,
22+
AssetIcons,
23+
AssetTitleMap,
24+
ServiceIcons,
25+
ServiceTitleMap,
26+
} from '../constants';
27+
import {
28+
AssetsGroupedByServiceByType,
29+
Assets,
30+
KibanaAssetType,
31+
AssetType,
32+
} from '../../common/types';
2233
import { useCore } from '../hooks/use_core';
2334

2435
export function AssetsFacetGroup({ assets }: { assets: AssetsGroupedByServiceByType }) {
@@ -39,6 +50,11 @@ export function AssetsFacetGroup({ assets }: { assets: AssetsGroupedByServiceByT
3950
<Fragment>
4051
{entries(assets).map(([service, typeToParts], index) => {
4152
const Header = index === 0 ? FirstHeaderRow : HeaderRow;
53+
// filter out assets we are not going to display
54+
const filteredTypes: Assets = entries(typeToParts).reduce((acc: any, [asset, value]) => {
55+
if (DisplayedAssets[service].includes(asset)) acc[asset] = value;
56+
return acc;
57+
}, {});
4258
return (
4359
<Fragment key={service}>
4460
<Header gutterSize="s" alignItems="center">
@@ -56,8 +72,12 @@ export function AssetsFacetGroup({ assets }: { assets: AssetsGroupedByServiceByT
5672
</Header>
5773

5874
<FacetGroup>
59-
{entries(typeToParts).map(([type, parts]) => {
60-
const iconType = AssetIcons[type];
75+
{entries(filteredTypes).map(([type, parts]) => {
76+
let iconType = null;
77+
if (type in AssetIcons) {
78+
// only kibana assets have icons
79+
iconType = AssetIcons[type as KibanaAssetType];
80+
}
6181
const iconNode = iconType ? <EuiIcon type={iconType} size="s" /> : '';
6282
const FacetButton = styled(EuiFacetButton)`
6383
padding: '${theme.eui.paddingSizes.xs} 0';

x-pack/legacy/plugins/integrations_manager/public/constants.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,36 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import { IconType } from '@elastic/eui';
7-
import { AssetType, ServiceName } from '../common/types';
7+
import { KibanaAssetType, AssetType, ServiceName } from '../common/types';
8+
9+
export const DisplayedAssets: Record<ServiceName, AssetType[]> = {
10+
kibana: ['index-pattern', 'visualization', 'search', 'dashboard'],
11+
elasticsearch: ['index-template', 'ingest-pipeline', 'ilm-policy'],
12+
};
813

914
export const AssetTitleMap: Record<AssetType, string> = {
10-
config: 'Config',
1115
dashboard: 'Dashboard',
12-
'index-pattern': 'Index Pattern',
16+
'ilm-policy': 'ILM Policy',
1317
'ingest-pipeline': 'Ingest Pipeline',
18+
'index-pattern': 'Index Pattern',
19+
'index-template': 'Index Template',
1420
search: 'Saved Search',
15-
'timelion-sheet': 'Timelion Sheet',
1621
visualization: 'Visualization',
1722
};
1823

1924
export const ServiceTitleMap: Record<ServiceName, string> = {
2025
elasticsearch: 'Elasticsearch',
21-
filebeat: 'Filebeat',
2226
kibana: 'Kibana',
23-
metricbeat: 'Metricbeat',
2427
};
2528

26-
export const AssetIcons: Record<AssetType, IconType> = {
27-
config: 'advancedSettingsApp',
28-
visualization: 'visualizeApp',
29+
export const AssetIcons: Record<KibanaAssetType, IconType> = {
2930
dashboard: 'dashboardApp',
30-
search: 'searchProfilerApp',
3131
'index-pattern': 'indexPatternApp',
32-
// spaces: 'spacesApp',
33-
'ingest-pipeline': 'pipelineApp',
34-
// 'index-template': 'indexManagementApp'
35-
// 'ilm-policy': 'reportingApp',
36-
'timelion-sheet': 'timelionApp',
32+
search: 'searchProfilerApp',
33+
visualization: 'visualizeApp',
3734
};
3835

3936
export const ServiceIcons: Record<ServiceName, IconType> = {
4037
elasticsearch: 'logoElasticsearch',
41-
filebeat: 'logoBeats',
4238
kibana: 'logoKibana',
43-
metricbeat: 'logoBeats',
4439
};

x-pack/legacy/plugins/integrations_manager/server/packages/get.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,15 @@ export async function getPackageInfo(options: {
5353
pkgkey: string;
5454
}) {
5555
const { savedObjectsClient, pkgkey } = options;
56-
const [item, savedObject, paths] = await Promise.all([
56+
const [item, savedObject] = await Promise.all([
5757
Registry.fetchInfo(pkgkey),
5858
getInstallationObject({ savedObjectsClient, pkgkey }),
59-
Registry.getArchiveInfo(pkgkey),
6059
]);
61-
62-
// add properties that aren't (or aren't yet) on Registry response
63-
const updated = Object.assign({}, item, {
60+
const updated = {
61+
...item,
6462
title: item.title || nameAsTitle(item.name),
65-
assets: Registry.groupPathsByService(paths),
66-
});
67-
63+
assets: Registry.groupPathsByService(item.assets),
64+
};
6865
return createInstallableFrom(updated, savedObject);
6966
}
7067

x-pack/legacy/plugins/integrations_manager/server/packages/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ export * from './handlers';
1515
export type CallESAsCurrentUser = ScopedClusterClient['callAsCurrentUser'];
1616

1717
export const SAVED_OBJECT_TYPES = new Set<AssetType>([
18-
'config',
1918
'dashboard',
19+
'ilm-policy',
2020
'index-pattern',
21+
'index-template',
22+
'ingest-pipeline',
2123
'search',
22-
'timelion-sheet',
2324
'visualization',
2425
]);
2526

x-pack/legacy/plugins/integrations_manager/server/registry/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,19 @@ export function getAsset(key: string) {
116116
return buffer;
117117
}
118118

119-
export function groupPathsByService(paths: string[]) {
119+
export function groupPathsByService(paths: string[]): AssetsGroupedByServiceByType {
120120
// ASK: best way, if any, to avoid `any`?
121-
const byServiceByType: AssetsGroupedByServiceByType = paths.reduce((map: any, path) => {
122-
const parts = pathParts(path);
121+
const assets = paths.reduce((map: any, path) => {
122+
const parts = pathParts(path.replace(/^\/package\//, ''));
123123
if (!map[parts.service]) map[parts.service] = {};
124124
if (!map[parts.service][parts.type]) map[parts.service][parts.type] = [];
125125
map[parts.service][parts.type].push(parts);
126126

127127
return map;
128128
}, {});
129129

130-
return byServiceByType;
130+
return {
131+
kibana: assets.kibana,
132+
elasticsearch: assets.elasticsearch,
133+
};
131134
}

0 commit comments

Comments
 (0)