Skip to content

chore: replace hardcoded query-library component ID with PluginExtensionExposedComponents enum #1099

@nicwestvold

Description

@nicwestvold

What is this?

Follow-up from PR #1064 (saved queries). The string 'grafana/query-library-context/v1' is hardcoded in two places:

  • src/shared/savedQueries/SaveQueryButton.tsx
  • src/shared/savedQueries/LoadQueryScene.tsx

Extract it into a shared constant using the same backwards-compatible pattern used for ADD_TO_DASHBOARD_COMPONENT_ID in src/shared/GmdVizPanel/components/addToDashboard/constants.ts (#890):

import { PluginExtensionExposedComponents } from '@grafana/data';

export const QUERY_LIBRARY_COMPONENT_ID =
    PluginExtensionExposedComponents?.OpenQueryLibraryV1 || 'grafana/query-library-context/v1';

PluginExtensionExposedComponents.OpenQueryLibraryV1 was added to the Grafana repo in grafana/grafana#116622 but is not yet in the published @grafana/data@12.3.2. The ?. fallback ensures backwards compatibility in the meantime.

Note: src/plugin.json also contains the string but must remain as-is (JSON config).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions