diff --git a/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.test.tsx b/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.test.tsx index 486391fec2e..b23434fd2a6 100644 --- a/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.test.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.test.tsx @@ -1,7 +1,6 @@ import { screen } from '@testing-library/react'; import { render } from 'test/test-utils'; -import { OrgRole } from '@grafana/data'; import { contextSrv } from 'app/core/core'; import { QueryLibraryContextProviderMock } from '../QueryLibrary/mocks'; @@ -10,6 +9,7 @@ import { RichHistoryAddToLibrary } from './RichHistoryAddToLibrary'; describe('RichHistoryAddToLibrary', () => { it('should render button when save query is enabled', () => { + contextSrv.isEditor = true; render( @@ -28,7 +28,7 @@ describe('RichHistoryAddToLibrary', () => { expect(screen.queryByRole('button', { name: /Save query/i })).not.toBeInTheDocument(); }); it('should not render button when user has Viewer role', () => { - contextSrv.user.orgRole = OrgRole.Viewer; + contextSrv.isEditor = false; render( diff --git a/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx b/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx index c89764d4aae..1165e71ff42 100644 --- a/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx @@ -31,7 +31,7 @@ export const RichHistoryAddToLibrary = ({ query }: Props) => { const buttonLabel = t('explore.rich-history-card.add-to-library', 'Save query'); - if (contextSrv.hasRole('Viewer')) { + if (!contextSrv.isEditor) { return null; }