Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,24 @@ export const createAllRelationShapeTools = (
override onEnter = () => {
this.didTimeout = false;

const selectedRelations = discourseContext.relations[name] || [];
const hasIncompleteSelectedRelation = selectedRelations.some(
(relation) =>
!relation.label?.trim?.() ||
!relation.complement?.trim?.() ||
relation.complement === "?" ||
!relation.source?.trim?.() ||
relation.source === "?" ||
!relation.destination?.trim?.() ||
relation.destination === "?",
);
if (hasIncompleteSelectedRelation) {
this.cancelAndWarn(
"Relation type is incomplete. Set label, complement, source, and destination in settings.",
);
return;
}

const target = this.editor.getShapeAtPoint(
this.editor.inputs.currentPagePoint,
// {
Expand Down
11 changes: 11 additions & 0 deletions apps/roam/src/components/canvas/overlays/RelationTypeDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ export const RelationTypeDropdown = ({
const seenLabels = new Set<string>();

for (const relation of allRelations) {
if (
!relation.label?.trim?.() ||
!relation.complement?.trim?.() ||
relation.complement === "?" ||
!relation.source?.trim?.() ||
relation.source === "?" ||
!relation.destination?.trim?.() ||
relation.destination === "?"
) {
continue;
}
Comment thread
trangdoan982 marked this conversation as resolved.
const { isDirect: isForward, isReverse } = checkConnectionType(
relation,
startNodeType,
Expand Down
12 changes: 10 additions & 2 deletions apps/roam/src/components/settings/DiscourseRelationConfigPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,15 @@ export const RelationEditPanel = ({
const relationEl = document.getElementById("relation-label");
relationEl?.focus();
}
}, []);
}, [label]);

const isRelationComplete =
label.trim().length > 0 &&
complement.trim().length > 0 &&
source.trim().length > 0 &&
source !== "?" &&
destination.trim().length > 0 &&
destination !== "?";

return (
<>
Expand All @@ -535,7 +543,7 @@ export const RelationEditPanel = ({
icon={"floppy-disk"}
text={"Save"}
intent={Intent.PRIMARY}
disabled={loading || !hasChanges}
disabled={loading || !hasChanges || !isRelationComplete}
className="select-none"
onClick={() => {
setLoading(true);
Expand Down