-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create slot in product detail to show use of product in workspaces (#300
) * fix: create product detail use component and do init slot setup * fix: finish slot setup * fix: add info box in case of undefined slot * fix: delete used ws in intern tab, update all test files to drop deprecated http components --------- Co-authored-by: Christian Badura <[email protected]>
- Loading branch information
Showing
19 changed files
with
143 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 3 additions & 14 deletions
17
src/app/product-store/product-detail/product-intern/product-intern.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,22 @@ | ||
import { Component, Input, OnChanges, ElementRef, ViewChild } from '@angular/core' | ||
import { TranslateService } from '@ngx-translate/core' | ||
import { Component, Input, OnChanges } from '@angular/core' | ||
|
||
import { ProductAndWorkspaces } from 'src/app/shared/generated' | ||
import { sortByLocale } from 'src/app/shared/utils' | ||
import { Product } from 'src/app/shared/generated' | ||
|
||
@Component({ | ||
selector: 'app-product-intern', | ||
templateUrl: './product-intern.component.html' | ||
}) | ||
export class ProductInternComponent implements OnChanges { | ||
@Input() product: ProductAndWorkspaces | undefined | ||
@Input() product: Product | undefined | ||
@Input() dateFormat = 'medium' | ||
|
||
@ViewChild('usedInWorkspaces') usedInWorkspaces: ElementRef = {} as ElementRef | ||
public operator = false | ||
public undeployed = false | ||
|
||
constructor(private readonly translate: TranslateService) {} | ||
|
||
public ngOnChanges(): void { | ||
if (this.product) { | ||
this.operator = this.product.operator ?? false | ||
this.undeployed = this.product.undeployed ?? false | ||
} | ||
setTimeout(() => { | ||
if (this.usedInWorkspaces?.nativeElement) { | ||
const wList = this.product?.workspaces?.sort(sortByLocale) | ||
this.usedInWorkspaces.nativeElement.innerHTML = wList?.join(', ') | ||
} | ||
}, 2) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/app/product-store/product-detail/product-use/product-use.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="sm:pt-2 pb-2 sm:pb-3 px-3"> | ||
<ocx-slot | ||
*ngIf="isListWorkspacesUsingProductComponentDefined$ | async" | ||
[name]="listWorkspacesUsingProductSlotName" | ||
[inputs]="{ productName: product?.name }" | ||
> | ||
</ocx-slot> | ||
<div *ngIf="(isListWorkspacesUsingProductComponentDefined$ | async) === false" id="ps_product_use_error"> | ||
<p-message | ||
id="ps_product_use_error_message" | ||
severity="info" | ||
styleClass="p-2" | ||
[text]="'SLOT.NOT_DEFINED' | translate" | ||
></p-message> | ||
</div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
src/app/product-store/product-detail/product-use/product-use.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing' | ||
import { NO_ERRORS_SCHEMA } from '@angular/core' | ||
import { provideHttpClient } from '@angular/common/http' | ||
import { provideHttpClientTesting } from '@angular/common/http/testing' | ||
import { TranslateTestingModule } from 'ngx-translate-testing' | ||
|
||
import { ProductUseComponent } from './product-use.component' | ||
|
||
describe('ProductUseComponent', () => { | ||
let component: ProductUseComponent | ||
let fixture: ComponentFixture<ProductUseComponent> | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ProductUseComponent], | ||
imports: [ | ||
TranslateTestingModule.withTranslations({ | ||
de: require('src/assets/i18n/de.json'), | ||
en: require('src/assets/i18n/en.json') | ||
}).withDefaultLanguage('en') | ||
], | ||
schemas: [NO_ERRORS_SCHEMA], | ||
providers: [provideHttpClientTesting(), provideHttpClient()] | ||
}).compileComponents() | ||
})) | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ProductUseComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
}) |
21 changes: 21 additions & 0 deletions
21
src/app/product-store/product-detail/product-use/product-use.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Component, Input } from '@angular/core' | ||
|
||
import { SlotService } from '@onecx/angular-remote-components' | ||
import { Observable } from 'rxjs' | ||
import { Product } from 'src/app/shared/generated' | ||
|
||
@Component({ | ||
selector: 'app-product-use', | ||
templateUrl: './product-use.component.html' | ||
}) | ||
export class ProductUseComponent { | ||
@Input() product: Product | undefined | ||
public isListWorkspacesUsingProductComponentDefined$: Observable<boolean> | undefined | ||
public listWorkspacesUsingProductSlotName = 'onecx-product-list-workspaces-using-product' | ||
|
||
constructor(private readonly slotService: SlotService) { | ||
this.isListWorkspacesUsingProductComponentDefined$ = this.slotService.isSomeComponentDefinedForSlot( | ||
this.listWorkspacesUsingProductSlotName | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.