Skip to content
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

[SECURITY_SOLUTION][ENDPOINT] Trusted Apps List page Empty State when no trusted apps exist #87252

Merged

Conversation

paul-tavares
Copy link
Contributor

Summary

Displays an Empty Prompt on the Trusted Apps List page when there are no trusted applications.

olm-63-trusted-apps-empty-state

Checklist

@paul-tavares paul-tavares added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.12.0 Team:Defend Workflows “EDR Workflows” sub-team of Security Solution labels Jan 4, 2021
@paul-tavares paul-tavares self-assigned this Jan 4, 2021
@paul-tavares paul-tavares requested review from a team as code owners January 4, 2021 22:35
@paul-tavares paul-tavares requested a review from a team January 6, 2021 17:45
Copy link
Member

@pzl pzl left a comment

Choose a reason for hiding this comment

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

okay? A bit too front-endy for my opinion to carry much weight on this approval though.

payload: { type: 'LoadingResourceState', previousState: currentEntriesExistState },
});

let doTheyExist: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

aliens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤣 Love that guy


http.get.mockImplementation(async (...args) => {
const path = (args[0] as unknown) as string;
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

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

why, and how annoying would it be to not do this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I might need to bring in a type guard function to check args. I found that worked while I investigated this ts error else where. (FYI: the problem is that the interface (HttpHandler) is an interface with multiple calling signatures)

if (path === TRUSTED_APPS_LIST_API) {
return {
data: [getFakeTrustedApp()],
total: 50, // << Should be a value large enough to fulfill two pages
Copy link
Member

Choose a reason for hiding this comment

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

first, 🔥 for the comment explaining the number chosen.

second,

const per_page = httpOptions?.query?.per_page ?? 20;

return {
  //...
  total: per_page*2, // need to fill two full pages
  per_page: per_page,
}

perhaps? but purely subjective

});

beforeEach(() => {
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

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

🎅 sees you when you're coding. He knows when you're @ts-ignore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤣
YOU MUST do all code reviews on my PRs. I'm rolling over here.

if (path === TRUSTED_APPS_LIST_API) {
const { page, per_page: perPage } = options.query as { page: number; per_page: number };

if (page === 1 && perPage === 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Again, not a big fan of putting too much fake logic in these mocks. Probably better patterns to accomplish this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure there is a better way here. We call the same API twice - one with "normal" arguments for populating the list, and another one to check if entries exist. This check here is to ensure we can identify both of them and are able to control the response for each in the test case.

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 should mention: there is another way to mock the responses without having the logic, and that's to use .mockResolvedValueOnce() for each sequential API call that is made. This felt more brittle to me because if any http.get() call is inserted at some point in the future, the test would break, so I opted for mocking the entire implementation in order to have the ability to inspect the call's arguments

@paul-tavares paul-tavares requested a review from pzl January 7, 2021 13:52
@paul-tavares
Copy link
Contributor Author

@pzl thanks for the review - great feedback 👍
Can you take another look when you get a chance. I addressed most of your comments 🕺

Copy link
Member

@pzl pzl left a comment

Choose a reason for hiding this comment

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

👍

10 points from gryffindor for adding 2 ts-ignore's, but those points are as meaningless as caring about that in test files anyway

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2168 2169 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 8.5MB 8.5MB +6.5KB

History

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

@paul-tavares paul-tavares merged commit 14df31b into elastic:master Jan 7, 2021
@paul-tavares paul-tavares deleted the task/olm-63-trusted-apps-empty-state branch January 7, 2021 16:22
paul-tavares added a commit that referenced this pull request Jan 7, 2021
… no trusted apps exist (#87252) (#87672)

* Show loading spinner while trying to determine if entries exist
* Handle display of the 3 conditions: loading, entries exist, no entries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants