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

[Uptime] Fix/details page tabs #86296

Merged
merged 32 commits into from
Jan 11, 2021

Conversation

dominiqueclarke
Copy link
Contributor

@dominiqueclarke dominiqueclarke commented Dec 17, 2020

Summary

Fixes: #85826
Fixes: #86743
Fixes: #86174

  • Refactors PageHeader component to rely on props
  • Removes tabs from detail monitor pages
  • Uses the monitor url as the Monitor title when the name is undefined and the id is auto generated

To test

  • Certificates header renders appropriately, with tabs and cert refresh button
  • Settings header renders appropriately, with tabs
  • Monitor header renders appropriately, without tabs and with date picker
  • Overview header renders appropriately, with tabs and with date picker
  • Step details page renders without a header

Overview Page Heading
Screen Shot 2021-01-07 at 12 28 01 PM

Monitor Page Heading
Screen Shot 2021-01-07 at 12 38 39 PM

Certificates Page Header
Screen Shot 2021-01-07 at 12 28 07 PM
Settings Page Header
Screen Shot 2021-01-07 at 12 44 26 PM

Waterfall Page Heading
Screen Shot 2021-01-07 at 12 33 26 PM

@dominiqueclarke dominiqueclarke added v8.0.0 Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Dec 17, 2020
@dominiqueclarke dominiqueclarke requested a review from a team as a code owner December 17, 2020 14:27
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@dominiqueclarke dominiqueclarke added the bug Fixes for quality problems that affect the customer experience label Dec 17, 2020
@dominiqueclarke dominiqueclarke changed the title Fix/details page tabs [Uptime] Fix/details page tabs Dec 17, 2020
@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

history
);
expect(component.find('h1').text()).toBe(monitorName);
expect(component.find('[data-test-subj="uptimeSettingsToOverviewLink"]').length).toBe(0);
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 a way we can just add a data-test-subj to the whole tab group instead of looking for specific links? Seems like the wrong approach, and fragile if the links themselves change.

<EuiFlexItem>
<PageTabs />
</EuiFlexItem>
<EuiFlexItem>{isMonitorRoute ? <MonitorPageTitle /> : <PageTabs />}</EuiFlexItem>
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit weird to me that the header should care about what page it's on. It would make more sense, IMHO, for the page to tell the header what should be in the header, that would, IMHO be less fragile. Each page could just say explicitly "I want this type of header".

Thinking ahead here, when we add a new page we want whoever works on it to make an explicit choice of header.


jest.mock('react-router-dom', () => ({
__esModule: true,
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this being ignored? Any type script ignore statements should come with a comment explaining the why here. As a reviewer (or someone coming along later) it answers a lot of questions.

const url = {
full: 'https://www.elastic.co/',
};
const monitorStatus = {
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like the complexity of these mocks at this point justifies a bit of refactoring here.

We do things like this elsewhere, but it's something we should avoid when we can. The reason is, if we add any additional mandatory fields to this type, this is one more file we must update. Also, it's hard to read etc.

I am wondering if we could make a new selector in redux that just pulls the fields we need, so we would only need to mock that minimal set of fields. In general, when passing a complex mocked object, that can point to a need to reduce the surface area of the function (or component) being tested. It may accept a more complex object than it needs to. I'm also open to other approaches that could simplify the tests here.

@dominiqueclarke
Copy link
Contributor Author

dominiqueclarke commented Jan 4, 2021

I am fine with the refactored appraoch, but it causes few issues

this means whole tabs component will be re-rendered in each page, which means the focus like we see now

image

is gone if we switch tabs

image

Good catch! I'm thinking to resolve this issue, while still keeping the PageHeader component prop based, to move the PageHeader component back to routes.tsx, and pass the props for each route through the route object.

@dominiqueclarke
Copy link
Contributor Author

dominiqueclarke commented Jan 4, 2021

I am fine with the refactored appraoch, but it causes few issues

this means whole tabs component will be re-rendered in each page, which means the focus like we see now

image

is gone if we switch tabs

image

My original thought of how to resolve this was misguided, as it still causes the tabs component to be mounted, unmounted, and remounted, causing loss of focus. We could focus on the current tab on mount, but that would cause an odd experience when a user visits the page outside of using the tabs, for example visiting the direct url. @shahzad31's original implementation tracking the routes is likely the best approach given these challenges.

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

Comment on lines 24 to 31
jest.mock('react-redux', () => {
const originalModule = jest.requireActual('react-redux');

return {
...originalModule,
useSelector: jest.fn(),
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

i wonder if it make sense to use mocks we have in file

x-pack/plugins/uptime/public/lib/helper/test_helpers.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! This works great. I tried to create one for react-router-dom too, but it wouldn't let me use a spy without first running jest.mock in the test file, making a reusable function less helpful.

@dominiqueclarke dominiqueclarke force-pushed the fix/details-page-tabs branch 2 times, most recently from 06f4d7a to 59a59cc Compare January 7, 2021 02:39
</EuiFlexGroup>
{isMonRoute && <EuiHorizontalRule margin="m" />}
{!isMonRoute && <EuiSpacer size="m" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

i believe this includeSpacer prop isn't needed, can we move this perhaps to top of those pages? where it's needed?

Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Please address the includeSpacer stuff, otherwise it's looking good !!

@dominiqueclarke
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
uptime 567 568 +1

Async chunks

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

id before after diff
uptime 1.0MB 1.0MB +193.0B

History

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

@dominiqueclarke dominiqueclarke merged commit 0ff6965 into elastic:master Jan 11, 2021
@dominiqueclarke dominiqueclarke deleted the fix/details-page-tabs branch January 11, 2021 01:55
dominiqueclarke added a commit to dominiqueclarke/kibana that referenced this pull request Jan 11, 2021
* Remove tabs from details page

* update

* fix monitord id

* var name

* add Uptime PageHeader tests to test for the presences of tabs or header

* add Uptime MonitorPageTitle test

* Uptime adjust auto generated monitor id regex

* Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids

* remove history from MonitorPageTitle test

* adjust uptime tabs tests

* adjust MonitorPageTitle tests to mock useSelector

* adjust uptime PageHeader tests

* adjust import order in page_header.test

* add props to Uptime PageHeader to determine render, rather than route context

* alphabetize props in Uptime PageHeader

* remove header from individual pages

* add indepdent page header route that matches all paths

* adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks

* update tests

* adjust header spacing

Co-authored-by: Shahzad <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
dominiqueclarke added a commit to dominiqueclarke/kibana that referenced this pull request Jan 11, 2021
* Remove tabs from details page

* update

* fix monitord id

* var name

* add Uptime PageHeader tests to test for the presences of tabs or header

* add Uptime MonitorPageTitle test

* Uptime adjust auto generated monitor id regex

* Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids

* remove history from MonitorPageTitle test

* adjust uptime tabs tests

* adjust MonitorPageTitle tests to mock useSelector

* adjust uptime PageHeader tests

* adjust import order in page_header.test

* add props to Uptime PageHeader to determine render, rather than route context

* alphabetize props in Uptime PageHeader

* remove header from individual pages

* add indepdent page header route that matches all paths

* adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks

* update tests

* adjust header spacing

Co-authored-by: Shahzad <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 11, 2021
* master:
  [APM] Define placement “Right” to offset tooltip (elastic#87729)
  Fix UI glitch on SOM delete confirmation modal (elastic#87623)
  Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies (elastic#86988)
  [Timelion] Fix tests flakiness on suggestion click (elastic#87273)
  [Uptime] Fix/details page tabs (elastic#86296)
  [ML] Fix earliest and latest texts for date fields (elastic#87482)
  chore(NA): move grokdebugger plugin test fixtures out of __tests__ folder (elastic#87765)
  [Security Solution] Refactor Cypress scenarios to use internal contex… (elastic#86609)
  [Security Solution] Unskip cypress tests (elastic#86653)
dominiqueclarke added a commit that referenced this pull request Jan 11, 2021
* Remove tabs from details page

* update

* fix monitord id

* var name

* add Uptime PageHeader tests to test for the presences of tabs or header

* add Uptime MonitorPageTitle test

* Uptime adjust auto generated monitor id regex

* Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids

* remove history from MonitorPageTitle test

* adjust uptime tabs tests

* adjust MonitorPageTitle tests to mock useSelector

* adjust uptime PageHeader tests

* adjust import order in page_header.test

* add props to Uptime PageHeader to determine render, rather than route context

* alphabetize props in Uptime PageHeader

* remove header from individual pages

* add indepdent page header route that matches all paths

* adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks

* update tests

* adjust header spacing

Co-authored-by: Shahzad <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Shahzad <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
dominiqueclarke added a commit that referenced this pull request Jan 11, 2021
* Remove tabs from details page

* update

* fix monitord id

* var name

* add Uptime PageHeader tests to test for the presences of tabs or header

* add Uptime MonitorPageTitle test

* Uptime adjust auto generated monitor id regex

* Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids

* remove history from MonitorPageTitle test

* adjust uptime tabs tests

* adjust MonitorPageTitle tests to mock useSelector

* adjust uptime PageHeader tests

* adjust import order in page_header.test

* add props to Uptime PageHeader to determine render, rather than route context

* alphabetize props in Uptime PageHeader

* remove header from individual pages

* add indepdent page header route that matches all paths

* adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks

* update tests

* adjust header spacing

Co-authored-by: Shahzad <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Shahzad <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.11.0 v8.0.0
Projects
None yet
5 participants