OCPBUGS-36678: Add useQuickStartContext hook and expose it via dynamic plugin API#14055
Conversation
|
@vojtechszocs: This pull request references Jira Issue OCPBUGS-36678, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
No objections if it unused, but we probably need to deprecate first. |
|
/jira refresh |
|
@jhadvig: This pull request references Jira Issue OCPBUGS-36678, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Forgot to add API docs change, I'll update the PR. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhamilto, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
/label acknowledge-critical-fixes-only |
|
@vojtechszocs: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
@vojtechszocs: Jira Issue OCPBUGS-36678: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-36678 has been moved to the MODIFIED state. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[ART PR BUILD NOTIFIER] This PR has been included in build openshift-enterprise-console-container-v4.17.0-202407160240.p0.g7ba2bdc.assembly.stream.el9 for distgit openshift-enterprise-console. |
|
/cherry-pick release-4.16 |
|
@vojtechszocs: new pull request created: #14070 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Problem
When working with React contexts in Console frontend and its dynamic plugins, the context object passed to
React.useContexthook must be identical (i.e.===referentially equal) in order for the context value (hook result) to work properly across all plugins.The exact use case here is importing
QuickStartContextfrom@patternfly/quickstartspackage.From a plugin's perspective, unless
@patternfly/quickstartsis marked as a shared module, that plugin will always use its own "copy" of@patternfly/quickstartsmodule(s) during its webpack build. This behavior is normal and expected; code not shared between the host application and its plugins can be loaded multiple times in possibly different versions.The problem arises when some objects, like
QuickStartContextmentioned above, must be referentially equal in order for plugin to properly interoperate with the host application.❗ If a plugin uses
@openshift-console/dynamic-plugin-sdk-webpackversion that includes #13992 and that plugin also uses PatternFly 5 or higher,@patternfly/quickstartswill not be treated as a shared module. This is because Console provided PatternFly shared modules are limited to PF 4 implementation for backwards compatibility reasons. Plugins using PatternFly 5 or higher will share PF modules between themselves via dynamic modules #13521.Solution
Add new React hook
useQuickStartContextand expose it via@openshift-console/dynamic-plugin-sdkpackage.(*) Requires that we publish a new version of
@openshift-console/dynamic-plugin-sdkpackage with this change included.Notes
Console already has
withQuickStartContextReact utility that injectsquickStartContextprop into the wrapped component. The value ofquickStartContextprop is the context value retrieved viaReact.useContext(QuickStartContext)which means the prop name is misleading and we should improve it at some point.@rhamilto @TheRealJon The above mentioned
withQuickStartContextutility seems to be unused in Console frontend and not exposed via dynamic plugin API. I'd suggest removing it, do you have any thoughts or objections?