Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 624b699

Browse files
authored
Merge pull request #2 from maxceem/feature/cross-imports
Cross Imports
2 parents 4fa5e66 + a00e26a commit 624b699

13 files changed

+153
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
.DS_Store

extra-webpack.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ const singleSpaAngularWebpack = require('single-spa-angular/lib/webpack').defaul
33
module.exports = (config, options) => {
44
const singleSpaWebpackConfig = singleSpaAngularWebpack(config, options);
55

6+
// we have to list here all the microapps which we would like to use in imports
7+
// so webpack doesn't tries to import them
8+
singleSpaWebpackConfig.externals = {
9+
'@topcoder/micro-frontends-navbar-app':
10+
'@topcoder/micro-frontends-navbar-app',
11+
};
12+
613
// Feel free to modify this webpack config however you'd like to
714
return singleSpaWebpackConfig;
815
};

src/app/app.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ <h1>Angular child app example</h1>
88
/>
99

1010
<div><a routerLink="/micro-frontends-react-route">Link to React child app</a></div>
11+
12+
<tc-ex-auth-demo></tc-ex-auth-demo>
1113
</div>
1214

1315
<router-outlet></router-outlet>

src/app/app.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
2+
import { setAppMenu } from '@topcoder/micro-frontends-navbar-app';
3+
import appMenu from './constants/appMenu';
24

35
@Component({
46
selector: 'tc-ex-root',
57
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.scss']
8+
styleUrls: ['./app.component.scss'],
79
})
8-
export class AppComponent {
10+
export class AppComponent implements OnInit {
911
title = 'micro-frontends-angular-app';
12+
13+
ngOnInit(): void {
14+
// when app starts it should set its side menu structure
15+
setAppMenu('/micro-frontends-angular-route', appMenu);
16+
}
1017
}

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { NgModule } from '@angular/core';
44
import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
66
import { EmptyRouteComponent } from './empty-route/empty-route.component';
7+
import { AuthDemoComponent } from './auth-demo/auth-demo.component';
78

89
@NgModule({
910
declarations: [
1011
AppComponent,
11-
EmptyRouteComponent
12+
EmptyRouteComponent,
13+
AuthDemoComponent
1214
],
1315
imports: [
1416
BrowserModule,
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

src/app/assets/images/home-green.svg

Lines changed: 3 additions & 0 deletions
Loading

src/app/assets/images/home.svg

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<h2>Authentication</h2>
2+
<div *ngIf="authUserTokens.loading">Authentication...</div>
3+
<div *ngIf="!authUserTokens.loading && authUserTokens.error">Authentication Error: {{authUserTokens.error.message}}</div>
4+
<div *ngIf="!authUserTokens.loading && !authUserTokens.error && authUserTokens.value.tokenV3">
5+
User is logged-in <button (click)="logout()">Logout</button>
6+
7+
<h3>User Profile</h3>
8+
<div *ngIf="authUserProfile.loading">User Profile Loading...</div>
9+
<div *ngIf="!authUserProfile.loading && authUserProfile.error">Profile Loading Error: {{authUserProfile.error.message}}</div>
10+
<ul *ngIf="!authUserProfile.loading && !authUserProfile.error && authUserProfile.value">
11+
<li><strong>Handle:</strong> {{authUserProfile.value.handle}}</li>
12+
<li><strong>First Name:</strong> {{authUserProfile.value.firstName}}</li>
13+
<li><strong>Last Name:</strong> {{authUserProfile.value.lastName}}</li>
14+
</ul>
15+
</div>
16+
<div *ngIf="!authUserTokens.loading && !authUserTokens.error && !authUserTokens.value.tokenV3">
17+
User is logged-out <button (click)="login()">Login</button>
18+
</div>

0 commit comments

Comments
 (0)