chore: Move link actions to their own module and inline link checks

This commit is contained in:
Tom Moor committed 2026-11-11 21:18:44 -05:00
1 parent 080a9e59c8
commit fb7b024489
23 files changed
+226 -223

No files matched your search

+4 -4
View File
@@ -40,7 +40,6 @@
"Export": "Export",
"Export collection": "Export collection",
"New document": "New document",
"Add link": "Add link",
"New template": "New template",
"Delete comment": "Delete comment",
"Mark as resolved": "Mark as resolved",
@@ -70,9 +69,6 @@
"New document below": "New document below",
"{{ count }} document starred": "{{ count }} document starred",
"{{ count }} document starred_plural": "{{ count }} documents starred",
"Add link above": "Add link above",
"Add link below": "Add link below",
"Add nested link": "Add nested link",
"{{ count }} document unstarred": "{{ count }} document unstarred",
"{{ count }} document unstarred_plural": "{{ count }} documents unstarred",
"Publish": "Publish",
@@ -182,6 +178,10 @@
"{{userName}} was removed from the group": "{{userName}} was removed from the group",
"Disconnect": "Disconnect",
"Disconnect analytics": "Disconnect analytics",
"Add link": "Add link",
"Add link above": "Add link above",
"Add link below": "Add link below",
"Add nested link": "Add nested link",
"Home": "Home",
"Drafts": "Drafts",
"Search": "Search",
+7 -3
View File
@@ -3,7 +3,6 @@ import {
filterNavigationNodes,
findNavigationNode,
insertNavigationNode,
isLinkNode,
moveNavigationNode,
removeNavigationNode,
updateNavigationNode,
@@ -143,13 +142,18 @@ describe("removeNavigationNode", () => {
describe("filterNavigationNodes", () => {
it("should remove links at every depth and keep unchanged nodes", () => {
const tree = [node("a", [node("a1"), link("l2")]), link("l1"), node("b")];
const result = filterNavigationNodes(tree, (n) => !isLinkNode(n));
const result = filterNavigationNodes(
tree,
(n) => n.type !== NavigationNodeType.Link
);
expect(ids(result)).toEqual([["a", ["a1"]], "b"]);
expect(result[1]).toBe(tree[2]);
});
it("should return the same array when nothing is removed", () => {
const tree = [node("a", [node("a1")])];
expect(filterNavigationNodes(tree, (n) => !isLinkNode(n))).toBe(tree);
expect(
filterNavigationNodes(tree, (n) => n.type !== NavigationNodeType.Link)
).toBe(tree);
});
});
+1 -11
View File
@@ -1,4 +1,4 @@
import { NavigationNodeType, type NavigationNode } from "../types";
import type { NavigationNode } from "../types";
import shallowEqual from "./shallowEqual";
import naturalSort from "./naturalSort";
@@ -7,16 +7,6 @@ type Sort = {
direction: "asc" | "desc";
};
/**
* Returns whether the node is a link to an external location, rather than a
* document.
*
* @param node The navigation node to check.
* @returns true if the node is a link.
*/
export const isLinkNode = (node: Pick<NavigationNode, "type">): boolean =>
node.type === NavigationNodeType.Link;
/**
* Inserts a node into a navigation tree.
*