-
Notifications
You must be signed in to change notification settings - Fork 12
feat: allow goodmaps plugins #379
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
raven-wing
merged 19 commits into
Problematy:next
from
raven-wing:fix/plugin-module-name-plugin
Jul 6, 2026
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e81669c
feat: allow goodmaps plugins
raven-wing cd4c62c
fix not working deps
raven-wing 77fc38c
linting
raven-wing 79d7eb1
kind is overlay now
raven-wing 294b6a9
better docs
raven-wing 9c16a07
naming fixed
raven-wing 2f6733e
fixes after review
raven-wing 7cc377f
fixes for plugin handling
raven-wing d923db6
fixes
raven-wing a89dc9d
todo added
raven-wing 3027ee1
added field decorator
raven-wing 5390465
added plugin example
raven-wing 80e7a6b
remove unnecessary keys
raven-wing 6379b9f
fixes for example plugin
raven-wing c091ea1
merge two plugin bases
raven-wing 7f09f87
simplification
raven-wing 151930b
fix docs
raven-wing 2457539
some docs aligns
raven-wing fbba156
simplify renderer
raven-wing 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
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 was deleted.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import React, { useState, useEffect } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { getOverlayPlugins, subscribe } from './pluginRegistry'; | ||
|
|
||
| // Renders map-overlay plugins (MapOverlayPluginBase): components mounted once over the | ||
| // map, not tied to any marker. Field-renderer plugins are mounted per marker by PluginSlot. | ||
| // Each overlay receives `config` and `isMapLoading` so it can defer rendering until the | ||
| // map's data has loaded (e.g. avoid flashing a "no points" message during the first fetch). | ||
| const MapOverlays = ({ isMapLoading }) => { | ||
| const [plugins, setPlugins] = useState(() => getOverlayPlugins()); | ||
|
|
||
| useEffect(() => subscribe(() => setPlugins(getOverlayPlugins())), []); | ||
|
|
||
| return ( | ||
| <> | ||
| {plugins.map(([scope, Component, config]) => ( | ||
| <Component key={scope} config={config} isMapLoading={isMapLoading} /> | ||
| ))} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| MapOverlays.propTypes = { | ||
| isMapLoading: PropTypes.bool.isRequired, | ||
| }; | ||
|
|
||
| export default MapOverlays; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import '@testing-library/jest-dom'; | ||
| import { render, screen, act } from '@testing-library/react'; | ||
| import MapOverlays from '../../src/plugins/MapOverlays'; | ||
| import { registerPlugin, getPluginConfig } from '../../src/plugins/pluginRegistry'; | ||
|
|
||
| describe('MapOverlays', () => { | ||
| it('renders overlay plugins and passes config as a prop', () => { | ||
| const Overlay = ({ config }) => <span>{config.message}</span>; | ||
| Overlay.propTypes = { config: PropTypes.shape({ message: PropTypes.string }).isRequired }; | ||
| act(() => | ||
| registerPlugin('overlay-scope', Overlay, { message: 'nothing nearby' }, 'overlay'), | ||
| ); | ||
|
|
||
| render(<MapOverlays isMapLoading={false} />); | ||
|
|
||
| expect(screen.getByText('nothing nearby')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('does not render field-renderer plugins', () => { | ||
| const Field = () => <span>field plugin</span>; | ||
| act(() => registerPlugin('field-scope', Field, {}, 'field')); | ||
|
|
||
| render(<MapOverlays isMapLoading={false} />); | ||
|
|
||
| expect(screen.queryByText('field plugin')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('exposes the registered config via getPluginConfig and defaults to {}', () => { | ||
| const Noop = () => null; | ||
| act(() => registerPlugin('with-config', Noop, { a: 1 }, 'overlay')); | ||
| act(() => registerPlugin('without-config', Noop, undefined, 'overlay')); | ||
|
|
||
| expect(getPluginConfig('with-config')).toEqual({ a: 1 }); | ||
| expect(getPluginConfig('without-config')).toEqual({}); | ||
| }); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| from goodmap.plugin import GoodmapPluginBase | ||
| from goodmap.plugin import MapOverlayPluginBase | ||
|
|
||
| __all__ = ["GoodmapPluginBase"] | ||
| __all__ = ["MapOverlayPluginBase"] |
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
Oops, something went wrong.
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.