Skip to content

Commit 0da8051

Browse files
authored
Use InfoTooltip hover for all provenance information (#1030)
1 parent 44c55d9 commit 0da8051

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

apps/obsidian/src/components/DiscourseContextView.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type InfoTooltipProps = {
3131
content: string;
3232
};
3333

34-
const InfoTooltip = ({ content }: InfoTooltipProps) => (
34+
export const InfoTooltip = ({ content }: InfoTooltipProps) => (
3535
<button
3636
ref={(el) => {
3737
if (el) setTooltip(el, content);
@@ -243,7 +243,14 @@ const DiscourseContext = ({ activeFile }: DiscourseContextProps) => {
243243
View only
244244
</span>
245245
<InfoTooltip
246-
content={`Imported from ${formattedVaultName}. Direct edits will be overwritten when refreshed.`}
246+
content={
247+
`Imported from ${formattedVaultName}. ` +
248+
(frontmatter.authorId &&
249+
typeof frontmatter.authorId === "number"
250+
? `By ${getUserNameById(plugin, frontmatter.authorId)}. `
251+
: "") +
252+
"Direct edits will be overwritten when refreshed."
253+
}
247254
/>
248255
</div>
249256
)}
@@ -255,15 +262,6 @@ const DiscourseContext = ({ activeFile }: DiscourseContextProps) => {
255262
</div>
256263
)}
257264

258-
{isImported &&
259-
frontmatter.authorId &&
260-
typeof frontmatter.authorId === "number" && (
261-
<div className="text-modifier-text mt-2 text-xs">
262-
<div>
263-
Author: {getUserNameById(plugin, frontmatter.authorId)}
264-
</div>
265-
</div>
266-
)}
267265
{isImported && sourceDates && (
268266
<div className="text-modifier-text mt-2 text-xs">
269267
<div>Created in source: {sourceDates.createdAt}</div>

apps/obsidian/src/components/RelationshipSection.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
removeRelationBySourceDestinationType,
2727
updateRelation,
2828
} from "~/utils/relationsStore";
29+
import { InfoTooltip } from "./DiscourseContextView";
2930

3031
type RelationTypeOption = {
3132
id: string;
@@ -528,19 +529,7 @@ const CurrentRelationships = ({
528529
</div>
529530
<ul className="m-0 ml-6 list-none p-0">
530531
{group.linkedEntries.map((entry) => (
531-
<li
532-
key={entry.relation.id}
533-
className="mt-1 flex items-center gap-2"
534-
title={
535-
entry.relation.importedFromRid && entry.relation.authorId
536-
? `relation by ${getUserNameById(plugin, entry.relation.authorId)} from space ${getAndFormatImportSource(entry.relation.importedFromRid, plugin.settings.spaceNames)}`
537-
: entry.relation.authorId
538-
? `relation by ${getUserNameById(plugin, entry.relation.authorId)}`
539-
: entry.relation.importedFromRid
540-
? `relation from space ${getAndFormatImportSource(entry.relation.importedFromRid, plugin.settings.spaceNames)}`
541-
: ""
542-
}
543-
>
532+
<li key={entry.relation.id} className="mt-1 flex items-center gap-2">
544533
<a
545534
href="#"
546535
className="text-accent-text flex-1"
@@ -554,6 +543,19 @@ const CurrentRelationships = ({
554543
>
555544
{entry.file.basename}
556545
</a>
546+
{(entry.relation.importedFromRid || entry.relation.authorId) && (
547+
<InfoTooltip
548+
content={
549+
entry.relation.importedFromRid && entry.relation.authorId
550+
? `Relation by ${getUserNameById(plugin, entry.relation.authorId)}, imported from space ${getAndFormatImportSource(entry.relation.importedFromRid, plugin.settings.spaceNames)}`
551+
: entry.relation.authorId
552+
? `Relation by ${getUserNameById(plugin, entry.relation.authorId)}`
553+
: entry.relation.importedFromRid
554+
? `Imported from space ${getAndFormatImportSource(entry.relation.importedFromRid, plugin.settings.spaceNames)}`
555+
: ""
556+
}
557+
/>
558+
)}
557559
{renderAction(entry)}
558560
</li>
559561
))}

0 commit comments

Comments
 (0)