Skip to content

Commit 411309a

Browse files
committed
Add a placeholder "mode" to custom_integrations with tests (I think)
1 parent db9449e commit 411309a

5 files changed

Lines changed: 182 additions & 0 deletions

File tree

src/plugins/custom_integrations/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export const SHIPPER_DISPLAY = {
8282
sample_data: 'Sample data',
8383
tests: 'Tests',
8484
tutorial: 'Tutorials',
85+
placeholders: 'Extra Integrations',
8586
};
8687

8788
/**
Lines changed: 84 additions & 0 deletions
Loading
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { i18n } from '@kbn/i18n';
10+
import { CoreSetup } from '@kbn/core/server';
11+
import { CustomIntegrationRegistry } from '../custom_integration_registry';
12+
import { CustomIntegrationIcon, IntegrationCategory, PLUGIN_ID } from '../../common';
13+
14+
interface PlaceholderIntegration {
15+
id: string;
16+
title: string;
17+
icon?: string;
18+
euiIconName?: string;
19+
description: string;
20+
docUrlTemplate: string;
21+
categories: IntegrationCategory[];
22+
}
23+
24+
export const integrations: PlaceholderIntegration[] = [
25+
{
26+
id: 'esf',
27+
title: i18n.translate('customIntegrations.placeholders.EsfTitle', {
28+
defaultMessage: 'AWS Serverless Application Repository',
29+
}),
30+
icon: 'logo_esf.svg',
31+
description: i18n.translate('customIntegrations.placeholders.EsfDescription', {
32+
defaultMessage:
33+
'Collect logs using AWS Lambda application available in AWS Serverless Application Repository.',
34+
}),
35+
docUrlTemplate: `https://github.com/elastic/elastic-serverless-forwarder/blob/main/docs/README-AWS.md`,
36+
categories: ['aws', 'custom'],
37+
},
38+
];
39+
40+
export function registerPlaceholders(
41+
core: CoreSetup,
42+
registry: CustomIntegrationRegistry,
43+
branch: string
44+
) {
45+
integrations.forEach((integration: PlaceholderIntegration) => {
46+
const icons: CustomIntegrationIcon[] = [];
47+
if (integration.euiIconName) {
48+
icons.push({
49+
type: 'eui',
50+
src: integration.euiIconName,
51+
});
52+
} else if (integration.icon) {
53+
icons.push({
54+
type: 'svg',
55+
src: core.http.basePath.prepend(
56+
`/plugins/${PLUGIN_ID}/assets/placeholders/${integration.icon}`
57+
),
58+
});
59+
}
60+
61+
registry.registerCustomIntegration({
62+
id: `placeholder.${integration.id}`,
63+
title: integration.title,
64+
description: integration.description,
65+
type: 'ui_link',
66+
shipper: 'placeholders',
67+
// Documentation for `main` branches is still published at a `master` URL.
68+
uiInternalPath: integration.docUrlTemplate.replace(
69+
'{branch}',
70+
branch === 'main' ? 'master' : branch
71+
),
72+
isBeta: false,
73+
icons,
74+
categories: integration.categories,
75+
});
76+
});
77+
}

src/plugins/custom_integrations/server/plugin.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,23 @@ describe('CustomIntegrationsPlugin', () => {
141141
},
142142
]);
143143
});
144+
145+
test('should register placeholders', () => {
146+
const setup = new CustomIntegrationsPlugin(initContext).setup(mockCoreSetup);
147+
expect(setup.getAppendCustomIntegrations()).toEqual([
148+
{
149+
id: 'placeholder.esf',
150+
title: 'AWS Serverless Application Repository',
151+
description: 'Collect logs using AWS Lambda application available in AWS Serverless Application Repository.',
152+
type: 'ui_link',
153+
shipper: 'placeholders',
154+
uiInternalPath:
155+
'https://github.com/elastic/elastic-serverless-forwarder/blob/main/docs/README-AWS.md',
156+
isBeta: false,
157+
icons: [{ type: 'svg' }],
158+
categories: ['aws', 'custom'],
159+
},
160+
]);
161+
});
144162
});
145163
});

src/plugins/custom_integrations/server/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { CustomIntegration } from '../common';
1313
import { CustomIntegrationRegistry } from './custom_integration_registry';
1414
import { defineRoutes } from './routes/define_routes';
1515
import { registerLanguageClients } from './language_clients';
16+
import { registerPlaceholders } from './placeholders';
1617

1718
export class CustomIntegrationsPlugin
1819
implements Plugin<CustomIntegrationsPluginSetup, CustomIntegrationsPluginStart>
@@ -37,6 +38,7 @@ export class CustomIntegrationsPlugin
3738
defineRoutes(router, this.customIngegrationRegistry);
3839

3940
registerLanguageClients(core, this.customIngegrationRegistry, this.branch);
41+
registerPlaceholders(core, this.customIngegrationRegistry, this.branch);
4042

4143
return {
4244
registerCustomIntegration: (integration: Omit<CustomIntegration, 'type'>) => {

0 commit comments

Comments
 (0)