-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add bookmarks to handover (#641)
- Loading branch information
1 parent
a48ea42
commit 77a8554
Showing
8 changed files
with
70 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './createRender'; | ||
export * from './useWorkspaceBookmark'; |
37 changes: 37 additions & 0 deletions
37
libs/shared/src/packages/fusion-framework/useWorkspaceBookmark.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Bookmark } from '@equinor/workspace-fusion'; | ||
import { useRef, useEffect } from 'react'; | ||
import { | ||
useCurrentBookmark, | ||
useBookmark, | ||
} from '@equinor/fusion-framework-react-app/bookmark'; | ||
|
||
export function useWorkspaceBookmarks() { | ||
const bookmarkRef = useRef<Partial<Bookmark>>({}); | ||
const bookmark = useCurrentBookmark<Bookmark>().currentBookmark; | ||
const id = bookmark?.id; | ||
const payload = bookmark?.payload; | ||
const bookmarkHandler = useBookmark<Partial<Bookmark>>(); | ||
|
||
useEffect(() => { | ||
console.log('Registering handler'); | ||
const unsub = bookmarkHandler.addBookmarkCreator(async () => { | ||
console.log('bookmark requested'); | ||
return bookmarkRef.current; | ||
}); | ||
|
||
return () => { | ||
typeof unsub === 'function' && unsub(); | ||
}; | ||
}, [bookmarkHandler]); | ||
|
||
const onBookmarkChange = (ref: Partial<Bookmark>) => { | ||
bookmarkRef.current = ref; | ||
}; | ||
|
||
return { | ||
currentBookmark: payload, | ||
bookmarkKey: id, | ||
/** Add as prop to workspace */ | ||
onBookmarkChange, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.