-
Notifications
You must be signed in to change notification settings - Fork 26
feat: integrate dynamic plugin infrastructure #1109
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import React from "react"; | ||
| import { | ||
| PageSection, | ||
| Content, | ||
| ContentVariants, | ||
| Gallery, | ||
| GalleryItem, | ||
| Card, | ||
| CardTitle, | ||
| CardBody, | ||
| CardHeader, | ||
| Icon, | ||
| } from "@patternfly/react-core"; | ||
| import { ServerIcon } from "@patternfly/react-icons"; | ||
| import { ExtensionSlot, EXTENSION_POINTS } from "@freeipa/plugin-sdk"; | ||
|
Check failure on line 15 in src/pages/Dashboard/Dashboard.tsx
|
||
|
|
||
| const Dashboard: React.FC = () => { | ||
| return ( | ||
| <PageSection> | ||
| <Content component={ContentVariants.h1}>Dashboard</Content> | ||
| <Gallery hasGutter> | ||
| <GalleryItem> | ||
| <Card isCompact> | ||
| <CardHeader> | ||
| <CardTitle> | ||
| <Icon isInline> | ||
| <ServerIcon /> | ||
| </Icon>{" "} | ||
| System Status | ||
| </CardTitle> | ||
| </CardHeader> | ||
| <CardBody> | ||
| FreeIPA server is running. Use the navigation to manage identity, | ||
| policy, and authentication. | ||
| </CardBody> | ||
| </Card> | ||
| </GalleryItem> | ||
| <ExtensionSlot | ||
| extensionPointId={EXTENSION_POINTS.DASHBOARD_CONTENT} | ||
| /> | ||
| </Gallery> | ||
| </PageSection> | ||
| ); | ||
| }; | ||
|
|
||
| export default Dashboard; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,53 @@ | ||
| import { configureStore } from "@reduxjs/toolkit"; | ||
| import { configureStore, combineReducers } from "@reduxjs/toolkit"; | ||
| import type { Reducer } from "@reduxjs/toolkit"; | ||
| import { setupListeners } from "@reduxjs/toolkit/query"; | ||
| import globalReducer from "./Global/global-slice"; | ||
| import { api } from "../services/rpc"; | ||
| import routesReducer from "./Global/routes-slice"; | ||
| import authReducer from "./Global/auth-slice"; | ||
| import alertsReducer from "./Global/alerts-slice"; | ||
|
|
||
| const staticReducers = { | ||
| api: api.reducer, | ||
| global: globalReducer, | ||
| routes: routesReducer, | ||
| auth: authReducer, | ||
| alerts: alertsReducer, | ||
| }; | ||
|
|
||
| const pluginReducers: Record<string, Reducer> = {}; | ||
|
|
||
| function createRootReducer() { | ||
| return combineReducers({ | ||
| ...staticReducers, | ||
| ...pluginReducers, | ||
| }); | ||
| } | ||
|
|
||
| export const setupStore = () => { | ||
| const store = configureStore({ | ||
| reducer: { | ||
| api: api.reducer, | ||
| global: globalReducer, | ||
| routes: routesReducer, | ||
| auth: authReducer, | ||
| alerts: alertsReducer, | ||
| }, | ||
| // Adding the api middleware enables caching, invalidation, polling, | ||
| // and other useful features of `rtk-query`. | ||
| reducer: createRootReducer(), | ||
| middleware: (getDefaultMiddleware) => | ||
| getDefaultMiddleware({ | ||
| serializableCheck: false, // Removes the warning about non-serializable data | ||
| serializableCheck: false, | ||
| }).concat(api.middleware), | ||
| }); | ||
|
|
||
| // optional, but required for refetchOnFocus/refetchOnReconnect behaviors | ||
| // see `setupListeners` docs - takes an optional callback as the 2nd arg for customization | ||
| setupListeners(store.dispatch); | ||
| return store; | ||
| }; | ||
|
|
||
| const store = setupStore(); | ||
|
|
||
| /** Called by the plugin registry to inject a new reducer at runtime. */ | ||
| export function injectPluginReducer(key: string, reducer: Reducer): void { | ||
| if (pluginReducers[key]) { | ||
| return; | ||
| } | ||
| pluginReducers[key] = reducer; | ||
| store.replaceReducer(createRootReducer()); | ||
| } | ||
|
|
||
| export type RootState = ReturnType<typeof store.getState>; | ||
| export type AppDispatch = typeof store.dispatch; | ||
| export default store; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Consider adding basic error handling around the async bootstrap pipeline.
loadPlugins()andpluginRegistry.runPhase("ready")are awaited without any error handling, so a failure in any plugin will prevent the app from rendering and leave users on a blank page. Wrap these calls in atry/catchthat logs the error and still renders either the core app without the failing plugin(s) or a dedicated error screen, so one bad plugin doesn’t break the whole UI.