Skip to content

Commit

Permalink
update spacesPlugin name. update current user check
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Mar 4, 2020
1 parent d9d5f73 commit 9759791
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class MlServerPlugin {
mlLicense: this.mlLicense,
};

annotationRoutes(routeInit, plugins?.security);
annotationRoutes(routeInit, plugins.security);
calendars(routeInit);
dataFeedRoutes(routeInit);
dataFrameAnalyticsRoutes(routeInit);
Expand All @@ -117,7 +117,7 @@ export class MlServerPlugin {
resultsServiceRoutes(routeInit);
jobValidationRoutes(routeInit, this.version);
systemRoutes(routeInit, {
spacesPlugin: plugins.spaces,
spaces: plugins.spaces,
cloud: plugins.cloud,
});
initMlServerLog({ log: this.log });
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/ml/server/routes/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ export function annotationRoutes(
const { indexAnnotation } = annotationServiceProvider(context);

const currentUser =
securityPlugin !== undefined && securityPlugin.authc.getCurrentUser(request);
const user = currentUser ? currentUser : {};
securityPlugin !== undefined ? securityPlugin.authc.getCurrentUser(request) : {};
// @ts-ignore username doesn't exist on {}
const resp = await indexAnnotation(request.body, user.username || ANNOTATION_USER_UNKNOWN);
const username = currentUser?.username ?? ANNOTATION_USER_UNKNOWN;
const resp = await indexAnnotation(request.body, username);

return response.ok({
body: resp,
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/ml/server/routes/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { RouteInitialization, SystemRouteDeps } from '../types';
*/
export function systemRoutes(
{ router, mlLicense }: RouteInitialization,
{ spacesPlugin, cloud }: SystemRouteDeps
{ spaces, cloud }: SystemRouteDeps
) {
async function getNodeCount(context: RequestHandlerContext) {
const filterPath = 'nodes.*.attributes';
Expand Down Expand Up @@ -120,8 +120,8 @@ export function systemRoutes(
const ignoreSpaces = request.query && request.query.ignoreSpaces === 'true';
// if spaces is disabled force isMlEnabledInSpace to be true
const { isMlEnabledInSpace } =
spacesPlugin !== undefined
? spacesUtilsProvider(spacesPlugin, (request as unknown) as Request)
spaces !== undefined
? spacesUtilsProvider(spaces, (request as unknown) as Request)
: { isMlEnabledInSpace: async () => true };

const { getPrivileges } = privilegesProvider(
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface LicenseCheckResult {

export interface SystemRouteDeps {
cloud: CloudSetup;
spacesPlugin?: SpacesPluginSetup;
spaces?: SpacesPluginSetup;
}

export interface PluginsSetup {
Expand Down

0 comments on commit 9759791

Please sign in to comment.