From 13cc669e2cb27761458be3b7549f9fe5505b4720 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:38:49 -0400 Subject: [PATCH] fix: prevents rendering of version actions when a user does not have permission --- src/admin/components/Routes.tsx | 11 +++++++--- .../components/elements/Status/index.tsx | 7 ++++-- .../forms/field-types/Array/index.tsx | 3 +-- .../forms/field-types/Blocks/index.tsx | 3 +-- .../utilities/DocumentInfo/index.tsx | 8 +++---- .../utilities/DocumentInfo/types.ts | 4 ---- .../components/views/Version/Version.tsx | 22 ++++++++++++------- 7 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/admin/components/Routes.tsx b/src/admin/components/Routes.tsx index b264c01269..d4423ee211 100644 --- a/src/admin/components/Routes.tsx +++ b/src/admin/components/Routes.tsx @@ -273,10 +273,15 @@ const Routes = () => { render={(routeProps) => { if (permissions?.collections?.[collection.slug]?.readVersions?.permission) { return ( - + id={routeProps.match.params.id} + > + + ); } diff --git a/src/admin/components/elements/Status/index.tsx b/src/admin/components/elements/Status/index.tsx index 17b0e5a371..5a502f473c 100644 --- a/src/admin/components/elements/Status/index.tsx +++ b/src/admin/components/elements/Status/index.tsx @@ -24,6 +24,7 @@ const Status: React.FC = () => { global, id, getVersions, + docPermissions, } = useDocumentInfo(); const { toggleModal } = useModal(); const { @@ -114,12 +115,14 @@ const Status: React.FC = () => { } }, [collection, global, publishedDoc, serverURL, api, id, i18n, locale, resetForm, getVersions, t, toggleModal, revertModalSlug, unPublishModalSlug]); + const canUpdate = docPermissions?.update?.permission; + if (statusToRender) { return (
{t(statusToRender)} - {statusToRender === 'published' && ( + {canUpdate && statusToRender === 'published' && (  —