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
Support code references at any level within extension's properties #9070
Conversation
export const mergeExtensionProperties = <E extends Extension>(e: E, properties: {}): E => | ||
Object.freeze({ | ||
...e, | ||
properties: Object.assign({}, e.properties, properties), | ||
properties: _.merge({}, e.properties, properties), |
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.
@christianvogt FYI, this change affects translation of strings within extension's properties in useExtensions
hook:
mergeExtensionProperties(e, translate(e.properties, t))
There should be no change in above behavior, since the translate
function returns the "full" object (except for strings which may get replaced and container arrays & objects having the same content but different referential identity).
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.
@vojtechszocs This is the change which breaks the guided tour! See other comment.
@@ -8,7 +8,8 @@ | |||
"experimentalDecorators": true, | |||
"sourceMap": true, | |||
"noUnusedLocals": true, | |||
"skipLibCheck": true | |||
"skipLibCheck": true, | |||
"lib": ["es2020", "dom"] |
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.
@rawagner @christianvogt FYI, this is a workaround to allow using ES2020 Promise.allSettled
types consistently in different modules within the dynamic SDK package.
Based on discussion with @tetchel I think it's best to use "target": "es2020"
- I'll post a separate PR for that.
According to Console README
We support the latest versions of the following browsers:
- Edge
- Chrome
- Safari
- Firefox
IE 11 and earlier is not supported.
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.
Another alternative is to use "target": "es2016"
with "lib": ["es2016", "es2020.promise", "dom"]
to add specific types we need on top of the existing target spec.
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.
Another alternative is to use
"target": "es2016"
with"lib": ["es2016", "es2020.promise", "dom"]
to add specific types we need on top of the existing target spec.
I've updated the PR to use this approach.
Tested with following steps
then check browser console logs, we can see
Both testHandler and testFunc are called and executed |
/label qe-approved |
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
/retest Please review the full test history for this PR and help us cut down flakes. |
17 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest |
Hey @vojtechszocs, I investigate why the E2E tests fails. They missed the guided tour when the user switches the first time to the developer perspective. And thanks these tests I can confirm with some manual tests now that this alert / modal doesn't appear anymore. The guided tour is also not shown anymore in the dropdown menu in the top right corner. The component is included here https://github.com/openshift/console/blob/master/frontend/public/components/masthead-toolbar.jsx#L361-L363 Debugging shows that the The Edit: Looks like it is related to this change: #9070 (review) Menu for kubeadmin before (it is similar for devs): Menu for kubeadmin with this change (it is similar for devs): |
The last comment above shows that this PR breaks the devconsole Guided Tour. As mentioned, the change from /lgtm cancel |
@jerolimov Thanks so much for looking into this! I'll rebase & update PR accordingly. |
42a671e
to
f5de7be
Compare
import { Extension } from '../typings'; | ||
|
||
export const isTranslatableString = (value): value is string => { | ||
return typeof value === 'string' && /^%.+%$/.test(value); |
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 don't like micro optimizations, but I also think its not necessary to create/compile/match a regex pattern here.
return typeof value === 'string' && /^%.+%$/.test(value); | |
return typeof value === 'string' && value.startsWith('%') && value.endsWith('%'); |
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.
Agreed, we can use startsWith '%' and endsWith '%' and length > 2
condition instead of RegExp here.
Thanks for the update. The Guided tour is back again. I also tested a code ref on a second level by changing the ContextProvider extension locally. Works fine. 👍 /lgtm |
/retest |
f5de7be
to
a278d80
Compare
a278d80
to
a3913a8
Compare
Rebased, updated |
/test e2e-gcp-console |
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.
Tested nested code refs again and works. Guided tour also works.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bipuladh, christianvogt, jerolimov, 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 |
With this PR,
CodeRef<T>
values can appear at any level within extension's properties object.For example, using the following Console extension declaration
both
e.properties.bar
ande.properties.baz.qux
values will beEncodedCodeRef
toCodeRef
) when loading the given pluginCodeRef<T>
toT
) when consumed viauseResolvedExtensions
hookDetection of code references (both encoded & executable) relies on a recursive equivalent of
_.forOwn
function that traverses plain objects and arrays. This means that e.g.CodeRef<VoidFunction>[]
(array of code references) properties are supported as well.cc @bipuladh @christianvogt