From bdf9e1d668a7eff77f4cd2f88cf1ed84b328a450 Mon Sep 17 00:00:00 2001 From: Enrico Alvarenga Date: Wed, 2 Aug 2023 13:46:39 -0700 Subject: [PATCH] refactor: move config to search-backend plugin Signed-off-by: Enrico Alvarenga --- .../uffizzi.production.app-config.yaml | 4 ++ plugins/search-backend/README.md | 16 ++++++++ plugins/search-backend/config.d.ts | 16 ++++++++ plugins/search-react/api-report.md | 3 -- .../src/context/SearchContext.tsx | 2 +- plugins/search-react/src/context/index.tsx | 1 - plugins/search-react/src/index.ts | 1 - plugins/search/README.md | 14 ------- plugins/search/config.d.ts | 40 ------------------- plugins/search/package.json | 6 +-- 10 files changed, 39 insertions(+), 64 deletions(-) delete mode 100644 plugins/search/config.d.ts diff --git a/.github/uffizzi/uffizzi.production.app-config.yaml b/.github/uffizzi/uffizzi.production.app-config.yaml index 4f64e5ffcb..2f84e766d7 100644 --- a/.github/uffizzi/uffizzi.production.app-config.yaml +++ b/.github/uffizzi/uffizzi.production.app-config.yaml @@ -280,3 +280,7 @@ gocd: permission: enabled: true + +search: + query: + pageLimit: 100 \ No newline at end of file diff --git a/plugins/search-backend/README.md b/plugins/search-backend/README.md index b89c6acf68..3c85258b2c 100644 --- a/plugins/search-backend/README.md +++ b/plugins/search-backend/README.md @@ -10,3 +10,19 @@ centralized in the `search` plugin README.md. For a better overview of how the search platform is put together, check the [Backstage Search Architecture](https://backstage.io/docs/features/search/architecture) documentation. + +### Optional Settings + +Configure the search query values via `app-config.yaml` to define how it behaves by default. + +```yaml +# app-config.yaml +search: + query: + pageLimit: 50 +``` + +Acceptable values for `pageLimit` are `10`, `25`, `50` or `100`. + +**NOTE**: Currently this configuration only reflects the initial state of the Search React components. This means that +it defines how it behaves when it is first loaded or reset. diff --git a/plugins/search-backend/config.d.ts b/plugins/search-backend/config.d.ts index 3dbdf78dfe..ff225be500 100644 --- a/plugins/search-backend/config.d.ts +++ b/plugins/search-backend/config.d.ts @@ -40,5 +40,21 @@ export interface Config { */ queryLatencyBudgetMs?: number; }; + + /** + * An object representing the default search query configuration. + * By configuring and modifying the values of this object, + * you can customize the default values of the search queries + * and define how it behaves by default. + */ + query?: { + /** + * A number indicating the maximum number of results to be returned + * per page during pagination. + * + * @visibility frontend + */ + pageLimit?: 10 | 25 | 50 | 100; + }; }; } diff --git a/plugins/search-react/api-report.md b/plugins/search-react/api-report.md index f938906d3f..97c8300c14 100644 --- a/plugins/search-react/api-report.md +++ b/plugins/search-react/api-report.md @@ -61,9 +61,6 @@ export type DefaultResultListItemProps = { toggleModal?: () => void; }; -// @public -export const getSearchContextInitialStateDefaults: () => SearchContextState; - // @public (undocumented) export const HighlightedSearchResultText: ( props: HighlightedSearchResultTextProps, diff --git a/plugins/search-react/src/context/SearchContext.tsx b/plugins/search-react/src/context/SearchContext.tsx index ea041d6bc1..e62aeedbc0 100644 --- a/plugins/search-react/src/context/SearchContext.tsx +++ b/plugins/search-react/src/context/SearchContext.tsx @@ -249,7 +249,7 @@ export const SearchContextProvider = (props: SearchContextProviderProps) => { ...searchInitialState, ...(initialState || {}), pageLimit: - configApi.getOptionalNumber('app.search.query.pageLimit') || + configApi.getOptionalNumber('search.query.pageLimit') || initialState?.pageLimit, }; diff --git a/plugins/search-react/src/context/index.tsx b/plugins/search-react/src/context/index.tsx index f00ba3ecfa..720af8a949 100644 --- a/plugins/search-react/src/context/index.tsx +++ b/plugins/search-react/src/context/index.tsx @@ -18,7 +18,6 @@ export { SearchContextProvider, useSearch, useSearchContextCheck, - getSearchContextInitialStateDefaults, } from './SearchContext'; export type { diff --git a/plugins/search-react/src/index.ts b/plugins/search-react/src/index.ts index 250bb2e893..8b234e3c05 100644 --- a/plugins/search-react/src/index.ts +++ b/plugins/search-react/src/index.ts @@ -28,7 +28,6 @@ export { SearchContextProvider, useSearch, useSearchContextCheck, - getSearchContextInitialStateDefaults, } from './context'; export type { SearchContextProviderProps, diff --git a/plugins/search/README.md b/plugins/search/README.md index f7dbcd9617..3803b71e43 100644 --- a/plugins/search/README.md +++ b/plugins/search/README.md @@ -8,20 +8,6 @@ Development is ongoing. You can follow the progress and contribute at the Backst Run `yarn dev` in the root directory, and then navigate to [/search](http://localhost:3000/search) to check out the plugin. -### Optional Settings - -Configure the SearchPage component initial state via `app-config.yaml` to define how it behaves when it is first loaded or reset. - -```yaml -# app-config.yaml -app: - search: - initialState: - pageLimit: 50 -``` - -Acceptable values for `pageLimit` are `10`, `25`, `50` or `100`. - ### Areas of Responsibility This search plugin is primarily responsible for the following: diff --git a/plugins/search/config.d.ts b/plugins/search/config.d.ts deleted file mode 100644 index 7ec00425d3..0000000000 --- a/plugins/search/config.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2023 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export interface Config { - app: { - /** - * Configuration options for the search plugin - */ - search?: { - /** - * An object representing the default search query configuration. - * By configuring and modifying the values of this object, - * you can customize the default values of the search component - * and define how it behaves when it is first loaded or reset. - */ - query?: { - /** - * A number indicating the maximum number of results to be returned - * per page during pagination. - * - * @visibility frontend - */ - pageLimit?: 10 | 25 | 50 | 100; - }; - }; - }; -} diff --git a/plugins/search/package.json b/plugins/search/package.json index e155783fc8..3bca411e3e 100644 --- a/plugins/search/package.json +++ b/plugins/search/package.json @@ -70,8 +70,6 @@ "msw": "^1.0.0" }, "files": [ - "dist", - "config.d.ts" - ], - "configSchema": "config.d.ts" + "dist" + ] }