Skip to content

[Tech Debt] Reorder Rules page#152897

Merged
CoenWarmer merged 6 commits intoelastic:mainfrom
CoenWarmer:chore/152790-reorder-rules-page
Mar 20, 2023
Merged

[Tech Debt] Reorder Rules page#152897
CoenWarmer merged 6 commits intoelastic:mainfrom
CoenWarmer:chore/152790-reorder-rules-page

Conversation

@CoenWarmer
Copy link
Contributor

Resolves #152790

Summary

This PR updates the Rules Page to follow the newly agreed upon structure for the Observability app.

This PR is part of a larger effort to have all pages in the Observability app follow the same structure so they are more consistent with each other. More details in the epic: #152783

It also cleans up dead and unused components where found.

All design and functionality should be exactly the same as before.

@CoenWarmer CoenWarmer added the release_note:skip Skip the PR/issue when compiling release notes label Mar 8, 2023
@CoenWarmer CoenWarmer force-pushed the chore/152790-reorder-rules-page branch 2 times, most recently from 78a1847 to bc4a886 Compare March 8, 2023 11:44
@CoenWarmer CoenWarmer changed the title Reorder Rules page [Tech Debt] Reorder Rules page Mar 8, 2023
@CoenWarmer CoenWarmer force-pushed the chore/152790-reorder-rules-page branch from bc4a886 to e47ab7c Compare March 8, 2023 12:51
@CoenWarmer CoenWarmer marked this pull request as ready for review March 8, 2023 14:46
@CoenWarmer CoenWarmer requested a review from a team March 8, 2023 14:46
@CoenWarmer CoenWarmer marked this pull request as draft March 10, 2023 11:53
@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observability 517 513 -4

Async chunks

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

id before after diff
observability 1.1MB 1.1MB -1.9KB
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 433 436 +3

Total ESLint disabled count

id before after diff
securitySolution 513 516 +3

History

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

@CoenWarmer CoenWarmer marked this pull request as ready for review March 19, 2023 20:13
@CoenWarmer CoenWarmer requested a review from a team as a code owner March 19, 2023 20:13
updateFilters({ filter: 'ruleLastRunOutcomes', value: lastRunOutcomeFilter });
}
}, [lastResponseFilter]);
}, [lastRunOutcomeFilter]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't ESLint have caught this? It seems the exhaustive-deps rule is not kicking in here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, looks like we have a legacy file wide /* eslint-disable react-hooks/exhaustive-deps */ at the top of the file.

I will create an issue to remove it

'ruleExecutionStatus',
'ruleExecutionState',
]}
onLastRunOutcomeFilterChange={handleLastRunOutcomeFilterChange}
Copy link
Contributor Author

@CoenWarmer CoenWarmer Mar 19, 2023

Choose a reason for hiding this comment

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

Changing the lastResponse filter in the Rules List UI didn't update the URL in the previous implementation. Now updated so it does


function WrappedRulesPage() {
return (
<Provider value={rulesPageStateContainer}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced state container with a simpler pattern that offers the same functionality

Copy link
Member

Choose a reason for hiding this comment

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

What pattern did you use instead and where is the implementation?

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've tagged you in 2 comments.

"xpack.observability.rules.addRuleButtonLabel": "Créer une règle",
"xpack.observability.rules.deleteSelectedIdsConfirmModal.cancelButtonLabel": "Annuler",
"xpack.observability.rules.docsLinkText": "Documentation",
"xpack.observability.rules.loadError": "Impossible de charger les règles",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All these translations were exported from translations.ts but never imported anywhere

}

const transitions: RulesPageStateTransitions = {
setLastResponse: (state) => (lastResponse) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this code seems to be referencing a previous implementation of this table that is not used in the current page.

I suspect the RuleList component used to live inside Observability, but has been moved to TriggersActionUi. In that process this implementation was not properly cleaned up.

@CoenWarmer CoenWarmer enabled auto-merge (squash) March 19, 2023 21:50
Copy link
Contributor

@JiaweiWu JiaweiWu left a comment

Choose a reason for hiding this comment

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

triggers actions UI changes LGTM!

updateFilters({ filter: 'ruleLastRunOutcomes', value: lastRunOutcomeFilter });
}
}, [lastResponseFilter]);
}, [lastRunOutcomeFilter]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, looks like we have a legacy file wide /* eslint-disable react-hooks/exhaustive-deps */ at the top of the file.

I will create an issue to remove it

Comment on lines +45 to +58
const urlStateStorage = createKbnUrlStateStorage({
history,
useHash: false,
useHashQuery: false,
});

const { status, lastResponse } = urlStateStorage.get<{
status: RuleStatus[];
lastResponse: string[];
}>('_a') || { status: [], lastResponse: [] };

const [stateStatus, setStatus] = useState<RuleStatus[]>(status);
const [stateLastResponse, setLastResponse] = useState<string[]>(lastResponse);
const [stateRefresh, setRefresh] = useState(new Date());
Copy link
Contributor Author

@CoenWarmer CoenWarmer Mar 20, 2023

Choose a reason for hiding this comment

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

@maryam-saeidi new code as replacement of state container (part 1) (line 45-58)

Comment on lines +76 to +87
const handleStatusFilterChange = (newStatus: RuleStatus[]) => {
setStatus(newStatus);
urlStateStorage.set('_a', { status: newStatus, lastResponse });
return { lastResponse: stateLastResponse || [], status: newStatus };
};

const handleLastRunOutcomeFilterChange = (newLastResponse: string[]) => {
setRefresh(new Date());
setLastResponse(newLastResponse);
urlStateStorage.set('_a', { status, lastResponse: newLastResponse });
return { lastResponse: newLastResponse, status: stateStatus || [] };
};
Copy link
Contributor Author

@CoenWarmer CoenWarmer Mar 20, 2023

Choose a reason for hiding this comment

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

@maryam-saeidi and part 2 (line 76-87)

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

LGTM and works as expected locally 👍🏻

@CoenWarmer CoenWarmer merged commit 6a78ca4 into elastic:main Mar 20, 2023
@kibanamachine kibanamachine added v8.8.0 backport:skip This PR does not require backporting labels Mar 20, 2023
v1v added a commit to v1v/kibana that referenced this pull request Mar 20, 2023
…loy-my-kibana-oblt

* upstream/main: (727 commits)
  Upgrade caniuse-lite db (elastic#153318)
  [Security Solution] expanded flyout - right section - json tab implementation (elastic#152935)
  chore(slo): Make APM indicator's index required (elastic#153311)
  skip failing test suite (elastic#136688)
  [Security Solution] Fix security-solution storybook package codeowners (elastic#153307)
  [EUI] Add `scrollLock` workaround CSS to Kibana's `body` (elastic#153227)
  [Cloud Security] Show coming soon deployments of vulnerability management (elastic#153249)
  [Cloud Security] fixed onboarding link directs to cspm integration (elastic#153268)
  [Response Ops][Alerting] Reusable functions for FAAD resource installation (elastic#152849)
  remove geohash_grid aggregation support (elastic#152952)
  [Tech Debt] Reorder Rules page (elastic#152897)
  [Saved Object Finder] Add help text & left button (elastic#152742)
  [Transform] Replace SavedObjectsFinder component (elastic#153128)
  Make pipeline creation endpoint accept a full pipeline definition (elastic#153133)
  [Fleet] Displaying policy changes in Agent activity (elastic#153237)
  skip flaky suite (elastic#152852)
  [Security Solution][Endpoint] Add tests to cover RBAC entries in the Role Kibana Privileges flyout (elastic#153068)
  [Security Solution][Endpoint] Additional tests for Response Console History Log page (covers TestRail manual tests) (elastic#153042)
  [Monitoring] Display node roles in Nodes table (elastic#152127)
  Rename getEditAlertFlyout to getEditRuleFlyout (elastic#153243)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes v8.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjust folder structure in Rules page

6 participants