From 415333725c948d58d1d646572250585befa31e0f Mon Sep 17 00:00:00 2001 From: J <93984341+VWSCoronaDashboard18@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:41:22 +0200 Subject: [PATCH] task: Remove add new document button in navbar (#4868) --- .../cms/src/studio/document-options/document-options.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cms/src/studio/document-options/document-options.ts b/packages/cms/src/studio/document-options/document-options.ts index bc3d4bfaee..c1c31e6be3 100644 --- a/packages/cms/src/studio/document-options/document-options.ts +++ b/packages/cms/src/studio/document-options/document-options.ts @@ -4,9 +4,16 @@ import { PublishOrAcceptAction } from './custom-actions/publish-or-accept'; // Removes lokalize from the global "create new" interface at the top left of the navigation bar. export const newDocumentOptions = (prev: TemplateResponse[], { creationContext }: { creationContext: NewDocumentCreationContext }) => { - if (creationContext.type === 'global' || creationContext.type === 'structure') { + if (creationContext.type === 'structure') { return prev.filter((templateItem) => templateItem.templateId !== 'lokalizeText'); } + if (creationContext.type === 'global') { + // Removes the button visually from the header + + window.document.querySelector('style')?.append('[data-ui="Navbar"] button[aria-label^="Create new document"] {display: none}'); + // Removes the functionality from the button in the header + return []; + } return prev; };