From be906108320eca41607767bbbead460a58b7bad5 Mon Sep 17 00:00:00 2001 From: kosukeKK Date: Sat, 9 Mar 2024 15:46:04 +0900 Subject: [PATCH] refactoring code Signed-off-by: kosukeKK --- .../TemplateWizardPage/TemplateWizardPage.tsx | 19 ++---------------- .../TemplateWizardPageContextMenu.tsx | 20 +++++++++---------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx index 1deefaaa21..6a103b03b3 100644 --- a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx +++ b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx @@ -46,10 +46,7 @@ import { selectedTemplateRouteRef, } from '../../routes'; -import { - TemplateWizardPageContextMenu, - TemplateWizardPageContextMenuProps, -} from './TemplateWizardPageContextMenu'; +import { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu'; /** * @alpha @@ -90,16 +87,6 @@ export const TemplateWizardPage = (props: TemplateWizardPageProps) => { return data?.metadata.annotations?.[ANNOTATION_EDIT_URL] || ''; }, [templateRef, catalogApi]); - const templateWizardPageContextMenuProps: TemplateWizardPageContextMenuProps = - { - onEditorClicked: - editUrl !== '' - ? () => { - window.open(editUrl, '_blank'); - } - : undefined, - }; - const onCreate = async (values: Record) => { const { taskId } = await scaffolderApi.scaffold({ templateRef, @@ -121,9 +108,7 @@ export const TemplateWizardPage = (props: TemplateWizardPageProps) => { subtitle="Create new software components using standard templates in your organization" {...props.headerOptions} > - + ({ })); export type TemplateWizardPageContextMenuProps = { - onEditorClicked?: () => void; + editUrl?: string; }; export function TemplateWizardPageContextMenu( props: TemplateWizardPageContextMenuProps, ) { - const { onEditorClicked } = props; + const { editUrl } = props; const classes = useStyles(); const [anchorEl, setAnchorEl] = useState(); - if (!onEditorClicked) { + if (!editUrl) { return null; } @@ -79,14 +79,12 @@ export function TemplateWizardPageContextMenu( transformOrigin={{ vertical: 'top', horizontal: 'right' }} > - {onEditorClicked && ( - - - - - - - )} + window.open(editUrl, '_blank')}> + + + + +