From f4f406cc64bf1021b26b3efbccef22311b2c548a Mon Sep 17 00:00:00 2001 From: Alexa Vargas <239999+axelavargas@users.noreply.github.com> Date: Thu, 21 Aug 2025 10:19:07 +0200 Subject: [PATCH] Query Library: Rename "Query Library"to "Saved Queries" in Explore components (#109891) * rename query library user interface text with "saved queries" * add missing replacement on "Query history" * fix unit test * Fix test and apply PR feedback --- public/app/features/explore/Explore.test.tsx | 4 ++-- public/app/features/explore/QueryRows.test.tsx | 6 +++--- .../explore/RichHistory/RichHistoryAddToLibrary.tsx | 2 +- public/app/features/explore/SecondaryActions.test.tsx | 4 ++-- public/app/features/explore/SecondaryActions.tsx | 4 ++-- public/app/features/explore/spec/helper/assert.ts | 4 ++-- public/app/features/explore/spec/helper/interactions.ts | 6 +++--- public/app/features/query/components/QueryEditorRow.tsx | 2 +- public/locales/en-US/grafana.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/public/app/features/explore/Explore.test.tsx b/public/app/features/explore/Explore.test.tsx index a59ece64805..e1d4e71ad21 100644 --- a/public/app/features/explore/Explore.test.tsx +++ b/public/app/features/explore/Explore.test.tsx @@ -244,7 +244,7 @@ describe('Explore', () => { }); }); - describe('Query Library Integration', () => { + describe('Saved Queries Integration', () => { it('should enable add query buttons when queryLibraryRef is undefined', async () => { setup({ queryLibraryRef: undefined }); @@ -290,7 +290,7 @@ describe('Explore', () => { await screen.findByTestId(selectors.components.DataSourcePicker.container); const addQueryButton = screen.getByRole('button', { name: /Add query$/i }); - const addFromLibraryButton = screen.getByRole('button', { name: /Add query from library/i }); + const addFromLibraryButton = screen.getByRole('button', { name: /Add from saved queries/i }); expect(addQueryButton).toBeDisabled(); expect(addFromLibraryButton).toBeDisabled(); diff --git a/public/app/features/explore/QueryRows.test.tsx b/public/app/features/explore/QueryRows.test.tsx index cd11f943811..72e7355fd6b 100644 --- a/public/app/features/explore/QueryRows.test.tsx +++ b/public/app/features/explore/QueryRows.test.tsx @@ -94,7 +94,7 @@ describe('Explore QueryRows', () => { expect(await screen.findByLabelText('Query editor row title B')).toBeInTheDocument(); }); - it('Should contain a select query from library button when query library is enabled', async () => { + it('Should contain a select query from library button when saved queries is enabled', async () => { const { store } = setup([{ refId: 'A' }]); render( @@ -108,10 +108,10 @@ describe('Explore QueryRows', () => { // waiting for the component to fully render. await screen.findAllByText('someDs query editor'); - expect(screen.getByLabelText(/Replace with query from library/i)).toBeInTheDocument(); + expect(screen.getByLabelText(/Replace with saved query/i)).toBeInTheDocument(); }); - it('Should not contain a select query from library button when query library is disabled', async () => { + it('Should not contain a select query from library button when saved queries is disabled', async () => { const { store } = setup([{ refId: 'A' }]); render( diff --git a/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx b/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx index 9082d02bfc2..1c56a91e854 100644 --- a/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryAddToLibrary.tsx @@ -28,7 +28,7 @@ export const RichHistoryAddToLibrary = ({ query }: Props) => { } }; - const buttonLabel = t('explore.rich-history-card.add-to-library', 'Add to library'); + const buttonLabel = t('explore.rich-history-card.add-to-library', 'Save query'); return queryLibraryEnabled && !hasBeenSaved ? ( <> diff --git a/public/app/features/explore/SecondaryActions.test.tsx b/public/app/features/explore/SecondaryActions.test.tsx index 37ee5006393..4081b7b2efd 100644 --- a/public/app/features/explore/SecondaryActions.test.tsx +++ b/public/app/features/explore/SecondaryActions.test.tsx @@ -64,7 +64,7 @@ describe('SecondaryActions', () => { expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); - it('should disable both add query buttons when addQueryRowButtonDisabled=true and query library is enabled', () => { + it('should disable both add query buttons when addQueryRowButtonDisabled=true and saved queries is enabled', () => { render( { ); expect(screen.getByRole('button', { name: /Add query$/i })).toBeDisabled(); - expect(screen.getByRole('button', { name: /Add query from library/i })).toBeDisabled(); + expect(screen.getByRole('button', { name: /Add from saved queries/i })).toBeDisabled(); expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); diff --git a/public/app/features/explore/SecondaryActions.tsx b/public/app/features/explore/SecondaryActions.tsx index d3672f6fc32..fd4e29fe016 100644 --- a/public/app/features/explore/SecondaryActions.tsx +++ b/public/app/features/explore/SecondaryActions.tsx @@ -74,7 +74,7 @@ export function SecondaryActions({ {queryLibraryEnabled && ( openQueryLibraryDrawer({ @@ -86,7 +86,7 @@ export function SecondaryActions({ icon="plus" disabled={addQueryRowButtonDisabled} > - Add query from library + Add from saved queries )} diff --git a/public/app/features/explore/spec/helper/assert.ts b/public/app/features/explore/spec/helper/assert.ts index 84da5c925ba..f10a28d2866 100644 --- a/public/app/features/explore/spec/helper/assert.ts +++ b/public/app/features/explore/spec/helper/assert.ts @@ -50,9 +50,9 @@ export const assertAddToQueryLibraryButtonExists = async (value = true) => { expect(withinQueryHistory().getByRole('button', { name: /run query/i })).toBeInTheDocument(); if (value) { - expect(withinQueryHistory().queryByRole('button', { name: /add to library/i })).toBeInTheDocument(); + expect(withinQueryHistory().queryByRole('button', { name: /Save query/i })).toBeInTheDocument(); } else { - expect(withinQueryHistory().queryByRole('button', { name: /add to library/i })).not.toBeInTheDocument(); + expect(withinQueryHistory().queryByRole('button', { name: /Save query/i })).not.toBeInTheDocument(); } }); }; diff --git a/public/app/features/explore/spec/helper/interactions.ts b/public/app/features/explore/spec/helper/interactions.ts index 840eccdee1a..1d8e0914671 100644 --- a/public/app/features/explore/spec/helper/interactions.ts +++ b/public/app/features/explore/spec/helper/interactions.ts @@ -40,18 +40,18 @@ export const openQueryHistory = async () => { }; export const openQueryLibrary = async () => { - const button = screen.getByRole('button', { name: 'Add query from library' }); + const button = screen.getByRole('button', { name: 'Add from saved queries' }); await userEvent.click(button); await waitFor(async () => { const container = screen.getByRole('dialog', { name: /Drawer title/, }); - within(container).getByText('Query library'); + within(container).getByText('Saved queries'); }); }; export const addQueryHistoryToQueryLibrary = async () => { - const button = withinQueryHistory().getByRole('button', { name: /add to library/i }); + const button = withinQueryHistory().getByRole('button', { name: /Save query/i }); await userEvent.click(button); }; diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index d6e58fd8038..d36d72db9a7 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -637,7 +637,7 @@ function ReplaceQueryFromLibrary({ return queryLibraryEnabled ? (