Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
13b3038
Add write-restricted dashboards UI
kowalczyk-krzysztof Jul 27, 2025
dcc3d83
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 3, 2025
532aaf9
Test fixes
kowalczyk-krzysztof Sep 3, 2025
1ddc059
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 3, 2025
7097c8d
Fix tests
kowalczyk-krzysztof Sep 3, 2025
158a7e8
Add more tests
kowalczyk-krzysztof Sep 3, 2025
77cfad7
More tests
kowalczyk-krzysztof Sep 3, 2025
8929f79
Dont use bulk get author names
kowalczyk-krzysztof Sep 4, 2025
1fdcefe
Use query data directly
kowalczyk-krzysztof Sep 4, 2025
8f9b06f
Fix type
kowalczyk-krzysztof Sep 4, 2025
ac72605
Tsconfig update
kowalczyk-krzysztof Sep 4, 2025
baa4ed1
Remove unneeded mappings additions
kowalczyk-krzysztof Sep 4, 2025
381e70d
Changes import type
kowalczyk-krzysztof Sep 4, 2025
1f3e28c
Change type import
kowalczyk-krzysztof Sep 4, 2025
e657c1e
Change type import
kowalczyk-krzysztof Sep 4, 2025
3ecee85
Change type import
kowalczyk-krzysztof Sep 4, 2025
8b8b677
Remove author name
kowalczyk-krzysztof Sep 4, 2025
6711f3f
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 4, 2025
1d9612c
Change to package
kowalczyk-krzysztof Sep 4, 2025
d2d0848
Export types
kowalczyk-krzysztof Sep 4, 2025
f844d33
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 4, 2025
f293a07
type fix
kowalczyk-krzysztof Sep 4, 2025
b301477
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 4, 2025
c915f8d
Remove unusued files
kowalczyk-krzysztof Sep 4, 2025
889e098
Code cleanup
kowalczyk-krzysztof Sep 4, 2025
515cf9d
Rename method
kowalczyk-krzysztof Sep 4, 2025
0741e74
Fix package owner
kowalczyk-krzysztof Sep 4, 2025
844b707
Code cleanup
kowalczyk-krzysztof Sep 4, 2025
087746e
Fix listing page tests
kowalczyk-krzysztof Sep 5, 2025
a140efe
Move strings
kowalczyk-krzysztof Sep 5, 2025
dc83942
Change packasge architecture
kowalczyk-krzysztof Sep 5, 2025
5a47e11
Remove invalid reference
kowalczyk-krzysztof Sep 5, 2025
f674254
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 5, 2025
31d3624
Move AccessModeContainer
kowalczyk-krzysztof Sep 5, 2025
1c2d022
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 5, 2025
0a2e894
Remove dashboard references
kowalczyk-krzysztof Sep 5, 2025
8b64440
CR changes
kowalczyk-krzysztof Sep 5, 2025
43b573b
tsocnfig fix
kowalczyk-krzysztof Sep 5, 2025
a5dab3b
Add missing refs
kowalczyk-krzysztof Sep 5, 2025
68928c8
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 5, 2025
4f59179
Use same constant everywhere
kowalczyk-krzysztof Sep 6, 2025
6cbeda3
Merge conflicts fix
kowalczyk-krzysztof Sep 8, 2025
2cca054
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 8, 2025
14db110
Move access control to services
kowalczyk-krzysztof Sep 10, 2025
4ec2653
Handle view_mode_manager
kowalczyk-krzysztof Sep 11, 2025
ba7a5fb
Move to load_dashboard_api
kowalczyk-krzysztof Sep 11, 2025
8153105
Change view mode condition
kowalczyk-krzysztof Sep 11, 2025
f1263af
Fix wrong content_id import
kowalczyk-krzysztof Sep 11, 2025
43dddb4
Fix mocks
kowalczyk-krzysztof Sep 11, 2025
bb80c00
Make user optional
kowalczyk-krzysztof Sep 12, 2025
09e3cbf
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 12, 2025
ee232f8
CR changes
kowalczyk-krzysztof Sep 15, 2025
97ee885
Yarn lock cleanup
kowalczyk-krzysztof Sep 15, 2025
1fe849a
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 15, 2025
7be0d34
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 16, 2025
691f02e
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 17, 2025
68c48f0
Some CR changes
kowalczyk-krzysztof Sep 17, 2025
5142786
Wrap in internal api provider
kowalczyk-krzysztof Sep 17, 2025
837eefa
Revert "Wrap in internal api provider"
kowalczyk-krzysztof Sep 18, 2025
96514d2
Cleanup
kowalczyk-krzysztof Sep 18, 2025
1095946
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 19, 2025
6b19752
Add feature flag checks
kowalczyk-krzysztof Sep 19, 2025
4dab837
Improve feature flag behavior
kowalczyk-krzysztof Sep 22, 2025
2062000
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 23, 2025
2274242
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 25, 2025
976028e
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 26, 2025
1a4f53b
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 26, 2025
fab8899
Fix typo
kowalczyk-krzysztof Sep 28, 2025
4c10159
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 29, 2025
8f8faf1
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 30, 2025
8265787
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Sep 30, 2025
b0a17cd
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 1, 2025
de8543c
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 5, 2025
e160d70
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
elasticmachine Oct 6, 2025
74c636a
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 6, 2025
1bde627
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 7, 2025
f355a0b
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 7, 2025
b5ba2b4
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 8, 2025
d29e844
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 21, 2025
e474942
change supportsAccessControl to true
kowalczyk-krzysztof Oct 21, 2025
d6a3583
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 22, 2025
ccfbaef
Fix callout to work with new changes
kowalczyk-krzysztof Oct 23, 2025
4383a3d
Remove unneeded promise return
kowalczyk-krzysztof Oct 23, 2025
34c1e45
Change read_only const to write_restricted
kowalczyk-krzysztof Oct 23, 2025
b399ac6
Add tooltip on permissions change
kowalczyk-krzysztof Oct 23, 2025
42b56ba
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 23, 2025
8a7eee8
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 23, 2025
9a5bf3a
Fix tabbed_modal test
kowalczyk-krzysztof Oct 23, 2025
79146c3
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 27, 2025
668a91e
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 27, 2025
600aca1
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 28, 2025
2da38d4
Fix mock
kowalczyk-krzysztof Oct 28, 2025
85a1058
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 30, 2025
fdebe56
Fix access mode container tooltip
kowalczyk-krzysztof Oct 30, 2025
16631fb
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Oct 31, 2025
5ab0962
Fix duplicate modal
kowalczyk-krzysztof Nov 1, 2025
16bd3ee
Hide permission select on new dashboard
kowalczyk-krzysztof Nov 1, 2025
a196841
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 3, 2025
fda75da
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 4, 2025
4e472b9
Conflict resolution
kowalczyk-krzysztof Nov 4, 2025
81dbf5b
Fix type error
kowalczyk-krzysztof Nov 4, 2025
951727a
Fix button logic
kowalczyk-krzysztof Nov 4, 2025
589a068
Fix button state
kowalczyk-krzysztof Nov 4, 2025
ba1ca11
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 5, 2025
eb1c7a3
Remove permission select in managed dashboard
kowalczyk-krzysztof Nov 5, 2025
73eb003
Diffrentiate space icons
kowalczyk-krzysztof Nov 6, 2025
72d711b
Hide permission select for viewer role user
kowalczyk-krzysztof Nov 6, 2025
3cf8c2c
Optional chaining on space
kowalczyk-krzysztof Nov 6, 2025
01fb5f7
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 8, 2025
45b6910
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 11, 2025
def5364
Fix after create changes
kowalczyk-krzysztof Nov 11, 2025
a017792
Pass feature flag check to create endpoint
kowalczyk-krzysztof Nov 11, 2025
6e92e32
Use typeRegistry instead of passing down arguments
kowalczyk-krzysztof Nov 12, 2025
125f1bb
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 12, 2025
927a185
Use new tsconfig extends
kowalczyk-krzysztof Nov 12, 2025
8f310e6
Merge branch 'main' into feat/read-only-dashboards-sharedux-ui
kowalczyk-krzysztof Nov 12, 2025
a163801
Changes after search endpoint
kowalczyk-krzysztof Nov 12, 2025
9e6f998
Merge branch 'security/read-only-dashboards' into feat/read-only-dash…
kowalczyk-krzysztof Nov 13, 2025
53013c0
Changes from node scripts/lint_ts_projects --fix
kibanamachine Nov 13, 2025
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ src/platform/packages/private/shared-ux/storybook/config @elastic/appex-sharedux
src/platform/packages/shared/chart-expressions-common @elastic/kibana-visualizations
src/platform/packages/shared/chart-test-jest-helpers @elastic/kibana-visualizations
src/platform/packages/shared/cloud @elastic/kibana-core
src/platform/packages/shared/content-management/access_control/access_control_public @elastic/appex-sharedux
src/platform/packages/shared/content-management/access_control/access_control_server @elastic/appex-sharedux
src/platform/packages/shared/content-management/content_editor @elastic/appex-sharedux
src/platform/packages/shared/content-management/content_insights/content_insights_public @elastic/appex-sharedux
src/platform/packages/shared/content-management/content_insights/content_insights_server @elastic/appex-sharedux
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@
"@kbn/connector-specs": "link:src/platform/packages/shared/kbn-connector-specs",
"@kbn/console-plugin": "link:src/platform/plugins/shared/console",
"@kbn/content-connectors-plugin": "link:x-pack/platform/plugins/shared/content_connectors",
"@kbn/content-management-access-control-public": "link:src/platform/packages/shared/content-management/access_control/access_control_public",
"@kbn/content-management-access-control-server": "link:src/platform/packages/shared/content-management/access_control/access_control_server",
"@kbn/content-management-content-editor": "link:src/platform/packages/shared/content-management/content_editor",
"@kbn/content-management-content-insights-public": "link:src/platform/packages/shared/content-management/content_insights/content_insights_public",
"@kbn/content-management-content-insights-server": "link:src/platform/packages/shared/content-management/content_insights/content_insights_server",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/content-management-access-control-public

Helpers for access control management.
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { AccessControlClient, type AccessControlClientPublic } from './src';
export { AccessModeContainer } from './src';
export type {
CheckGlobalPrivilegeResponse,
ChangeAccesModeParameters,
ChangeAccessModeResponse,
CheckUserAccessControlParameters,
CanManageContentControlParameters,
} from './src';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../../../../..',
roots: [
'<rootDir>/src/platform/packages/shared/content-management/access_control/access_control_public',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "shared-common",
"id": "@kbn/content-management-access-control-public",
"owner": [
"@elastic/appex-sharedux"
],
"group": "platform",
"visibility": "shared"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/content-management-access-control-public",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { HttpStart } from '@kbn/core-http-browser';
import type { SavedObjectAccessControl } from '@kbn/core-saved-objects-common';
import type {
CanManageContentControlParameters,
ChangeAccesModeParameters,
ChangeAccessModeResponse,
CheckGlobalPrivilegeResponse,
CheckUserAccessControlParameters,
IsAccessControlEnabledResponse,
} from './types';

export interface AccessControlClientPublic {
checkGlobalPrivilege(contentTypeId: string): Promise<CheckGlobalPrivilegeResponse>;
changeAccessMode({
objects,
accessMode,
}: ChangeAccesModeParameters): Promise<ChangeAccessModeResponse>;
canManageAccessControl(params: CanManageContentControlParameters): Promise<boolean>;
checkUserAccessControl(params: CheckUserAccessControlParameters): boolean;
isInEditAccessMode(accessControl?: Partial<SavedObjectAccessControl>): boolean;
isAccessControlEnabled(): Promise<boolean>;
}

export class AccessControlClient implements AccessControlClientPublic {
constructor(
private readonly deps: {
http: HttpStart;
}
) {}

async checkGlobalPrivilege(contentTypeId: string): Promise<CheckGlobalPrivilegeResponse> {
const response = await this.deps.http.get<CheckGlobalPrivilegeResponse>(
`/internal/access_control/global_access/${contentTypeId}`
);

return {
isGloballyAuthorized: response?.isGloballyAuthorized,
};
}

async changeAccessMode({
objects,
accessMode,
}: ChangeAccesModeParameters): Promise<ChangeAccessModeResponse> {
const { result } = await this.deps.http.post<ChangeAccessModeResponse>(
`/internal/access_control/change_access_mode`,
{
body: JSON.stringify({ objects, accessMode }),
}
);

return {
result,
};
}

async canManageAccessControl({
accessControl,
createdBy,
userId,
contentTypeId,
}: CanManageContentControlParameters): Promise<boolean> {
const { isGloballyAuthorized } = await this.checkGlobalPrivilege(contentTypeId);
const canManage = this.checkUserAccessControl({
accessControl,
createdBy,
userId,
});
return isGloballyAuthorized || canManage;
}

checkUserAccessControl({
accessControl,
createdBy,
userId,
}: CheckUserAccessControlParameters): boolean {
if (!userId) {
return false;
}

if (!accessControl?.owner) {
// New saved object
if (!createdBy) {
return true;
}
return userId === createdBy;
}

return userId === accessControl.owner;
}

isInEditAccessMode(accessControl?: Partial<SavedObjectAccessControl>): boolean {
return (
!accessControl ||
accessControl.accessMode === undefined ||
accessControl.accessMode === 'default'
);
}

async isAccessControlEnabled(): Promise<boolean> {
const response = await this.deps.http.get<IsAccessControlEnabledResponse>(
'/internal/access_control/is_enabled'
);

return response?.isAccessControlEnabled ?? false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import { renderWithI18n } from '@kbn/test-jest-helpers';
import { AccessModeContainer } from './access_mode_container';
import type { SavedObjectAccessControl } from '@kbn/core-saved-objects-common';
import { act, waitFor, screen } from '@testing-library/react';

describe('Access Mode Container', () => {
const mockAccessControlClient = {
canManageAccessControl: jest.fn(),
isInEditAccessMode: jest.fn(),
checkGlobalPrivilege: jest.fn(),
changeAccessMode: jest.fn(),
checkUserAccessControl: jest.fn(),
isAccessControlEnabled: jest.fn(),
} as any;

const mockGetActiveSpace = jest.fn();
const mockGetCurrentUser = jest.fn();

beforeAll(() => {
mockGetActiveSpace.mockResolvedValue({
name: 'Default Space',
});

mockGetCurrentUser.mockResolvedValue({
uid: 'user-id',
});

mockAccessControlClient.isAccessControlEnabled.mockResolvedValue(true);
});

afterEach(() => {
jest.clearAllMocks();
});

const getDefaultProps = (accessControl?: Partial<SavedObjectAccessControl>) => ({
onChangeAccessMode: jest.fn(),
accessControl,
getCurrentUser: mockGetCurrentUser,
accessControlClient: mockAccessControlClient,
getActiveSpace: mockGetActiveSpace,
contentTypeId: 'dashboard',
});

it('should render access mode container', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(true);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

const accessControl: SavedObjectAccessControl = { owner: 'user-id', accessMode: 'default' };

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(accessControl)} />);
});

const container = screen.getByTestId('accessModeContainer');
expect(container).toBeInTheDocument();
});

it('should render access mode select when current user can manage access control', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(true);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

const accessControl: SavedObjectAccessControl = { owner: 'user-id', accessMode: 'default' };

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(accessControl)} />);
});

const select = screen.getByTestId('accessModeSelect');

expect(select).toBeInTheDocument();
});

it('should not render access mode select when accessControl is undefined', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(false);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(undefined)} />);
});

const select = screen.queryByTestId('dashboardAccessModeSelect');

await waitFor(() => {
expect(select).not.toBeInTheDocument();
});
});

it('should not render access mode select when current user cannot manage access control', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(false);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

const accessControl: SavedObjectAccessControl = { owner: 'user-id2', accessMode: 'default' };

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(accessControl)} />);
});

const select = screen.queryByTestId('dashboardAccessModeSelect');

await waitFor(() => {
expect(select).not.toBeInTheDocument();
});
});

it('should render space name', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(false);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(undefined)} />);
});

const spaceName = screen.getByText(/Default Space/i);

await waitFor(() => {
expect(spaceName).toBeInTheDocument();
});
});

it('should render description tooltip when current user cannot manage access control', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(false);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

const accessControl: SavedObjectAccessControl = { owner: 'user-id2', accessMode: 'default' };

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(accessControl)} />);
});

const tooltip = screen.getByTestId('accessModeContainerDescriptionTooltip');

await waitFor(() => {
expect(tooltip).toBeInTheDocument();
});
});

it('should not render description tooltip when current user can manage access control', async () => {
mockAccessControlClient.canManageAccessControl.mockResolvedValue(true);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

const accessControl: SavedObjectAccessControl = { owner: 'user-id', accessMode: 'default' };

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(accessControl)} />);
});

const tooltip = screen.queryByTestId('accessModeContainerDescriptionTooltip');

await waitFor(() => {
expect(tooltip).not.toBeInTheDocument();
});
});

it('should not render anything when access control is disabled', async () => {
mockAccessControlClient.isAccessControlEnabled.mockResolvedValueOnce(false);
mockAccessControlClient.canManageAccessControl.mockResolvedValue(true);
mockAccessControlClient.isInEditAccessMode.mockReturnValue(true);

const accessControl: SavedObjectAccessControl = { owner: 'user-id', accessMode: 'default' };

await act(async () => {
renderWithI18n(<AccessModeContainer {...getDefaultProps(accessControl)} />);
});

const container = screen.queryByTestId('accessModeContainer');

await waitFor(() => {
expect(container).not.toBeInTheDocument();
});
});
});
Loading