Skip to content

Commit abee7ae

Browse files
authored
Merge pull request #1982 from habitat-sh/angular_upgrade
Angular upgrade
2 parents 1382e66 + 3558851 commit abee7ae

127 files changed

Lines changed: 6888 additions & 10598 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/builder-web/app/actions/gitHub.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import 'whatwg-fetch';
1615
import { GitHubApiClient } from '../client/github-api';
1716
import { Browser } from '../browser';
1817

components/builder-web/app/actions/oauth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import 'whatwg-fetch';
1615
import config from '../config';
1716
import {
1817
setCurrentUsername,

components/builder-web/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h5>
3232
</h5>
3333
</div>
3434
</ng-container>
35-
<router-outlet *ngIf="!isSigningIn"></router-outlet>
35+
<router-outlet></router-outlet>
3636
<footer>
3737
<div class="pull-left">
3838
<p>

components/builder-web/app/app.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
import config from './config';
1616
import { Subscription } from 'rxjs';
1717
import { AppStore } from './app.store';
18-
import { Component, OnInit, OnDestroy } from '@angular/core';
19-
import { URLSearchParams } from '@angular/http';
18+
import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
2019
import { ActivatedRoute, Router, NavigationEnd, NavigationStart } from '@angular/router';
2120
import {
2221
identifyUser, loadFeatures, removeNotification, exchangeOAuthCode,
@@ -26,8 +25,9 @@ import {
2625
const md5 = require('blueimp-md5');
2726

2827
@Component({
28+
standalone: false,
2929
selector: 'hab-app',
30-
template: require('./app.component.html')
30+
templateUrl: './app.component.html'
3131
})
3232
export class AppComponent implements OnInit, OnDestroy {
3333
removeNotification: Function;
@@ -37,7 +37,7 @@ export class AppComponent implements OnInit, OnDestroy {
3737

3838
private sub: Subscription;
3939

40-
constructor(private route: ActivatedRoute, private router: Router, private store: AppStore) {
40+
constructor(private route: ActivatedRoute, private router: Router, private store: AppStore, private cdr: ChangeDetectorRef) {
4141
store.dispatch(loadFeatures());
4242
store.dispatch(loadOAuthProvider());
4343

@@ -70,6 +70,7 @@ export class AppComponent implements OnInit, OnDestroy {
7070
if (requestedRoute) {
7171
router.navigate(requestedRoute);
7272
}
73+
this.cdr.detectChanges();
7374
});
7475

7576
this.removeNotification = function (i) {

components/builder-web/app/app.module.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
// limitations under the License.
1414

1515
import { NgModule } from '@angular/core';
16-
import { RouterModule } from '@angular/router';
1716
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
18-
import { MatButtonModule, MatIconModule, MatRadioModule, MatTabsModule, MAT_LABEL_GLOBAL_OPTIONS } from '@angular/material';
17+
import { MatButtonModule } from '@angular/material/button';
18+
import { MatDialogModule } from '@angular/material/dialog';
19+
import { MatIconModule } from '@angular/material/icon';
20+
import { MatRadioModule } from '@angular/material/radio';
21+
import { MatTabsModule } from '@angular/material/tabs';
22+
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
1923
import { BrowserModule } from '@angular/platform-browser';
24+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
2025
import { HttpClientModule } from '@angular/common/http';
26+
import { RouterOutlet } from '@angular/router';
2127
import { routing } from './routes';
2228
import { AppStore } from './app.store';
2329
import { AppComponent } from './app.component';
@@ -34,23 +40,26 @@ import { SearchModule } from './search/search.module';
3440
import { EventsModule } from './events/events.module';
3541
import { SharedModule } from './shared/shared.module';
3642

43+
3744
@NgModule({
3845
imports: [
3946
MatIconModule,
4047
MatRadioModule,
4148
MatTabsModule,
49+
MatDialogModule,
4250
BrowserModule,
51+
BrowserAnimationsModule,
4352
FormsModule,
4453
HttpClientModule,
4554
MatButtonModule,
4655
OriginModule,
4756
PackageModule,
4857
ProfileModule,
4958
ReactiveFormsModule,
50-
RouterModule,
5159
SearchModule,
5260
EventsModule,
5361
SharedModule,
62+
RouterOutlet,
5463
routing
5564
],
5665
declarations: [
@@ -63,9 +72,10 @@ import { SharedModule } from './shared/shared.module';
6372
],
6473
providers: [
6574
{ provide: LocationStrategy, useClass: HashLocationStrategy, },
66-
{ provide: MAT_LABEL_GLOBAL_OPTIONS, useValue: { float: 'always' } },
75+
{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'always' } },
6776
AppStore
6877
],
6978
bootstrap: [AppComponent]
7079
})
7180
export class AppModule {}
81+

components/builder-web/app/app.scss

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,37 @@ nav {
108108
&.tabs {
109109
background-color: $light-blue;
110110

111-
.mat-tab-links {
111+
.mat-mdc-tab-links {
112112
display: flex;
113113
}
114114

115-
.mat-tab-link {
115+
.mat-mdc-tab-link {
116116
color: $black;
117117
text-transform: uppercase;
118+
font-family: $heading-font-family;
118119
font-size: 0.75rem;
119120
opacity: 1;
120121
min-width: inherit;
122+
flex-grow: 0 !important;
123+
height: 48px;
121124

122125
@include tablet-up {
123126
min-width: 100px;
124127
}
128+
129+
// MDC tab text label
130+
.mdc-tab__text-label {
131+
color: $black;
132+
}
133+
134+
&.mdc-tab--active .mdc-tab__text-label {
135+
color: $black;
136+
}
137+
138+
// Remove MDC indicator bottom border color override
139+
.mdc-tab-indicator .mdc-tab-indicator__content--underline {
140+
border-color: $dark-blue;
141+
}
125142
}
126143
}
127144
}

components/builder-web/app/app.store.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { Injectable } from '@angular/core';
15+
import { Injectable, NgZone, Optional } from '@angular/core';
1616
import { applyMiddleware, compose, createStore, Store } from 'redux';
1717
import rootReducer from './reducers/index';
1818
import thunk from 'redux-thunk';
@@ -24,12 +24,7 @@ import { get, isEqual } from 'lodash';
2424
const composeEnhancers = window['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'] || compose;
2525

2626
const finalCreateStore = composeEnhancers(
27-
// The thunk middleware allows an action to return a function that takes a
28-
// dispatch argument instead of returning an object directly. This allows
29-
// actions to make async calls.
3027
applyMiddleware(thunk),
31-
32-
// Allows resetting of the store
3328
reduxReset()
3429
)(createStore);
3530

@@ -43,10 +38,12 @@ export class AppStore {
4338

4439
private storeSource$: BehaviorSubject<any>;
4540

46-
constructor() {
41+
constructor(@Optional() private zone?: NgZone) {
4742
this.storeSource$ = new BehaviorSubject(this.store.getState());
4843
this.store$ = this.storeSource$.asObservable().pipe(distinctUntilChanged(isEqual));
49-
this.store.subscribe(() => this.storeSource$.next(this.store.getState()));
44+
this.store.subscribe(() => {
45+
this.storeSource$.next(this.store.getState());
46+
});
5047
}
5148

5249
getState(): any {
@@ -65,6 +62,9 @@ export class AppStore {
6562
}
6663

6764
subscribe(listener: Function) {
68-
return this.store.subscribe(() => listener(this.getState()));
65+
return this.store.subscribe(() => {
66+
const run = () => listener(this.getState());
67+
this.zone ? this.zone.run(run) : run();
68+
});
6969
}
7070
}

components/builder-web/app/client/builder-api.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ describe('BuilderApiClient', () => {
2424
beforeEach(() => {
2525
myObj = { myCallback: () => { } };
2626
spyOn(myObj, 'myCallback');
27-
spyOn(window, 'fetch').and.callFake(() => {
27+
spyOn(window, 'fetch').and.callFake((() => {
2828
return Promise.resolve({ ok: true });
29-
});
29+
}) as any);
3030
});
3131

3232
it('resolves true', (done) => {
@@ -46,9 +46,9 @@ describe('BuilderApiClient', () => {
4646
beforeEach(() => {
4747
myObj = { myCallback: () => { } };
4848
spyOn(myObj, 'myCallback');
49-
spyOn(window, 'fetch').and.callFake(() => {
49+
spyOn(window, 'fetch').and.callFake((() => {
5050
return Promise.resolve({ ok: false });
51-
});
51+
}) as any);
5252
});
5353

5454
it('resolves with an instance of Error', (done) => {

components/builder-web/app/client/builder-api.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import 'whatwg-fetch';
1615
import config from '../config';
1716
import { parseKey } from '../util';
1817
import { AppStore } from '../app.store';
@@ -203,7 +202,7 @@ export class BuilderApiClient {
203202
}
204203

205204
public generateOriginKeys(origin: string) {
206-
return new Promise((resolve, reject) => {
205+
return new Promise<void>((resolve, reject) => {
207206
fetch(`${this.urlPrefix}/depot/origins/${origin}/keys`, {
208207
method: 'POST',
209208
headers: this.headers
@@ -364,7 +363,7 @@ export class BuilderApiClient {
364363
}
365364

366365
public cancelJobGroup(id: string) {
367-
return new Promise((resolve, reject) => {
366+
return new Promise<void>((resolve, reject) => {
368367
fetch(`${this.urlPrefix}/jobs/group/${id}/cancel`, {
369368
method: 'POST',
370369
headers: this.headers
@@ -575,7 +574,7 @@ export class BuilderApiClient {
575574
}
576575

577576
public saveProfile(profile: any) {
578-
return new Promise((resolve, reject) => {
577+
return new Promise<void>((resolve, reject) => {
579578
fetch(`${this.urlPrefix}/profile`, {
580579
headers: this.jsonHeaders,
581580
method: 'PATCH',
@@ -725,7 +724,7 @@ export class BuilderApiClient {
725724
}
726725

727726
public setIntegration(originName: string, credentials, type: string, name: string) {
728-
return new Promise((resolve, reject) => {
727+
return new Promise<void>((resolve, reject) => {
729728
fetch(`${this.urlPrefix}/depot/origins/${originName}/integrations/${type}/${name}`, {
730729
headers: this.jsonHeaders,
731730
method: 'PUT',
@@ -762,7 +761,7 @@ export class BuilderApiClient {
762761
}
763762

764763
public setProjectIntegrationSettings(origin: string, name: string, integration: string, settings: any) {
765-
return new Promise((resolve, reject) => {
764+
return new Promise<void>((resolve, reject) => {
766765
fetch(`${this.urlPrefix}/projects/${origin}/${name}/integrations/${integration}/default`, {
767766
headers: this.jsonHeaders,
768767
method: 'PUT',
@@ -782,7 +781,7 @@ export class BuilderApiClient {
782781
}
783782

784783
public deleteProjectIntegration(origin: string, name: string, integration: string) {
785-
return new Promise((resolve, reject) => {
784+
return new Promise<void>((resolve, reject) => {
786785
fetch(`${this.urlPrefix}/projects/${origin}/${name}/integrations/${integration}/default`, {
787786
headers: this.headers,
788787
method: 'DELETE'
@@ -801,7 +800,7 @@ export class BuilderApiClient {
801800
}
802801

803802
public setProjectVisibility(origin: string, name: string, setting: string) {
804-
return new Promise((resolve, reject) => {
803+
return new Promise<void>((resolve, reject) => {
805804
fetch(`${this.urlPrefix}/projects/${origin}/${name}/${setting}`, {
806805
headers: this.headers,
807806
method: 'PATCH'
@@ -820,7 +819,7 @@ export class BuilderApiClient {
820819
}
821820

822821
public setPackageReleaseVisibility(origin: string, name: string, version: string, release: string, setting: string) {
823-
return new Promise((resolve, reject) => {
822+
return new Promise<void>((resolve, reject) => {
824823
fetch(`${this.urlPrefix}/depot/pkgs/${origin}/${name}/${version}/${release}/${setting}`, {
825824
headers: this.headers,
826825
method: 'PATCH'
@@ -839,7 +838,7 @@ export class BuilderApiClient {
839838
}
840839

841840
public deleteIntegration(origin: string, name: string, type: string) {
842-
return new Promise((resolve, reject) => {
841+
return new Promise<void>((resolve, reject) => {
843842
fetch(`${this.urlPrefix}/depot/origins/${origin}/integrations/${type}/${name}`, {
844843
headers: this.headers,
845844
method: 'DELETE',
@@ -857,7 +856,7 @@ export class BuilderApiClient {
857856
}
858857

859858
public updateOrigin(origin: any) {
860-
return new Promise((resolve, reject) => {
859+
return new Promise<void>((resolve, reject) => {
861860
fetch(`${this.urlPrefix}/depot/origins/${origin.name}`, {
862861
headers: this.jsonHeaders,
863862
method: 'PUT',
@@ -876,7 +875,7 @@ export class BuilderApiClient {
876875
}
877876

878877
public deleteOriginSecret(origin: string, key: string) {
879-
return new Promise((resolve, reject) => {
878+
return new Promise<void>((resolve, reject) => {
880879
fetch(`${this.urlPrefix}/depot/origins/${origin}/secret/${key}`, {
881880
headers: this.headers,
882881
method: 'DELETE'
@@ -916,7 +915,7 @@ export class BuilderApiClient {
916915
creds['url'] = url.trim();
917916
}
918917

919-
return new Promise((resolve, reject) => {
918+
return new Promise<void>((resolve, reject) => {
920919
fetch(`${this.urlPrefix}/ext/integrations/${type}/credentials/validate`, {
921920
headers: this.jsonHeaders,
922921
method: 'POST',

components/builder-web/app/client/depot-api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import 'whatwg-fetch';
1615
import { packageString } from '../util';
1716
import { AppStore } from '../app.store';
1817
import { addNotification, signOut } from '../actions/index';

0 commit comments

Comments
 (0)