From 7d5678713d33cc85f5427b0d4b7b688888dfccf3 Mon Sep 17 00:00:00 2001 From: Juan Escalada Date: Sat, 9 Nov 2024 14:02:47 +0900 Subject: [PATCH 1/6] Add contextMenu prop to Actions and ListTasks Signed-off-by: Juan Escalada --- .../ScaffolderPageContextMenu.tsx | 7 ++++- .../components/ActionsPage/ActionsPage.tsx | 26 ++++++++++++++++--- .../ListTasksPage/ListTasksPage.tsx | 20 +++++++++++--- .../src/components/Router/Router.tsx | 9 +++++-- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx b/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx index 23b34123d1..1cf5afdc0a 100644 --- a/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx +++ b/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx @@ -61,7 +61,12 @@ export function ScaffolderPageContextMenu( permission: taskReadPermission, }); - if (!onEditorClicked && !onActionsClicked) { + if ( + !onEditorClicked && + !onActionsClicked && + !onTasksClicked && + !onCreateClicked + ) { return null; } diff --git a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx index 539a5697d3..f85c1f0e6b 100644 --- a/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx +++ b/plugins/scaffolder/src/components/ActionsPage/ActionsPage.tsx @@ -407,7 +407,16 @@ export const ActionPageContent = () => { ); }; -export const ActionsPage = () => { + +export type ActionsPageProps = { + contextMenu?: { + editor?: boolean; + tasks?: boolean; + create?: boolean; + }; +}; + +export const ActionsPage = (props: ActionsPageProps) => { const navigate = useNavigate(); const editorLink = useRouteRef(editRouteRef); const tasksLink = useRouteRef(scaffolderListTaskRouteRef); @@ -415,10 +424,19 @@ export const ActionsPage = () => { const { t } = useTranslationRef(scaffolderTranslationRef); const scaffolderPageContextMenuProps = { - onEditorClicked: () => navigate(editorLink()), + onEditorClicked: + props?.contextMenu?.editor !== false + ? () => navigate(editorLink()) + : undefined, onActionsClicked: undefined, - onTasksClicked: () => navigate(tasksLink()), - onCreateClicked: () => navigate(createLink()), + onTasksClicked: + props?.contextMenu?.tasks !== false + ? () => navigate(tasksLink()) + : undefined, + onCreateClicked: + props?.contextMenu?.create !== false + ? () => navigate(createLink()) + : undefined, }; return ( diff --git a/plugins/scaffolder/src/components/ListTasksPage/ListTasksPage.tsx b/plugins/scaffolder/src/components/ListTasksPage/ListTasksPage.tsx index b07d7c7fd3..26c8d8c36f 100644 --- a/plugins/scaffolder/src/components/ListTasksPage/ListTasksPage.tsx +++ b/plugins/scaffolder/src/components/ListTasksPage/ListTasksPage.tsx @@ -46,6 +46,11 @@ import { scaffolderTranslationRef } from '../../translation'; export interface MyTaskPageProps { initiallySelectedFilter?: 'owned' | 'all'; + contextMenu?: { + editor?: boolean; + actions?: boolean; + create?: boolean; + }; } const ListTaskPageContent = (props: MyTaskPageProps) => { @@ -161,10 +166,19 @@ export const ListTasksPage = (props: MyTaskPageProps) => { const { t } = useTranslationRef(scaffolderTranslationRef); const scaffolderPageContextMenuProps = { - onEditorClicked: () => navigate(editorLink()), - onActionsClicked: () => navigate(actionsLink()), + onEditorClicked: + props?.contextMenu?.editor !== false + ? () => navigate(editorLink()) + : undefined, + onActionsClicked: + props?.contextMenu?.actions !== false + ? () => navigate(actionsLink()) + : undefined, onTasksClicked: undefined, - onCreateClicked: () => navigate(createLink()), + onCreateClicked: + props?.contextMenu?.create !== false + ? () => navigate(createLink()) + : undefined, }; return ( diff --git a/plugins/scaffolder/src/components/Router/Router.tsx b/plugins/scaffolder/src/components/Router/Router.tsx index 1121fd2766..cabd4cb906 100644 --- a/plugins/scaffolder/src/components/Router/Router.tsx +++ b/plugins/scaffolder/src/components/Router/Router.tsx @@ -96,6 +96,8 @@ export type RouterProps = { actions?: boolean; /** Whether to show a link to the tasks page */ tasks?: boolean; + /** Whether to show a link to the create page (on /create subroutes) */ + create?: boolean; }; }; @@ -200,12 +202,15 @@ export const Router = (props: PropsWithChildren) => { } /> - } /> + } + /> - + } /> From 69fb6e7b3b93ed53ab2d02b632be8f693c6eaf56 Mon Sep 17 00:00:00 2001 From: Juan Escalada Date: Sat, 9 Nov 2024 14:31:17 +0900 Subject: [PATCH 2/6] Add changeset Signed-off-by: Juan Escalada --- .changeset/ten-hats-appear.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/ten-hats-appear.md diff --git a/.changeset/ten-hats-appear.md b/.changeset/ten-hats-appear.md new file mode 100644 index 0000000000..37e3d1c939 --- /dev/null +++ b/.changeset/ten-hats-appear.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-scaffolder-react': minor +'@backstage/plugin-scaffolder': minor +--- + +Fix contextMenu prop bug in /create/\* routes From 9806596ac938ce9346299fb788f60448e734cbba Mon Sep 17 00:00:00 2001 From: Juan Escalada Date: Sat, 9 Nov 2024 14:41:45 +0900 Subject: [PATCH 3/6] Format with prettier Signed-off-by: Juan Escalada --- .../ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx b/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx index c1ea79a595..38d83ae6fd 100644 --- a/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx +++ b/plugins/scaffolder-react/src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx @@ -61,7 +61,7 @@ export function ScaffolderPageContextMenu( const { allowed: canReadTasks } = usePermission({ permission: taskReadPermission, }); - + const { allowed: canManageTemplates } = usePermission({ permission: templateManagementPermission, }); From 639fbba05c3c1c391e15e2f1e1f43f41fec948cd Mon Sep 17 00:00:00 2001 From: Juan Escalada Date: Sat, 9 Nov 2024 15:13:40 +0900 Subject: [PATCH 4/6] Update api reports Signed-off-by: Juan Escalada --- plugins/devtools/report-alpha.api.md | 2 +- plugins/scaffolder/report.api.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/devtools/report-alpha.api.md b/plugins/devtools/report-alpha.api.md index 1b026d1f78..e8681c6fbf 100644 --- a/plugins/devtools/report-alpha.api.md +++ b/plugins/devtools/report-alpha.api.md @@ -80,7 +80,7 @@ const _default: FrontendPlugin< >; inputs: {}; params: { - title: string; + title: string /** @alpha */; icon: IconComponent; routeRef: RouteRef; }; diff --git a/plugins/scaffolder/report.api.md b/plugins/scaffolder/report.api.md index 8a1d3db179..538b2cd9eb 100644 --- a/plugins/scaffolder/report.api.md +++ b/plugins/scaffolder/report.api.md @@ -499,6 +499,7 @@ export type RouterProps = { editor?: boolean; actions?: boolean; tasks?: boolean; + create?: boolean; }; }; From 44ddd2108ec863d5fa30ae1424eab4a94eac8b74 Mon Sep 17 00:00:00 2001 From: Juan Escalada Date: Sat, 9 Nov 2024 16:12:30 +0900 Subject: [PATCH 5/6] Undo devtools api report change Signed-off-by: Juan Escalada --- plugins/devtools/report-alpha.api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/devtools/report-alpha.api.md b/plugins/devtools/report-alpha.api.md index e8681c6fbf..1b026d1f78 100644 --- a/plugins/devtools/report-alpha.api.md +++ b/plugins/devtools/report-alpha.api.md @@ -80,7 +80,7 @@ const _default: FrontendPlugin< >; inputs: {}; params: { - title: string /** @alpha */; + title: string; icon: IconComponent; routeRef: RouteRef; }; From 3d6a9ae2b3967391bf9145a2ca4fa28798b09d66 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 12 Nov 2024 13:36:20 -0700 Subject: [PATCH 6/6] chore: updating changeset Signed-off-by: blam --- .changeset/ten-hats-appear.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/ten-hats-appear.md b/.changeset/ten-hats-appear.md index 37e3d1c939..318bbfbb25 100644 --- a/.changeset/ten-hats-appear.md +++ b/.changeset/ten-hats-appear.md @@ -3,4 +3,4 @@ '@backstage/plugin-scaffolder': minor --- -Fix contextMenu prop bug in /create/\* routes +Fix `contextMenu` not being disabled bug in new scaffolder pages