Remove legacy spaces plugin (#74532)
This commit is contained in:
parent
418e444d36
commit
32a8eb2aae
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -163,7 +163,6 @@
|
|||
|
||||
# Security
|
||||
/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-platform
|
||||
/x-pack/legacy/plugins/spaces/ @elastic/kibana-security
|
||||
/x-pack/plugins/spaces/ @elastic/kibana-security
|
||||
/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security
|
||||
/x-pack/plugins/security/ @elastic/kibana-security
|
||||
|
@ -281,7 +280,6 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
|
|||
# Core design
|
||||
/src/plugins/dashboard/**/*.scss @elastic/kibana-core-ui-designers
|
||||
/x-pack/plugins/canvas/**/*.scss @elastic/kibana-core-ui-designers
|
||||
/x-pack/legacy/plugins/spaces/**/*.scss @elastic/kibana-core-ui-designers
|
||||
/x-pack/plugins/spaces/**/*.scss @elastic/kibana-core-ui-designers
|
||||
/x-pack/plugins/security/**/*.scss @elastic/kibana-core-ui-designers
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -49,7 +49,7 @@
|
|||
"xpack.server": "legacy/server",
|
||||
"xpack.securitySolution": "plugins/security_solution",
|
||||
"xpack.snapshotRestore": "plugins/snapshot_restore",
|
||||
"xpack.spaces": ["legacy/plugins/spaces", "plugins/spaces"],
|
||||
"xpack.spaces": "plugins/spaces",
|
||||
"xpack.taskManager": "legacy/plugins/task_manager",
|
||||
"xpack.transform": "plugins/transform",
|
||||
"xpack.triggersActionsUI": "plugins/triggers_actions_ui",
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
*/
|
||||
|
||||
import { xpackMain } from './legacy/plugins/xpack_main';
|
||||
import { spaces } from './legacy/plugins/spaces';
|
||||
|
||||
module.exports = function (kibana) {
|
||||
return [xpackMain(kibana), spaces(kibana)];
|
||||
return [xpackMain(kibana)];
|
||||
};
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import KbnServer, { Server } from 'src/legacy/server/kbn_server';
|
||||
import { Legacy } from 'kibana';
|
||||
import { KibanaRequest } from '../../../../src/core/server';
|
||||
import { SpacesPluginSetup } from '../../../plugins/spaces/server';
|
||||
import { wrapError } from './server/lib/errors';
|
||||
|
||||
export const spaces = (kibana: Record<string, any>) =>
|
||||
new kibana.Plugin({
|
||||
id: 'spaces',
|
||||
configPrefix: 'xpack.spaces',
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
require: ['xpack_main'],
|
||||
config(Joi: any) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
})
|
||||
.unknown()
|
||||
.default();
|
||||
},
|
||||
uiExports: {
|
||||
injectDefaultVars(server: Server) {
|
||||
return {
|
||||
serverBasePath: server.config().get('server.basePath'),
|
||||
activeSpace: null,
|
||||
};
|
||||
},
|
||||
async replaceInjectedVars(
|
||||
vars: Record<string, any>,
|
||||
request: Legacy.Request,
|
||||
server: Server
|
||||
) {
|
||||
// NOTICE: use of `activeSpace` is deprecated and will not be made available in the New Platform.
|
||||
// Known usages:
|
||||
// - x-pack/plugins/infra/public/utils/use_kibana_space_id.ts
|
||||
const spacesPlugin = server.newPlatform.setup.plugins.spaces as SpacesPluginSetup;
|
||||
if (!spacesPlugin) {
|
||||
throw new Error('New Platform XPack Spaces plugin is not available.');
|
||||
}
|
||||
const kibanaRequest = KibanaRequest.from(request);
|
||||
const spaceId = spacesPlugin.spacesService.getSpaceId(kibanaRequest);
|
||||
const spacesClient = await spacesPlugin.spacesService.scopedClient(kibanaRequest);
|
||||
try {
|
||||
vars.activeSpace = {
|
||||
valid: true,
|
||||
space: await spacesClient.get(spaceId),
|
||||
};
|
||||
} catch (e) {
|
||||
vars.activeSpace = {
|
||||
valid: false,
|
||||
error: wrapError(e).output.payload,
|
||||
};
|
||||
}
|
||||
|
||||
return vars;
|
||||
},
|
||||
},
|
||||
|
||||
async init(server: Server) {
|
||||
const kbnServer = (server as unknown) as KbnServer;
|
||||
|
||||
const spacesPlugin = kbnServer.newPlatform.setup.plugins.spaces as SpacesPluginSetup;
|
||||
if (!spacesPlugin) {
|
||||
throw new Error('New Platform XPack Spaces plugin is not available.');
|
||||
}
|
||||
|
||||
server.expose('getSpaceId', (request: Legacy.Request) =>
|
||||
spacesPlugin.spacesService.getSpaceId(request)
|
||||
);
|
||||
server.expose('getActiveSpace', (request: Legacy.Request) =>
|
||||
spacesPlugin.spacesService.getActiveSpace(request)
|
||||
);
|
||||
server.expose('spaceIdToNamespace', spacesPlugin.spacesService.spaceIdToNamespace);
|
||||
server.expose('namespaceToSpaceId', spacesPlugin.spacesService.namespaceToSpaceId);
|
||||
server.expose('getBasePath', spacesPlugin.spacesService.getBasePath);
|
||||
},
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { boomify, isBoom } from 'boom';
|
||||
|
||||
export function wrapError(error: any) {
|
||||
if (isBoom(error)) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return boomify(error, { statusCode: error.status });
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
"kibana/public": ["src/core/public"],
|
||||
"kibana/server": ["src/core/server"],
|
||||
"plugins/xpack_main/*": ["x-pack/legacy/plugins/xpack_main/public/*"],
|
||||
"plugins/spaces/*": ["x-pack/legacy/plugins/spaces/public/*"],
|
||||
"test_utils/*": ["x-pack/test_utils/*"],
|
||||
"fixtures/*": ["src/fixtures/*"]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue