Skip to content
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

Fix layer generator with 2nd layer #204

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Change BigQuery source type name from 'bq' to 'bigquery' [#203](https://github.com/CartoDB/carto-react-template/pull/203)
- Add new hygen generators for components, models and slices [#171](https://github.com/CartoDB/carto-react-template/pull/171)
- Adapt to new **multi-package** structure for carto-react libs [#206](https://github.com/CartoDB/carto-react-lib/pull/206)
- Fix layer generator with second layer [#204](https://github.com/CartoDB/carto-react-template/pull/204)

## 1.0.0-beta12 (2021-02-08)
- Refactor on basic JSX & JS stuff [#170](https://github.com/CartoDB/carto-react-template/pull/170)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
inject: true
to: "<%= attach ? `src/${view_path}` : null %>"
after: "'react'"
skip_if: "addLayer"
after: "from 'react'"
skip_if: \{ addLayer,
---

import { addLayer, removeLayer, addSource, removeSource } from '@carto/react-redux';
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ to: "<%= attach ? `src/${view_path}` : null %>"
after: "from 'react'"
skip_if: "import { <%= h.changeCase.constantCase(name) %>_ID"
---
import { <%= h.changeCase.constantCase(name) %>_ID } from 'components/layers/<%= h.changeCase.pascalCase(name) -%>';
import { <%= h.changeCase.constantCase(name) %>_ID } from 'components/layers/<%= h.changeCase.pascalCase(name) -%>';
2 changes: 1 addition & 1 deletion hygen/_templates/layer/new/inject_view_import_source.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ to: "<%= attach ? `src/${view_path}` : null %>"
after: "from 'react'"
skip_if: "<%= `data/sources/${source_file}` %>"
---
import <%= h.changeCase.camelCase(source_file) %> from 'data/sources/<%= h.changeCase.camelCase(source_file) %>';
import <%= h.changeCase.camelCase(source_file) %> from 'data/sources/<%= h.changeCase.camelCase(source_file) %>';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
inject: true
to: "<%= attach ? `src/${view_path}` : null %>"
after: addSource\(<%= h.changeCase.camelCase(source_file) %>\)\n[ \t]*\)|addSource\(<%= h.changeCase.camelCase(source_file) %>\)\);
skip_if: <%= h.changeCase.constantCase(name) %>_ID,
---

dispatch(
addLayer({
id: <%= h.changeCase.constantCase(name) %>_ID,
source: <%= h.changeCase.camelCase(source_file) %>.id,
})
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
inject: true
to: "<%= attach ? `src/${view_path}` : null %>"
before: dispatch\(removeSource\(<%= h.changeCase.camelCase(source_file) %>.id\)\);
skip_if: dispatch\(removeLayer\(<%= h.changeCase.constantCase(name) %>_ID\)\);
---

dispatch(removeLayer(<%= h.changeCase.constantCase(name) %>_ID));