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

Migrate ILM to ManagementPageLayout #100838

Closed

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented May 27, 2021

Summary

Table loading state

image

Table error state

image

Table empty state

image

Table loaded state

image

Form loading state

image

Form error state

image

Form state

image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@cjcenizal cjcenizal requested a review from a team as a code owner May 27, 2021 23:32
@cjcenizal cjcenizal added chore Feature:ILM Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.0.0 labels May 27, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@cjcenizal cjcenizal added backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes and removed v8.0.0 labels May 27, 2021
@cjcenizal cjcenizal requested a review from sabarasaba May 27, 2021 23:45
@@ -49,7 +49,7 @@ export class IndexLifecycleManagementPlugin
id: PLUGIN.ID,
title: PLUGIN.TITLE,
order: 2,
mount: async ({ element, history, setBreadcrumbs }) => {
mount: async ({ element, history, setBreadcrumbs, managementPageLayout }) => {
Copy link
Contributor Author

@cjcenizal cjcenizal May 27, 2021

Choose a reason for hiding this comment

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

Step 1: Declare the injected managementPageLayout within the plugin's start lifecycle method. Note that we have to pass it into the context (wherever the plugin happens to define it), as seen below on line 80.

cloud?: CloudSetup
): UnmountCallback => {
render(
<I18nContext>
<KibanaContextProvider services={{ cloud, breadcrumbService, license }}>
<KibanaContextProvider services={{ cloud, breadcrumbService, license, managementPageLayout }}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Step 2: Use KibanaContextProvider to provide it to the app using React Context. Note that we have to update our types in the types.ts file to support the change to this interface.

iconType="managementApp"
title={
<h1>
<ManagementPageLayout isEmptyState={true}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Step 3: For every rendered view, use the useKibana hook to access managementPageLayout, cast it to ManagementPageLayout so it looks like a React component, and wrap the rendered view in it. Here on line 125 we're migrating an empty rendered view. On line 153, below, we're migrating a non-empty rendered view. Note the differences in the deltas.

services={{
breadcrumbService,
license: licensingMock.createLicense(),
managementPageLayout: KibanaPageTemplate,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Step 4: Update Jest tests to set up testbed by stubbing the injected managementPageLayout with KibanaPageTemplate.

Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

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

Nice one! I Tested locally and it all seems to be working a-ok. Only one issue I found is related to the colours of the ManagementPageLayout defined with isEmptyState={true} and the EuiSideNav being the same and giving no clear distinction between the both sections.

/>
}
/>
<ManagementPageLayout isEmptyState={true}>
Copy link
Member

@sabarasaba sabarasaba May 28, 2021

Choose a reason for hiding this comment

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

When using the isEmptyState prop, the content panel ends up with a grey background which is the same the apps navigation has. This makes it look a bit confusing as it seems its all one big section instead of two clearly distinct regions.

Screenshot 2021-05-28 at 11 59 15

We could try following a similar approach to what the observability team did, which is instead of using isEmpyState={true} use template="centeredContent". And while this will give us a more clear division between the navigation and content sections, it has one small drawback which is that we end up with an empty pageHeader (observability seems to have left it there regardless). We could fix that issue though by adding a pageTitle, but I cant find a way to just hide it.

Screenshot 2021-05-28 at 11 50 33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sabarasaba Great call! @cchaos This seems like a design problem. Do you have any suggestions on the best way to solve this?

Copy link
Contributor

Choose a reason for hiding this comment

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

+++ Yes, don't use the centeredBody when we've got side-nav. I'm currently working on an upgrade to create a pattern similar to the empty state one for loading.

<EuiButtonEmpty onClick={togglePolicyJsonFlyout} data-test-subj="requestButton">
{isShowingPolicyJsonFlyout ? (
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.hidePolicyJsonButto"
Copy link
Member

@sabarasaba sabarasaba May 28, 2021

Choose a reason for hiding this comment

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

Seems this was already here from before, but shouldnt this and line 326 be hidePolicyJsonButton instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great spot, you're right. I'll fix this in this PR.

<ManagementPageLayout
pageHeader={{
pageTitle: (
<span data-test-subj="policyTitle">
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess there's not a way to pass a data-test-subj to the page title?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's not supported. Per #100085 (comment) there is a hard-coded data-test-subj for the title created by ManagementPageLayout so we can migrate our code and tests over to use that instead I think. But it's also not a blocker IMO so I've decided not to implement that as part of this migration.

@kibanamachine
Copy link
Contributor

kibanamachine commented May 28, 2021

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / jest / Jest Tests.src/plugins/advanced_settings/public/management_app.AdvancedSettings should render unfiltered with query parsing error

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: Method “props” is meant to be run on 1 node. 0 found instead.
    at ShallowWrapper.single (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/enzyme/src/ShallowWrapper.js:1652:13)
    at ShallowWrapper.props (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/enzyme/src/ShallowWrapper.js:1175:17)
    at ShallowWrapper.prop (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/enzyme/src/ShallowWrapper.js:1311:17)
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx:312:35)
    at Promise.then.completed (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:276:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:216:10)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:40)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

Kibana Pipeline / jest / Jest Tests.x-pack/plugins/index_lifecycle_management/__jest__.policy table should show empty state when there are not any policies

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toMatchSnapshot()

Snapshot name: `policy table should show empty state when there are not any policies 1`

- Snapshot  - 5
+ Received  + 7

@@ -3,18 +3,20 @@
  >
    <main
      class="euiPageBody euiPageBody--borderRadiusNone"
    >
      <header
-       class="euiPageHeader euiPageHeader--responsive euiPage--restrictWidth-default euiPageHeader--center"
+       class="euiPageHeader euiPageHeader--paddingLarge euiPageHeader--responsive euiPage--restrictWidth-default euiPageHeader--center"
        data-test-subj="kibana-page-template-header"
      />
-     <main
-       class="euiPageBody euiPageBody--borderRadiusNone"
+     <div
+       class="euiPanel euiPanel--paddingLarge euiPanel--borderRadiusNone euiPanel--plain euiPanel--noShadow euiPageContent euiPageContent--borderRadiusNone"
+       role="main"
+       style="display: flex;"
      >
        <div
-         class="euiPanel euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter"
+         class="euiPanel euiPanel--paddingLarge euiPanel--borderRadiusMedium euiPanel--subdued euiPanel--noShadow euiPanel--noBorder euiPageContent euiPageContent--verticalCenter euiPageContent--horizontalCenter"
          role="main"
        >
          <div
            class="euiPageContentBody euiPage--restrictWidth-default"
          >
@@ -73,8 +75,8 @@
                </span>
              </button>
            </div>
          </div>
        </div>
-     </main>
+     </div>
    </main>
  </div>
    at mountedSnapshot (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx:57:41)
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx:120:5)
    at Promise.then.completed (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:276:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:216:10)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:40)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

Kibana Pipeline / jest / Jest Tests.src/plugins/kibana_react/public/page_template.KibanaPageTemplate render default empty prompt

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: expect(received).toMatchSnapshot()

Snapshot name: `KibanaPageTemplate render default empty prompt 1`

- Snapshot  - 0
+ Received  + 5

@@ -1,7 +1,12 @@
  <EuiPageTemplate
    paddingSize="none"
+   pageHeader={
+     Object {
+       "data-test-subj": "kibana-page-template-header",
+     }
+   }
    pageSideBarProps={
      Object {
        "className": "kbnPageTemplate__pageSideBar",
      }
    }
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/src/plugins/kibana_react/public/page_template/page_template.test.tsx:67:23)
    at Promise.then.completed (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:276:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:216:10)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:40)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

and 17 more failures, only showing the first 3.

History

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

@cjcenizal
Copy link
Contributor Author

Taking a different approach for this

@cjcenizal cjcenizal closed this Jun 10, 2021
@cjcenizal cjcenizal deleted the k8/ilm branch July 6, 2021 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting chore Feature:ILM release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants