Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/integrations_manager/common/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { PLUGIN_ID } from './constants';
export const API_ROOT = `/api/${PLUGIN_ID}`;
export const API_LIST_PATTERN = `${API_ROOT}/list`;
export const API_INFO_PATTERN = `${API_ROOT}/package/{pkgkey}`;
export const API_INSTALL_PATTERN = `${API_ROOT}/install/{pkgkey}/{feature?}`;
export const API_DELETE_PATTERN = `${API_ROOT}/delete/{pkgkey}/{feature?}`;
export const API_INSTALL_PATTERN = `${API_ROOT}/install/{pkgkey}/{asset?}`;
export const API_DELETE_PATTERN = `${API_ROOT}/delete/{pkgkey}/{asset?}`;

export function getListPath() {
return API_LIST_PATTERN;
Expand Down
22 changes: 11 additions & 11 deletions x-pack/legacy/plugins/integrations_manager/server/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ interface PackageRequest extends Request {
};
}

interface InstallFeatureRequest extends PackageRequest {
interface InstallAssetRequest extends PackageRequest {
params: {
pkgkey: string;
feature: string;
asset: string;
};
}

Expand All @@ -60,11 +60,11 @@ export async function handleGetInfo(req: PackageRequest) {
return installation;
}

export async function handleRequestInstall(req: InstallFeatureRequest) {
const { pkgkey, feature } = req.params;
export async function handleRequestInstall(req: InstallAssetRequest) {
const { pkgkey, asset } = req.params;

if (feature === 'dashboard') {
const toBeSavedObjects = await getObjects(pkgkey, feature);
if (asset === 'dashboard') {
const toBeSavedObjects = await getObjects(pkgkey, asset);
const client = getClient(req);
const createResults = await client.bulkCreate(toBeSavedObjects, { overwrite: true });
const installed = createResults.saved_objects.map(({ id, type }) => ({ id, type }));
Expand All @@ -79,13 +79,13 @@ export async function handleRequestInstall(req: InstallFeatureRequest) {

return {
pkgkey,
feature,
asset,
created: [],
};
}

export async function handleRequestDelete(req: InstallFeatureRequest) {
const { pkgkey, feature } = req.params;
export async function handleRequestDelete(req: InstallAssetRequest) {
const { pkgkey, asset } = req.params;
const client = getClient(req);

const installation = await getInstallationObject(client, pkgkey);
Expand All @@ -97,15 +97,15 @@ export async function handleRequestDelete(req: InstallFeatureRequest) {

// ASK: should the manager uninstall the assets it installed
// or just the references in SAVED_OBJECT_TYPE?
if (feature === 'dashboard') {
if (asset === 'dashboard') {
// Delete the installed assets
const deletePromises = installedObjects.map(async ({ id, type }) => client.delete(type, id));
await Promise.all(deletePromises);
}

return {
pkgkey,
feature,
asset,
deleted: installedObjects,
};
}
Expand Down