-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Expose
registerAlert
provider for custom UI alerts
Relates to #2503
- Loading branch information
1 parent
7089a62
commit 698ea0c
Showing
5 changed files
with
163 additions
and
31 deletions.
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
22 changes: 22 additions & 0 deletions
22
packages/admin-ui/src/lib/core/src/extension/register-alert.ts
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,22 @@ | ||
import { APP_INITIALIZER, FactoryProvider } from '@angular/core'; | ||
import { AlertConfig, AlertsService } from '../providers/alerts/alerts.service'; | ||
|
||
/** | ||
* @description | ||
* Registers an alert which can be displayed in the Admin UI alert dropdown in the top bar. | ||
* The alert is configured using the {@link AlertConfig} object. | ||
* | ||
* @since 2.2.0 | ||
* @docsCategory alerts | ||
*/ | ||
export function registerAlert(config: AlertConfig): FactoryProvider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (alertsService: AlertsService) => () => { | ||
alertsService.configureAlert(config); | ||
alertsService.refresh(config.id); | ||
}, | ||
deps: [AlertsService], | ||
}; | ||
} |
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