Skip to content

Tier 6: Migrate 8 standalone Reflux stores to react-query hooks and plain functions#25822

Open
dennisoelkers wants to merge 5 commits intomasterfrom
tier-6-migrate-8-reflux-stores
Open

Tier 6: Migrate 8 standalone Reflux stores to react-query hooks and plain functions#25822
dennisoelkers wants to merge 5 commits intomasterfrom
tier-6-migrate-8-reflux-stores

Conversation

@dennisoelkers
Copy link
Copy Markdown
Member

@dennisoelkers dennisoelkers commented Apr 27, 2026

Description

Motivation and Context

Replace 8 Reflux stores with modern alternatives:

  • AuthenticationStore → hooks/useAuthentication.ts (react-query hooks + plain functions)
  • SidecarsStore → hooks/useSidecars.ts (react-query hook with polling)
  • CollectorsStore → hooks/useCollectors.ts (react-query hooks)
  • CollectorConfigurationsStore → hooks/useCollectorConfigurations.ts (react-query hooks)
  • AuthzRolesStore → hooks/useAuthzRoles.ts (plain functions + react-query hooks)
  • ExtractorsStore → hooks/useExtractors.ts (plain functions + react-query hooks)
  • EntityShareStore → api/entity-share.ts + hooks/useEntityShareState.ts (react-query cache)
  • IndicesStore → hooks/useIndices.ts (react-query hooks with polling)

Also refactored consumers to use hook-based patterns instead of .then(setState) flows
and replaced Reflux completed.listen patterns with react-query cache invalidation or
prop-drilled callbacks.

Known follow-ups: 4 test cases in EntityShareModal/StreamModal/RolesOverview/UsersSection
need further mock updates for the new cache-based EntityShareState flow.

/nocl Internal refactoring.
/prd Graylog2/graylog-plugin-enterprise#14068

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

dennisoelkers and others added 4 commits April 24, 2026 18:23
…lain functions

Replace 8 Reflux stores with modern alternatives:
- AuthenticationStore → `hooks/useAuthentication.ts` (react-query hooks + plain functions)
- SidecarsStore → `hooks/useSidecars.ts` (react-query hook with polling)
- CollectorsStore → `hooks/useCollectors.ts` (react-query hooks)
- CollectorConfigurationsStore → `hooks/useCollectorConfigurations.ts` (react-query hooks)
- AuthzRolesStore → `hooks/useAuthzRoles.ts` (plain functions + react-query hooks)
- ExtractorsStore → `hooks/useExtractors.ts` (plain functions + react-query hooks)
- EntityShareStore → `api/entity-share.ts` + `hooks/useEntityShareState.ts` (react-query cache)
- IndicesStore → `hooks/useIndices.ts` (react-query hooks with polling)

Also refactored consumers to use hook-based patterns instead of `.then(setState)` flows
and replaced Reflux `completed.listen` patterns with react-query cache invalidation or
prop-drilled callbacks.

Known follow-ups: 4 test cases in EntityShareModal/StreamModal/RolesOverview/UsersSection
need further mock updates for the new cache-based EntityShareState flow.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Update useEntityShareState to provide a noop queryFn (react-query v5
  requires queryFn even when enabled: false) and wrap the setter from
  useSetEntityShareState in useCallback so consumer useEffect deps stay
  stable across renders.
- Add placeholderData: keepPreviousData to RolesOverview's paginated
  useQuery so the SearchForm stays mounted (keeping its internal query
  state and Reset button) during refetch.
- Update UsersSection test assertion to match the new 2-arg
  loadUsersForRole(roleId, pagination) signature.
- Update EntityShareModal test mock helpers to the new { data } query
  result shape.
- Hoist mockSetEntityShareState out of the jest.mock factory across all
  EntityShareState test mocks so the returned setter has a stable
  reference (was a new jest.fn() per call, causing infinite re-renders).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dennisoelkers dennisoelkers added the e2e-tests Run PR build with e2e tests. label Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-tests Run PR build with e2e tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant