-
Notifications
You must be signed in to change notification settings - Fork 7
ENG-1968 Pre-check groups a node is already shared to in the Publish tab #1353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,7 @@ import { AddReferencedNodeType } from "./canvas/DiscourseRelationShape/Discourse | |
| import posthog from "posthog-js"; | ||
| import { getMyGroups, type MyGroup } from "@repo/database/lib/groups"; | ||
| import { | ||
| getAllPublishedIdsByGroup, | ||
| publishNodeUidsWithTypeToGroups, | ||
| type NodeUidWithType, | ||
| } from "~/utils/publishNodesToGroups"; | ||
|
|
@@ -821,6 +822,23 @@ const ExportDialog: ExportDialogComponent = ({ | |
| const client = await getLoggedInClient(); | ||
| if (!client) throw new Error("Could not connect to sync."); | ||
| const groups = await getMyGroups(client); | ||
| const context = await getSupabaseContext(); | ||
| if (context && groups.length && publishableNodes.length) { | ||
| const publishedIdsByGroup = await getAllPublishedIdsByGroup( | ||
| client, | ||
| context.spaceId, | ||
| groups.map((g) => g.id), | ||
| ); | ||
| setSelectedGroupIds( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the persistent Useful? React with 👍 / 👎. |
||
| groups | ||
| .map((g) => g.id) | ||
| .filter((id) => | ||
| publishableNodes.every(({ uid }) => | ||
| publishedIdsByGroup[id].has(uid), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| setMyGroups(groups); | ||
| } catch (e) { | ||
| setGroupsError((e as Error).message || "Failed to load groups."); | ||
|
|
@@ -829,7 +847,14 @@ const ExportDialog: ExportDialogComponent = ({ | |
| setGroupsLoaded(true); | ||
| } | ||
| })(); | ||
| }, [syncEnabled, isOpen, selectedTabId, groupsLoaded, groupsLoading]); | ||
| }, [ | ||
| syncEnabled, | ||
| isOpen, | ||
| selectedTabId, | ||
| groupsLoaded, | ||
| groupsLoading, | ||
| publishableNodes, | ||
| ]); | ||
|
|
||
| const handlePublish = async () => { | ||
| setPublishError(""); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a space/group combination with more than 1,000
ResourceAccessentries, this call receives only the first page becausepackages/database/supabase/config.tomlsetsmax_rows = 1000, whilegetAllPublishedIdsByGroupneither paginates nor filters by the nodes being checked. An already-published node omitted from that page is therefore shown as unchecked. Query only the relevant node UIDs for this precheck or paginate until all matching rows have been read.Useful? React with 👍 / 👎.