Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@gmail.com>
  • Loading branch information
legrego and azasypkin authored Nov 19, 2020
1 parent 0a4a045 commit d8c3de0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi
: undefined,
});

const spaceIdToNamespace = (spaceId?: string): string | undefined => {
const spaceIdToNamespace = (spaceId?: string) => {
return plugins.spaces && spaceId
? plugins.spaces.spacesService.spaceIdToNamespace(spaceId)
: undefined;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerts/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class AlertingPlugin {
includedHiddenTypes: ['alert'],
});

const spaceIdToNamespace = (spaceId?: string): string | undefined => {
const spaceIdToNamespace = (spaceId?: string) => {
return plugins.spaces && spaceId
? plugins.spaces.spacesService.spaceIdToNamespace(spaceId)
: undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const setup = ({ securityEnabled = false }: Opts = {}) => {
if (!space) {
throw SavedObjectsErrorHelpers.createGenericNotFoundError('space', spaceId);
}
return Promise.resolve(space);
return space;
});

const authorization = authorizationMock.create({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class SecureSpacesClientWrapper implements ISpacesClient {
private readonly authorization: AuthorizationServiceSetup,
private readonly legacyAuditLogger: LegacySpacesAuditLogger
) {
this.useRbac = authorization.mode.useRbacForRequest(request);
}

public async getAll({
Expand Down Expand Up @@ -170,7 +169,7 @@ export class SecureSpacesClientWrapper implements ISpacesClient {
}

private async ensureAuthorizedGlobally(action: string, method: string, forbiddenMessage: string) {
const checkPrivileges = this.authorization!.checkPrivilegesWithRequest(this.request);
const checkPrivileges = this.authorization.checkPrivilegesWithRequest(this.request);
const { username, hasAllRequested } = await checkPrivileges.globally({ kibana: action });

if (hasAllRequested) {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/spaces/server/spaces_client/spaces_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Boom from '@hapi/boom';
import { omit } from 'lodash';
import { ISavedObjectsRepository } from 'src/core/server';
import { PublicMethodsOf } from '@kbn/utility-types';
import { isReservedSpace } from '../../common/is_reserved_space';
import { isReservedSpace } from '../../common';
import { Space } from '../../common/model/space';
import { ConfigType } from '../config';
import { GetAllSpacesPurpose, GetSpaceResult } from '../../common/model/types';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class SpacesClient {
return savedObjects.map(this.transformSavedObjectToSpace);
}

public async get(id: string): Promise<Space> {
public async get(id: string) {
const savedObject = await this.repository.get('space', id);
return this.transformSavedObjectToSpace(savedObject);
}
Expand Down Expand Up @@ -101,7 +101,7 @@ export class SpacesClient {
await this.repository.delete('space', id);
}

private transformSavedObjectToSpace(savedObject: any): Space {
private transformSavedObjectToSpace(savedObject: SavedObject<any>) {
return {
id: savedObject.id,
...savedObject.attributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface SpacesClientServiceSetup {
/**
* Sets the factory that should be used to create the Saved Objects Repository
* whenever a new instance of the SpacesClient is created. By default, a repository
* scoped the current user will be created.
* scoped to the current user will be created.
*/
setClientRepositoryFactory: (factory: SpacesClientRepositoryFactory) => void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { Subscription } from 'rxjs';
import type { KibanaRequest, IBasePath } from 'src/core/server';
import { SpacesClientServiceStart } from '../spaces_client';
import { getSpaceIdFromPath } from '../../common/lib/spaces_url_parser';
import { getSpaceIdFromPath } from '../../common';
import { DEFAULT_SPACE_ID } from '../../common/constants';
import { spaceIdToNamespace, namespaceToSpaceId } from '../lib/utils/namespace';
import { Space } from '..';
Expand Down

0 comments on commit d8c3de0

Please sign in to comment.