Skip to content

Commit fca44ce

Browse files
author
John Schulz
committed
Replace AssetType enum with union type
See #50609 (comment) Discussed in Slack and agree to revert for now. Can track down the issues & restore later
1 parent 19a5746 commit fca44ce

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

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

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

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

13-
export enum AssetType {
14-
config = 'config',
15-
dashboard = 'dashboard',
16-
visualization = 'visualization',
17-
search = 'search',
18-
ingestPipeline = 'ingest-pipeline',
19-
indexPattern = 'index-pattern',
20-
timelionSheet = 'timelion-sheet',
21-
}
13+
export type AssetType =
14+
| 'config'
15+
| 'dashboard'
16+
| 'visualization'
17+
| 'search'
18+
| 'ingest-pipeline'
19+
| 'index-pattern'
20+
| 'timelion-sheet';
2221

2322
// Registry's response types
2423
// from /search

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

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

1717
export const SAVED_OBJECT_TYPES = new Set<AssetType>([
18-
AssetType.config,
19-
AssetType.dashboard,
20-
AssetType.indexPattern,
21-
AssetType.search,
22-
AssetType.timelionSheet,
23-
AssetType.visualization,
18+
'config',
19+
'dashboard',
20+
'index-pattern',
21+
'search',
22+
'timelion-sheet',
23+
'visualization',
2424
]);
2525

2626
export function getClusterAccessor(esClient: IClusterClient, req: Request) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function installAssets(options: {
4545

4646
// Only install certain Kibana assets during package installation.
4747
// All other asset types need special handling
48-
const typesToInstall = [AssetType.visualization, AssetType.dashboard, AssetType.search];
48+
const typesToInstall: AssetType[] = ['visualization', 'dashboard', 'search'];
4949

5050
const installationPromises = typesToInstall.map(async assetType =>
5151
installKibanaSavedObjects({ savedObjectsClient, pkgkey, assetType })

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ export async function removeInstallation(options: {
2929

3030
// Delete the installed assets
3131
const deletePromises = installedObjects.map(async ({ id, type }) => {
32-
if (assetUsesObjects(type as AssetType)) {
33-
savedObjectsClient.delete(type, id);
34-
} else if (type === AssetType.ingestPipeline) {
32+
const assetType = type as AssetType;
33+
if (assetUsesObjects(assetType)) {
34+
savedObjectsClient.delete(assetType, id);
35+
} else if (assetType === 'ingest-pipeline') {
3536
deletePipeline(callCluster, id);
3637
}
3738
});

0 commit comments

Comments
 (0)