forked from deephaven/deephaven-plugins
-
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.
fix: Unit tests, and pass WidgetStatus instead of just an error
- More flexible, allowing a loading or ready status to be passed down as well - Could be used to show a proper loading spinner - Fix up unit tests that were failing
- Loading branch information
Showing
11 changed files
with
416 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { WidgetDescriptor } from '@deephaven/dashboard'; | ||
import { createContext } from 'react'; | ||
|
||
export type WidgetStatusLoading = { | ||
status: 'loading'; | ||
descriptor: WidgetDescriptor; | ||
}; | ||
|
||
export type WidgetStatusError = { | ||
status: 'error'; | ||
descriptor: WidgetDescriptor; | ||
error: NonNullable<unknown>; | ||
}; | ||
|
||
export type WidgetStatusReady = { | ||
status: 'ready'; | ||
descriptor: WidgetDescriptor; | ||
}; | ||
|
||
export type WidgetStatus = | ||
| WidgetStatusLoading | ||
| WidgetStatusError | ||
| WidgetStatusReady; | ||
|
||
/** Error status of the widget within this context */ | ||
export const WidgetStatusContext = createContext<WidgetStatus | null>(null); | ||
|
||
export default WidgetStatusContext; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useContextOrThrow } from '@deephaven/react-hooks'; | ||
import { WidgetStatus, WidgetStatusContext } from './WidgetStatusContext'; | ||
|
||
/** | ||
* Gets the overlay content from the nearest panel context. | ||
* @returns The overlay content or null if not in a panel | ||
*/ | ||
export function useWidgetStatus(): WidgetStatus { | ||
return useContextOrThrow(WidgetStatusContext); | ||
} | ||
|
||
export default useWidgetStatus; |
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.