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
feat(topology filter): added filter for knative event sources #3774
feat(topology filter): added filter for knative event sources #3774
Conversation
@@ -365,7 +365,9 @@ export const transformTopologyData = ( | |||
|
|||
const knSvcResources: K8sResourceKind[] = _.get(resources, ['ksservices', 'data'], []); | |||
knSvcResources.length && getKnativeTopologyData(knSvcResources, NodeType.KnService); | |||
const knEventSources: K8sResourceKind[] = getKnativeEventSources(); | |||
const knEventSources: K8sResourceKind[] = filters.display.eventSources |
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.
you might want to write it like :
const knEventSources: K8sResourceKind[] = filters.display.eventSources | |
const knEventSources: K8sResourceKind[] = filters.display.eventSources && getKnativeEventSources(); |
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 caution against this change. &&
is a sneaky beast in JavaScript. I am unsure if TypeScript properly catches this, but if your left-hand variable is falsey, you get that value. This isn't so much of a problem when rendering React as falsey usually means don't render it.
However if you do it with a JS statement, you can be getting unexpected values into your variable:
1 && 2
// 2
0 && 1
// 0
true && []
// []
false && []
// false
undefined && ['hello', 'world']
// undefined
Which can be confusing for your variable (in this case knEventSources
). Especially if you want it to be an array.
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.
@andrewballantyne Thank you for this piece of information.
When I executed this PR locally (after pulling in #3746) it worked fine without an error so I went ahead and suggested the change. But I will make a note of the example you just shared
/retest |
@nemesis09 All tests are failing. Can you please rebase your PR with the latest master. |
@vikram-raj waiting for PR #3746 to get in. |
/hold |
/kind feature |
/hold cancel |
@nemesis09 looks like you failed unit tests. Please take a look when you get a chance. /hold |
/hold cancel Adding the WIP label to distinguish that this is not ready for reviews. @nemesis09 Please see my previous message |
d84a934
to
f290fd7
Compare
I've added unit tests for the code change. PTAL |
const eventFilter: TopologyFilters = { | ||
display: { | ||
podCount: true, | ||
eventSources: true, | ||
knativeServices: true, | ||
appGrouping: true, | ||
operatorGrouping: true, | ||
}, | ||
searchQuery: '', | ||
}; |
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.
declare it once either in beforeEach or out of describe
block. and you should be importing this from redux/const.ts
and do something like this
const topologyFilters = {...DEFAULT_TOPOLOGY_FILTERS};
and change the topology filter in each test case as you need 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.
I've added the changes. PTAL
f290fd7
to
04b9994
Compare
@christianvogt @jeff-phillips-18 This is a bit odd. When I toggle it on / off, the Knative snaps around a bit. Any ideas? I don't think this PR is at fault as it's just filtering. |
/retest Please review the full test history for this PR and help us cut down flakes. |
19 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 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. |
/hold |
/test e2e-gcp-console |
/hold cancel |
/hold |
/hold cancel |
This PR adds functionality for topology filter option "event sources" under the "show" section
Jira issue - https://jira.coreos.com/browse/ODC-2458
this PR depends on #3746
screens