Commit Graph

9 Commits

Author SHA1 Message Date
Dennis Oelkers
26721094f8 Migrate MetricsStore and GlobalThroughputStore from Reflux to React Query (#25247)
* Migrate MetricsStore and GlobalThroughputStore from Reflux to React Query

Replace the Reflux-based MetricsStore and GlobalThroughputStore with a
shared MetricsProvider context that batches all metric subscriptions into
a single react-query POST to /cluster/metrics/multiple. This eliminates
Reflux from the metrics subsystem entirely.

New infrastructure:
- src/types/metrics.ts: shared metric type definitions
- src/contexts/MetricsProvider.tsx: batching context with ref-counted
  subscriptions, 2s refetchInterval, fetchPeriodically
- src/hooks/useMetrics.ts: useMetrics, useNodeMetrics, useMetricsNames,
  useGlobalThroughput hooks

Migrated 22 consumer files from useStore(MetricsStore) + MetricsActions
add/remove pattern to the new hooks. Deleted MetricsStore,
GlobalThroughputStore, and GlobalThroughputStore.test.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix MetricsContext singleton for cross-bundle compatibility

The MetricsContext was created with plain createContext(), causing
enterprise plugin bundles to get a separate context instance. Use the
singleton pattern (matching NodesContext, StreamsContext, etc.) so the
same context instance is shared across all bundles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix remaining MetricsStore type import in InputThroughputUtils

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add MetricsProvider to test WrappingContainer

Tests rendering components that use useMetrics (e.g. Navigation with
GlobalThroughput) need MetricsProvider in the test wrapper, matching
how it's provided in the app via LoggedInPage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add useMetric and useNodeMetric convenience hooks for single metrics

Avoids the repetitive `useMemo(() => [name], [name])` wrapper pattern
when subscribing to a single metric name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Use asMock helper in PipelineProcessingErrors test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix type errors in PipelineProcessingErrors test mock data

Add missing `full_name` and `name` properties to mock meter metrics
to satisfy the `BaseMetric<MeterMetric>` type requirements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Ousmane SAMBA <ousmane@graylog.com>
2026-03-10 10:45:46 +01:00
Linus Pahl
0c17237804 Render DefaultQueryParamProvider by default in component unit tests. (#25145)
* Render DefaultQueryParamProvider by default in wrappedTestingLibrary and remove redundant test wrappers.

* Fix `WidgetFocusProvider.test`.

* Fixing linter hints

* Fixing test
2026-02-27 16:58:38 +01:00
Dennis Oelkers
163cdfdff3 Updating to Mantine 8. (#23522)
* Bump the mantine group in /graylog2-web-interface with 4 updates

Bumps the mantine group in /graylog2-web-interface with 4 updates: [@mantine/core](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/core), [@mantine/dropzone](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/dropzone), [@mantine/hooks](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/hooks) and [@mantine/notifications](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/notifications).


Updates `@mantine/core` from 7.17.7 to 8.0.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/8.0.0/packages/@mantine/core)

Updates `@mantine/dropzone` from 7.17.7 to 8.0.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/8.0.0/packages/@mantine/dropzone)

Updates `@mantine/hooks` from 7.17.7 to 8.0.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/8.0.0/packages/@mantine/hooks)

Updates `@mantine/notifications` from 7.17.7 to 8.0.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/8.0.0/packages/@mantine/notifications)

---
updated-dependencies:
- dependency-name: "@mantine/core"
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: mantine
- dependency-name: "@mantine/dropzone"
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: mantine
- dependency-name: "@mantine/hooks"
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: mantine
- dependency-name: "@mantine/notifications"
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: mantine
...

Signed-off-by: dependabot[bot] <support@github.com>

* Passing test environment to Mantine theme provider.

* Correcting assertion in test.

* Making sure that `div` is not ancestor of `tr`.

* Suppressing nested element warnings for now.

* Suppressing nested `form` error until usage of `NestedForms` is fixed.

* Improving tests.

* Fixing type.

* Use `:hover` pseudo-class to fix hover color for menu items.

* Updating yarn lockfile.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linus Pahl <linus.pahl@graylog.com>
2025-09-03 08:51:33 +02:00
github-actions[bot]
e913e0d5f3 Running lint --fix & prettier (#21515)
Co-authored-by: Dr. Lint-a-lot <garybot2@graylog.com>
2025-02-13 08:15:43 +01:00
Dennis Oelkers
611bbc2688 Removing prop-types remainders. (#21425)
* Removing `prop-types` remainders.

* Fixing linter hint.
2025-01-30 16:17:26 +01:00
Dennis Oelkers
fd2979441f Updating to react-router v6. (#12911)
* Adding/updating packages.

* Make use of `Outlet`, migrate router config.

(cherry picked from commit ba22e4300c1fa967cb15f81fcdb458149a7dbf7d)

* Turning browser router into data router.

* Allowing to reuse `PageContentLayout` as well.

(cherry picked from commit 0937111630d76b0898494a86e1acf1fb5492bd07)

* Using `useNavigate` to navigate to link.

(cherry picked from commit 03d26a5bc862291c613985337e9ac925e1f09c1a)

* Making use of `useNavigate`.

(cherry picked from commit 84a8f6a0791db5345fa92af1b0972efb26708526)

* Using `navigate` instead of `history`.

(cherry picked from commit 5a73c7574f0012812be07c17a5cd08d9c95c2de9)

* Type is not generic anymore.

(cherry picked from commit b7d72912c40de190f9908728ddfe7ca49f350f0f)

* Fixing up.

* Replacing `useHistory` with `useNavigate`.

(cherry picked from commit e1965c7a976c09c554cecac40db9ff40b405ca92)

* Using `useNavigate`.

(cherry picked from commit 028589974244fa28fb512d7a837c1b9bc1671c7a)

* Removing generic parameter.

(cherry picked from commit 690a994e5a89026c15c638db085839404e6c0782)

* Using `useLinkClickHandler` instead of `useNavigate`.

(cherry picked from commit a637039d55cc4473893910702960394e42bee49b)

* Revert "Using `useLinkClickHandler` instead of `useNavigate`."

This reverts commit 17a219cc42ef48ad34001488e4f599c9e7342c8a.

* Making use of `useBlocker` to replace previous `Prompt`.

* Adjusting `LinkContainer` test.

* Using `useLinkClickHandler` instead of `useNavigate`.

(cherry picked from commit a637039d55cc4473893910702960394e42bee49b)

* Fixing up merge.

(cherry picked from commit 85fdb1fe33a79b319838c4536e49e772562c7a86)

* Fixing up `ReportedErrorBoundary` test.

* Improving typing in test.

(cherry picked from commit e62d80fb10be4fafb89c422892829adbd23fb9d0)

* Fixing up test.

(cherry picked from commit aec8daccb078b95abbee5c9e0923701d05289fbf)

* Improving `AppRouter` tests.

(cherry picked from commit dd7718a56a6064d02e528f7e7fe81e74fe7a6c59)

* Fixing up test.

(cherry picked from commit 18d1f047334ec4583dd1fc1e611f298d337427d8)

* Fixing up `AppRouter` test.

* Prevent double wrapping.

(cherry picked from commit d8e496131550bbf84bc986b53581c2927ac4acc8)

* Avoid double wrapping in test.

(cherry picked from commit 8020eac7becf144953ce58cc1ff3204c0679ac89)

* Updating test.

(cherry picked from commit 60bb82023aed585f021ab125cd04f2d069e89e42)

* Adding type.

* Improving tests for `WidgetFocusProvider`.

(cherry picked from commit 2b47daa1051b2a85a33a0fc727c79bf6dc46e319)

* Fixing up `Navigation` test.

(cherry picked from commit 3613e591e5e9e007b7d32eb74f7e4ab2213e256e)

* Fixing up type.

* Fixing up type.

* Adding `renderWithDataRouter`.

* Using `renderWithDataRouter` in test.

* Migrating test to `testing-library`.

* Fixing up test for `usePaginationQueryParameter`.

* Replacing usages of `util/History` with `useHistory`.

* Remove redirecting to start page when plain text request fails with 403.

* Removing `util/History`.

* Using `RouterProvider` in style guide wrapper.

* Adding license headers.

* Fixing up typing issues.

* Fixing up linter hints.

* Fixing up tests.
2023-03-21 10:16:52 +01:00
Linus Pahl
170bebe571 Create reusable query client provider for tests. (#14601)
* Create reusable query client provider for tests.

* Reexport renderHook from wrappedTestingLibrary.

* Update imports

* Update import of act.

* Ensure to import `act` from the same place like `renderHook`.

* Fixing linter hint

* Remove @ts-ignore

* Create seperate directory for `wrappedTestingLibray`.

* Move render hook helper to `wrappedTestingLibrary/hooks`.

* Fixing import

* Fixing linter hints
2023-02-23 11:10:03 +01:00
Linus Pahl
2591f25fe3 Disable react-query retries for tests. (#13509)
* Disable `useQuery` retries for tests.

* Add missing `useFieldTypes` mocks.

* Fixing linter hint.
2022-09-21 14:59:38 +02:00
Dennis Oelkers
7c0dbdc678 Normalize absolute time range for field types request. (#12302)
* Normalize absolute time range for field types request.

* Handling absent time range.

* Use `useUserDateTime` in `useFieldTypes`.

* Using provider in tests, cleaning up.

* Providing user timezone in integration test.

* Fixing linter hints.

* Providing user timezone context in tests.

* Removing `UserDateTimeProvider` from tests.

* Fixedc weird formatting.
2022-03-21 12:26:30 +01:00