feat(adr): create search result item extension

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2023-09-28 21:22:49 +02:00
parent ec01b3dad7
commit ca957d7a7d
5 changed files with 74 additions and 18 deletions
+12
View File
@@ -3,8 +3,16 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { BackstagePlugin } from '@backstage/frontend-plugin-api';
import { Extension } from '@backstage/frontend-plugin-api';
import { TranslationRef } from '@backstage/core-plugin-api/alpha';
// @alpha (undocumented)
export const AdrSearchResultListItemExtension: Extension<{
lineClamp: number;
noTrack: boolean;
}>;
// @alpha (undocumented)
export const adrTranslationRef: TranslationRef<
'adr',
@@ -15,5 +23,9 @@ export const adrTranslationRef: TranslationRef<
}
>;
// @alpha (undocumented)
const _default: BackstagePlugin;
export default _default;
// (No @packageDocumentation comment for this package)
```
+3 -2
View File
@@ -6,13 +6,13 @@
"license": "Apache-2.0",
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./alpha": "./src/alpha.tsx",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
"src/alpha.tsx"
],
"package.json": [
"package.json"
@@ -45,6 +45,7 @@
"@backstage/catalog-model": "workspace:^",
"@backstage/core-components": "workspace:^",
"@backstage/core-plugin-api": "workspace:^",
"@backstage/frontend-plugin-api": "workspace:^",
"@backstage/integration-react": "workspace:^",
"@backstage/plugin-adr-common": "workspace:^",
"@backstage/plugin-catalog-react": "workspace:^",
-16
View File
@@ -1,16 +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 * from './translations';
+58
View File
@@ -0,0 +1,58 @@
/*
* 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.
*/
import React from 'react';
import {
createPlugin,
createSchemaFromZod,
} from '@backstage/frontend-plugin-api';
import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha';
import { AdrDocument } from '@backstage/plugin-adr-common';
export * from './translations';
function isAdrDocument(result: any): result is AdrDocument {
return result.entityRef;
}
/** @alpha */
export const AdrSearchResultListItemExtension =
createSearchResultListItemExtension({
id: 'adr',
configSchema: createSchemaFromZod(z =>
z.object({
// TODO: Define how the icon can be configurable
noTrack: z.boolean().default(false),
lineClamp: z.number().default(5),
}),
),
predicate: result => result.type === 'adr',
component: async ({ config }) => {
const { AdrSearchResultListItem } = await import(
'./search/AdrSearchResultListItem'
);
return ({ result, ...rest }) =>
isAdrDocument(result) ? (
<AdrSearchResultListItem {...rest} {...config} result={result} />
) : null;
},
});
/** @alpha */
export default createPlugin({
id: 'adr',
extensions: [AdrSearchResultListItemExtension],
});
+1
View File
@@ -4501,6 +4501,7 @@ __metadata:
"@backstage/core-components": "workspace:^"
"@backstage/core-plugin-api": "workspace:^"
"@backstage/dev-utils": "workspace:^"
"@backstage/frontend-plugin-api": "workspace:^"
"@backstage/integration-react": "workspace:^"
"@backstage/plugin-adr-common": "workspace:^"
"@backstage/plugin-catalog-react": "workspace:^"