Skip to content

Commit 17f80b5

Browse files
authored
feat(package): individual module imports for notification components (#388)
This allows components to be imported individually without having to install an unused, optional dependency. Deprecations - NotificationModule: Use InlineNotificationModule, NotificationDrawerModule, NotificationServiceModule, ToastNotificationModule, or ToastNotificationListModule
1 parent 83629dc commit 17f80b5

17 files changed

+197
-41
lines changed

src/app/notification/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
export { InlineNotificationComponent } from './inline-notification/inline-notification.component';
21
export { Notification } from './notification';
3-
export { NotificationDrawerComponent } from './notification-drawer/notification-drawer.component';
42
export { NotificationEvent } from './notification-event';
53
export { NotificaitonGroup } from './notification-group';
6-
export { NotificationModule } from './notification.module';
4+
export { NotificationModule } from './notification.module'; // @deprecated
75
export { NotificationType } from './notification-type';
8-
export { NotificationService } from './notification-service/notification.service';
9-
export { ToastNotificationComponent } from './toast-notification/toast-notification.component';
10-
export { ToastNotificationListComponent } from './toast-notification-list/toast-notification-list.component';
6+
7+
export * from './inline-notification/index';
8+
export * from './notification-drawer/index';
9+
export * from './notification-service/index';
10+
export * from './toast-notification/index';
11+
export * from './toast-notification-list/index';

src/app/notification/inline-notification/example/inline-notification-example.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { BsDropdownConfig, BsDropdownModule } from 'ngx-bootstrap/dropdown';
66
import { TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs';
77

88
import { DemoComponentsModule } from '../../../../demo/components/demo-components.module';
9-
import { NotificationModule } from '../../notification.module';
109
import { InlineNotificationExampleComponent } from './inline-notification-example.component';
10+
import { InlineNotificationModule } from '../inline-notification.module';
1111

1212
@NgModule({
1313
declarations: [
@@ -18,7 +18,7 @@ import { InlineNotificationExampleComponent } from './inline-notification-exampl
1818
CommonModule,
1919
DemoComponentsModule,
2020
FormsModule,
21-
NotificationModule,
21+
InlineNotificationModule,
2222
TabsModule.forRoot()
2323
],
2424
providers: [
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { InlineNotificationComponent } from './inline-notification.component';
2+
export { InlineNotificationModule } from './inline-notification.module';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { CommonModule } from '@angular/common';
2+
import { FormsModule } from '@angular/forms';
3+
import { NgModule } from '@angular/core';
4+
5+
import { InlineNotificationComponent } from './inline-notification.component';
6+
import { NotificationType } from '../notification-type';
7+
8+
export {
9+
NotificationType
10+
};
11+
12+
/**
13+
* A module containing objects associated with inline notifications
14+
*/
15+
@NgModule({
16+
imports: [
17+
CommonModule,
18+
FormsModule
19+
],
20+
declarations: [
21+
InlineNotificationComponent
22+
],
23+
exports: [
24+
InlineNotificationComponent
25+
]
26+
})
27+
export class InlineNotificationModule {}

src/app/notification/notification-drawer/example/notification-drawer-example.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { NgModule } from '@angular/core';
44

55
import { TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs';
66

7-
import { NotificationModule } from '../../notification.module';
87
import { NotificationDrawerExampleComponent } from './notification-drawer-example.component';
8+
import { NotificationDrawerModule } from '../notification-drawer.module';
99
import { DemoComponentsModule } from '../../../../demo/components/demo-components.module';
1010
import { ActionModule } from '../../../action/action.module';
1111

@@ -15,11 +15,11 @@ import { ActionModule } from '../../../action/action.module';
1515
CommonModule,
1616
DemoComponentsModule,
1717
FormsModule,
18-
NotificationModule,
18+
NotificationDrawerModule,
1919
TabsModule.forRoot()
2020
],
21-
declarations: [ NotificationDrawerExampleComponent ],
22-
providers: [ TabsetConfig ]
21+
declarations: [NotificationDrawerExampleComponent],
22+
providers: [TabsetConfig]
2323
})
2424
export class NotificationDrawerExampleModule {
2525
constructor() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { NotificationDrawerComponent } from './notification-drawer.component';
2+
export { NotificationDrawerModule } from './notification-drawer.module';
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { CommonModule } from '@angular/common';
2+
import { FormsModule } from '@angular/forms';
3+
import { NgModule } from '@angular/core';
4+
5+
import { EmptyStateModule } from '../../empty-state/empty-state.module';
6+
import { NotificationDrawerComponent } from './notification-drawer.component';
7+
import { NotificaitonGroup } from '../notification-group';
8+
9+
export {
10+
NotificaitonGroup
11+
};
12+
13+
/**
14+
* A module containing objects associated with the notification drawer
15+
*/
16+
@NgModule({
17+
imports: [
18+
CommonModule,
19+
EmptyStateModule,
20+
FormsModule
21+
],
22+
declarations: [
23+
NotificationDrawerComponent
24+
],
25+
exports: [
26+
NotificationDrawerComponent
27+
]
28+
})
29+
export class NotificationDrawerModule {}

src/app/notification/notification-service/example/notification-service-example.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { BsDropdownConfig, BsDropdownModule } from 'ngx-bootstrap/dropdown';
66
import { TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs';
77

88
import { DemoComponentsModule } from '../../../../demo/components/demo-components.module';
9-
import { NotificationModule } from '../../notification.module';
109
import { NotificationService } from '../notification.service';
1110
import { NotificationServiceExampleComponent } from './notification-service-example.component';
1211
import { NotificationServiceBasicExampleComponent } from './notification-service-basic-example.component';
1312
import { NotificationServiceObserverExampleComponent } from './notification-service-observer-example.component';
13+
import { ToastNotificationListModule } from '../../toast-notification-list';
1414

1515
@NgModule({
1616
declarations: [
@@ -23,8 +23,8 @@ import { NotificationServiceObserverExampleComponent } from './notification-serv
2323
CommonModule,
2424
DemoComponentsModule,
2525
FormsModule,
26-
NotificationModule,
27-
TabsModule.forRoot()
26+
TabsModule.forRoot(),
27+
ToastNotificationListModule
2828
],
2929
providers: [
3030
BsDropdownConfig,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { NotificationService } from './notification.service';
Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { CommonModule } from '@angular/common';
2+
import { FormsModule } from '@angular/forms';
23
import { NgModule } from '@angular/core';
34

4-
import { BsDropdownConfig, BsDropdownModule } from 'ngx-bootstrap/dropdown';
5+
import { InlineNotificationComponent } from './inline-notification/inline-notification.component';
6+
import { InlineNotificationModule } from './inline-notification/inline-notification.module';
7+
import { NotificationDrawerComponent } from './notification-drawer/notification-drawer.component';
8+
import { NotificationDrawerModule } from './notification-drawer/notification-drawer.module';
59
import { NotificaitonGroup } from './notification-group';
610
import { NotificationEvent } from './notification-event';
711
import { NotificationType } from './notification-type';
8-
import { NotificationService } from './notification-service/notification.service';
912
import { ToastNotificationComponent } from './toast-notification/toast-notification.component';
13+
import { ToastNotificationModule } from './toast-notification/toast-notification.module';
1014
import { ToastNotificationListComponent } from './toast-notification-list/toast-notification-list.component';
11-
import { InlineNotificationComponent } from './inline-notification/inline-notification.component';
12-
import { NotificationDrawerComponent } from './notification-drawer/notification-drawer.component';
13-
import { EmptyStateModule } from '../empty-state/empty-state.module';
15+
import { ToastNotificationListModule } from './toast-notification-list/toast-notification-list.module';
1416

1517
export {
1618
NotificationEvent,
@@ -20,13 +22,35 @@ export {
2022

2123
/**
2224
* A module containing objects associated with notification components
25+
*
26+
* @deprecated Use individual module imports
27+
*
28+
* import {
29+
* InlineNotificationModule,
30+
* NotificationDrawerModule,
31+
* ToastNotificationModule,
32+
* ToastNotificationListModule
33+
* } from 'patternfly-ng/notification';
2334
*/
2435
@NgModule({
25-
imports: [BsDropdownModule.forRoot(), CommonModule, EmptyStateModule],
26-
declarations: [ToastNotificationComponent, ToastNotificationListComponent, InlineNotificationComponent,
27-
NotificationDrawerComponent],
28-
exports: [ToastNotificationComponent, ToastNotificationListComponent, InlineNotificationComponent,
29-
NotificationDrawerComponent],
30-
providers: [BsDropdownConfig, NotificationService]
36+
imports: [
37+
CommonModule,
38+
FormsModule,
39+
InlineNotificationModule,
40+
NotificationDrawerModule,
41+
ToastNotificationModule,
42+
ToastNotificationListModule
43+
],
44+
exports: [
45+
InlineNotificationComponent,
46+
NotificationDrawerComponent,
47+
ToastNotificationComponent,
48+
ToastNotificationListComponent
49+
]
3150
})
32-
export class NotificationModule {}
51+
export class NotificationModule {
52+
constructor() {
53+
console.log('patternfly-ng: NotificationModule is deprecated; use InlineNotificationModule, ' +
54+
'NotificationDrawerModule, ToastNotificationModule, or ToastNotificationListModule');
55+
}
56+
}

src/app/notification/toast-notification-list/example/toast-notification-list-example.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { BsDropdownConfig, BsDropdownModule } from 'ngx-bootstrap/dropdown';
66
import { TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs';
77

88
import { DemoComponentsModule } from '../../../../demo/components/demo-components.module';
9-
import { NotificationModule } from '../../notification.module';
109
import { ToastNotificationListExampleComponent } from './toast-notification-list-example.component';
10+
import { ToastNotificationListModule } from '../toast-notification-list.module';
1111

1212
@NgModule({
1313
declarations: [
@@ -18,8 +18,8 @@ import { ToastNotificationListExampleComponent } from './toast-notification-list
1818
CommonModule,
1919
DemoComponentsModule,
2020
FormsModule,
21-
NotificationModule,
22-
TabsModule.forRoot()
21+
TabsModule.forRoot(),
22+
ToastNotificationListModule
2323
],
2424
providers: [
2525
BsDropdownConfig,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { ToastNotificationListComponent } from './toast-notification-list.component';
2+
export { ToastNotificationListModule } from './toast-notification-list.module';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { CommonModule } from '@angular/common';
2+
import { FormsModule } from '@angular/forms';
3+
import { NgModule } from '@angular/core';
4+
5+
import { Notification } from '../notification';
6+
import { NotificationEvent } from '../notification-event';
7+
import { ToastNotificationListComponent } from './toast-notification-list.component';
8+
import { ToastNotificationModule } from '../toast-notification';
9+
10+
export {
11+
Notification,
12+
NotificationEvent
13+
};
14+
15+
/**
16+
* A module containing objects associated with toast notification lists
17+
*/
18+
@NgModule({
19+
imports: [
20+
CommonModule,
21+
FormsModule,
22+
ToastNotificationModule
23+
],
24+
declarations: [
25+
ToastNotificationListComponent
26+
],
27+
exports: [
28+
ToastNotificationListComponent
29+
]
30+
})
31+
export class ToastNotificationListModule {}

src/app/notification/toast-notification/example/toast-notification-example.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { BsDropdownConfig, BsDropdownModule } from 'ngx-bootstrap/dropdown';
66
import { TabsetConfig, TabsModule } from 'ngx-bootstrap/tabs';
77

88
import { DemoComponentsModule } from '../../../../demo/components/demo-components.module';
9-
import { NotificationModule } from '../../notification.module';
109
import { ToastNotificationExampleComponent } from './toast-notification-example.component';
10+
import { ToastNotificationModule } from '../toast-notification.module';
1111

1212
@NgModule({
1313
declarations: [
@@ -18,8 +18,8 @@ import { ToastNotificationExampleComponent } from './toast-notification-example.
1818
CommonModule,
1919
DemoComponentsModule,
2020
FormsModule,
21-
NotificationModule,
22-
TabsModule.forRoot()
21+
TabsModule.forRoot(),
22+
ToastNotificationModule
2323
],
2424
providers: [
2525
BsDropdownConfig,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { ToastNotificationComponent } from './toast-notification.component';
2+
export { ToastNotificationModule } from './toast-notification.module';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { CommonModule } from '@angular/common';
2+
import { FormsModule } from '@angular/forms';
3+
import { NgModule } from '@angular/core';
4+
5+
import { BsDropdownConfig, BsDropdownModule } from 'ngx-bootstrap/dropdown';
6+
7+
import { Notification } from '../notification';
8+
import { NotificationEvent } from '../notification-event';
9+
import { ToastNotificationComponent } from './toast-notification.component';
10+
11+
export {
12+
Notification,
13+
NotificationEvent
14+
};
15+
16+
/**
17+
* A module containing objects associated with toast notifications
18+
*/
19+
@NgModule({
20+
imports: [
21+
BsDropdownModule.forRoot(),
22+
CommonModule,
23+
FormsModule
24+
],
25+
declarations: [
26+
ToastNotificationComponent
27+
],
28+
exports: [
29+
ToastNotificationComponent
30+
],
31+
providers: [
32+
BsDropdownConfig
33+
]
34+
})
35+
export class ToastNotificationModule {}

src/app/patternfly-ng.module.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { FormsModule } from '@angular/forms';
44
import {
55
ActionModule,
66
CardModule,
7-
ChartModule,
7+
ChartModule, // @deprecated
88
EmptyStateModule,
99
FilterModule,
1010
ListModule,
1111
ModalModule,
12-
NavigationModule,
13-
NotificationModule,
12+
NavigationModule, // @deprecated
13+
NotificationModule, // @deprecated
1414
PaginationModule,
15-
PipeModule,
15+
PipeModule, // @deprecated
1616
RemainingCharsCountModule,
1717
SampleModule,
1818
SortModule,
@@ -31,16 +31,16 @@ import {
3131
exports: [
3232
ActionModule,
3333
CardModule,
34-
ChartModule,
34+
ChartModule, // @deprecated
3535
EmptyStateModule,
3636
FilterModule,
3737
ListModule,
3838
ModalModule,
39-
NavigationModule,
40-
NotificationModule,
39+
NavigationModule, // @deprecated
40+
NotificationModule, // @deprecated
4141
PaginationModule,
4242
RemainingCharsCountModule,
43-
PipeModule,
43+
PipeModule, // @deprecated
4444
SampleModule,
4545
SortModule,
4646
TableModule,

0 commit comments

Comments
 (0)