-
Notifications
You must be signed in to change notification settings - Fork 12
feat: added initial view nad rendering field content #402
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
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c2cdd7e
feat: initial view added and update field renders
raven-wing c289f52
Field renderers fixes
raven-wing b8f1c43
updated dependencies
raven-wing 2994172
missing file
raven-wing ee488fa
fixes
raven-wing 1215962
fix lint
raven-wing 3bac337
fixes after review
raven-wing f408b11
fix lnting
raven-wing dac541a
less comments
raven-wing 21b646a
back to google
raven-wing ac64cc2
fix wiring
raven-wing e045f5c
remove max zoom
raven-wing 55ef5fc
simplify
raven-wing 8f8f46e
docs fixed
raven-wing a6939b5
fixes after review
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 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
78 changes: 0 additions & 78 deletions
78
frontend/src/components/MarkerPopup/builtinFieldRenderers.jsx
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,30 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
|
|
||
| /** | ||
| * Renders the HTML the server produced for a field value. | ||
| * | ||
| * Two things arrive this way. A platzky plugin's shortcode renders its own field, and | ||
| * goodmap renders its own first-party types (`hyperlink`, `CTA` — see | ||
| * goodmap/field_types.py). Neither needs a component here, which is the point: a field | ||
| * type is added by teaching the server to render it, not by shipping React. | ||
| * | ||
| * The markup is not sanitized, and deliberately so. It is either goodmap's own or comes | ||
| * from an installed plugin package, which already runs arbitrary code in the server | ||
| * process — the same trust platzky extends to shortcode output in post content. | ||
| * Sanitizing would filter nothing such a package could not do more directly, while | ||
| * breaking legitimate markup. The obligation in return is to escape the *data* being | ||
| * interpolated, which is untrusted; `field_types.py` and `Shortcode.render` both do. | ||
| * | ||
| * This is the innermost stage of the fold, so a field plugin attached to the same `type` | ||
| * wraps it and cannot replace it. That is what stops a plugin taking over a first-party | ||
| * type: the server always emits `html` for one, so there is always a seed beneath the | ||
| * wrapper. | ||
| */ | ||
| const ServerHtmlField = ({ input }) => <span dangerouslySetInnerHTML={{ __html: input.html }} />; | ||
|
|
||
| ServerHtmlField.propTypes = { | ||
| input: PropTypes.shape({ html: PropTypes.string.isRequired }).isRequired, | ||
| }; | ||
|
|
||
| export default ServerHtmlField; | ||
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,74 @@ | ||
| import React from 'react'; | ||
| import '@testing-library/jest-dom'; | ||
| import { act } from '@testing-library/react'; | ||
| import MapContainer from '../../src/components/Map/Map'; | ||
|
|
||
| jest.mock('../../src/components/Map/MapComponent', () => () => <div data-testid="map-component" />); | ||
| jest.mock('../../src/components/FiltersForm/FiltersForm', () => () => ( | ||
| <div data-testid="filters-form" /> | ||
| )); | ||
| jest.mock('../../src/components/common/AppToaster', () => () => null); | ||
| jest.mock('../../src/services/http/httpService', () => ({ | ||
| __esModule: true, | ||
| default: { | ||
| getCategoriesData: jest.fn().mockResolvedValue({ categories: [], defaultChecked: {} }), | ||
| getLocationSchema: jest.fn().mockResolvedValue({}), | ||
| }, | ||
| })); | ||
|
|
||
| // Map.jsx creates its own React root instead of being rendered by a test renderer, | ||
| // so act() has to be told this is an act environment. | ||
| globalThis.IS_REACT_ACT_ENVIRONMENT = true; | ||
|
|
||
| const renderApp = async () => { | ||
| await act(async () => { | ||
| MapContainer(); | ||
| }); | ||
| }; | ||
|
|
||
| describe('MapWrap placeholders', () => { | ||
| let error; | ||
|
|
||
| // PropTypes' `node` validator does not recognise portals, so every render here | ||
| // warns about FiltersProvider's children (a pre-existing dev-only warning, not | ||
| // something these tests are about). console.error is silenced and asserted on by | ||
| // message instead of by call count. | ||
| beforeEach(() => { | ||
| error = jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| document.body.innerHTML = ''; | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('renders both portals when the left panel is present', async () => { | ||
| document.body.innerHTML = '<div id="map"></div><div id="filter-form"></div>'; | ||
|
|
||
| await renderApp(); | ||
|
|
||
| expect(document.querySelector('[data-testid="map-component"]')).not.toBeNull(); | ||
| expect(document.querySelector('[data-testid="filters-form"]')).not.toBeNull(); | ||
| }); | ||
|
|
||
| // A deployment with no categories renders no left panel at all, so #filter-form is | ||
| // legitimately missing - the map must still come up rather than the whole app | ||
| // bailing out. | ||
| it('still renders the map when the filters placeholder is missing', async () => { | ||
| document.body.innerHTML = '<div id="map"></div>'; | ||
| await renderApp(); | ||
|
|
||
| expect(document.querySelector('[data-testid="map-component"]')).not.toBeNull(); | ||
| expect(document.querySelector('[data-testid="filters-form"]')).toBeNull(); | ||
| expect(error).not.toHaveBeenCalledWith(expect.stringContaining('render the map')); | ||
| }); | ||
|
|
||
| it('renders nothing when the map placeholder is missing', async () => { | ||
| document.body.innerHTML = '<div id="filter-form"></div>'; | ||
| await renderApp(); | ||
|
|
||
| expect(document.querySelector('[data-testid="map-component"]')).toBeNull(); | ||
| expect(document.querySelector('[data-testid="filters-form"]')).toBeNull(); | ||
| expect(error).toHaveBeenCalledWith(expect.stringContaining('render the map')); | ||
| }); | ||
| }); | ||
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.