fix(catalog): Address PR feedback

Signed-off-by: Carlos Esteban Lopez <lcarlosesteb@vmware.com>
This commit is contained in:
Carlos Esteban Lopez
2023-05-23 11:10:11 -05:00
parent 62f4c6d195
commit 62d2a70660
8 changed files with 19 additions and 17 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ export const catalogPlugin: BackstagePlugin<
},
true
>;
selectedTemplateRoute: ExternalRouteRef<
createFromTemplate: ExternalRouteRef<
{
namespace: string;
templateName: string;
@@ -30,7 +30,7 @@ import { renderInTestApp, TestApiProvider } from '@backstage/test-utils';
import userEvent from '@testing-library/user-event';
import { screen } from '@testing-library/react';
import React from 'react';
import { selectedTemplateRouteRef, viewTechDocRouteRef } from '../../routes';
import { createFromTemplateRouteRef, viewTechDocRouteRef } from '../../routes';
import { AboutCard } from './AboutCard';
describe('<AboutCard />', () => {
@@ -545,7 +545,7 @@ describe('<AboutCard />', () => {
mountedRoutes: {
'/catalog/:namespace/:kind/:name': entityRouteRef,
'/create/templates/:namespace/:templateName':
selectedTemplateRouteRef,
createFromTemplateRouteRef,
},
},
);
@@ -612,7 +612,7 @@ describe('<AboutCard />', () => {
mountedRoutes: {
'/catalog/:namespace/:kind/:name': entityRouteRef,
'/create/templates/:namespace/:templateName':
selectedTemplateRouteRef,
createFromTemplateRouteRef,
},
},
);
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
ANNOTATION_EDIT_URL,
ANNOTATION_LOCATION,
@@ -42,6 +41,7 @@ import {
getEntitySourceLocation,
useEntity,
} from '@backstage/plugin-catalog-react';
import { isTemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
import {
Card,
CardContent,
@@ -50,14 +50,14 @@ import {
IconButton,
makeStyles,
} from '@material-ui/core';
import AddIcon from '@material-ui/icons/Add';
import CreateComponentIcon from '@material-ui/icons/AddCircleOutline';
import CachedIcon from '@material-ui/icons/Cached';
import DocsIcon from '@material-ui/icons/Description';
import EditIcon from '@material-ui/icons/Edit';
import React, { useCallback } from 'react';
import { selectedTemplateRouteRef, viewTechDocRouteRef } from '../../routes';
import { createFromTemplateRouteRef, viewTechDocRouteRef } from '../../routes';
import { AboutContent } from './AboutContent';
import { isTemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
const useStyles = makeStyles({
gridItemCard: {
@@ -91,7 +91,8 @@ export interface AboutCardProps {
/**
* Exported publicly via the EntityAboutCard
*/
export function AboutCard({ variant }: AboutCardProps) {
export function AboutCard(props: AboutCardProps) {
const { variant } = props;
const app = useApp();
const classes = useStyles();
const { entity } = useEntity();
@@ -100,7 +101,7 @@ export function AboutCard({ variant }: AboutCardProps) {
const alertApi = useApi(alertApiRef);
const errorApi = useApi(errorApiRef);
const viewTechdocLink = useRouteRef(viewTechDocRouteRef);
const templateRoute = useRouteRef(selectedTemplateRouteRef);
const templateRoute = useRouteRef(createFromTemplateRouteRef);
const entitySourceLocation = getEntitySourceLocation(
entity,
@@ -133,7 +134,7 @@ export function AboutCard({ variant }: AboutCardProps) {
const subHeaderLinks = [viewInSource, viewInTechDocs];
if (isTemplateEntityV1beta3(entity)) {
const Icon = app.getSystemIcon('scaffolder') ?? AddIcon;
const Icon = app.getSystemIcon('scaffolder') ?? CreateComponentIcon;
const launchTemplate: IconLinkVerticalProps = {
label: 'Launch Template',
+2 -2
View File
@@ -23,7 +23,7 @@ import {
} from '@backstage/plugin-catalog-react';
import {
createComponentRouteRef,
selectedTemplateRouteRef,
createFromTemplateRouteRef,
viewTechDocRouteRef,
} from './routes';
import {
@@ -81,7 +81,7 @@ export const catalogPlugin = createPlugin({
externalRoutes: {
createComponent: createComponentRouteRef,
viewTechDoc: viewTechDocRouteRef,
selectedTemplateRoute: selectedTemplateRouteRef,
createFromTemplate: createFromTemplateRouteRef,
},
__experimentalConfigure(
options?: CatalogInputPluginOptions,
+2 -2
View File
@@ -30,8 +30,8 @@ export const viewTechDocRouteRef = createExternalRouteRef({
params: ['namespace', 'kind', 'name'],
});
export const selectedTemplateRouteRef = createExternalRouteRef({
id: 'selected-template',
export const createFromTemplateRouteRef = createExternalRouteRef({
id: 'create-from-template',
optional: true,
params: ['namespace', 'templateName'],
});