Skip to content

Conversation

@sahil143
Copy link
Contributor

@sahil143 sahil143 commented Dec 10, 2019

ODC-Story: https://jira.coreos.com/browse/ODC-2342
ODC-Story: https://jira.coreos.com/browse/ODC-2343

ODC-2343: store all the filters in local storage to presist them across user sessions

ODC-2342:
[TODO]:

  • Remove the Badge from Dropdown Toggle
  • Fix Failing unit tests and add new unit tests

This Pr adds

  • FilterToolbar to topology view and sets up the redux store connection with the toolbar
  • adds action, reducer and default state for toolbar
  • Redux State
topologyFilters: {
    display: {
      podCount: true,
      setTraffic: true,
      eventSources: true,
      knativeServices: true,
      appGrouping: true,
      operatorGrouping: true,
    },
    searchQuery: null,
  }
  • adds the functionality to show # of pods on donut in topology view
    Screenshot from 2019-12-10 20-28-59
    Screenshot from 2019-12-10 20-29-10
    Screenshot from 2019-12-10 23-36-30
    Screenshot from 2019-12-10 23-38-21
    Screenshot from 2019-12-10 23-38-33

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/core Related to console core functionality component/dev-console Related to dev-console component/knative Related to knative-plugin component/shared Related to console-shared labels Dec 10, 2019
@sahil143
Copy link
Contributor Author

cc @openshift/team-devconsole-ux

Copy link
Member

@vikram-raj vikram-raj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot from 2019-12-12 15-04-17

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 12, 2019
@sahil143
Copy link
Contributor Author

@vikram-raj error fixed. Please review again.

@invincibleJai
Copy link
Member

@sahil143 this needs to rebase

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 13, 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can have similar in key-value i.e searchQuery: SearchQuery

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 2cb083e

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type for topologyFilters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 2cb083e

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 16, 2019
Copy link
Contributor

@nemesis09 nemesis09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws Cannot find module './filters/TopologyFilterBar' error for me.

Copy link
Contributor

@nemesis09 nemesis09 Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TopologyFilterBar is located at '../topology2/filters/TopologyFilterBar'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemesis09 fixed all the import errors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting this error in Console

Screenshot from 2019-12-16 18-11-40

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vikram-raj I'm not able to reproduce this error. Can you provide more information regarding this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sahil143 This error shows up when I import Operator backed service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am able to see this error too. resp.status is a optional attribute so add checks to prevent cannot read property of null error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karthikjeeyar @vikram-raj Added a check. Can you confirm that this error is resolved. e14a5a7

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sahil143 Now, I do not see this error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelFor will not work for crd based models (such knative revisions, event sources).

Suggested change
modelFor(data.dc.kind),
modelFor(referenceFor(data.dc)),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing the error in the console.
error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 15b341d

Copy link
Member

@vikram-raj vikram-raj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The topology filter is not persisting after the page refresh.

@vikram-raj
Copy link
Member

The topology filter is not persisting after the page refresh.

It is working fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 7f87818

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this var(--pf-chart-global--FontSize--sm)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 7f87818

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this var(--pf-chart-global--FontSize--sm)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 7f87818

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use RevisionModel.kind instead of Revision string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we don't want to have shared with a dependency on knative-plugin.
We actually need a better approach or an extension to the pod ring.

@@ -0,0 +1,3 @@
.odc-pod-status__chart-label {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

Suggested change
.odc-pod-status__chart-label {
.odc-pod-set__chart-label {

@sahil143 sahil143 force-pushed the pod-count branch 2 times, most recently from 00866d4 to 229435d Compare December 30, 2019 11:45
Copy link
Member

@vikram-raj vikram-raj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 30, 2019
@vikram-raj
Copy link
Member

/retest

@andrewballantyne
Copy link
Contributor

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 30, 2019
Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a followup PR but the styling for the filter bar has an extra line through it:
image

Please be sure to log a ticket for this @sahil143


I seriously question the use of Redux here. @sahil143 can you give me some feedback to why this is in redux and local storage? This feels to double down on the same front.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't exist and causes a crashing exception on load of Topology.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sahil143 Christian is referring to the throw will likely break the thread and more than likely end up in a white screen.

Error modal wouldn't be the end of the world (helps the user report the error for instance)... but since this is an access-check perhaps we just log the error in the console. This is unlikely to happen, but if it does, the user shouldn't have to reach for browser refresh. Perhaps gracefully fail the access check to a false state and leave it at that. It'll be rare, but if it happens, under no circumstances should we crash the Console application.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}: RootState): any => topology.get('filters');
}: RootState): { [filterName: string]: any } => topology.get('filters');

Not sure if we have a pre-defined filter structure... but we can at least showcase this will be a map. I see them all being boolean, is that an intended design? If so, make the any be boolean as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this change was for organization of what data comes from the store... but there is no need to export it. I'm on the fence on if it was worth breaking it out to its own type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm - technically this is the wrong type. showPodCount is a boolean, and icon is an optional string. !true && value will be false. If we were using PropTypes, this would cause an error. TypeScript doesn't know any better because it's not strongly typed.

Suggested change
icon={!workloadData.showPodCount && workloadData.builderImage}
icon={!workloadData.showPodCount ? workloadData.builderImage : undefined}

I'd prefer we make a stronger effort to make our code predictable. If I (the component) expect a string or nothing, then let us provide that. Otherwise code within' the BaseNode needs to understand the type isn't a strict contract, and that's a violation of TypeScript principles.

The more I think about it - the more I am irritated TypeScript doesn't catch this. ! anything is a boolean. It should be able to tell optional string !== boolean. 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason we don't want to elaborate on this state structure?

Comment on lines +13 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do this inside a reducer; this is a side-effect.

The reducer is a pure function that takes the previous state and an action, and returns the next state.

Docs: https://redux.js.org/basics/reducers/#handling-actions

We need to use middleware to provide this kind of side-effecty operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a standard to use _.merge - surprised this isn't breaking a lint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a side-effect... see my other comment.

Copy link
Contributor

@andrewballantyne andrewballantyne Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutates DEFAULT_TOPOLOGY_FILTERS and that is not desired. Any imports of this will have a mutated value. Please make sure you avoid using lodash methods that mutate an object that is not to be mutated (constants, props, state, etc).

Note: This method mutates object.

Docs: https://lodash.com/docs/4.17.15#merge

A fix, for instance, could be:

Suggested change
return merge(DEFAULT_TOPOLOGY_FILTERS, JSON.parse(filters));
return merge({}, DEFAULT_TOPOLOGY_FILTERS, JSON.parse(filters));

@andrewballantyne
Copy link
Contributor

/lgtm cancel

This is actually broken right now.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 31, 2019
initial commit

use select  instead of dropdown from pf and add pod count to the nodes

add input field for search

fix unit tests and add new unit tests

add checks for pods and  rc

use value on input field from searchQuery

ODC-2343: store filters in locaStorage

https://jira.coreos.com/browse/ODC-2343

change SearchFilter to searchQuery

update imports from topology2 to topology

add checks for resp for checkPodEditAccess

add support fo crd to get K8sKind

add type for impersonate and add scss file for PodSet

use reducer for topologyFilters using plugin extension

refactor pod-ring utility

refactor filter dropdown and change styles for filter bar

fix locaal storage bug

fix failing tests and remove setTraffic from the filters list

change css class name

remove podset.scss

remove not extra line

make requested changes
filters: getTopologyFilters(state),
});

const dispatchToProps = (dispatch: Dispatch): DispatchProps => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention this, but it's not a needed change so it doesn't matter.

Feel free to use the short-hand dispatchToProps layout, which is just an object. If all you need to do is pass-through values and nothing else, you can use the short-hand:

const dispatchToProps = {
  onFilterChange: setTopologyFilters,
};

Not sure what this means to our typing, but React-Redux handles this nicely.

expect(wrapper.exists()).toBeTruthy();
});

it('should have 5 filters in total', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have a number in the test description... it's easy for this to get out of sync (see my previous review comment to see what I named it)

Comment on lines +20 to +23
export type TopologyFilters = {
display: DisplayFilters;
searchQuery: SearchQuery;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't create types after they're used... but I suspect TypeScript is handling this. You cannot do this with variables, our linter errors out on it.

Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

My last set of comments don't require changing... it seems not to be an issue. Definitely something to consider though.

Christian will have to give the approval.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 2, 2020
@andrewballantyne
Copy link
Contributor

/kind feature

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 2, 2020
@christianvogt
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, christianvogt, sahil143, vikram-raj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 2, 2020
@spadgett
Copy link
Member

spadgett commented Jan 2, 2020

/hold cancel
/retest
#3847 has fixed the e2e tests

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 2, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console component/knative Related to knative-plugin component/shared Related to console-shared kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.