moved ScaffolderWizardContextMenu.tsx

Signed-off-by: kosukeKK <koskacts@gmail.com>
This commit is contained in:
kosukeKK
2024-03-07 22:30:40 +09:00
parent 96511604f6
commit 93acaade9a
6 changed files with 25 additions and 56 deletions
-5
View File
@@ -1,5 +0,0 @@
---
'@backstage/plugin-scaffolder-react': minor
---
Added a header menu for ScaffolderWizard
@@ -149,16 +149,6 @@ export type ScaffolderReactComponentsNameToClassKey = {
// @alpha (undocumented)
export type ScaffolderReactTemplateCategoryPickerClassKey = 'root' | 'label';
// @alpha (undocumented)
export function ScaffolderWizardContextMenu(
props: ScaffolderWizardContextMenuProps,
): React_2.JSX.Element | null;
// @alpha (undocumented)
export type ScaffolderWizardContextMenuProps = {
onEditorClicked?: () => void;
};
// @alpha
export const Stepper: (stepperProps: StepperProps) => React_2.JSX.Element;
@@ -1,19 +0,0 @@
/*
* Copyright 2022 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 {
ScaffolderWizardContextMenu,
type ScaffolderWizardContextMenuProps,
} from './ScaffolderWizardContextMenu';
@@ -25,5 +25,4 @@ export * from './TaskSteps';
export * from './TaskLogStream';
export * from './TemplateCategoryPicker';
export * from './ScaffolderPageContextMenu';
export * from './ScaffolderWizardContextMenu';
export * from './ScaffolderField';
@@ -16,7 +16,10 @@
import React from 'react';
import { Navigate, useNavigate } from 'react-router-dom';
import useAsync from 'react-use/lib/useAsync';
import { stringifyEntityRef } from '@backstage/catalog-model';
import {
stringifyEntityRef,
ANNOTATION_EDIT_URL,
} from '@backstage/catalog-model';
import {
AnalyticsContext,
useApi,
@@ -33,7 +36,6 @@ import {
} from '@backstage/plugin-scaffolder-react';
import { catalogApiRef } from '@backstage/plugin-catalog-react';
import { ScaffolderWizardContextMenu } from '@backstage/plugin-scaffolder-react/alpha';
import { Workflow } from '@backstage/plugin-scaffolder-react/alpha';
import { JsonValue } from '@backstage/types';
import { Header, Page } from '@backstage/core-components';
@@ -44,6 +46,11 @@ import {
selectedTemplateRouteRef,
} from '../../routes';
import {
TemplateWizardPageContextMenu,
TemplateWizardPageContextMenuProps,
} from './TemplateWizardPageContextMenu';
/**
* @alpha
*/
@@ -80,17 +87,18 @@ export const TemplateWizardPage = (props: TemplateWizardPageProps) => {
const { value: editUrl } = useAsync(async () => {
const data = await catalogApi.getEntityByRef(templateRef);
return data?.metadata.annotations?.['backstage.io/edit-url'] || '';
return data?.metadata.annotations?.[ANNOTATION_EDIT_URL] || '';
}, [templateRef, catalogApi]);
const scaffolderWizardContextMenuProps = {
onEditorClicked:
editUrl !== ''
? () => {
window.open(editUrl, '_blank');
}
: undefined,
};
const templateWizardPageContextMenuProps: TemplateWizardPageContextMenuProps =
{
onEditorClicked:
editUrl !== ''
? () => {
window.open(editUrl, '_blank');
}
: undefined,
};
const onCreate = async (values: Record<string, JsonValue>) => {
const { taskId } = await scaffolderApi.scaffold({
@@ -113,7 +121,9 @@ export const TemplateWizardPage = (props: TemplateWizardPageProps) => {
subtitle="Create new software components using standard templates in your organization"
{...props.headerOptions}
>
<ScaffolderWizardContextMenu {...scaffolderWizardContextMenuProps} />
<TemplateWizardPageContextMenu
{...templateWizardPageContextMenuProps}
/>
</Header>
<Workflow
namespace={namespace}
@@ -31,18 +31,12 @@ const useStyles = makeStyles(theme => ({
},
}));
/**
* @alpha
*/
export type ScaffolderWizardContextMenuProps = {
export type TemplateWizardPageContextMenuProps = {
onEditorClicked?: () => void;
};
/**
* @alpha
*/
export function ScaffolderWizardContextMenu(
props: ScaffolderWizardContextMenuProps,
export function TemplateWizardPageContextMenu(
props: TemplateWizardPageContextMenuProps,
) {
const { onEditorClicked } = props;
const classes = useStyles();