refactor: apply review suggestions

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2025-05-27 08:39:59 +02:00
parent 406acb6d61
commit 3c59ece2e0
34 changed files with 523 additions and 283 deletions
+30 -2
View File
@@ -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,
}),
});
+11 -1
View File
@@ -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',
});
+27
View File
@@ -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',
},
},
});