Skip to content

Conversation

@efreeti
Copy link
Contributor

@efreeti efreeti commented Oct 5, 2020

Summary

Implemented grid view for trusted apps and toggling between views.

grid view

Checklist

Delete any items that are not applicable to this PR.

const isLoading = useTrustedAppsSelector(isListLoading);
const error = useTrustedAppsSelector(getListErrorMessage);

const handleTrustedAppDelete = useTrustedAppsStoreActionCallback((trustedApp) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we need custom hooks for these? why not just use useCallback()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I resolved all other conversations and let's keep one thread here.

Cause my feeling is that code using pure useCallback to do history navigation and redux action dispatch becomes unnecessarily bulky (prettier is not making it prettier :) )

I would appreciate if we try this out. The whole goal is to write concise code that is not hard to navigate. Currently one single callback that doesn't do much more than navigating url by changing parameters, occupies more than 6 lines.

I also don't like the idea of having to disable the eslint rules, but I've googled for this quite a bit and there are similar stories like this on the git hub page for this rule. In the end we disable eslint rules for even more minor cases which cost almost no effort to do correctly.

If you are worried about memoization of variables from lexical scope then it's true that you can use those in memoization and I could add dependencies list, but I don't think that's the goal of this hook to depend on scope - all that could come from scope is abstracted away (I mean current location) so that you are not supposed to worry about that. It should only get params from event and use those.

In the end this is like ~10 lines of code using this hook? and only in trusted apps (which is pretty small codebase). If it doesn't work out it's an half an hour job (if not less) to replace them.

Copy link
Contributor

Choose a reason for hiding this comment

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

@efreeti my preference leans towards using useCallback() since it's an established pattern and a built in hook, so there's some familiarity as well. Unless there's a strong reason to do otherwise, I don't see a need to break from the pattern just yet.

Also, since we're right on the line and we'd like to ship this in 7.10, I'd suggest we save the conversation for later. You've built a great view here - let's get it in!

@paul-tavares what are your thoughts?

…bala/grid-view-1

� Conflicts:
�	x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/trusted_app_card/index.stories.tsx
@efreeti efreeti self-assigned this Oct 5, 2020
@efreeti efreeti added Feature:Endpoint Elastic Endpoint feature release_note:skip Skip the PR/issue when compiling release notes Team:Endpoint Management v7.10.0 v8.0.0 labels Oct 5, 2020
@efreeti efreeti marked this pull request as ready for review October 5, 2020 21:07
@efreeti efreeti requested review from a team as code owners October 5, 2020 21:07
@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-app-team (Feature:Endpoint)

@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-management (Team:Endpoint Management)

@efreeti efreeti changed the title Btsymbala/grid view [ENDPOINT] Grid view for trusted apps. Oct 5, 2020
@efreeti efreeti changed the title [ENDPOINT] Grid view for trusted apps. [SECURITY_SOLUTION][ENDPOINT] Grid view for trusted apps. Oct 5, 2020
…bala/grid-view-1

� Conflicts:
�	x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx
* you may not use this file except in compliance with the Elastic License.
*/
import { render } from '@testing-library/react';
import { shallow } from 'enzyme';
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe consider using only one testing library per test module and not have a mix of the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will see how to resolve this. Enzyme has shallow, render doesn't. But with shallow you can't do the clicking. I will follow up next on this. Will create Debt issue.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

@kbn/optimizer bundle module count

id before after diff
securitySolution 2000 2003 +3

async chunks size

id before after diff
securitySolution 10.4MB 10.4MB +14.4KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@efreeti efreeti merged commit f340d71 into elastic:master Oct 6, 2020
@efreeti efreeti deleted the btsymbala/grid-view branch October 6, 2020 15:31
efreeti added a commit to efreeti/kibana that referenced this pull request Oct 6, 2020
)

* Refactored store code to group properties related to location so that would be easy to introduce a new view type parameter.

* Added view type to the location and routing.

* Added a simple hook to make navigation easier.

* Improved the navigation hook to get params.

* Some fix for double notification after creating trusted app.

* Added a hook to perform trusted app store actions.

* Fixed trusted app card delete callback.

* Added grid view.

* Fixed the stories structuring.

* Shared more logic between grid and list.

* Finalized the grid view.

* Flattened the props.

* Improved memoization.

* Moved the flex item elements inside conditions.

* Fixed broken stories.

* Updated the snapshot.

* Updated the snapshot.
efreeti added a commit that referenced this pull request Oct 6, 2020
…79704)

* Refactored store code to group properties related to location so that would be easy to introduce a new view type parameter.

* Added view type to the location and routing.

* Added a simple hook to make navigation easier.

* Improved the navigation hook to get params.

* Some fix for double notification after creating trusted app.

* Added a hook to perform trusted app store actions.

* Fixed trusted app card delete callback.

* Added grid view.

* Fixed the stories structuring.

* Shared more logic between grid and list.

* Finalized the grid view.

* Flattened the props.

* Improved memoization.

* Moved the flex item elements inside conditions.

* Fixed broken stories.

* Updated the snapshot.

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

Labels

Feature:Endpoint Elastic Endpoint feature release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants