-
Notifications
You must be signed in to change notification settings - Fork 605
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
OCPBUGS-36678: Add useQuickStartContext hook and expose it via dynamic plugin API #14055
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. In 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: In 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. |
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.
/lgtm
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
Needs 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. 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. 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. In 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 In 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.useContext
hook 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
QuickStartContext
from@patternfly/quickstarts
package.From a plugin's perspective, unless
@patternfly/quickstarts
is marked as a shared module, that plugin will always use its own "copy" of@patternfly/quickstarts
module(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
QuickStartContext
mentioned 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-webpack
version that includes #13992 and that plugin also uses PatternFly 5 or higher,@patternfly/quickstarts
will 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
useQuickStartContext
and expose it via@openshift-console/dynamic-plugin-sdk
package.(*) Requires that we publish a new version of
@openshift-console/dynamic-plugin-sdk
package with this change included.Notes
Console already has
withQuickStartContext
React utility that injectsquickStartContext
prop into the wrapped component. The value ofquickStartContext
prop 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
withQuickStartContext
utility 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?