-
Notifications
You must be signed in to change notification settings - Fork 24
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
ENDOC-549 Add React context params tutorial #577
Conversation
@@ -0,0 +1,74 @@ | |||
# Entando MFE Context Parameters | |||
|
|||
Entando MFEs can be made more powerful using one or more configuration techniques. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace the period with a colon
# Entando MFE Context Parameters | ||
|
||
Entando MFEs can be made more powerful using one or more configuration techniques. | ||
1. Provide a configuration MFE. See the [Widget configuration tutorial](./widget-configuration.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Provide a configuration MFE" flows a little better
Entando MFEs can be made more powerful using one or more configuration techniques. | ||
1. Provide a configuration MFE. See the [Widget configuration tutorial](./widget-configuration.md). | ||
2. Access context parameters from the Entando Application. | ||
3. Setup API Claims so MFEs are automatically connected to microservices in the same bundle or namespace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set up
i believe API claims uses a lowercase "c"
@@ -0,0 +1,74 @@ | |||
# Entando MFE Context Parameters | |||
|
|||
Entando MFEs can be made more powerful using one or more configuration techniques. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would remove periods from the entries in this list (minor but matches our current formatting preference)
This tutorial will demonstrate the second technique by making use of context parameters drawn from the Entando Application. | ||
|
||
::: tip | ||
Context params are provided via the `@wp.page` and `wp.info` custom tags on the server side. `wp.info` provides values by key for the info context, and also provides system parameters where the key is `systemParam`. See the [Core Tag Library](../../../docs/reference/freemarker-tags/freemarker-core-tags.md) for more information on these tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last sentence: given the link/ref name, "on these tags" is kind of redundant/repetitive
slightly more linear to reverse the order of the first sentence: "Context params are provided on the server side via the @wp.page
and wp.info
custom tags."
a bit awkward to begin a sentence with a backticked & lowercase term
"...context, and also provides system..." -> "...context and system..."
is there another word just as fitting as "provides" to eliminate repetition?
what does @wp.page
do? odd to elaborate on one tag and not the other
</> | ||
)} | ||
``` | ||
3. Provide sample data in the `simple-mfe/public/mfe-config.json` so you can test this locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
punctuate with :
"systemParam_applicationBaseURL": "https://my-production-url/entando-de-app" | ||
} | ||
``` | ||
4. Startup your MFE and you should see the values displayed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start up; use :
|
||
## Configure and publish the bundle | ||
|
||
1. Edit the `entando.json` and add the following block to the `simple-mfe` microfrontend definition: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omit "the" in front of entando.json
micro frontend
"systemParam_applicationBaseURL" | ||
] | ||
``` | ||
2. You can now build and install the bundle. See [the Build and Publish tutorial](../pb/publish-project-bundle.md) for more details on these steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
steps:
ent bundle deploy | ||
ent bundle install | ||
``` | ||
3. Add the widget to a page in your Entando Application to confirm the live context parameters are shown as expected. For example, if you modify a page URL to select a different language (e.g. change `YOUR-BASE-URL/entando-de-app/en/demo.page` to `YOUR-BASE-URL/entando-de-app/it/demo.page`, the current language parameter (`info_currentLang`) should change from `en` to `it`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"are shown as" hits a little off; appear or display
missing parenthesis after e.g.
@@ -17,12 +17,12 @@ Start by adding a configuration option to an existing MFE. If you don't already | |||
|
|||
### Add an Attribute to the Custom Element | |||
|
|||
1. Replace the contents of `src/WidgetElement.js` with the following code to add attribute handling to the custom element and re-render the app when an attribute changes. This enables the Entando-provided `config` attribute of the custom element to be passed as a property to the React root component (`App`). | |||
1. Replace the contents of `src/custom-elements/WidgetElement.js` with the following code to add attribute handling to the custom element and re-render the app when an attribute changes. This enables the Entando-provided `config` attribute of the custom element to be passed as a property to the React root component (`App`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enables the Entando-provided config
attribute of the custom element to be passed as a property to the React root component (App
). << this sentence was always really hard to understand. Can we simplify to >> This enables the Entando-provided config
attribute to be passed as a property to the React root component (App
).
* `systemParam_applicationBaseURL`: the full base URL of the Entando Application | ||
|
||
::: tip | ||
Context params are provided on the server side via the `@wp.page` and `wp.info` custom tags. Note that the `wp.info` tag retrieves values by key for the info context as well as system parameters when the key is `systemParam`. See the [Core Tag Library](../../../docs/reference/freemarker-tags/freemarker-core-tags.md) for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean wp.info key retrieves values for both info context and system parameters only when the key is systemParam? complex sentence so making sure it reads correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Might be too much detail even for a tip but best I could come up with.
1. Edit the `simple-mfe/src/App.js`. Start by mapping the `contextParams` from the `config` structure: | ||
```js | ||
const { contextParams, params} = config || {}; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only section that gave me trouble doing the tutorial. I added this line and did not remove the other params line. I'm guessing programmers would understand what the 'config' structure hints at but just wanted to let you know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you had to delete the other params line to get it to build correctly? It shouldn't have allowed the original line with this addition. I'll reword it.
- [A working instance of Entando](../../../docs/getting-started/) | ||
- [A configurable React MFE](./widget-configuration.md) | ||
|
||
## Configure the MFE to accept and display context parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the second level headers be capitalized since it shows up in the nav bar
No description provided.