forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Convert core DashboardPlugins to new config type (deephaven…
…#1519) Fixes deephaven#1507 Didn't convert `ConsolePlugin` yet. The `notebooksUrl` prop was added for markdown notebooks, but uses a Vite env variable to set it
- Loading branch information
1 parent
3e834de
commit 1442ace
Showing
30 changed files
with
418 additions
and
285 deletions.
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 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 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 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 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,42 @@ | ||
import { useCallback } from 'react'; | ||
import { | ||
type TablePluginComponent, | ||
isTablePlugin, | ||
isLegacyTablePlugin, | ||
} from '@deephaven/plugin'; | ||
import Log from '@deephaven/log'; | ||
import usePlugins from './usePlugins'; | ||
|
||
const log = Log.module('@deephaven/app-utils/useTablePlugin'); | ||
|
||
/** | ||
* Creates a table plugin loader function. | ||
* @returns A function to load a Table plugin element by name | ||
*/ | ||
export function useLoadTablePlugin(): (name: string) => TablePluginComponent { | ||
const plugins = usePlugins(); | ||
|
||
const plugin = useCallback( | ||
(name: string) => { | ||
// First check if we have any plugin modules loaded that match the TablePlugin. | ||
const pluginModule = plugins.get(name); | ||
if (pluginModule != null) { | ||
if (isTablePlugin(pluginModule)) { | ||
return pluginModule.component; | ||
} | ||
if (isLegacyTablePlugin(pluginModule)) { | ||
return pluginModule.TablePlugin; | ||
} | ||
} | ||
|
||
const errorMessage = `Unable to find table plugin ${name}.`; | ||
log.error(errorMessage); | ||
throw new Error(errorMessage); | ||
}, | ||
[plugins] | ||
); | ||
|
||
return plugin; | ||
} | ||
|
||
export default useLoadTablePlugin; |
This file contains 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 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
Oops, something went wrong.