Skip to content

Commit 7ef1d07

Browse files
authored
Merge pull request #2692 from Azure/dev
Deployment
2 parents 43df85e + 719f039 commit 7ef1d07

File tree

106 files changed

+8592
-5365
lines changed

Some content is hidden

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

106 files changed

+8592
-5365
lines changed

client/.angular-cli.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
"src/**/*.spec.ts",
6363
"src/app/shared/**/*.ts",
6464
"src/app/pickers/microsoft-graph/microsoft-graph-helper.ts",
65-
"**/radio-selector/**"
65+
"**/radio-selector/**",
66+
"**/try-now-busy-state/**",
67+
"**/load-image.directive.ts",
68+
"**/pop-over/**"
6669
]
6770
},
6871
"karma": {

client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"marked": "^0.3.9",
3737
"moment-mini-ts": "^2.20.1",
3838
"monaco-editor": "^0.10.0",
39-
"ng-sidebar": "^6.0.1",
39+
"ng-sidebar": "^7.1.0",
4040
"ng2-cookies": "^1.0.3",
4141
"ng2-file-upload": "~1.2.1",
4242
"ng2-popover": "^0.0.14",

client/src/app/api/api-details/api-details.component.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { AiService } from '../../shared/services/ai.service';
1616
import { RequestResposeOverrideComponent } from '../request-respose-override/request-respose-override.component';
1717
import { ArmSiteDescriptor } from '../../shared/resourceDescriptors';
1818
import { NavigableComponent, ExtendedTreeViewInfo } from '../../shared/components/navigable-component';
19+
import { SiteService } from '../../shared/services/site.service';
1920

2021
@Component({
2122
selector: 'api-details',
@@ -42,6 +43,7 @@ export class ApiDetailsComponent extends NavigableComponent implements OnDestroy
4243
private _translateService: TranslateService,
4344
private _aiService: AiService,
4445
private _functionAppService: FunctionAppService,
46+
private _siteService: SiteService,
4547
injector: Injector) {
4648
super('api-details', injector, DashboardType.ProxyDashboard);
4749

@@ -62,7 +64,7 @@ export class ApiDetailsComponent extends NavigableComponent implements OnDestroy
6264
this.initEdit();
6365
return Observable.zip(
6466
this._functionAppService.getApiProxies(context),
65-
this._functionAppService.getFunctionAppAzureAppSettings(context));
67+
this._siteService.getAppSettings(context.site.id));
6668
});
6769
})
6870
.do(r => {

client/src/app/api/api-new/api-new.component.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { FunctionInfo } from '../../shared/models/function-info';
1515
import { errorIds } from '../../shared/models/error-ids';
1616
import { RequestResposeOverrideComponent } from '../request-respose-override/request-respose-override.component';
1717
import { NavigableComponent } from '../../shared/components/navigable-component';
18+
import { SiteService } from '../../shared/services/site.service';
1819

1920
@Component({
2021
selector: 'api-new',
@@ -55,6 +56,7 @@ export class ApiNewComponent extends NavigableComponent {
5556
private _translateService: TranslateService,
5657
private _aiService: AiService,
5758
private _functionAppService: FunctionAppService,
59+
private _siteService: SiteService,
5860
fb: FormBuilder,
5961
injector: Injector) {
6062
super('api-new', injector, DashboardType.CreateProxyDashboard);
@@ -94,7 +96,7 @@ export class ApiNewComponent extends NavigableComponent {
9496
return Observable.zip(
9597
this._functionAppService.getFunctions(context),
9698
this._functionAppService.getApiProxies(context),
97-
this._functionAppService.getFunctionAppAzureAppSettings(context),
99+
this._siteService.getAppSettings(context.site.id),
98100
(f, p, a) => ({ fcs: f, proxies: p, appSettings: a, context: context }));
99101
});
100102
})

client/src/app/binding/binding.component.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { FunctionInfo } from '../shared/models/function-info';
1717
import { FunctionAppService } from 'app/shared/services/function-app.service';
1818
import { FunctionAppContext } from 'app/shared/function-app-context';
1919
import { FunctionAppContextComponent } from 'app/shared/components/function-app-context-component';
20+
import { SiteService } from '../shared/services/site.service';
2021

2122
declare var marked: any;
2223

@@ -59,6 +60,7 @@ export class BindingComponent extends FunctionAppContextComponent implements OnD
5960
constructor(@Inject(ElementRef) elementRef: ElementRef,
6061
broadcastService: BroadcastService,
6162
private _functionAppService: FunctionAppService,
63+
private _siteService: SiteService,
6264
private _portalService: PortalService,
6365
private _cacheService: CacheService,
6466
private _translateService: TranslateService,
@@ -116,7 +118,7 @@ export class BindingComponent extends FunctionAppContextComponent implements OnD
116118
.switchMap(viewInfo => {
117119
// TODO: [alrod] handle error
118120
this._functionInfo = viewInfo.functionInfo.result;
119-
return this._functionAppService.getFunctionAppAzureAppSettings(viewInfo.context);
121+
return this._siteService.getAppSettings(viewInfo.context.site.id);
120122
})
121123
.subscribe(appSettingsResult => {
122124
// TODO: [alrod] handle error
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
2+
import { async } from 'q';
3+
import { BusyStateComponent } from './busy-state.component';
4+
import { TryNowBusyStateComponent } from '../try-now-busy-state/try-now-busy-state.component';
5+
import { MockComponent } from 'ng-mocks';
6+
import { BroadcastService } from '../shared/services/broadcast.service';
7+
import { MockLogService } from '../test/mocks/log.service.mock';
8+
import { LogService } from '../shared/services/log.service';
9+
import { Component, ViewChild } from '@angular/core';
10+
import { BusyStateScopeManager } from './busy-state-scope-manager';
11+
12+
@Component({
13+
selector: `app-host-component`,
14+
template: `<busy-state name="global"></busy-state>`
15+
})
16+
class TestBusyStateHostComponent {
17+
@ViewChild(BusyStateComponent)
18+
public busyStateComponent: BusyStateComponent;
19+
20+
private _busyManager: BusyStateScopeManager;
21+
22+
constructor(broadcastService: BroadcastService) {
23+
this._busyManager = new BusyStateScopeManager(broadcastService, 'global');
24+
}
25+
26+
public setBusy() {
27+
this._busyManager.setBusy();
28+
}
29+
30+
public clearBusy() {
31+
this._busyManager.clearBusy();
32+
}
33+
}
34+
describe('BusyStateComponent', () => {
35+
36+
let busyStateComponent: BusyStateComponent;
37+
let hostComponent: TestBusyStateHostComponent;
38+
let testFixture: ComponentFixture<TestBusyStateHostComponent>;
39+
40+
beforeEach(async(() => {
41+
TestBed.configureTestingModule({
42+
declarations: [BusyStateComponent, TestBusyStateHostComponent, MockComponent(TryNowBusyStateComponent)],
43+
providers: [
44+
BroadcastService,
45+
{ provide: LogService, useClass: MockLogService }
46+
],
47+
imports: []
48+
})
49+
.compileComponents();
50+
51+
}));
52+
53+
beforeEach(() => {
54+
testFixture = TestBed.createComponent(TestBusyStateHostComponent);
55+
hostComponent = testFixture.componentInstance;
56+
busyStateComponent = hostComponent.busyStateComponent;
57+
testFixture.detectChanges();
58+
});
59+
60+
describe('init', () => {
61+
it('component show init', () => {
62+
expect(busyStateComponent).toBeTruthy();
63+
});
64+
});
65+
66+
describe('public use', () => {
67+
it('set busy broadcast should set busy state to true', fakeAsync(() => {
68+
hostComponent.setBusy();
69+
tick(100); // wait 100 ms for debounce time
70+
expect(busyStateComponent.busy).toBeTruthy();
71+
}));
72+
73+
it('clear busy broadcast should set busy state to false', fakeAsync(() => {
74+
hostComponent.setBusy();
75+
tick(100); // wait 100 ms for debounce time
76+
hostComponent.clearBusy();
77+
tick(100);
78+
expect(busyStateComponent.busy).toBeFalsy();
79+
}));
80+
});
81+
});

client/src/app/controls/card-info-control/card-info-control.component.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
vertical-align: middle
44
}
55
.cardContainer {
6-
padding: 25px 25px;
6+
padding-top: 10px;
7+
padding-left: 25px;
8+
padding-right: 25px;
9+
padding-bottom: 10px;
710
}
811

912

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { TestBed, ComponentFixture } from '@angular/core/testing';
2+
import { async } from 'q';
3+
import { Component, ViewChild } from '@angular/core';
4+
import { CardInfoControlComponent } from './card-info-control.component';
5+
import { MockDirective } from 'ng-mocks';
6+
import { LoadImageDirective } from '../load-image/load-image.directive';
7+
import { TranslateModule } from '@ngx-translate/core';
8+
9+
@Component({
10+
selector: `app-card-info-host-component`,
11+
template: `<app-card-info-control [image]="image" [header]="header" [description]="description" [learnMoreLink]="learnMoreLink"></app-card-info-control>`
12+
})
13+
class TestCardInfoHostComponent {
14+
@ViewChild(CardInfoControlComponent)
15+
public cardDashbaordComponent: CardInfoControlComponent;
16+
17+
public image = '';
18+
public header = '';
19+
public description = '';
20+
public learnMoreLink = '';
21+
}
22+
23+
describe('CardInfoControl', () => {
24+
let cardInfoComponent: CardInfoControlComponent;
25+
let hostComponent: TestCardInfoHostComponent;
26+
let testFixture: ComponentFixture<TestCardInfoHostComponent>;
27+
28+
beforeEach(async(() => {
29+
TestBed.configureTestingModule({
30+
declarations: [CardInfoControlComponent, TestCardInfoHostComponent, MockDirective(LoadImageDirective)],
31+
providers: [
32+
],
33+
imports: [TranslateModule.forRoot()]
34+
})
35+
.compileComponents();
36+
37+
}));
38+
39+
beforeEach(() => {
40+
testFixture = TestBed.createComponent(TestCardInfoHostComponent);
41+
hostComponent = testFixture.componentInstance;
42+
cardInfoComponent = hostComponent.cardDashbaordComponent;
43+
testFixture.detectChanges();
44+
});
45+
46+
describe('init', () => {
47+
it('control initiates', () => {
48+
expect(cardInfoComponent).toBeTruthy();
49+
});
50+
});
51+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { CommandBarComponent } from './command-bar.component';
2+
import { CommonModule } from '@angular/common';
3+
import { async } from 'q';
4+
import { ComponentFixture, TestBed } from '@angular/core/testing';
5+
6+
describe('CommandBar', () => {
7+
let commandBar: CommandBarComponent;
8+
let testFixture: ComponentFixture<CommandBarComponent>;
9+
10+
beforeEach(async(() => {
11+
TestBed.configureTestingModule({
12+
declarations: [CommandBarComponent],
13+
imports: [CommonModule]
14+
})
15+
.compileComponents();
16+
17+
}));
18+
19+
beforeEach(() => {
20+
testFixture = TestBed.createComponent(CommandBarComponent);
21+
commandBar = testFixture.componentInstance;
22+
testFixture.detectChanges();
23+
});
24+
25+
describe('init', () => {
26+
it('should initialize component', () => {
27+
expect(commandBar).toBeTruthy();
28+
});
29+
});
30+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import { Component, ViewChild } from '@angular/core';
2+
import { CommandComponent } from './command.component';
3+
import { ComponentFixture, TestBed } from '@angular/core/testing';
4+
import { async } from 'q';
5+
import { MockDirective } from 'ng-mocks';
6+
import { LoadImageDirective } from '../../load-image/load-image.directive';
7+
import { By } from '@angular/platform-browser';
8+
import { KeyCodes } from '../../../shared/models/constants';
9+
10+
@Component({
11+
selector: `app-command-host-component`,
12+
template: `<command [displayText]="displayText" [iconUrl]="iconUrl" [disabled]="disabled" (click)="onClick($event)"></command>`
13+
})
14+
class TestCommandHostComponent {
15+
@ViewChild(CommandComponent)
16+
public commandComponent: CommandComponent;
17+
18+
public iconUrl = 'testicon';
19+
public displayText = 'testtext';
20+
public disabled = false;
21+
22+
public clicked = false;
23+
public onClick(event) {
24+
this.clicked = true;
25+
}
26+
}
27+
28+
describe('CommandControl', () => {
29+
let commandComponent: CommandComponent;
30+
let hostComponent: TestCommandHostComponent;
31+
let testFixture: ComponentFixture<TestCommandHostComponent>;
32+
33+
beforeEach(async(() => {
34+
TestBed.configureTestingModule({
35+
declarations: [CommandComponent, TestCommandHostComponent, MockDirective(LoadImageDirective)]
36+
})
37+
.compileComponents();
38+
39+
}));
40+
41+
beforeEach(() => {
42+
testFixture = TestBed.createComponent(TestCommandHostComponent);
43+
hostComponent = testFixture.componentInstance;
44+
commandComponent = hostComponent.commandComponent;
45+
testFixture.detectChanges();
46+
});
47+
48+
describe('init', () => {
49+
it('should init control', () => {
50+
expect(commandComponent).toBeTruthy();
51+
});
52+
it('should have correct text and icon', () => {
53+
expect(commandComponent.displayText).toBe('testtext');
54+
expect(commandComponent.iconUrl).toBe('testicon');
55+
});
56+
57+
it('should be enabled by default', () => {
58+
expect(commandComponent.disabled).toBeFalsy();
59+
});
60+
61+
});
62+
63+
describe('Enabled Behavior', () => {
64+
it('should not have disabled-command class', () => {
65+
const elem = testFixture.debugElement.query(By.css('.disabled-command'));
66+
expect(elem).toBeFalsy();
67+
});
68+
69+
it('click should trigger click event', () => {
70+
const elem = testFixture.debugElement.query(By.css('a'));
71+
elem.nativeElement.click();
72+
expect(hostComponent.clicked).toBeTruthy();
73+
});
74+
75+
it('enter keypress should trigger click event', () => {
76+
const elem = testFixture.debugElement.query(By.css('a'));
77+
elem.triggerEventHandler('keydown', {
78+
keyCode: KeyCodes.enter
79+
});
80+
expect(hostComponent.clicked).toBeTruthy();
81+
});
82+
});
83+
84+
describe('Disabled Behavior', () => {
85+
it('should have disabled-command class', () => {
86+
hostComponent.disabled = true;
87+
testFixture.detectChanges();
88+
const elem = testFixture.debugElement.query(By.css('.disabled-command'));
89+
expect(elem).toBeTruthy();
90+
});
91+
it('click should not trigger click event', () => {
92+
hostComponent.disabled = true;
93+
testFixture.detectChanges();
94+
const elem = testFixture.debugElement.query(By.css('a'));
95+
elem.nativeElement.click();
96+
expect(hostComponent.clicked).toBeFalsy();
97+
});
98+
99+
it('enter keypress should trigger click event', () => {
100+
hostComponent.disabled = true;
101+
testFixture.detectChanges();
102+
const elem = testFixture.debugElement.query(By.css('a'));
103+
elem.triggerEventHandler('keydown', {
104+
keyCode: KeyCodes.enter
105+
});
106+
expect(hostComponent.clicked).toBeFalsy();
107+
});
108+
});
109+
});

client/src/app/controls/command-bar/command/command.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class CommandComponent {
2525
}
2626

2727
onKeyPress(event: KeyboardEvent) {
28-
if (event.keyCode === KeyCodes.enter) {
28+
if (event.keyCode === KeyCodes.enter && !this.disabled) {
2929
this.click.next(event);
3030
}
3131
}

0 commit comments

Comments
 (0)