-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: implement plugin wrappers #1332
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
be38607
feat: ideas for plugin wrappers [LIBS-397]
tomzemp 30c963c
feat: update plugin wrappers
tomzemp b14952b
fix: clean up, add useless test
tomzemp 46c9219
chore: start pluginwrapper error boundary
tomzemp ddc4251
chore: sample error
tomzemp c72fc6e
fix: custom error handling
tomzemp bda6a43
feat: plugin wrappers, errors + alerts
tomzemp 1681f6e
chore: move plugin wrapper logic to app-platform
tomzemp c537590
fix: add documentation, clean up
tomzemp 41124e8
Merge branch 'alpha' into LIBS-397/plugin-wrappers-sender
tomzemp 2480c1c
fix: dependency resolution
tomzemp 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
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { AlertsProvider } from './AlertsProvider' | ||
export { useAlerts } from './useAlerts' | ||
export { useAlert } from './useAlert' | ||
export { AlertsManagerContext } from './AlertsManagerContext' | ||
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 |
---|---|---|
|
@@ -6,7 +6,8 @@ export const useAlert = ( | |
message: string | ((props: any) => string), | ||
options: AlertOptions | ((props: any) => AlertOptions) = {} | ||
): { show: (props?: any) => void; hide: () => void } => { | ||
const { add }: AlertsManager = useContext(AlertsManagerContext) | ||
const { add, plugin, parentAlertsAdd, showAlertsInPlugin }: AlertsManager = | ||
useContext(AlertsManagerContext) | ||
const alertRef = useRef(<Alert | null>null) | ||
|
||
const show = useCallback( | ||
|
@@ -17,15 +18,25 @@ export const useAlert = ( | |
const resolvedOptions = | ||
typeof options === 'function' ? options(props) : options | ||
|
||
alertRef.current = add( | ||
{ | ||
message: resolvedMessage, | ||
options: resolvedOptions, | ||
}, | ||
alertRef | ||
) | ||
if (plugin && parentAlertsAdd && !showAlertsInPlugin) { | ||
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. I passed this showAlertsInPlugin down to useAlert as I thought it made the logic clearer here, but it could be incorporated into logic further up and then not passed down. |
||
alertRef.current = parentAlertsAdd( | ||
{ | ||
message: resolvedMessage, | ||
options: resolvedOptions, | ||
}, | ||
alertRef | ||
) | ||
} else { | ||
alertRef.current = add( | ||
{ | ||
message: resolvedMessage, | ||
options: resolvedOptions, | ||
}, | ||
alertRef | ||
) | ||
} | ||
}, | ||
[add, message, options] | ||
[add, parentAlertsAdd, message, options, plugin, showAlertsInPlugin] | ||
) | ||
|
||
const hide = useCallback(() => { | ||
|
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,5 @@ | ||
# DHIS2 Platform | ||
node_modules | ||
.d2 | ||
src/locales | ||
build |
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,11 @@ | ||
# DHIS2 App Data Service | ||
|
||
Application configuration for [DHIS2](https://dhis2.org) applications | ||
|
||
This library is intended for use with the [DHIS2 Application Platform](https://github.com/dhis2/app-platform). | ||
|
||
## Installation | ||
|
||
This package is internal to `@dhis2/app-runtime` and generally should not be installed independently. | ||
|
||
See [the docs](https://runtime.dhis2.nu) for more. |
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,9 @@ | ||
const config = { | ||
type: 'lib', | ||
|
||
entryPoints: { | ||
lib: './src/index.ts', | ||
}, | ||
} | ||
|
||
module.exports = config |
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,10 @@ | ||
module.exports = { | ||
collectCoverageFrom: [ | ||
'src/**/*.(js|jsx|ts|tsx)', | ||
'!src/index.ts', | ||
'!src/types.ts', | ||
], | ||
|
||
// Setup react-testing-library | ||
setupFilesAfterEnv: ['<rootDir>/src/setupRTL.ts'], | ||
} |
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.
this is now being exported so that the PluginSender can access
add
from the parent (app) and pass it to the plugin, so that the alerts can then be added to the app's AlertsManager rather than the plugin's