Skip to content

Commit

Permalink
feat(tree-viewer): adding a goto link
Browse files Browse the repository at this point in the history
  • Loading branch information
julienfrcds committed Apr 23, 2021
1 parent 00a8332 commit 917d5df
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@request/api": "0.6.0",
"knex": "0.95.4",
"pg": "8.6.0",
"react-sortable-tree": "2.8.0",
"react-sortable-tree": "2.7.1",
"sqlite3": "5.0.2",
"strapi": "3.6.0",
"strapi-admin": "3.6.0",
Expand Down Expand Up @@ -48,4 +48,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* HomePage
*
*/
import SortableTree from "react-sortable-tree";
import SortableTree, { toggleExpandedForAll } from "react-sortable-tree";
import "react-sortable-tree/style.css";
import * as StrapiHelper from "strapi-helper-plugin";

Expand All @@ -20,13 +20,15 @@ const mapFolderTreeItem = (item) => {
const bookmarksTree = item.bookmarks.map((bookmark) => ({
title: "📌 " + bookmark.title,
id: bookmark.id,
url: `/admin/plugins/content-manager/collectionType/application::bookmarks.bookmarks/${bookmark.id}`,
type: "bookmark",
}));
children.push(...bookmarksTree);
}
return {
title,
children,
url: `/admin/plugins/content-manager/collectionType/application::folders.folders/${id}`,
type: "folder",
id,
};
Expand Down Expand Up @@ -101,13 +103,33 @@ class HomePage extends Component {
description="Let's drag and drop"
style={{ marginBottom: 12, height: 700 }}
>
<button
onClick={() => {
console.log(treeData);
const res = toggleExpandedForAll(treeData);
console.log(res);
}}
>
Expand
</button>
<SortableTree
treeData={treeData}
onChange={(treeData) => changeTree(treeData, this)}
canDrop={(tree) =>
!(tree.nextParent && tree.nextParent.type === "bookmark")
}
onMoveNode={onMoveNode}
generateNodeProps={({ node }) => ({
buttons: [
<button
onClick={() => {
window.location.href = node.url;
}}
>
Go to link
</button>,
],
})}
/>
</Block>
</div>
Expand Down
61 changes: 57 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,11 @@
dependencies:
defer-to-connect "^1.0.1"

"@types/asap@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/asap/-/asap-2.0.0.tgz#d529e9608c83499a62ae08c871c5e62271aa2963"
integrity sha512-upIS0Gt9Mc8eEpCbYMZ1K8rhNosfKUtimNcINce+zLwJF5UpM3Vv7yz3S5l/1IX+DxTa8lTkUjqynvjRXyJzsg==

"@types/bson@*":
version "4.0.3"
resolved "https://registry.yarnpkg.com/@types/bson/-/bson-4.0.3.tgz#30889d2ffde6262abbe38659364c631454999fbf"
Expand Down Expand Up @@ -1429,7 +1434,7 @@
"@types/react" "*"
hoist-non-react-statics "^3.3.0"

"@types/invariant@^2.2.31":
"@types/invariant@^2.2.30", "@types/invariant@^2.2.31":
version "2.2.34"
resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.34.tgz#05e4f79f465c2007884374d4795452f995720bbe"
integrity sha512-lYUtmJ9BqUN688fGY1U1HZoWT1/Jrmgigx2loq4ZcJpICECm/Om3V314BxdzypO0u5PORKGMM6x0OXaljV1YFg==
Expand Down Expand Up @@ -1491,6 +1496,11 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==

"@types/shallowequal@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/shallowequal/-/shallowequal-1.1.1.tgz#aad262bb3f2b1257d94c71d545268d592575c9b1"
integrity sha512-Lhni3aX80zbpdxRuWhnuYPm8j8UQaa571lHP/xI4W+7BAFhSIhRReXnqjEgT/XzPoXZTJkCqstFMJ8CZTK6IlQ==

"@webassemblyjs/ast@1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
Expand Down Expand Up @@ -1892,7 +1902,7 @@ array.prototype.flat@^1.2.1:
define-properties "^1.1.3"
es-abstract "^1.18.0-next.1"

asap@~2.0.3:
asap@^2.0.6, asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
Expand Down Expand Up @@ -3622,6 +3632,17 @@ dnd-core@^11.1.3:
"@react-dnd/invariant" "^2.0.0"
redux "^4.0.4"

dnd-core@^9.5.1:
version "9.5.1"
resolved "https://registry.yarnpkg.com/dnd-core/-/dnd-core-9.5.1.tgz#e9ec02d33529b68fa528865704d40ac4b14f2baf"
integrity sha512-/yEWFF2jg51yyB8uA2UbvBr9Qis0Oo/4p9cqHLEKZdxzHHVSPfq0a/ool8NG6dIS6Q4uN+oKGObY0rNWiopJDA==
dependencies:
"@types/asap" "^2.0.0"
"@types/invariant" "^2.2.30"
asap "^2.0.6"
invariant "^2.2.4"
redux "^4.0.4"

dns-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d"
Expand Down Expand Up @@ -8113,6 +8134,13 @@ react-dnd-html5-backend@^11.1.3:
dependencies:
dnd-core "^11.1.3"

react-dnd-html5-backend@^9.3.4:
version "9.5.1"
resolved "https://registry.yarnpkg.com/react-dnd-html5-backend/-/react-dnd-html5-backend-9.5.1.tgz#e6a0aed3ece800c1abe004f9ed9991513e2e644c"
integrity sha512-wUdzjREwLqHxFkA6E+XDVL5IFjRDbBI3SHVKil9n3qrGT5dm2tA2oi1aIALdfMKsu00c+OXA9lz/LuKZCE9KXg==
dependencies:
dnd-core "^9.5.1"

react-dnd@^10.0.2:
version "10.0.2"
resolved "https://registry.yarnpkg.com/react-dnd/-/react-dnd-10.0.2.tgz#a6ad8eb3d9f2c573031f7ce05012e5c767a0b1fc"
Expand All @@ -8133,6 +8161,17 @@ react-dnd@^11.1.3:
dnd-core "^11.1.3"
hoist-non-react-statics "^3.3.0"

react-dnd@^9.3.4:
version "9.5.1"
resolved "https://registry.yarnpkg.com/react-dnd/-/react-dnd-9.5.1.tgz#907e55c791d6c50cbed1a4021c14b989b86ac467"
integrity sha512-j2MvziPNLsxXkb3kIJzLvvOv/TQ4sysp6U4CmxAXd4C884dXm/9UGdB7K1wkTW3ZxVpI1K7XhKbX0JgNlPfLcA==
dependencies:
"@types/hoist-non-react-statics" "^3.3.1"
"@types/shallowequal" "^1.1.1"
dnd-core "^9.5.1"
hoist-non-react-statics "^3.3.0"
shallowequal "^1.1.0"

react-dom@^16.3.0, react-dom@^16.9.0:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.14.0.tgz#7ad838ec29a777fb3c75c3a190f661cf92ab8b89"
Expand Down Expand Up @@ -8317,7 +8356,21 @@ react-side-effect@^2.1.0:
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-2.1.1.tgz#66c5701c3e7560ab4822a4ee2742dee215d72eb3"
integrity sha512-2FoTQzRNTncBVtnzxFOk2mCpcfxQpenBMbk5kSVBg5UcPqV9fRbgY2zhb7GTWWOlpFmAxhClBDlIq8Rsubz1yQ==

react-sortable-tree@2.8.0:
react-sortable-tree@2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/react-sortable-tree/-/react-sortable-tree-2.7.1.tgz#99bce93fe838ed90258c1796ccd7ac59b70f8fbd"
integrity sha512-J78/6AXv9RN0XxoBAIDz8a7aNFdi/Mezcv/9lKNYTYzqAWxEyOTMeqZjpmvwLhM2HRpChTn0yYLHTdRSNHRACw==
dependencies:
frontend-collective-react-dnd-scrollzone "^1.0.2"
lodash.isequal "^4.5.0"
prop-types "^15.6.1"
react-dnd "^9.3.4"
react-dnd-html5-backend "^9.3.4"
react-lifecycles-compat "^3.0.4"
react-sortable-tree "^2.6.0"
react-virtualized "^9.19.1"

react-sortable-tree@^2.6.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/react-sortable-tree/-/react-sortable-tree-2.8.0.tgz#9901711778628d0546c045f845216480507c366a"
integrity sha512-gTjwxRNt7z0FC76KeNTnGqx1qUSlV3N78mMPRushBpSUXzZYhiFNsWHUIruyPnaAbw4SA7LgpItV7VieAuwDpw==
Expand Down Expand Up @@ -8366,7 +8419,7 @@ react-transition-group@^2.3.1:
prop-types "^15.6.2"
react-lifecycles-compat "^3.0.4"

react-virtualized@^9.21.2, react-virtualized@^9.22.3:
react-virtualized@^9.19.1, react-virtualized@^9.21.2, react-virtualized@^9.22.3:
version "9.22.3"
resolved "https://registry.yarnpkg.com/react-virtualized/-/react-virtualized-9.22.3.tgz#f430f16beb0a42db420dbd4d340403c0de334421"
integrity sha512-MKovKMxWTcwPSxE1kK1HcheQTWfuCxAuBoSTf2gwyMM21NdX/PXUhnoP8Uc5dRKd+nKm8v41R36OellhdCpkrw==
Expand Down

0 comments on commit 917d5df

Please sign in to comment.