-
Notifications
You must be signed in to change notification settings - Fork 47
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
Small Plugin Cleanup #206
Small Plugin Cleanup #206
Changes from 10 commits
28b7f32
40e2453
dc3f9c4
c4a762d
b9aa8c6
c807505
4057be6
11e4304
cf868b0
a7b11eb
d871824
7581469
4496560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import { | |
PluginType, | ||
AnyPluginImplementation, | ||
JsonObject, | ||
ALL_PLUGIN_TYPES, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change to have a runtime list of all plugin types simplifies some of the registry code below so that now there are fewer places to go make changes whenever we add a new plugin type. |
||
} from '@perses-ui/core'; | ||
import { BUNDLED_PLUGINS } from './bundled-plugins'; | ||
import { createGraphQueryPlugin, createPanelPlugin, createVariablePlugin } from './create-plugin'; | ||
|
@@ -43,11 +44,10 @@ export function useRegistryState(installedPlugins: PluginResource[]) { | |
// Go through all installed plugins and bundled plugins and build an index of | ||
// those resources by type and kind | ||
const loadablePlugins = useMemo(() => { | ||
const loadableProps: PluginResourcesByTypeAndKind = { | ||
Variable: new Map(), | ||
Panel: new Map(), | ||
GraphQuery: new Map(), | ||
}; | ||
const loadableProps = {} as PluginResourcesByTypeAndKind; | ||
for (const pluginType of ALL_PLUGIN_TYPES) { | ||
loadableProps[pluginType] = new Map(); | ||
} | ||
|
||
const addToLoadable = (resource: PluginResource) => { | ||
const supportedKinds = resource.spec.supported_kinds; | ||
|
@@ -75,15 +75,17 @@ export function useRegistryState(installedPlugins: PluginResource[]) { | |
return loadableProps; | ||
}, [installedPlugins]); | ||
|
||
const [plugins, setPlugins] = useImmer<LoadedPluginsByTypeAndKind>(() => ({ | ||
Variable: new Map(), | ||
Panel: new Map(), | ||
GraphQuery: new Map(), | ||
})); | ||
const [plugins, setPlugins] = useImmer<LoadedPluginsByTypeAndKind>(() => { | ||
const loadedPlugins = {} as LoadedPluginsByTypeAndKind; | ||
for (const pluginType of ALL_PLUGIN_TYPES) { | ||
loadedPlugins[pluginType] = new Map(); | ||
} | ||
return loadedPlugins; | ||
}); | ||
|
||
// Create the register callback to pass to the module's setup function | ||
const registerPlugin: RegisterPlugin = useCallback( | ||
<Kind extends string, Options extends JsonObject>(config: PluginRegistrationConfig<Kind, Options>) => { | ||
<Options extends JsonObject>(config: PluginRegistrationConfig<Options>) => { | ||
switch (config.pluginType) { | ||
case 'Variable': | ||
setPlugins((draft) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ import App from './App'; | |
import { createTheme } from './styles/theme'; | ||
import { SnackbarProvider } from './context/SnackbarProvider'; | ||
|
||
const queryClient = new QueryClient(); | ||
const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just turns off the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool ! That was simple at then. Nice catch ! Do you know what this behavior is the one by default ? It's a bit odd to have it by default, but probably I miss some context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I felt like it was a weird choice to have by default too, so don't think you're missing anything. The docs have a bit of an explanation of some of the defaults: |
||
|
||
function renderApp() { | ||
ReactDOM.render( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ export const commonConfig: Configuration = { | |
new ForkTsCheckerWebpackPlugin({ | ||
typescript: { | ||
configFile: path.resolve(__dirname, './tsconfig.json'), | ||
build: true, // Since we use project references... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should fix the error that we see sometimes locally where TypeScript complains that "XXX has not been built from source file YYY". I also tried to clean-up the |
||
}, | ||
eslint: { | ||
files: '../*/src/**/*.{ts,tsx,js,jsx}', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ const devConfig: Configuration = { | |
port: parseInt(process.env.PORT ?? '3000'), | ||
open: true, | ||
https: getHttpsConfig(), | ||
http2: process.env.HTTP2 === 'true', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allows enabling HTTP2 for the webpack dev server (like I mentioned in chat). |
||
historyApiFallback: true, | ||
allowedHosts: 'all', | ||
proxy: { | ||
|
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.
Just adding a browser data source to the sample data here...