Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickstart: more templates option #3223

Merged
merged 6 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions client/src/app/function/function-new/function-new.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogCategories, Order, Regex, KeyCodes, ScenarioIds, Constants, WorkerRuntimeLanguages, Links } from './../../shared/models/constants';
import { LogCategories, Order, Regex, KeyCodes, ScenarioIds, Constants, WorkerRuntimeLanguages, Links, SiteTabIds } from './../../shared/models/constants';
import { Dom } from './../../shared/Utilities/dom';
import { Binding } from './../../shared/models/binding';
import { Template } from './../../shared/models/template-picker';
Expand Down Expand Up @@ -26,6 +26,7 @@ import { ScenarioService } from '../../shared/services/scenario/scenario.service
import { ArmObj } from '../../shared/models/arm/arm-obj';
import { ApplicationSettings } from '../../shared/models/arm/application-settings';
import { SiteService } from '../../shared/services/site.service';
import { BroadcastEvent } from 'app/shared/models/broadcast-event';

interface CategoryOrder {
name: string;
Expand Down Expand Up @@ -784,7 +785,15 @@ export class FunctionNewComponent extends FunctionAppContextComponent implements
}

quickstart() {
this.functionsNode.openCreateDashboard(DashboardType.CreateFunctionQuickstartDashboard);
if (this.runtimeVersion === 'V1') {
this.functionsNode.openCreateDashboard(DashboardType.CreateFunctionQuickstartDashboard);
} else {
this._broadcastService.broadcastEvent(BroadcastEvent.OpenTab, SiteTabIds.quickstart);
this._broadcastService.broadcastEvent(BroadcastEvent.TreeUpdate, {
operation: 'navigate',
data: 'appNode',
});
}
}

onKeyPressQuick(event: KeyboardEvent) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/shared/models/broadcast-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface BusyStateEvent {
}

export interface TreeUpdateEvent {
operation: 'add' | 'remove' | 'removeChild' | 'update' | 'navigate' | 'newFunction';
operation: 'add' | 'remove' | 'removeChild' | 'update' | 'navigate' | 'newFunction' | 'moreTemplates';
resourceId: string;
data?: any;
}
2,675 changes: 1,339 additions & 1,336 deletions client/src/app/shared/models/portal-resources.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
</div>
<div class="footer">
<button type="button" class="custom-button form-button" previousStep>{{'back' | translate}}</button>
<button type="button" class="custom-button form-button" *ngIf="selectedPortalTemplateCard" (click)="create()">{{'create' | translate}}</button>
<button type="button" class="custom-button form-button" *ngIf="selectedPortalTemplateCard" (click)="finish()">{{finishButtonText}}</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,40 @@ import { errorIds } from 'app/shared/models/error-ids';
})
export class StepCreatePortalFunctionComponent implements OnInit, OnDestroy {

public readonly portalTemplateCards: PortalTemplateCard[] = [
{
id: 'HttpTrigger',
name: this._translateService.instant(PortalResources.intro_webHook),
icon: 'image/http.svg',
color: '#731DDA',
description: this._translateService.instant(PortalResources.httpCardDescription),
},
{
id: 'TimerTrigger',
name: this._translateService.instant(PortalResources.intro_timer),
icon: 'image/timer.svg',
color: '#3C86FF',
description: this._translateService.instant(PortalResources.timerCardDescription),
},
];
public readonly httpTriggerCard: PortalTemplateCard = {
id: 'HttpTrigger',
name: this._translateService.instant(PortalResources.intro_webHook),
icon: 'image/http.svg',
color: '#731DDA',
description: this._translateService.instant(PortalResources.httpCardDescription),
};

public readonly timerTriggerCard: PortalTemplateCard = {
id: 'TimerTrigger',
name: this._translateService.instant(PortalResources.intro_timer),
icon: 'image/timer.svg',
color: '#3C86FF',
description: this._translateService.instant(PortalResources.timerCardDescription),
};

public readonly moreTemplatesCard: PortalTemplateCard = {
id: 'MoreTemplates',
name: this._translateService.instant(PortalResources.moreTemplatesTitle),
icon: 'image/other.svg',
color: '#000000',
description: this._translateService.instant(PortalResources.moreTemplatesDescription),
};

public portalTemplateCards: PortalTemplateCard[];
public selectedPortalTemplateCard: PortalTemplateCard = null;
public bindingManager: BindingManager = new BindingManager();
public context: FunctionAppContext;
public isLinux: boolean;
public workerRuntime: workerRuntimeOptions;
public language: string;
public templates: FunctionTemplate[];
public functionsInfo: FunctionInfo[];
public finishButtonText: string;

private _ngUnsubscribe = new Subject();

Expand All @@ -59,8 +69,10 @@ export class StepCreatePortalFunctionComponent implements OnInit, OnDestroy {
private _broadcastService: BroadcastService) {

this.context = this._wizardService.context.value;
this.isLinux = this._wizardService.isLinux.value;
this.workerRuntime = this._wizardService.workerRuntime.value;
this.language = this._getLanguage();
this.portalTemplateCards = this._getPortalTemplateCards();

this._wizardService.context.statusChanges
.takeUntil(this._ngUnsubscribe)
Expand All @@ -74,6 +86,13 @@ export class StepCreatePortalFunctionComponent implements OnInit, OnDestroy {
this.workerRuntime = this._wizardService.workerRuntime.value;
this.language = this._getLanguage();
});

this._wizardService.isLinux.statusChanges
.takeUntil(this._ngUnsubscribe)
.subscribe(() => {
this.isLinux = this._wizardService.isLinux.value;
this.portalTemplateCards = this._getPortalTemplateCards();
});
}

ngOnInit() {
Expand All @@ -88,10 +107,19 @@ export class StepCreatePortalFunctionComponent implements OnInit, OnDestroy {

public selectPortalTemplate(card: PortalTemplateCard) {
this.selectedPortalTemplateCard = card;
this._setButtonText();
this._wizardService.portalTemplate.setValue(card.id);
}

create() {
public finish() {
if (this.selectedPortalTemplateCard.id === 'MoreTemplates') {
this._navigateToMoreTempaltes();
} else {
this._createFunction();
}
}

private _createFunction() {
if (!this._globalStateService.IsBusy) {

this._globalStateService.setBusyState();
Expand Down Expand Up @@ -127,6 +155,26 @@ export class StepCreatePortalFunctionComponent implements OnInit, OnDestroy {
}
}

private _getPortalTemplateCards(): PortalTemplateCard[] {
if (this.isLinux) {
return [this.httpTriggerCard, this.timerTriggerCard];
}
return [this.httpTriggerCard, this.timerTriggerCard, this.moreTemplatesCard];
}

private _navigateToMoreTempaltes() {
this._broadcastService.broadcastEvent(BroadcastEvent.CloseTab, SiteTabIds.quickstart);
this._broadcastService.broadcastEvent(BroadcastEvent.TreeUpdate, {operation: 'moreTemplates'});
}

private _setButtonText() {
if (this.selectedPortalTemplateCard.id === 'MoreTemplates') {
this.finishButtonText = this._translateService.instant(PortalResources.moreTemplatesButton);
} else {
this.finishButtonText = this._translateService.instant(PortalResources.create);
}
}

private _getLanguage(): string {
return WorkerRuntimeLanguages[this.workerRuntime] === 'C#' ? 'CSharp' : WorkerRuntimeLanguages[this.workerRuntime];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export class WizardForm {

export type devEnvironmentOptions = 'vs' | 'vscode' | 'coretools' | 'maven' | 'portal';
export type workerRuntimeOptions = 'dotnet' | 'node' | 'nodejs' | 'python' | 'java';
export type portalTemplateOptions = 'HttpTrigger' | 'TimerTrigger' | 'QueueTrigger';
export type portalTemplateOptions = 'HttpTrigger' | 'TimerTrigger' | 'MoreTemplates';
export type deploymentOptions = 'vsDirectPublish' | 'vscodeDirectPublish' | 'coretoolsDirectPublish' | 'mavenDirectPublish' | 'deploymentCenter';
2 changes: 2 additions & 0 deletions client/src/app/tree-view/app-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export class AppNode extends TreeNode
.subscribe(event => {
if (event.operation === 'newFunction') {
(<FunctionsNode>this.children[0]).addChild(event.data);
} else if (event.operation === 'moreTemplates') {
(<FunctionsNode>this.children[0]).openCreateDashboard(DashboardType.CreateFunctionDashboard);
}
});

Expand Down
9 changes: 9 additions & 0 deletions server/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4135,6 +4135,15 @@ Set to "External URL" to use an API definition that is hosted elsewhere.</value>
<data name="singleContainerPreviewTitle" xml:space="preserve">
<value>Single Container (Preview)</value>
</data>
<data name="moreTemplatesTitle" xml:space="preserve">
<value>More templates...</value>
</data>
<data name="moreTemplatesDescription" xml:space="preserve">
<value>View all templates available to this function app</value>
</data>
<data name="moreTemplatesButton" xml:space="preserve">
<value>Finish and view templates</value>
</data>
<data name="dockerComposeSample1TitleLinux" xml:space="preserve">
<value>ASP.NET Core with SQL Server</value>
</data>
Expand Down