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

[Obs Alerting] Save/use active group state from url !! #197771

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

shahzad31
Copy link
Contributor

Summary

Fixes #195627
Save/use active group state from url !!

if url state exists it will be propagated to component and mixed with local state

image

@shahzad31 shahzad31 requested review from a team as code owners October 25, 2024 08:08
@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-management Observability Management User Experience Team labels Oct 25, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@shahzad31 shahzad31 added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) and removed ci:project-deploy-observability Create an Observability project Team:obs-ux-management Observability Management User Experience Team labels Oct 25, 2024
Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

Thanks Shahzad for picking this up!

When I test locally, the grouping functionality does not work for me:

Screen.Recording.2024-10-25.at.17.32.28.mov

@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-management Observability Management User Experience Team labels Oct 25, 2024
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

Worked like a charm on the alerts page!

Would you please also apply this logic to the alert details page > related alerts?

image

@@ -118,6 +120,21 @@ const AlertsGroupingInternal = <T extends BaseAlertsGroupAggregations>(
onOptionsChange,
});

useEffect(() => {
Copy link
Member

@umbopepato umbopepato Oct 31, 2024

Choose a reason for hiding this comment

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

How about moving the initialization logic to the grouping context provider?

export const AlertsGroupingContextProvider = ({
  initialState = {},
  children,
}: PropsWithChildren<{ initialState?: AlertsGroupingState }>) => {
  const [groupingState, setGroupingState] = useState<AlertsGroupingState>(initialState);
  return (
    <AlertsGroupingContext.Provider
      value={useMemo(
        () => ({ groupingState, setGroupingState }),
        [groupingState, setGroupingState]
      )}
    >
      {children}
    </AlertsGroupingContext.Provider>
  );
};

This way we could avoid the initialization effect.

In case, this is how AlertsGrouping could forward the initialState to the provider:

export const AlertsGrouping = typedMemo(
  <T extends BaseAlertsGroupAggregations>(props: AlertsGroupingProps<T>) => {
    return (
      <AlertsGroupingContextProvider
        initialState={
          props.initialGroupings
            ? { [props.groupingId]: { activeGroups: props.initialGroupings } }
            : undefined
        }
      >
        <AlertsGroupingInternal {...props} />
      </AlertsGroupingContextProvider>
    );
  }
);

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

To my understanding this PR tries to sync the URL state with the grouping state. Instead of modifying the grouping component could something like that work?

useEffect(() => {
  groupingStateFromURL = getURLGroupingState()
  updateGrouping(groupingStateFromURL)
}, [// deps]

@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

History

@shahzad31 shahzad31 marked this pull request as draft November 21, 2024 18:49
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Obs][Alerts] Control "group by" view via the URL
5 participants