Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

task: Remove add new document button in navbar #4868

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/cms/src/studio/document-options/document-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Loading