From c02717ff22732fd9e3bcc0fb70e8b995aa118077 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 9 Aug 2018 12:37:22 +0200 Subject: [PATCH] fix: pipeline selection reacts on the runtime change (#351) * fix: pipeline selection reacts on runtime change * chore: removes reduntant === true in ngIf * chore: aligns techPreview case in html templates --- .../cancel-overlay.component.html | 2 +- ...n-runtime-createapp-step.component.spec.ts | 3 +- ...ission-runtime-createapp-step.component.ts | 2 +- .../mission-runtime-createapp-step.model.ts | 2 + ...progress-createapp-nextstep.component.html | 8 +- ...ject-summary-createapp-step.component.html | 18 +- .../pipelines.fixture.spec.ts | 267 ++++++++++++++++++ ...ase-strategy-createapp-step.component.html | 16 +- ...-strategy-createapp-step.component.spec.ts | 114 ++++---- ...lease-strategy-createapp-step.component.ts | 22 +- ...progress-importapp-nextstep.component.html | 10 +- ...gress-importapp-nextstep.component.spec.ts | 9 +- ...ject-summary-importapp-step.component.html | 16 +- ...ase-strategy-importapp-step.component.html | 16 +- ...-strategy-importapp-step.component.spec.ts | 7 +- src/app/launcher/launcher.component.html | 4 +- src/app/launcher/model/pipeline.model.ts | 3 +- .../service/mission-runtime.service.spec.ts | 2 +- .../step-indicator.component.html | 6 +- 19 files changed, 399 insertions(+), 128 deletions(-) create mode 100644 src/app/launcher/create-app/release-strategy-createapp-step/pipelines.fixture.spec.ts diff --git a/src/app/launcher/cancel-overlay/cancel-overlay.component.html b/src/app/launcher/cancel-overlay/cancel-overlay.component.html index 3cfaa747..6e328b6d 100644 --- a/src/app/launcher/cancel-overlay/cancel-overlay.component.html +++ b/src/app/launcher/cancel-overlay/cancel-overlay.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts index 11fbae4f..4158ac05 100644 --- a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts +++ b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.spec.ts @@ -22,7 +22,8 @@ import { } from '../../service/mission-runtime.service.spec'; import { BroadcasterTestProvider -} from '../targetenvironment-createapp-step/target-environment-createapp-step.component.spec'; +} + from '../targetenvironment-createapp-step/target-environment-createapp-step.component.spec'; import { Observable } from 'rxjs/Observable'; import { Catalog } from '../../model/catalog.model'; diff --git a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.ts b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.ts index 4c01d15b..0192347e 100644 --- a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.ts +++ b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.component.ts @@ -149,12 +149,12 @@ export class MissionRuntimeCreateappStepComponent extends LauncherStep implement this.versionId = newVersion.id; this.launcherComponent.summary.runtime = runtime; this.launcherComponent.summary.runtime.version = newVersion; - // FIXME: use a booster change event listener to do this // set maven artifact if (this.launcherComponent.flow === 'osio' && this.completed) { this.launcherComponent.summary.dependencyCheck.mavenArtifact = this.createMavenArtifact(); } + this.broadcaster.broadcast('runtime-changed', runtime); } this.handleBlankMissionFlow(); this.updateBoosterViewStatus(); diff --git a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.model.ts b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.model.ts index 698e3c05..6dda7c37 100644 --- a/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.model.ts +++ b/src/app/launcher/create-app/mission-runtime-createapp-step/mission-runtime-createapp-step.model.ts @@ -23,6 +23,7 @@ export class ViewRuntime extends Runtime { prerequisite: boolean; canChangeVersion: boolean; suggested: boolean; + pipelinePlatform: string; selectedVersion: { id: string; name: string; }; versions: BoosterVersion[]; showMore: boolean = false; @@ -59,6 +60,7 @@ export function createViewRuntimes(boosters: Booster[], canChangeVersion: boolea canChangeVersion: canChangeVersion, suggested: _.get(runtime, 'metadata.suggested', false), prerequisite: _.get(runtime, 'metadata.prerequisite', false), + pipelinePlatform: _.get(runtime, 'metadata.pipelinePlatform', false), showMore: false, disabled: true, boosters: runtimeBoosters diff --git a/src/app/launcher/create-app/project-progress-createapp-nextstep/project-progress-createapp-nextstep.component.html b/src/app/launcher/create-app/project-progress-createapp-nextstep/project-progress-createapp-nextstep.component.html index 14dede4a..2e429031 100644 --- a/src/app/launcher/create-app/project-progress-createapp-nextstep/project-progress-createapp-nextstep.component.html +++ b/src/app/launcher/create-app/project-progress-createapp-nextstep/project-progress-createapp-nextstep.component.html @@ -9,7 +9,7 @@

Next Steps

-
+
Set Up Incomplete There were some problems. @@ -34,10 +34,10 @@

Working Through Setup - + Your Application is Ready - + Set Up Incomplete

@@ -72,7 +72,7 @@

-
+
diff --git a/src/app/launcher/create-app/project-summary-createapp-step/project-summary-createapp-step.component.html b/src/app/launcher/create-app/project-summary-createapp-step/project-summary-createapp-step.component.html index df44721b..488d4c66 100644 --- a/src/app/launcher/create-app/project-summary-createapp-step/project-summary-createapp-step.component.html +++ b/src/app/launcher/create-app/project-summary-createapp-step/project-summary-createapp-step.component.html @@ -116,7 +116,7 @@

+ [ngClass]="{'suggested': launcherComponent.summary?.pipeline?.suggested || launcherComponent.summary?.pipeline?.techpreview}">
@@ -165,11 +165,11 @@

-
+ [ngClass]="{'suggested': summary?.pipeline?.suggested || summary?.pipeline?.techPreview}"> +
@@ -190,25 +190,25 @@

-
+
+ *ngIf="summary?.pipeline?.suggested"> Red Hat Suggests + *ngIf="summary?.pipeline?.techPreview"> Tech Preview
+ *ngIf="summary?.pipeline?.expanded">
diff --git a/src/app/launcher/create-app/release-strategy-createapp-step/pipelines.fixture.spec.ts b/src/app/launcher/create-app/release-strategy-createapp-step/pipelines.fixture.spec.ts new file mode 100644 index 00000000..dfeb9c0f --- /dev/null +++ b/src/app/launcher/create-app/release-strategy-createapp-step/pipelines.fixture.spec.ts @@ -0,0 +1,267 @@ +import { Pipeline } from '../../model/pipeline.model'; +import { PipelineService } from '../../service/pipeline.service'; +import { Observable } from 'rxjs'; + +export class StubbedPipelineService implements PipelineService { + getPipelines(filterByRuntime?: string): Observable { + return Observable.of(pipelines()); + } +} + +export const mavenReleasePipeline: Pipeline = { + 'id': 'maven-release', + 'platform': 'maven', + 'name': 'Release', + 'description': 'Maven based pipeline which:\n\n' + + '* creates a new version then builds and deploys the project into the maven repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }], + 'suggested': false, + 'techPreview': false +}; + +/** + * Data based on https://github.com/fabric8io/fabric8-jenkinsfile-library + */ +export function pipelines(): Pipeline[] { + + return [{ + 'id': 'django-releaseandstage', + 'platform': 'django', + 'name': 'Release and Stage', + 'description': 'Django based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'django-releasestageapproveandpromote', + 'platform': 'django', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'Django based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, { + 'id': 'dotnet-releaseandstage', + 'platform': 'dotnet', + 'name': 'Release and Stage', + 'description': 'dotnet based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'dotnet-releasestageapproveandpromote', + 'platform': 'dotnet', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'dotnet based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, { + 'id': 'golang-releaseandstage', + 'platform': 'golang', + 'name': 'Release and Stage', + 'description': 'Golang based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'golang-releasestageapproveandpromote', + 'platform': 'golang', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'Golang based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, mavenReleasePipeline, { + 'id': 'maven-releaseandstage', + 'platform': 'maven', + 'name': 'Release and Stage', + 'description': 'Maven based pipeline which:\n\n' + + '* creates a new version then builds and deploys the project into the maven repository\n' + + '* stages the new version into the **Stage** environment', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'maven-releasestageapproveandpromote', + 'platform': 'maven', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'Maven based pipeline which:\n\n' + + '* creates a new version then builds and deploys the project into the maven repository\n' + + '* stages the new version into the **Stage** environment\n' + + '* waits for **Approval** to promote \n' + + '* promotes to the **Run** environment', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, { + 'id': 'node-releaseandstage', + 'platform': 'node', + 'name': 'Release and Stage', + 'description': 'NodeJS based pipeline which creates a new version then builds and deploys the project ' + + 'into the Nexus repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'node-releasestageapproveandpromote', + 'platform': 'node', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'NodeJS based pipeline which creates a new version then builds and deploys the project ' + + 'into the Nexus repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, { + 'id': 'php-releaseandstage', + 'platform': 'php', + 'name': 'Release and Stage', + 'description': 'PHP apache based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'php-releasestageapproveandpromote', + 'platform': 'php', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'PHP apache based pipeline which creates a new version then builds and deploys the project', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, { + 'id': 'rails-releaseandstage', + 'platform': 'rails', + 'name': 'Release and Stage', + 'description': 'Ruby on Rails based pipeline which creates a new version then builds and deploys the project ' + + 'into the Nexus repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'rails-releasestageapproveandpromote', + 'platform': 'rails', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'Ruby on Rails based pipeline which creates a new version then builds and deploys the project ' + + 'into the Nexus repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }, { + 'id': 'swift-releaseandstage', + 'platform': 'swift', + 'name': 'Release and Stage', + 'description': 'NodeJS based pipeline which creates a new version then builds and deploys the project ' + + 'into the Nexus repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, {'name': 'Rollout to Stage', 'description': 'stages the new version into the Stage environment'}], + 'suggested': false, + 'techPreview': false + }, { + 'id': 'swift-releasestageapproveandpromote', + 'platform': 'swift', + 'name': 'Release, Stage, Approve and Promote', + 'description': 'NodeJS based pipeline which creates a new version then builds and deploys the project ' + + 'into the Nexus repository', + 'stages': [{ + 'name': 'Build Release', + 'description': 'creates a new version then builds and deploys the project into the maven repository' + }, { + 'name': 'Rollout to Stage', + 'description': 'stages the new version into the Stage environment' + }, {'name': 'Approve', 'description': 'waits for Approval to promote'}, { + 'name': 'Rollout to Run', + 'description': 'promotes to the Run environment' + }], + 'suggested': true, + 'techPreview': false + }] as Pipeline[]; +} diff --git a/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.html b/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.html index ebd1ca88..1958e793 100644 --- a/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.html +++ b/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.html @@ -22,12 +22,12 @@

-
+
@@ -54,18 +54,18 @@

-
+
+ *ngIf="pipeline.suggested"> Red Hat Suggests + *ngIf="pipeline.techPreview"> Tech Preview
@@ -75,7 +75,7 @@

+ *ngIf="pipeline.expanded">
diff --git a/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.spec.ts b/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.spec.ts index 5170c36d..163a4683 100644 --- a/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.spec.ts +++ b/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.spec.ts @@ -1,16 +1,9 @@ -import { - Component, - EventEmitter, - Input, - Output -} from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import {async, ComponentFixture, TestBed, tick} from '@angular/core/testing'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; -import { By } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; -import { Observable } from 'rxjs'; import { InViewportModule, WindowRef } from '@thisissoon/angular-inviewport'; import { FilterEvent } from 'patternfly-ng/filter'; @@ -20,43 +13,15 @@ import { SortEvent } from 'patternfly-ng/sort'; import { LauncherComponent } from '../../launcher.component'; import { LauncherStep } from '../../launcher-step'; import { PipelineService } from '../../service/pipeline.service'; -import { Pipeline } from '../../model/pipeline.model'; import { ReleaseStrategyCreateappStepComponent } from './release-strategy-createapp-step.component'; import { Selection } from '../../model/selection.model'; import { Summary } from '../../model/summary.model'; -@Component({ - selector: 'pfng-toolbar', - template: '' -}) -export class FakePfngToolbarComponent { - @Input() config: any; - @Output() onFilterChange = new EventEmitter(); - @Output() onSortChange = new EventEmitter(); -} - -let mockPipelineService = { - getPipelines(): Observable { - let pipelines = Observable.of([{ - 'id': 'Pipeline1', - 'suggested': true, - 'name': 'Release', - 'description': 'A slightly longer description of this pipeline\'s capabilities and usage.', - 'stages': [{ - name: 'Stage Name', - description: 'description...' - }, { - name: 'Stage Name', - description: 'description...' - }, { - name: 'Stage Name', - description: 'description...' - }], - 'platform': 'maven' - }]); - return pipelines; - } -}; +import { BroadcasterTestProvider } from + '../targetenvironment-createapp-step/target-environment-createapp-step.component.spec'; +import { Broadcaster } from 'ngx-base'; +import {mavenReleasePipeline, StubbedPipelineService} from './pipelines.fixture.spec'; +import { ViewRuntime } from '../mission-runtime-createapp-step/mission-runtime-createapp-step.model'; export interface TypeWizardComponent { selectedSection: string; @@ -114,8 +79,9 @@ let mockWizardComponent: TypeWizardComponent = { }; describe('ReleaseStrategyStepComponent', () => { - let component: ReleaseStrategyCreateappStepComponent; + let releaseStrategyComponent: ReleaseStrategyCreateappStepComponent; let fixture: ComponentFixture; + let element: HTMLElement; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -127,30 +93,64 @@ describe('ReleaseStrategyStepComponent', () => { SortArrayPipeModule ], declarations: [ - ReleaseStrategyCreateappStepComponent, - FakePfngToolbarComponent + ReleaseStrategyCreateappStepComponent ], providers : [ - { - provide: PipelineService, useValue: mockPipelineService - }, - { - provide: LauncherComponent, useValue: mockWizardComponent - }, - { - provide: WindowRef, useValue: window - } + { provide: PipelineService, useClass: StubbedPipelineService }, + { provide: LauncherComponent, useValue: mockWizardComponent }, + { provide: WindowRef, useValue: window }, + { provide: Broadcaster, useValue: BroadcasterTestProvider.broadcaster } ] }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(ReleaseStrategyCreateappStepComponent); - component = fixture.componentInstance; + releaseStrategyComponent = fixture.componentInstance; + element = fixture.nativeElement; fixture.detectChanges(); }); - it('should create', () => { - expect(component).toBeTruthy(); + describe('pipeline selection', () => { + + it('should change pipeline selection to node when runtime event change', () => { + // given + let pipelines = releaseStrategyComponent.pipelines; + expect(pipelines.length).toBe(0); + BroadcasterTestProvider.broadcaster.broadcast('runtime-changed', {pipelinePlatform: 'node'} as ViewRuntime); + + // when + fixture.detectChanges(); + pipelines = releaseStrategyComponent.pipelines; + + // then + expect(pipelines.length).toBe(2); + expect(pipelines.map(value => value.id)) + .toContain( 'node-releaseandstage', 'node-releasestageapproveandpromote' ); + }); + + it('should reset pipeline selection when runtime changes from maven to node', () => { + // given + BroadcasterTestProvider.broadcaster.broadcast('runtime-changed', {pipelinePlatform: 'maven'} as ViewRuntime); + let pipelines = releaseStrategyComponent.pipelines; + expect(pipelines.length).toBe(3); + + // when + releaseStrategyComponent.updatePipelineSelection(mavenReleasePipeline); + BroadcasterTestProvider.broadcaster.broadcast('runtime-changed', {pipelinePlatform: 'node'} as ViewRuntime); + fixture.detectChanges(); + pipelines = releaseStrategyComponent.pipelines; + + // then + expect(pipelines.length).toBe(2); + expect(pipelines.map(value => value.id)) + .toContain( 'node-releaseandstage', 'node-releasestageapproveandpromote' ); + }); + + it('should not show pipelines when runtime not selected', () => { + expect(releaseStrategyComponent.pipelines.length).toBe(0); + }); + }); + }); diff --git a/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.ts b/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.ts index e0d45e50..ba7bb2c2 100644 --- a/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.ts +++ b/src/app/launcher/create-app/release-strategy-createapp-step/release-strategy-createapp-step.component.ts @@ -13,6 +13,8 @@ import { Selection } from '../../model/selection.model'; import { LauncherComponent } from '../../launcher.component'; import { LauncherStep } from '../../launcher-step'; import { broadcast } from '../../shared/telemetry.decorator'; +import { Broadcaster} from 'ngx-base'; +import { Runtime } from '../../model/runtime.model'; @Component({ encapsulation: ViewEncapsulation.None, @@ -23,26 +25,30 @@ import { broadcast } from '../../shared/telemetry.decorator'; export class ReleaseStrategyCreateappStepComponent extends LauncherStep implements OnInit, OnDestroy { @Input() id: string; - private _pipelines: Pipeline[]; + private _pipelines: Pipeline[] = []; + private _allPipelines: Pipeline[] = []; private _pipelineId: string; private subscriptions: Subscription[] = []; constructor(@Host() public launcherComponent: LauncherComponent, - private pipelineService: PipelineService) { + private pipelineService: PipelineService, + private broadcaster: Broadcaster) { super(); } ngOnInit() { this.launcherComponent.addStep(this); - let filterByRuntime: string = 'maven'; - if (this.launcherComponent && this.launcherComponent.summary && this.launcherComponent.summary.runtime) { - filterByRuntime = this.launcherComponent.summary.runtime.pipelinePlatform; - } - this.subscriptions.push(this.pipelineService.getPipelines(filterByRuntime).subscribe((result: Array) => { - this._pipelines = result; + this.subscriptions.push(this.pipelineService.getPipelines().subscribe((result: Array) => { + this._allPipelines = result; this.restoreSummary(); })); + this.subscriptions.push(this.broadcaster.on('runtime-changed').subscribe((runtime: Runtime) => { + this._pipelines = this._allPipelines.filter(({platform}) => platform === runtime.pipelinePlatform); + if ((this.launcherComponent.summary.pipeline || {} as Pipeline).platform !== runtime.pipelinePlatform) { + this.updatePipelineSelection(undefined); + } + })); } ngOnDestroy() { diff --git a/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.html b/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.html index 14dc1fbb..c1c6858f 100644 --- a/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.html +++ b/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.html @@ -9,7 +9,7 @@

Next Steps: Import Application

-
+
Set Up Incomplete There were some problems. @@ -33,10 +33,10 @@

Working Through Setup - + Your Application is Ready - + Set Up Incomplete

@@ -50,7 +50,7 @@

@@ -62,7 +62,7 @@

+ *ngIf="item?.hyperText !== undefined && item?.completed"> {{item?.hyperText}}
diff --git a/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.spec.ts b/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.spec.ts index 2d9d58d1..c8967bd9 100644 --- a/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.spec.ts +++ b/src/app/launcher/import-app/project-progress-importapp-nextstep/project-progress-importapp-nextstep.component.spec.ts @@ -1,13 +1,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; -import { By } from '@angular/platform-browser'; import { Observable, Subject } from 'rxjs'; import { ProjectProgressImportappNextstepComponent } from './project-progress-importapp-nextstep.component'; import { ProjectProgressService } from '../../service/project-progress.service'; import { Progress } from '../../model/progress.model'; import { LauncherComponent } from '../../launcher.component'; -import { LauncherStep } from '../../launcher-step'; let progressSubject: Subject = new Subject(); let mockProjectProgressService = { @@ -18,17 +16,14 @@ let mockProjectProgressService = { let progress = [{ 'completed': false, 'description': 'Creating Your Project on the OpenShift Cloud', - 'inProgress': false, 'hypertext': 'View New Application', 'url': 'https://github.com/fabric8-launcher/ngx-launcher' }, { 'completed': false, - 'description': 'Setting up Build Pipeline', - 'inProgress': false + 'description': 'Setting up Build Pipeline' }, { 'completed': false, - 'description': 'Configure Trigger Builds on Git Pushes', - 'inProgress': false + 'description': 'Configure Trigger Builds on Git Pushes' }] as Progress[]; return progress; } diff --git a/src/app/launcher/import-app/project-summary-importapp-step/project-summary-importapp-step.component.html b/src/app/launcher/import-app/project-summary-importapp-step/project-summary-importapp-step.component.html index 45063831..13de4733 100644 --- a/src/app/launcher/import-app/project-summary-importapp-step/project-summary-importapp-step.component.html +++ b/src/app/launcher/import-app/project-summary-importapp-step/project-summary-importapp-step.component.html @@ -37,11 +37,11 @@

-
+ [ngClass]="{'suggested': summary?.pipeline?.suggested || summary?.pipeline?.techPreview}"> +
@@ -62,25 +62,25 @@

-
+
+ *ngIf="summary?.pipeline?.suggested"> Red Hat Suggests + *ngIf="summary?.pipeline?.techPreview"> Tech Preview
+ *ngIf="summary?.pipeline?.expanded">
diff --git a/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.html b/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.html index db13c670..377f51c3 100644 --- a/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.html +++ b/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.html @@ -22,12 +22,12 @@

-
+
@@ -54,25 +54,25 @@

-
+
+ *ngIf="pipeline.suggested"> Red Hat Suggests + *ngIf="pipeline.techPreview"> Tech Preview
+ *ngIf="pipeline.expanded">
diff --git a/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.spec.ts b/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.spec.ts index 6c822183..458210af 100644 --- a/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.spec.ts +++ b/src/app/launcher/import-app/release-strategy-importapp-step/release-strategy-importapp-step.component.spec.ts @@ -8,14 +8,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; -import { By } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; import { Observable } from 'rxjs'; import { InViewportModule, WindowRef } from '@thisissoon/angular-inviewport'; - import { FilterEvent } from 'patternfly-ng/filter'; - import { SortArrayPipeModule } from 'patternfly-ng/pipe'; - import { SortEvent } from 'patternfly-ng/sort'; +import { FilterEvent } from 'patternfly-ng/filter'; +import { SortArrayPipeModule } from 'patternfly-ng/pipe'; +import { SortEvent } from 'patternfly-ng/sort'; import { LauncherComponent } from '../../launcher.component'; import { LauncherStep } from '../../launcher-step'; diff --git a/src/app/launcher/launcher.component.html b/src/app/launcher/launcher.component.html index 0f5d0949..c9761b15 100644 --- a/src/app/launcher/launcher.component.html +++ b/src/app/launcher/launcher.component.html @@ -1,4 +1,4 @@ - +
@@ -37,7 +37,7 @@ [title]="'Select Pipeline'"> diff --git a/src/app/launcher/model/pipeline.model.ts b/src/app/launcher/model/pipeline.model.ts index 48c875f8..73122fbe 100644 --- a/src/app/launcher/model/pipeline.model.ts +++ b/src/app/launcher/model/pipeline.model.ts @@ -3,10 +3,11 @@ export class Pipeline { name: string; id: string; platform: string; + description?: string; stages: [{ description: string; name: string; }]; suggested?: boolean; - techpreview?: boolean; + techPreview?: boolean; } diff --git a/src/app/launcher/service/mission-runtime.service.spec.ts b/src/app/launcher/service/mission-runtime.service.spec.ts index 8e216b27..1f3cfa1a 100644 --- a/src/app/launcher/service/mission-runtime.service.spec.ts +++ b/src/app/launcher/service/mission-runtime.service.spec.ts @@ -28,7 +28,7 @@ export const createRuntime = (name: string, versions: string[]): CatalogRuntime suggested: true, prerequisite: 'prerequisite text' }, - versions: versions.map(createVersion) as CatalogRuntimeVersion[] + versions: versions.map(version => createVersion(version)) as CatalogRuntimeVersion[] }); export const createBooster = (mission: string, runtime: string, version: string): CatalogBooster => ({ diff --git a/src/app/launcher/step-indicator/step-indicator.component.html b/src/app/launcher/step-indicator/step-indicator.component.html index 2e62c348..7517d45e 100644 --- a/src/app/launcher/step-indicator/step-indicator.component.html +++ b/src/app/launcher/step-indicator/step-indicator.component.html @@ -14,14 +14,14 @@
+ [ngClass]="{'in-progress': inProgress}">
+ [ngClass]="{'completed': step.completed}">
{{step.title}}