Skip to content

Commit

Permalink
fix: edit-and-preview block - filter onRequestBlocksRepos by path
Browse files Browse the repository at this point in the history
  • Loading branch information
Wattenberger committed Jul 19, 2022
1 parent 25175f7 commit 3944eed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
13 changes: 10 additions & 3 deletions blocks/file-blocks/edit-and-preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
FileBlockProps,
} from "@githubnext/blocks";
import { Box } from "@primer/react";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";

export default function (props: FileBlockProps) {
const { metadata, BlockComponent, context, onRequestBlocksRepos } = props;
Expand All @@ -28,6 +28,13 @@ export default function (props: FileBlockProps) {
setDefaultBlockOptions();
}, [context.path]);

const onRequestBlocksReposFiltered = useCallback(
(params) => {
return onRequestBlocksRepos({ ...params, path });
},
[onRequestBlocksRepos, path]
);

return (
<Box
display="grid"
Expand All @@ -37,7 +44,7 @@ export default function (props: FileBlockProps) {
width="100%"
overflow="hidden"
p={2}
relative
position="relative"
>
{panes.map((pane, index) => (
<Box
Expand Down Expand Up @@ -65,7 +72,7 @@ export default function (props: FileBlockProps) {
newPanes[index] = pane;
setPanes(newPanes);
}}
onRequestBlocksRepos={onRequestBlocksRepos}
onRequestBlocksRepos={onRequestBlocksReposFiltered}
/>
</Box>
<Box flex="1" overflow="auto">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@excalidraw/excalidraw": "^0.10.0",
"@fullstackio/cq": "^6.0.9",
"@fullstackio/remark-cq": "^6.1.2",
"@githubnext/blocks": "^1.2.0",
"@githubnext/blocks": "^1.2.1",
"@githubocto/flat-ui": "^0.14.1",
"@mdx-js/runtime": "2.0.0-next.9",
"@octokit/rest": "^18.12.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,10 @@
unist-util-visit "^1.0.0"
uuid "^3.3.2"

"@githubnext/blocks@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@githubnext/blocks/-/blocks-1.2.0.tgz#8d380a39f5f782f3a7a9fd3d0b7f8bbf0a37132d"
integrity sha512-SN/9WLiObR1M62c0z2RGeI4Wwe/ONIrEZpwRnIRIkcEmrr+T/ttrhdZM0JZJadu8+iVJNVbJ1ZpiqxNwrM1hpQ==
"@githubnext/blocks@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@githubnext/blocks/-/blocks-1.2.1.tgz#6503f54e69743565d38d78ecf0fd0e86bd0cc3dc"
integrity sha512-S7XALCnD3atLR3zBdxS7nrBVqYQDB8+LXqZgK8VEFX7UXdZabXqkAJ7Dv89ORygVB0ADyWJPaoclR4ueLF64Hw==
dependencies:
"@loadable/component" "^5.15.0"
"@octokit/openapi-types" "^11.2.0"
Expand Down

0 comments on commit 3944eed

Please sign in to comment.