@@ -5,14 +5,15 @@ import {
55 Notice ,
66 FrontMatterCache ,
77 setIcon ,
8+ setTooltip ,
89} from "obsidian" ;
910import { createRoot , Root } from "react-dom/client" ;
1011import DiscourseGraphPlugin from "~/index" ;
1112import { getDiscourseNodeFormatExpression } from "~/utils/getDiscourseNodeFormatExpression" ;
1213import { RelationshipSection } from "~/components/RelationshipSection" ;
1314import { VIEW_TYPE_DISCOURSE_CONTEXT } from "~/types" ;
1415import { PluginProvider , usePlugin } from "~/components/PluginContext" ;
15- import { getNodeTypeById } from "~/utils/typeUtils" ;
16+ import { getNodeTypeById , getAndFormatImportSource } from "~/utils/typeUtils" ;
1617import { refreshImportedFile } from "~/utils/importNodes" ;
1718import { publishNode } from "~/utils/publishNode" ;
1819import { createBaseForNodeType } from "~/utils/baseForNodeType" ;
@@ -22,6 +23,21 @@ type DiscourseContextProps = {
2223 activeFile : TFile | null ;
2324} ;
2425
26+ type InfoTooltipProps = {
27+ content : string ;
28+ } ;
29+
30+ const InfoTooltip = ( { content } : InfoTooltipProps ) => (
31+ < button
32+ ref = { ( el ) => {
33+ if ( el ) setTooltip ( el , content ) ;
34+ } }
35+ className = "clickable-icon text-muted hover:text-normal flex h-4 w-4 items-center justify-center"
36+ >
37+ < div ref = { ( el ) => ( el && setIcon ( el , "info" ) ) || undefined } />
38+ </ button >
39+ ) ;
40+
2541const DiscourseContext = ( { activeFile } : DiscourseContextProps ) => {
2642 const plugin = usePlugin ( ) ;
2743 const [ isRefreshing , setIsRefreshing ] = useState ( false ) ;
@@ -157,12 +173,16 @@ const DiscourseContext = ({ activeFile }: DiscourseContextProps) => {
157173 ) }
158174 { nodeType . name || "Unnamed Node Type" }
159175 < button
176+ ref = { ( el ) => {
177+ if ( el ) {
178+ const name = nodeType . name || "Unnamed Node Type" ;
179+ setTooltip ( el , `Create Base view for ${ name } nodes` ) ;
180+ }
181+ } }
160182 onClick = { ( ) => {
161183 void createBaseForNodeType ( plugin , nodeType ) ;
162184 } }
163185 className = "clickable-icon ml-1"
164- title = { `Create Base view for ${ nodeType . name } ` }
165- aria-label = { `Create Base view for ${ nodeType . name } ` }
166186 >
167187 < div
168188 ref = { ( el ) => ( el && setIcon ( el , "layout-list" ) ) || undefined }
@@ -206,8 +226,19 @@ const DiscourseContext = ({ activeFile }: DiscourseContextProps) => {
206226 ) }
207227 </ div >
208228
229+ { isImported && (
230+ < div className = "mt-3 flex items-center gap-1.5" >
231+ < span className = "cursor-default rounded bg-amber-300 px-2 py-1 text-xs font-semibold text-amber-950 dark:bg-amber-900/40 dark:text-amber-300" >
232+ View only
233+ </ span >
234+ < InfoTooltip
235+ content = { `Imported from ${ getAndFormatImportSource ( frontmatter . importedFromRid as string , plugin . settings . spaceNames ) } . Direct edits will be overwritten when refreshed.` }
236+ />
237+ </ div >
238+ ) }
239+
209240 { nodeType . format && (
210- < div className = "mb-1" >
241+ < div className = "mb-1 mt-2 " >
211242 < span className = "font-bold" > Content: </ span >
212243 { extractContentFromTitle ( nodeType . format , activeFile . basename ) }
213244 </ div >
0 commit comments