forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from eokoneyo/assign-roles-to-space
Further improvements to spaces role assignment tab
- Loading branch information
Showing
34 changed files
with
1,863 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/spaces/public/management/privilege_api_client.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { PrivilegesAPIClientPublicContract } from '@kbn/security-plugin-types-public'; | ||
|
||
export const createPrivilegeAPIClientMock = (): PrivilegesAPIClientPublicContract => { | ||
return { | ||
getAll: jest.fn(), | ||
}; | ||
}; | ||
|
||
export const getPrivilegeAPIClientMock = jest | ||
.fn() | ||
.mockResolvedValue(createPrivilegeAPIClientMock()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
x-pack/plugins/spaces/public/management/view_space/hooks/view_space_context_provider.tsx
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/spaces/public/management/view_space/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { ComponentProps, PropsWithChildren } from 'react'; | ||
|
||
import { ViewSpaceProvider, type ViewSpaceProviderProps } from './provider'; | ||
import { ViewSpace } from './view_space'; | ||
|
||
type ViewSpacePageProps = ComponentProps<typeof ViewSpace> & ViewSpaceProviderProps; | ||
|
||
export function ViewSpacePage({ | ||
spaceId, | ||
getFeatures, | ||
history, | ||
onLoadSpace, | ||
selectedTabId, | ||
allowFeatureVisibility, | ||
allowSolutionVisibility, | ||
children, | ||
...viewSpaceServicesProps | ||
}: PropsWithChildren<ViewSpacePageProps>) { | ||
return ( | ||
<ViewSpaceProvider {...viewSpaceServicesProps}> | ||
<ViewSpace | ||
spaceId={spaceId} | ||
getFeatures={getFeatures} | ||
history={history} | ||
onLoadSpace={onLoadSpace} | ||
selectedTabId={selectedTabId} | ||
allowFeatureVisibility={allowFeatureVisibility} | ||
allowSolutionVisibility={allowSolutionVisibility} | ||
/> | ||
</ViewSpaceProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/spaces/public/management/view_space/provider/reducers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { type Reducer } from 'react'; | ||
|
||
import type { Role } from '@kbn/security-plugin-types-common'; | ||
|
||
export type IDispatchAction = | ||
| { | ||
/** @description updates a single role record */ | ||
type: 'update_roles' | 'remove_roles'; | ||
payload: Role[]; | ||
} | ||
| { | ||
type: 'string'; | ||
payload: any; | ||
}; | ||
|
||
export interface IViewSpaceStoreState { | ||
/** roles assigned to current space */ | ||
roles: Map<Role['name'], Role>; | ||
} | ||
|
||
export const createSpaceRolesReducer: Reducer<IViewSpaceStoreState, IDispatchAction> = ( | ||
state, | ||
action | ||
) => { | ||
const _state = structuredClone(state); | ||
|
||
switch (action.type) { | ||
case 'update_roles': { | ||
action.payload.forEach((role) => { | ||
_state.roles.set(role.name, role); | ||
}); | ||
|
||
return _state; | ||
} | ||
case 'remove_roles': { | ||
action.payload.forEach((role) => { | ||
_state.roles.delete(role.name); | ||
}); | ||
|
||
return _state; | ||
} | ||
default: { | ||
return _state; | ||
} | ||
} | ||
}; |
Oops, something went wrong.