From 612af5ef5501c5c16699ae91c41c479561e7321a Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 3 Dec 2025 13:28:59 +0300 Subject: [PATCH] Search: improve openapi operation ids (#114754) --- package.json | 2 +- .../rtkq/dashboard/v0alpha1/endpoints.gen.ts | 20 +++++------ pkg/registry/apis/dashboard/search.go | 2 ++ .../dashboard.grafana.app-v0alpha1.json | 2 ++ .../api/clients/dashboard/v0alpha1/index.ts | 2 +- .../useFoldersQueryAppPlatform.ts | 14 ++++---- yarn.lock | 34 +++++++++---------- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index f8aee8390ee..987ccf379e7 100644 --- a/package.json +++ b/package.json @@ -427,7 +427,7 @@ "slate": "0.47.9", "slate-plain-serializer": "0.7.13", "slate-react": "0.22.10", - "swagger-ui-react": "5.30.2", + "swagger-ui-react": "5.30.3", "symbol-observable": "4.0.0", "systemjs": "6.15.1", "tslib": "2.8.1", diff --git a/packages/grafana-api-clients/src/clients/rtkq/dashboard/v0alpha1/endpoints.gen.ts b/packages/grafana-api-clients/src/clients/rtkq/dashboard/v0alpha1/endpoints.gen.ts index e2346105856..5d3e72b13aa 100644 --- a/packages/grafana-api-clients/src/clients/rtkq/dashboard/v0alpha1/endpoints.gen.ts +++ b/packages/grafana-api-clients/src/clients/rtkq/dashboard/v0alpha1/endpoints.gen.ts @@ -235,7 +235,7 @@ const injectedRtkApi = api }), invalidatesTags: ['LibraryPanel'], }), - getSearch: build.query({ + searchDashboardsAndFolders: build.query({ query: (queryArg) => ({ url: `/search`, params: { @@ -253,7 +253,7 @@ const injectedRtkApi = api }), providesTags: ['Search'], }), - getSearchSortable: build.query({ + getSortableFields: build.query({ query: () => ({ url: `/search/sortable` }), providesTags: ['Search'], }), @@ -653,8 +653,8 @@ export type UpdateLibraryPanelApiArg = { force?: boolean; patch: Patch; }; -export type GetSearchApiResponse = /** status 200 undefined */ SearchResults; -export type GetSearchApiArg = { +export type SearchDashboardsAndFoldersApiResponse = /** status 200 undefined */ SearchResults; +export type SearchDashboardsAndFoldersApiArg = { /** user query string */ query?: string; /** search dashboards or folders. When empty, this will search both */ @@ -676,7 +676,7 @@ export type GetSearchApiArg = { /** add debugging info that may help explain why the result matched */ explain?: boolean; }; -export type GetSearchSortableApiResponse = /** status 200 undefined */ { +export type GetSortableFieldsApiResponse = /** status 200 undefined */ { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ apiVersion?: string; /** Sortable fields (depends on backend support) */ @@ -684,7 +684,7 @@ export type GetSearchSortableApiResponse = /** status 200 undefined */ { /** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds */ kind?: string; }; -export type GetSearchSortableApiArg = void; +export type GetSortableFieldsApiArg = void; export type ListSnapshotApiResponse = /** status 200 OK */ SnapshotList; export type ListSnapshotApiArg = { /** allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. */ @@ -1262,10 +1262,10 @@ export const { useReplaceLibraryPanelMutation, useDeleteLibraryPanelMutation, useUpdateLibraryPanelMutation, - useGetSearchQuery, - useLazyGetSearchQuery, - useGetSearchSortableQuery, - useLazyGetSearchSortableQuery, + useSearchDashboardsAndFoldersQuery, + useLazySearchDashboardsAndFoldersQuery, + useGetSortableFieldsQuery, + useLazyGetSortableFieldsQuery, useListSnapshotQuery, useLazyListSnapshotQuery, useCreateSnapshotMutation, diff --git a/pkg/registry/apis/dashboard/search.go b/pkg/registry/apis/dashboard/search.go index 19e5b71e0d9..e28eeedcecc 100644 --- a/pkg/registry/apis/dashboard/search.go +++ b/pkg/registry/apis/dashboard/search.go @@ -66,6 +66,7 @@ func (s *SearchHandler) GetAPIRoutes(defs map[string]common.OpenAPIDefinition) * Get: &spec3.Operation{ OperationProps: spec3.OperationProps{ Tags: []string{"Search"}, + OperationId: "searchDashboardsAndFolders", Description: "Dashboard search", Parameters: []*spec3.Parameter{ { @@ -218,6 +219,7 @@ func (s *SearchHandler) GetAPIRoutes(defs map[string]common.OpenAPIDefinition) * Get: &spec3.Operation{ OperationProps: spec3.OperationProps{ Tags: []string{"Search"}, + OperationId: "getSortableFields", Description: "Get sortable fields", Parameters: []*spec3.Parameter{ { diff --git a/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json b/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json index 3b7a79228bc..b65fa2ad0d7 100644 --- a/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json +++ b/pkg/tests/apis/openapi_snapshots/dashboard.grafana.app-v0alpha1.json @@ -1751,6 +1751,7 @@ "Search" ], "description": "Dashboard search", + "operationId": "searchDashboardsAndFolders", "parameters": [ { "name": "namespace", @@ -1891,6 +1892,7 @@ "Search" ], "description": "Get sortable fields", + "operationId": "getSortableFields", "parameters": [ { "name": "namespace", diff --git a/public/app/api/clients/dashboard/v0alpha1/index.ts b/public/app/api/clients/dashboard/v0alpha1/index.ts index 02cbd74b8ed..770a23486e4 100644 --- a/public/app/api/clients/dashboard/v0alpha1/index.ts +++ b/public/app/api/clients/dashboard/v0alpha1/index.ts @@ -2,4 +2,4 @@ import { generatedAPI } from '@grafana/api-clients/rtkq/dashboard/v0alpha1'; export const dashboardAPIv0alpha1 = generatedAPI.enhanceEndpoints({}); -export const { useGetSearchQuery } = dashboardAPIv0alpha1; +export const { useSearchDashboardsAndFoldersQuery } = dashboardAPIv0alpha1; diff --git a/public/app/core/components/NestedFolderPicker/useFoldersQueryAppPlatform.ts b/public/app/core/components/NestedFolderPicker/useFoldersQueryAppPlatform.ts index ae6c8574adb..b169230ccbf 100644 --- a/public/app/core/components/NestedFolderPicker/useFoldersQueryAppPlatform.ts +++ b/public/app/core/components/NestedFolderPicker/useFoldersQueryAppPlatform.ts @@ -13,7 +13,9 @@ import { getPaginationPlaceholders } from '../../../features/browse-dashboards/s import { UseFoldersQueryProps } from './useFoldersQuery'; import { getRootFolderItem } from './utils'; -type GetFolderChildrenQuery = ReturnType>; +type GetFolderChildrenQuery = ReturnType< + ReturnType +>; type GetFolderChildrenRequest = { unsubscribe: () => void; }; @@ -44,9 +46,9 @@ export function useFoldersQueryAppPlatform({ const [emptyFolders, setEmptyFolders] = useState>(new Set()); // Keep a list of selectors for dynamic state selection - const [selectors, setSelectors] = useState>>( - [] - ); + const [selectors, setSelectors] = useState< + Array> + >([]); // This is an aggregated dynamic selector of all the selectors for all the request issued while loading the folder // tree and returns the whole tree that was loaded so far. @@ -92,10 +94,10 @@ export function useFoldersQueryAppPlatform({ const args = { folder: finalParentUid, type: 'folder', permission } as const; // Make a request - const subscription = dispatch(dashboardAPIv0alpha1.endpoints.getSearch.initiate(args)); + const subscription = dispatch(dashboardAPIv0alpha1.endpoints.searchDashboardsAndFolders.initiate(args)); // Add selector for the response to the list so we can then have an aggregated selector for all the folders - const selector = dashboardAPIv0alpha1.endpoints.getSearch.select(args); + const selector = dashboardAPIv0alpha1.endpoints.searchDashboardsAndFolders.select(args); setSelectors((selectors) => selectors.concat(selector)); // the subscriptions are saved in a ref so they can be unsubscribed on unmount diff --git a/yarn.lock b/yarn.lock index 7b9bf525a9f..cb495d132ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19523,7 +19523,7 @@ __metadata: style-loader: "npm:4.0.0" stylelint: "npm:16.23.0" stylelint-config-sass-guidelines: "npm:12.1.0" - swagger-ui-react: "npm:5.30.2" + swagger-ui-react: "npm:5.30.3" symbol-observable: "npm:4.0.0" systemjs: "npm:6.15.1" testing-library-selector: "npm:0.3.1" @@ -22422,6 +22422,17 @@ __metadata: languageName: node linkType: hard +"js-yaml@npm:=4.1.1, js-yaml@npm:^4.1.0": + version: 4.1.1 + resolution: "js-yaml@npm:4.1.1" + dependencies: + argparse: "npm:^2.0.1" + bin: + js-yaml: bin/js-yaml.js + checksum: 10/a52d0519f0f4ef5b4adc1cde466cb54c50d56e2b4a983b9d5c9c0f2f99462047007a6274d7e95617a21d3c91fde3ee6115536ed70991cd645ba8521058b78f77 + languageName: node + linkType: hard + "js-yaml@npm:^3.10.0, js-yaml@npm:^3.13.1": version: 3.14.2 resolution: "js-yaml@npm:3.14.2" @@ -22434,17 +22445,6 @@ __metadata: languageName: node linkType: hard -"js-yaml@npm:^4.1.0": - version: 4.1.1 - resolution: "js-yaml@npm:4.1.1" - dependencies: - argparse: "npm:^2.0.1" - bin: - js-yaml: bin/js-yaml.js - checksum: 10/a52d0519f0f4ef5b4adc1cde466cb54c50d56e2b4a983b9d5c9c0f2f99462047007a6274d7e95617a21d3c91fde3ee6115536ed70991cd645ba8521058b78f77 - languageName: node - linkType: hard - "jsbn@npm:1.1.0": version: 1.1.0 resolution: "jsbn@npm:1.1.0" @@ -31792,9 +31792,9 @@ __metadata: languageName: node linkType: hard -"swagger-ui-react@npm:5.30.2": - version: 5.30.2 - resolution: "swagger-ui-react@npm:5.30.2" +"swagger-ui-react@npm:5.30.3": + version: 5.30.3 + resolution: "swagger-ui-react@npm:5.30.3" dependencies: "@babel/runtime-corejs3": "npm:^7.27.1" "@scarf/scarf": "npm:=1.4.0" @@ -31807,7 +31807,7 @@ __metadata: ieee754: "npm:^1.2.1" immutable: "npm:^3.x.x" js-file-download: "npm:^0.4.12" - js-yaml: "npm:=4.1.0" + js-yaml: "npm:=4.1.1" lodash: "npm:^4.17.21" prop-types: "npm:^15.8.1" randexp: "npm:^0.5.3" @@ -31833,7 +31833,7 @@ __metadata: peerDependencies: react: ">=16.8.0 <20" react-dom: ">=16.8.0 <20" - checksum: 10/814d56c641102d6ba9b9ba1834c1d48279aed0b53bc90956c5515a618944c1dda4ef2c93f3f72ae7f4b9275e226044df59f04b763835d7f59087259140cd7ea5 + checksum: 10/6f466414072806e60a3e36d58029b0679cd80cd9488e79a2142bebcd0829efa587f1b3249c2feab3ab692b3a70f5b90038f3fd14430f8ae41c6ec904f8041f79 languageName: node linkType: hard