mirror of
https://github.com/outline/outline.git
synced 2026-11-25 23:24:06 +03:00
chore: Move link actions to their own module and inline link checks
This commit is contained in:
23 files changed
+226
-223
No files matched your search
@@ -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,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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user