diff --git a/app/components/Menu/MenuFilter.tsx b/app/components/Menu/MenuFilter.tsx index 6fae2db542..b5a01b43d7 100644 --- a/app/components/Menu/MenuFilter.tsx +++ b/app/components/Menu/MenuFilter.tsx @@ -200,7 +200,10 @@ export function MenuFilter({ query, onChange }: Props) { ); return ( - + !!element ); } @@ -47,4 +47,33 @@ describe("toMenuItems", () => { it("returns null when nothing matches", () => { expect(toMenuItems(items, "zzz")).toBeNull(); }); + + it("removes a separator above a group", () => { + const keys = render(undefined, [ + { type: "button", title: "Team", onClick: noop }, + { type: "separator" }, + { + type: "group", + title: "Group", + items: [{ type: "button", title: "Design", onClick: noop }], + }, + ]).map((element) => element.key); + expect(keys).toEqual(["button-0", "group-1"]); + }); + + it("keeps a separator above a group that has no visible items", () => { + const keys = render(undefined, [ + { type: "button", title: "Team", onClick: noop }, + { type: "separator" }, + { + type: "group", + title: "Group", + items: [ + { type: "button", title: "Design", visible: false, onClick: noop }, + ], + }, + { type: "button", title: "Due date", onClick: noop }, + ]).map((element) => element.key); + expect(keys).toEqual(["button-0", "separator-1", "button-2"]); + }); }); diff --git a/app/components/Menu/transformer.tsx b/app/components/Menu/transformer.tsx index 2dadb495ae..852b95cc31 100644 --- a/app/components/Menu/transformer.tsx +++ b/app/components/Menu/transformer.tsx @@ -290,7 +290,7 @@ export function toMobileMenuItems( } return ( -
+
{item.title} {groupItems}
@@ -340,7 +340,11 @@ function matchesQuery(item: MenuItem, query: string): boolean { function filterMenuItems(items: MenuItem[]): MenuItem[] { return items - .filter((item) => item.visible !== false) + .filter( + (item) => + item.visible !== false && + (item.type !== "group" || filterMenuItems(item.items).length > 0) + ) .reduce((acc, item) => { // trim separator when the previous item is also a separator. if ( @@ -352,10 +356,12 @@ function filterMenuItems(items: MenuItem[]): MenuItem[] { return [...acc, item]; }, [] as MenuItem[]) .filter((item, index, arr) => { - // trim when first or last item is a separator. + // trim when first or last item is a separator, or above a group header. if ( item.type === "separator" && - (index === 0 || index === arr.length - 1) + (index === 0 || + index === arr.length - 1 || + arr[index + 1]?.type === "group") ) { return false; } diff --git a/app/components/MouseSafeArea.tsx b/app/components/MouseSafeArea.tsx index 5efe84f25e..bcce555bb2 100644 --- a/app/components/MouseSafeArea.tsx +++ b/app/components/MouseSafeArea.tsx @@ -55,6 +55,7 @@ export const MouseSafeArea = observer(function MouseSafeArea_(props: { return (
*), + [data-menu-hidden]:first-child + &, + [role="group"]:first-child > &:first-child, + [data-menu-hidden]:first-child + [role="group"] > &:first-child { + margin-top: 0; + } + `} `; export const MenuDisclosure = styled(ExpandedIcon)` diff --git a/app/hooks/useTemplateMenuActions.tsx b/app/hooks/useTemplateMenuActions.tsx index ad1545b387..fd55b6a349 100644 --- a/app/hooks/useTemplateMenuActions.tsx +++ b/app/hooks/useTemplateMenuActions.tsx @@ -24,7 +24,8 @@ type Props = { * they are published and organizes them into appropriate sections. * * Collection-specific templates are displayed first, followed by workspace templates - * with a separator in between (if both types exist). + * in a group with a separator in between. Workspace templates are not grouped + * when there are no collection-specific templates. * * @returns An array of Action objects representing templates that can be applied * to the current document. Returns an empty array if no callback is provided. @@ -90,6 +91,10 @@ export function useTemplateMenuActions({ return []; } + if (!collectionTemplatesActions.length) { + return workspaceTemplatesActions; + } + return [ ...collectionTemplatesActions, ActionSeparator, diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 2ddb856713..e29071f852 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -733,6 +733,7 @@ "Integrations": "Integrations", "Back to app": "Back to app", "Installation": "Installation", + "Available on {{ planName }}": "Available on {{ planName }}", "Split pane": "Split pane", "Main pane": "Main pane", "Unstar document": "Unstar document", @@ -896,6 +897,11 @@ "Upload a video": "Upload a video", "Edit video URL": "Edit video URL", "Could not import file": "Could not import file", + "Community": "Community", + "Standard": "Standard", + "Business": "Business", + "Enterprise": "Enterprise", + "Legacy": "Legacy", "Unsubscribed from document": "Unsubscribed from document", "Unsubscribed from collection": "Unsubscribed from collection", "Subscription successful": "Subscription successful", @@ -1466,6 +1472,8 @@ "This color has low contrast against the accent color": "This color has low contrast against the accent color", "Accent color": "Accent color", "Accent text color": "Accent text color", + "This feature is included in {{planName}} and above. Upgrade your workspace to unlock it for your team.": "This feature is included in {{planName}} and above. Upgrade your workspace to unlock it for your team.", + "View plans": "View plans", "All roles": "All roles", "Admins": "Admins", "Editors": "Editors", @@ -1520,7 +1528,6 @@ "Import a zip file of Markdown documents in the Open Knowledge Format": "Import a zip file of Markdown documents in the Open Knowledge Format", "Import a JSON data file exported from another {{ appName }} instance": "Import a JSON data file exported from another {{ appName }} instance", "Import pages from a Confluence instance": "Import pages from a Confluence instance", - "Enterprise": "Enterprise", "Quickly transfer your existing documents, pages, and files from other tools and services into {{appName}}. You can also drag and drop any HTML, Markdown, and text documents directly into Collections in the app.": "Quickly transfer your existing documents, pages, and files from other tools and services into {{appName}}. You can also drag and drop any HTML, Markdown, and text documents directly into Collections in the app.", "Recent imports": "Recent imports", "Configure a variety of integrations with third-party services.": "Configure a variety of integrations with third-party services.", @@ -1677,7 +1684,7 @@ "Failed to save revision": "Failed to save revision", "Invite to document": "Invite to document", "Sorry, invalid embed link": "Sorry, invalid embed link", - "Data Attributes": "Data Attributes", + "Data attributes": "Data attributes", "Edit attribute": "Edit attribute", "Property": "Property", "Yes": "Yes", @@ -1709,7 +1716,7 @@ "Text": "Text", "List": "List", "Could not load events": "Could not load events", - "Audit Log": "Audit Log", + "Audit log": "Audit log", "The audit log details the history of security-related and other events across your knowledge base.": "The audit log details the history of security-related and other events across your knowledge base.", "IP address": "IP address", "Actor": "Actor", @@ -1852,6 +1859,10 @@ "Script name": "Script name", "The name of the script file that Umami uses to track analytics.": "The name of the script file that Umami uses to track analytics.", "An ID that uniquely identifies the website in your Umami instance.": "An ID that uniquely identifies the website in your Umami instance.", + "The audit log details the history of security related and other events across your knowledge base.": "The audit log details the history of security related and other events across your knowledge base.", + "Content": "Content", + "Manage the permissions and settings of all collections in the knowledge base. As a workspace admin you can also administer private collections.": "Manage the permissions and settings of all collections in the knowledge base. As a workspace admin you can also administer private collections.", + "Automatically index and search document content from {{appName}} inside Glean in realtime.": "Automatically index and search document content from {{appName}} inside Glean in realtime.", "New webhook": "New webhook", "Edit webhook": "Edit webhook", "Delete webhook": "Delete webhook",