-
Notifications
You must be signed in to change notification settings - Fork 33
feat: DH-19146: ElementPlugin mapping hook #2477
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
Merged
jnumainville
merged 22 commits into
deephaven:main
from
jnumainville:19146_element_plugin
Jul 14, 2025
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
004a347
wip
jnumainville 72c5ede
wip
jnumainville 44925e6
wip
jnumainville 748e148
wip
jnumainville 3d96d9d
wip
jnumainville d684133
wip
jnumainville 998f724
wip
jnumainville 4e9b5c9
wip
jnumainville 29f35a4
Merge remote-tracking branch 'origin/main' into 19146_element_plugin
jnumainville 8975d56
wip
jnumainville dcad4fb
wip
jnumainville e05bf46
wip
jnumainville 5a81898
wip
jnumainville de2a318
wip
jnumainville a95ac16
wip
jnumainville 24f7803
wip
jnumainville 1f9ebc4
wip
jnumainville 003027c
fix file name
jnumainville 9b0bf6b
fix index
jnumainville f5425c3
Merge remote-tracking branch 'origin/main' into 19146_element_plugin
jnumainville 160661d
fix package lock
jnumainville e783149
fix import
jnumainville File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
mofojed marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,28 @@ | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { TestUtils } from '@deephaven/test-utils'; | ||
import type { PluginModuleMap } from './PluginTypes'; | ||
import { useElementPluginMapping } from './useElementPluginMapping'; | ||
import { getElementPluginMapping } from './PluginUtils'; | ||
import { usePlugins } from './usePlugins'; | ||
|
||
jest.mock('./PluginUtils'); | ||
jest.mock('./usePlugins'); | ||
|
||
const { asMock } = TestUtils; | ||
|
||
const mockElementPluginMapping = new Map< | ||
string, | ||
React.ComponentType<unknown> | ||
>(); | ||
|
||
const mockPlugins: PluginModuleMap = new Map(); | ||
|
||
it('should return element plugin mapping from plugins context', () => { | ||
asMock(getElementPluginMapping).mockReturnValue(mockElementPluginMapping); | ||
asMock(usePlugins).mockReturnValue(mockPlugins); | ||
|
||
const { result } = renderHook(() => useElementPluginMapping()); | ||
|
||
expect(getElementPluginMapping).toHaveBeenCalledWith(mockPlugins); | ||
expect(result.current).toEqual(mockElementPluginMapping); | ||
}); |
This file contains hidden or 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
mofojed marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,21 @@ | ||
import { type ComponentType, useMemo } from 'react'; | ||
import { usePlugins } from './usePlugins'; | ||
import { getElementPluginMapping } from './PluginUtils'; | ||
|
||
/** | ||
* Get all ElementPlugin elements from the plugins context | ||
* @returns ElementPlugin mapping as a Map of plugin name to component type | ||
*/ | ||
export function useElementPluginMapping(): Map<string, ComponentType> { | ||
// Get all plugins from the context | ||
const plugins = usePlugins(); | ||
|
||
const elementPlugins = useMemo( | ||
() => getElementPluginMapping(plugins), | ||
[plugins] | ||
); | ||
|
||
return elementPlugins; | ||
} | ||
|
||
export default useElementPluginMapping; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.