From ef458b79d08c5939ea0a414e3372d490d6b20d7b Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 25 May 2022 08:16:14 -0400 Subject: [PATCH] AccessControl: Pass current org id to UsersTable (#49584) (#49606) * Pass current org id to UsersTable * Mock contextSrv and update snapshot (cherry picked from commit ef6b53ed23763ffa3bc1e918fb332891fbef14c2) Co-authored-by: Karl Persson --- .betterer.results | 2 +- public/app/features/users/UsersListPage.test.tsx | 6 ++++++ public/app/features/users/UsersListPage.tsx | 2 ++ .../users/__snapshots__/UsersListPage.test.tsx.snap | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.betterer.results b/.betterer.results index 7c54b12b30d..59543858a39 100644 --- a/.betterer.results +++ b/.betterer.results @@ -203,7 +203,7 @@ exports[`no enzyme tests`] = { "public/app/features/teams/TeamSettings.test.tsx:2043271249": [ [0, 19, 13, "RegExp match", "2409514259"] ], - "public/app/features/users/UsersListPage.test.tsx:3908145117": [ + "public/app/features/users/UsersListPage.test.tsx:2518052139": [ [0, 19, 13, "RegExp match", "2409514259"] ], "public/app/features/users/UsersTable.test.tsx:263958312": [ diff --git a/public/app/features/users/UsersListPage.test.tsx b/public/app/features/users/UsersListPage.test.tsx index bc334b6287a..e5a2837e98f 100644 --- a/public/app/features/users/UsersListPage.test.tsx +++ b/public/app/features/users/UsersListPage.test.tsx @@ -12,6 +12,12 @@ jest.mock('../../core/app_events', () => ({ emit: jest.fn(), })); +jest.mock('app/core/services/context_srv', () => ({ + contextSrv: { + user: { orgId: 1 }, + }, +})); + const setup = (propOverrides?: object) => { const props: Props = { navModel: { diff --git a/public/app/features/users/UsersListPage.tsx b/public/app/features/users/UsersListPage.tsx index f53b3f47b9f..803deead884 100644 --- a/public/app/features/users/UsersListPage.tsx +++ b/public/app/features/users/UsersListPage.tsx @@ -5,6 +5,7 @@ import { renderMarkdown } from '@grafana/data'; import { HorizontalGroup, Pagination, VerticalGroup } from '@grafana/ui'; import Page from 'app/core/components/Page/Page'; import { getNavModel } from 'app/core/selectors/navModel'; +import { contextSrv } from 'app/core/services/context_srv'; import { OrgUser, OrgRole, StoreState } from 'app/types'; import InviteesTable from '../invites/InviteesTable'; @@ -106,6 +107,7 @@ export class UsersListPage extends PureComponent { this.onRoleChange(role, user)} onRemoveUser={(user) => this.props.removeUser(user.userId)} /> diff --git a/public/app/features/users/__snapshots__/UsersListPage.test.tsx.snap b/public/app/features/users/__snapshots__/UsersListPage.test.tsx.snap index 08b3ba0ec22..01d1dbeeba2 100644 --- a/public/app/features/users/__snapshots__/UsersListPage.test.tsx.snap +++ b/public/app/features/users/__snapshots__/UsersListPage.test.tsx.snap @@ -26,6 +26,7 @@ exports[`Render should render List page 1`] = `