refactor: apply review suggestions
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -12,14 +12,17 @@ import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityPredicate } from '@backstage/plugin-catalog-react/alpha';
|
||||
import { ExtensionDefinition } from '@backstage/frontend-plugin-api';
|
||||
import { ExtensionInput } from '@backstage/frontend-plugin-api';
|
||||
import { ExternalRouteRef } from '@backstage/frontend-plugin-api';
|
||||
import { FrontendPlugin } from '@backstage/frontend-plugin-api';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { IconLinkVerticalProps } from '@backstage/core-components';
|
||||
import { JSX as JSX_2 } from 'react';
|
||||
import { RouteRef } from '@backstage/frontend-plugin-api';
|
||||
import { SearchResultItemExtensionComponent } from '@backstage/plugin-search-react/alpha';
|
||||
import { SearchResultItemExtensionPredicate } from '@backstage/plugin-search-react/alpha';
|
||||
import { SearchResultListItemBlueprintParams } from '@backstage/plugin-search-react/alpha';
|
||||
import { TechDocsAddonOptions } from '@backstage/plugin-techdocs-react';
|
||||
import { TranslationRef } from '@backstage/core-plugin-api/alpha';
|
||||
|
||||
// @alpha (undocumented)
|
||||
const _default: FrontendPlugin<
|
||||
@@ -32,7 +35,13 @@ const _default: FrontendPlugin<
|
||||
}>;
|
||||
entityContent: RouteRef<undefined>;
|
||||
},
|
||||
{},
|
||||
{
|
||||
viewTechDoc: ExternalRouteRef<{
|
||||
name: string;
|
||||
kind: string;
|
||||
namespace: string;
|
||||
}>;
|
||||
},
|
||||
{
|
||||
'api:techdocs': ExtensionDefinition<{
|
||||
kind: 'api';
|
||||
@@ -173,6 +182,38 @@ const _default: FrontendPlugin<
|
||||
filter?: string | EntityPredicate | ((entity: Entity) => boolean);
|
||||
};
|
||||
}>;
|
||||
'entity-icon-link:techdocs/read-docs': ExtensionDefinition<{
|
||||
kind: 'entity-icon-link';
|
||||
name: 'read-docs';
|
||||
config: {
|
||||
label: string | undefined;
|
||||
title: string | undefined;
|
||||
filter: EntityPredicate | undefined;
|
||||
};
|
||||
configInput: {
|
||||
filter?: EntityPredicate | undefined;
|
||||
label?: string | undefined;
|
||||
title?: string | undefined;
|
||||
};
|
||||
output:
|
||||
| ConfigurableExtensionDataRef<
|
||||
(entity: Entity) => boolean,
|
||||
'catalog.entity-filter-function',
|
||||
{
|
||||
optional: true;
|
||||
}
|
||||
>
|
||||
| ConfigurableExtensionDataRef<
|
||||
() => IconLinkVerticalProps,
|
||||
'entity-icon-link-props',
|
||||
{}
|
||||
>;
|
||||
inputs: {};
|
||||
params: {
|
||||
useProps: () => Omit<IconLinkVerticalProps, 'color'>;
|
||||
filter?: EntityPredicate | ((entity: Entity) => boolean);
|
||||
};
|
||||
}>;
|
||||
'nav-item:techdocs': ExtensionDefinition<{
|
||||
kind: 'nav-item';
|
||||
name: undefined;
|
||||
@@ -340,5 +381,13 @@ export const techDocsSearchResultListItemExtension: ExtensionDefinition<{
|
||||
params: SearchResultListItemBlueprintParams;
|
||||
}>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export const techdocsTranslationRef: TranslationRef<
|
||||
'techdocs',
|
||||
{
|
||||
readonly 'aboutCard.viewTechdocs': 'View TechDocs';
|
||||
}
|
||||
>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -35,7 +35,10 @@ import {
|
||||
convertLegacyRouteRef,
|
||||
convertLegacyRouteRefs,
|
||||
} from '@backstage/core-compat-api';
|
||||
import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
||||
import {
|
||||
EntityContentBlueprint,
|
||||
EntityIconLinkBlueprint,
|
||||
} from '@backstage/plugin-catalog-react/alpha';
|
||||
import { SearchResultListItemBlueprint } from '@backstage/plugin-search-react/alpha';
|
||||
import { AddonBlueprint } from '@backstage/plugin-techdocs-react/alpha';
|
||||
import { TechDocsClient, TechDocsStorageClient } from './client';
|
||||
@@ -43,15 +46,36 @@ import {
|
||||
rootCatalogDocsRouteRef,
|
||||
rootDocsRouteRef,
|
||||
rootRouteRef,
|
||||
viewTechDocRouteRef,
|
||||
} from './routes';
|
||||
import { TechDocsReaderLayout } from './reader';
|
||||
import { attachTechDocsAddonComponentData } from '@backstage/plugin-techdocs-react/alpha';
|
||||
import {
|
||||
attachTechDocsAddonComponentData,
|
||||
useTechdocsReaderIconLinkProps,
|
||||
} from '@backstage/plugin-techdocs-react/alpha';
|
||||
import {
|
||||
TechDocsAddons,
|
||||
techdocsApiRef,
|
||||
techdocsStorageApiRef,
|
||||
} from '@backstage/plugin-techdocs-react';
|
||||
|
||||
import { techdocsTranslationRef } from './translation';
|
||||
|
||||
export { techdocsTranslationRef } from './translation';
|
||||
|
||||
/** @alpha */
|
||||
const techdocsEntityIconLink = EntityIconLinkBlueprint.make({
|
||||
name: 'read-docs',
|
||||
params: {
|
||||
useProps: () => {
|
||||
return useTechdocsReaderIconLinkProps({
|
||||
translationRef: techdocsTranslationRef,
|
||||
externalRouteRef: viewTechDocRouteRef,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** @alpha */
|
||||
const techDocsStorageApi = ApiBlueprint.make({
|
||||
name: 'storage',
|
||||
@@ -243,6 +267,7 @@ export default createFrontendPlugin({
|
||||
techDocsNavItem,
|
||||
techDocsPage,
|
||||
techDocsReaderPage,
|
||||
techdocsEntityIconLink,
|
||||
techDocsEntityContent,
|
||||
techDocsEntityContentEmptyState,
|
||||
techDocsSearchResultListItemExtension,
|
||||
@@ -252,4 +277,7 @@ export default createFrontendPlugin({
|
||||
docRoot: rootDocsRouteRef,
|
||||
entityContent: rootCatalogDocsRouteRef,
|
||||
}),
|
||||
externalRoutes: convertLegacyRouteRefs({
|
||||
viewTechDoc: viewTechDocRouteRef,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createRouteRef } from '@backstage/core-plugin-api';
|
||||
import {
|
||||
createRouteRef,
|
||||
createExternalRouteRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
|
||||
export const rootRouteRef = createRouteRef({
|
||||
id: 'techdocs:index-page',
|
||||
@@ -28,3 +31,10 @@ export const rootDocsRouteRef = createRouteRef({
|
||||
export const rootCatalogDocsRouteRef = createRouteRef({
|
||||
id: 'techdocs:catalog-reader-view',
|
||||
});
|
||||
|
||||
export const viewTechDocRouteRef = createExternalRouteRef({
|
||||
id: 'view-techdoc',
|
||||
optional: true,
|
||||
params: ['namespace', 'kind', 'name'],
|
||||
defaultTarget: 'techdocs.docRoot',
|
||||
});
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2025 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 { createTranslationRef } from '@backstage/core-plugin-api/alpha';
|
||||
|
||||
/** @alpha */
|
||||
export const techdocsTranslationRef = createTranslationRef({
|
||||
id: 'techdocs',
|
||||
messages: {
|
||||
aboutCard: {
|
||||
viewTechdocs: 'View TechDocs',
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user