From 0733f33d5a9c8181bc861930477ece6a495ca6eb Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Mon, 27 May 2024 13:54:08 +0200 Subject: [PATCH 01/10] feat: menu harnesses enhancements (#260) * feat: menu harnesses enchanced * feat: removed external check from harnesses * feat: further menu harness enchancements --- libs/angular-testing/src/index.ts | 9 +++++- .../harnesses/menu-item-with-icon.harness.ts | 8 ++++++ .../src/lib/harnesses/menu-item.harness.ts | 6 +++- .../primeng/p-accordion-tab.harness.ts | 11 ++++++++ .../harnesses/primeng/p-accordion.harness.ts | 8 ++++++ .../harnesses/primeng/p-menu-item.harness.ts | 27 ++++++++++++++++++ .../lib/harnesses/primeng/p-menu.harness.ts | 2 +- .../harnesses/primeng/p-menubar.harness.ts | 8 ++++++ .../primeng/p-panelmenu-item.harness.ts | 28 +++++++++++++++++++ .../harnesses/primeng/p-panelmenu.harness.ts | 8 ++++++ 10 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 libs/angular-testing/src/lib/harnesses/menu-item-with-icon.harness.ts create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-accordion-tab.harness.ts create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-accordion.harness.ts create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-menu-item.harness.ts create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-menubar.harness.ts create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu-item.harness.ts create mode 100644 libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu.harness.ts diff --git a/libs/angular-testing/src/index.ts b/libs/angular-testing/src/index.ts index 1a2b7edf..377f1270 100644 --- a/libs/angular-testing/src/index.ts +++ b/libs/angular-testing/src/index.ts @@ -1,3 +1,5 @@ +export * from './lib/harnesses/primeng/p-accordion.harness' +export * from './lib/harnesses/primeng/p-accordion-tab.harness' export * from './lib/harnesses/primeng/p-breadcrumb.harness' export * from './lib/harnesses/primeng/p-button-directive.harness' export * from './lib/harnesses/primeng/p-button.harness' @@ -5,13 +7,17 @@ export * from './lib/harnesses/primeng/p-chart.harness' export * from './lib/harnesses/primeng/p-checkbox.harness' export * from './lib/harnesses/primeng/p-dialog.harness' export * from './lib/harnesses/primeng/p-dropdown.harness' +export * from './lib/harnesses/primeng/p-menu-item.harness' export * from './lib/harnesses/primeng/p-menu.harness' +export * from './lib/harnesses/primeng/p-menubar.harness' export * from './lib/harnesses/primeng/p-multiSelect.harness' export * from './lib/harnesses/primeng/p-multiSelectListItem.harness' +export * from './lib/harnesses/primeng/p-panelmenu-item.harness' +export * from './lib/harnesses/primeng/p-panelmenu.harness' +export * from './lib/harnesses/primeng/p-paginator.harness' export * from './lib/harnesses/primeng/p-password.harness' export * from './lib/harnesses/primeng/p-picklist.harness' export * from './lib/harnesses/primeng/p-selectButton.harness' -export * from './lib/harnesses/primeng/p-paginator.harness' export * from './lib/harnesses/utils/primeicon.utils' @@ -20,6 +26,7 @@ export * from './lib/harnesses/div.harness' export * from './lib/harnesses/input.harness' export * from './lib/harnesses/list-item.harness' export * from './lib/harnesses/menu-item.harness' +export * from './lib/harnesses/menu-item-with-icon.harness' export * from './lib/harnesses/p-tableCheckbox.harness' export * from './lib/harnesses/p.harness' export * from './lib/harnesses/span.harness' diff --git a/libs/angular-testing/src/lib/harnesses/menu-item-with-icon.harness.ts b/libs/angular-testing/src/lib/harnesses/menu-item-with-icon.harness.ts new file mode 100644 index 00000000..3aed3648 --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/menu-item-with-icon.harness.ts @@ -0,0 +1,8 @@ +import { MenuItemHarness } from './menu-item.harness' + +export class MenuItemWithIconHarness extends MenuItemHarness { + async hasIcon(icon: string): Promise { + const classList = await (await this.locatorForOptional('i')())?.getAttribute('class') + return classList?.includes(icon) + } +} diff --git a/libs/angular-testing/src/lib/harnesses/menu-item.harness.ts b/libs/angular-testing/src/lib/harnesses/menu-item.harness.ts index 94b191c9..bd86d4f3 100644 --- a/libs/angular-testing/src/lib/harnesses/menu-item.harness.ts +++ b/libs/angular-testing/src/lib/harnesses/menu-item.harness.ts @@ -13,11 +13,15 @@ export class MenuItemHarness extends ComponentHarness { ) } - async getText() { + async getText(): Promise { return await (await this.host()).text() } async selectItem() { await (await this.host()).click() } + + async getLink(): Promise { + return await (await this.host()).getAttribute('href') + } } diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-accordion-tab.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-accordion-tab.harness.ts new file mode 100644 index 00000000..11f2931c --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-accordion-tab.harness.ts @@ -0,0 +1,11 @@ +import { ComponentHarness } from '@angular/cdk/testing' + +export class PAccordionTabHarness extends ComponentHarness { + static hostSelector = 'p-accordiontab' + + getButton = this.locatorFor('a.p-accordion-header-link') + + async expand() { + await (await this.getButton()).click() + } +} diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-accordion.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-accordion.harness.ts new file mode 100644 index 00000000..bf899291 --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-accordion.harness.ts @@ -0,0 +1,8 @@ +import { ComponentHarness } from '@angular/cdk/testing' +import { PAccordionTabHarness } from './p-accordion-tab.harness' + +export class PAccordionHarness extends ComponentHarness { + static hostSelector = 'p-accordion' + + getAllAccordionTabs = this.locatorForAll(PAccordionTabHarness) +} diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-menu-item.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-menu-item.harness.ts new file mode 100644 index 00000000..5355dcf2 --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-menu-item.harness.ts @@ -0,0 +1,27 @@ +import { ComponentHarness } from '@angular/cdk/testing' +import { SpanHarness } from '../span.harness' + +export class PMenuItemHarness extends ComponentHarness { + static hostSelector = 'li.p-menuitem' + + getAnchor = this.locatorFor('a') + getChildren = this.locatorForAll(PMenuItemHarness) + getIconSpan = this.locatorForOptional(SpanHarness.with({ class: 'p-menuitem-icon' })) + + async getText(): Promise { + return await (await this.getAnchor()).text() + } + + async hasIcon(icon: string): Promise { + const classList = await (await (await this.getIconSpan())?.host())?.getAttribute('class') + return classList?.includes(icon) + } + + async click() { + return await (await this.getAnchor()).click() + } + + async getLink(): Promise { + return await (await this.getAnchor()).getAttribute('href') + } +} diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-menu.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-menu.harness.ts index 9d8e432d..3afcdd1b 100644 --- a/libs/angular-testing/src/lib/harnesses/primeng/p-menu.harness.ts +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-menu.harness.ts @@ -12,7 +12,7 @@ export class PMenuHarness extends ContentContainerComponentHarness { return !!(await this.getHarnessLoaderForPMenuOverlay()) } - async getAllMenuItems() { + async getAllMenuItems(): Promise { if (await this.isOpen()) { return await (await this.getHarnessLoaderForPMenuOverlay())?.getAllHarnesses(MenuItemHarness) } else { diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-menubar.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-menubar.harness.ts new file mode 100644 index 00000000..c535e803 --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-menubar.harness.ts @@ -0,0 +1,8 @@ +import { ComponentHarness } from '@angular/cdk/testing' +import { PMenuItemHarness } from './p-menu-item.harness' + +export class PMenuBarHarness extends ComponentHarness { + static hostSelector = 'p-menubar' + + getAllMenuItems = this.locatorForAll(PMenuItemHarness) +} diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu-item.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu-item.harness.ts new file mode 100644 index 00000000..ded18462 --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu-item.harness.ts @@ -0,0 +1,28 @@ +import { ComponentHarness } from '@angular/cdk/testing' +import { SpanHarness } from '../span.harness' +import { PMenuItemHarness } from './p-menu-item.harness' + +export class PanelMenuItemHarness extends ComponentHarness { + static hostSelector = 'div.p-panelmenu-panel' + + getAnchor = this.locatorFor('a') + getChildren = this.locatorForAll(PMenuItemHarness) + getIconSpan = this.locatorForOptional(SpanHarness.with({ class: 'p-menuitem-icon' })) + + async getText(): Promise { + return await (await this.getAnchor()).text() + } + + async hasIcon(icon: string): Promise { + const classList = await (await (await this.getIconSpan())?.host())?.getAttribute('class') + return classList?.includes(icon) + } + + async click() { + await (await this.getAnchor()).click() + } + + async getLink(): Promise { + return await (await this.getAnchor()).getAttribute('href') + } +} diff --git a/libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu.harness.ts b/libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu.harness.ts new file mode 100644 index 00000000..9b550451 --- /dev/null +++ b/libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu.harness.ts @@ -0,0 +1,8 @@ +import { ComponentHarness } from '@angular/cdk/testing' +import { PanelMenuItemHarness } from './p-panelmenu-item.harness' + +export class PPanelMenuHarness extends ComponentHarness { + static hostSelector = 'p-panelmenu' + + getAllPanels = this.locatorForAll(PanelMenuItemHarness) +} From 6d6b9c638906860ab1aca6fb86d1562b09f800b3 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 27 May 2024 12:52:36 +0000 Subject: [PATCH 02/10] chore(release): -v4.26.0 [skip ci] ## [4.26.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.25.1...v4.26.0) (2024-05-27) ### Features * menu harnesses enhancements ([#260](https://github.com/onecx/onecx-portal-ui-libs/issues/260)) ([0733f33](https://github.com/onecx/onecx-portal-ui-libs/commit/0733f33d5a9c8181bc861930477ece6a495ca6eb)) --- CHANGELOG.md | 7 +++++++ libs/accelerator/package.json | 2 +- libs/angular-accelerator/package.json | 2 +- libs/angular-auth/package.json | 2 +- libs/angular-integration-interface/package.json | 2 +- libs/angular-remote-components/package.json | 2 +- libs/angular-testing/package.json | 2 +- libs/integration-interface/package.json | 2 +- libs/keycloak-auth/package.json | 2 +- libs/portal-integration-angular/package.json | 2 +- libs/portal-layout-styles/package.json | 2 +- libs/shell-core/package.json | 2 +- package.json | 2 +- 13 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39dcf4f4..f30b46b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [4.26.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.25.1...v4.26.0) (2024-05-27) + + +### Features + +* menu harnesses enhancements ([#260](https://github.com/onecx/onecx-portal-ui-libs/issues/260)) ([0733f33](https://github.com/onecx/onecx-portal-ui-libs/commit/0733f33d5a9c8181bc861930477ece6a495ca6eb)) + ## [4.25.1](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.25.0...v4.25.1) (2024-05-17) diff --git a/libs/accelerator/package.json b/libs/accelerator/package.json index ddc479db..2e49c2c7 100644 --- a/libs/accelerator/package.json +++ b/libs/accelerator/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/accelerator", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "tslib": "^2.3.0", "rxjs": "7.8.1" diff --git a/libs/angular-accelerator/package.json b/libs/angular-accelerator/package.json index 144e48d0..6cca5518 100644 --- a/libs/angular-accelerator/package.json +++ b/libs/angular-accelerator/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-accelerator", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-auth/package.json b/libs/angular-auth/package.json index bae0b4f4..859944b5 100644 --- a/libs/angular-auth/package.json +++ b/libs/angular-auth/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-auth", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-integration-interface/package.json b/libs/angular-integration-interface/package.json index 2aa757ea..53414212 100644 --- a/libs/angular-integration-interface/package.json +++ b/libs/angular-integration-interface/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-integration-interface", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", "@onecx/integration-interface": "~4", diff --git a/libs/angular-remote-components/package.json b/libs/angular-remote-components/package.json index c44b6133..52f25fc4 100644 --- a/libs/angular-remote-components/package.json +++ b/libs/angular-remote-components/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-remote-components", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-testing/package.json b/libs/angular-testing/package.json index 79e50155..7717fe61 100644 --- a/libs/angular-testing/package.json +++ b/libs/angular-testing/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-testing", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/cdk": "^15.2.7 || ^16.0.0 || ^17.0.0", "primeng": "^15.0.0 || ^16.0.0 || ^17.0.0" diff --git a/libs/integration-interface/package.json b/libs/integration-interface/package.json index 08449128..5e956522 100644 --- a/libs/integration-interface/package.json +++ b/libs/integration-interface/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/integration-interface", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "tslib": "^2.3.0", "rxjs": "7.8.1", diff --git a/libs/keycloak-auth/package.json b/libs/keycloak-auth/package.json index b893e94b..317f0496 100644 --- a/libs/keycloak-auth/package.json +++ b/libs/keycloak-auth/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/keycloak-auth", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/portal-integration-angular/package.json b/libs/portal-integration-angular/package.json index 0d4eb30c..0ae38bd5 100644 --- a/libs/portal-integration-angular/package.json +++ b/libs/portal-integration-angular/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/portal-integration-angular", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/portal-layout-styles/package.json b/libs/portal-layout-styles/package.json index c8063f7b..ed052d80 100644 --- a/libs/portal-layout-styles/package.json +++ b/libs/portal-layout-styles/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/portal-layout-styles", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "tslib": "^2.5.0" }, diff --git a/libs/shell-core/package.json b/libs/shell-core/package.json index 2c2b4e4e..60eeba68 100644 --- a/libs/shell-core/package.json +++ b/libs/shell-core/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/shell-core", - "version": "4.25.1", + "version": "4.26.0", "peerDependencies": { "rxjs": "7.8.1", "@angular/animations": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/package.json b/package.json index d5cbaea1..84b8ace7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/onecx-portal-ui-libs", - "version": "4.25.1", + "version": "4.26.0", "license": "Apache-2.0", "scripts": { "sass": "npx sass libs/portal-integration-angular/assets/styles.scss libs/portal-integration-angular/assets/output.css", From ae72fc7920c9890b9cfd1abee35588a76fac21e1 Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Tue, 28 May 2024 12:41:03 +0200 Subject: [PATCH 03/10] feat: object details in page header can be styled (#261) * feat: object details for page header can be styled * feat: object detail styles test --- .../page-header/page-header.component.html | 2 +- .../page-header/page-header.component.spec.ts | 19 +++++++++++++++++++ .../page-header.component.stories.ts | 6 ++++++ .../page-header/page-header.component.ts | 8 ++++++++ .../testing/page-header.harness.ts | 4 ++++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.html b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.html index 0ccefa05..5adad452 100644 --- a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.html +++ b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.html @@ -91,7 +91,7 @@

{{ subheader }}

diff --git a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.spec.ts b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.spec.ts index 8abc869e..25595fe6 100644 --- a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.spec.ts +++ b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.spec.ts @@ -214,6 +214,25 @@ describe('PageHeaderComponent', () => { expect(await fourthDetail?.getIcon()).toBeUndefined() }) + it('should use styles to render objectDetails in the page header', async () => { + const objectDetailsWithIcons: ObjectDetailItem[] = [ + { + label: 'Venue', + value: 'AIE Munich', + valueCssClass: 'bg-green-400 text-white', + }, + ] + expect((await pageHeaderHarness.getObjectInfos()).length).toEqual(0) + + component.objectDetails = objectDetailsWithIcons + + expect((await pageHeaderHarness.getObjectInfos()).length).toEqual(1) + const firstDetail = await pageHeaderHarness.getObjectInfoByLabel('Venue') + const firstDetailStyles = await firstDetail?.getValueStyles() + expect(firstDetailStyles?.includes('bg-green-400')).toBeTruthy() + expect(firstDetailStyles?.includes('text-white')).toBeTruthy() + }) + it('should show overflow actions when menu overflow button clicked', async () => { component.actions = mockActions diff --git a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.stories.ts b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.stories.ts index d5a91c90..c600fb8e 100644 --- a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.stories.ts +++ b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.stories.ts @@ -323,6 +323,12 @@ const objectDetailsWithIcons: ObjectDetailItem[] = [ { label: 'I have no value', }, + { + label: 'Status with style', + value: 'Completed', + icon: PrimeIcons.CHECK_SQUARE, + valueCssClass: 'bg-green-400 text-white border-round-sm p-1', + }, ] export const WithObjectDetailsAndIcons = { diff --git a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.ts b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.ts index 7682cf51..d5e4e27d 100644 --- a/libs/angular-accelerator/src/lib/components/page-header/page-header.component.ts +++ b/libs/angular-accelerator/src/lib/components/page-header/page-header.component.ts @@ -51,6 +51,7 @@ export interface ObjectDetailItem { labelPipe?: Type valuePipe?: Type valuePipeArgs?: string + valueCssClass?: string } export interface HomeItem { @@ -172,6 +173,13 @@ export class PageHeaderComponent implements OnInit, OnChanges { } } + public generateItemStyle(item: ObjectDetailItem): string { + let style = '' + if (item.icon) style = style.concat(style, ' ', 'gap-1 align-items-center') + if (item.valueCssClass) style = style.concat(style, ' ', item.valueCssClass) + return style + } + /** * Generates a list of actions that should be rendered in an overflow menu */ diff --git a/libs/angular-accelerator/testing/page-header.harness.ts b/libs/angular-accelerator/testing/page-header.harness.ts index 9938bb51..5926eac1 100644 --- a/libs/angular-accelerator/testing/page-header.harness.ts +++ b/libs/angular-accelerator/testing/page-header.harness.ts @@ -98,6 +98,10 @@ class ObjectDetailItemHarness extends ComponentHarness { return (await this.getValueElement())?.text() } + async getValueStyles() { + return (await this.getValueElement())?.getAttribute('class') + } + async getIcon() { return (await this.getIconElement())?.getAttribute('class') } From c15aad3394ccbd698cb33016b2d48152dec3a707 Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Tue, 28 May 2024 12:51:47 +0200 Subject: [PATCH 04/10] feat: CUSTOM column type for data table (#262) --- .../data-table/data-table.component.html | 15 +++++++++++++++ .../components/data-table/data-table.component.ts | 8 +++++++- .../components/data-view/data-view.component.html | 9 +++++++++ .../components/data-view/data-view.component.ts | 6 ++++++ .../interactive-data-view.component.html | 1 + .../interactive-data-view.component.ts | 6 +++++- .../src/lib/model/column-type.model.ts | 1 + 7 files changed, 44 insertions(+), 2 deletions(-) diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html index 7c2099c1..bf607440 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html @@ -196,6 +196,18 @@ + + + + + + {{ rowObject[column.id] | date: 'medium' }} diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts index 8882cf31..afaea53b 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.ts @@ -125,6 +125,12 @@ export class DataTableComponent extends DataSortBase implements OnInit { return this.numberCellTemplate || this.numberCellChildTemplate } + @Input() customCellTemplate: TemplateRef | undefined + @ContentChild('customCell') customCellChildTemplate: TemplateRef | undefined + get _customCell(): TemplateRef | undefined { + return this.customCellTemplate || this.customCellChildTemplate + } + @Input() dateCellTemplate: TemplateRef | undefined @ContentChild('dateCell') dateCellChildTemplate: TemplateRef | undefined get _dateCell(): TemplateRef | undefined { @@ -341,6 +347,6 @@ export class DataTableComponent extends DataSortBase implements OnInit { } fieldIsTruthy(object: any, key: any) { - return !!(ObjectUtils.resolveFieldData(object, key)) + return !!ObjectUtils.resolveFieldData(object, key) } } diff --git a/libs/angular-accelerator/src/lib/components/data-view/data-view.component.html b/libs/angular-accelerator/src/lib/components/data-view/data-view.component.html index 62deac92..f1f3ae1f 100644 --- a/libs/angular-accelerator/src/lib/components/data-view/data-view.component.html +++ b/libs/angular-accelerator/src/lib/components/data-view/data-view.component.html @@ -96,6 +96,7 @@ [additionalActions]="additionalActions" [stringCellTemplate]="_stringTableCell ? stringCell : undefined" [numberCellTemplate]="_numberTableCell ? numberCell : undefined" + [customCellTemplate]="_customTableCell ? customCell : undefined" [dateCellTemplate]="_tableDateCell ? dateCell : undefined" [relativeDateCellTemplate]="_tableRelativeDateCell ? relativeDateCell : undefined" [cellTemplate]="_tableCell ? cell : undefined" @@ -123,6 +124,14 @@ > + + + | undefined + @ContentChild('customTableCell') customTableCellChildTemplate: TemplateRef | undefined + get _customTableCell(): TemplateRef | undefined { + return this.customTableCellTemplate || this.customTableCellChildTemplate + } + @Input() tableDateCellTemplate: TemplateRef | undefined @ContentChild('tableDateCell') tableDateCellChildTemplate: TemplateRef | undefined get _tableDateCell(): TemplateRef | undefined { diff --git a/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html b/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html index f4972c4d..d4002d95 100644 --- a/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html +++ b/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.html @@ -78,6 +78,7 @@ [actionColumnPosition]="actionColumnPosition" [stringTableCellTemplate]="_stringTableCell ? stringTableCell : undefined" [numberTableCellTemplate]="_numberTableCell ? numberTableCell : undefined" + [customTableCellTemplate]="_customTableCell ? customTableCell : undefined" [tableDateCellTemplate]="_tableDateCell ? tableDateCell : undefined" [tableRelativeDateCellTemplate]="_tableRelativeDateCell ? tableRelativeDateCell : undefined" [tableCellTemplate]="_tableCell ? tableCell : undefined" diff --git a/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.ts b/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.ts index 6197c85f..c87b6787 100644 --- a/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.ts +++ b/libs/angular-accelerator/src/lib/components/interactive-data-view/interactive-data-view.component.ts @@ -77,10 +77,11 @@ export class InteractiveDataViewComponent implements OnInit { @ContentChild('listItemSubtitleLines') listItemSubtitleLines: TemplateRef | undefined @ContentChild('stringTableCell') stringTableCell: TemplateRef | undefined @ContentChild('numberTableCell') numberTableCell: TemplateRef | undefined + @ContentChild('customTableCell') customTableCell: TemplateRef | undefined @ContentChild('gridItem') gridItem: TemplateRef | undefined @ContentChild('listItem') listItem: TemplateRef | undefined @ContentChild('topCenter') topCenter: TemplateRef | undefined - + @Output() filtered = new EventEmitter() @Output() sorted = new EventEmitter() @Output() deleteItem = new EventEmitter() @@ -121,6 +122,9 @@ export class InteractiveDataViewComponent implements OnInit { get _numberTableCell(): TemplateRef | undefined { return this.numberTableCell } + get _customTableCell(): TemplateRef | undefined { + return this.customTableCell + } get _tableDateCell(): TemplateRef | undefined { return this.tableDateCell } diff --git a/libs/angular-accelerator/src/lib/model/column-type.model.ts b/libs/angular-accelerator/src/lib/model/column-type.model.ts index 4181cbda..5a4ad746 100644 --- a/libs/angular-accelerator/src/lib/model/column-type.model.ts +++ b/libs/angular-accelerator/src/lib/model/column-type.model.ts @@ -4,4 +4,5 @@ export enum ColumnType { DATE = 'DATE', RELATIVE_DATE = 'RELATIVE_DATE', TRANSLATION_KEY = 'TRANSLATION_KEY', + CUSTOM = 'CUSTOM', } From 45b183e71cc0bde5ca6afd640b4371fdd377d3f7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 28 May 2024 11:45:57 +0000 Subject: [PATCH 05/10] chore(release): -v4.27.0 [skip ci] ## [4.27.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.26.0...v4.27.0) (2024-05-28) ### Features * CUSTOM column type for data table ([#262](https://github.com/onecx/onecx-portal-ui-libs/issues/262)) ([c15aad3](https://github.com/onecx/onecx-portal-ui-libs/commit/c15aad3394ccbd698cb33016b2d48152dec3a707)) * object details in page header can be styled ([#261](https://github.com/onecx/onecx-portal-ui-libs/issues/261)) ([ae72fc7](https://github.com/onecx/onecx-portal-ui-libs/commit/ae72fc7920c9890b9cfd1abee35588a76fac21e1)) --- CHANGELOG.md | 8 ++++++++ libs/accelerator/package.json | 2 +- libs/angular-accelerator/package.json | 2 +- libs/angular-auth/package.json | 2 +- libs/angular-integration-interface/package.json | 2 +- libs/angular-remote-components/package.json | 2 +- libs/angular-testing/package.json | 2 +- libs/integration-interface/package.json | 2 +- libs/keycloak-auth/package.json | 2 +- libs/portal-integration-angular/package.json | 2 +- libs/portal-layout-styles/package.json | 2 +- libs/shell-core/package.json | 2 +- package.json | 2 +- 13 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f30b46b6..7dc803c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [4.27.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.26.0...v4.27.0) (2024-05-28) + + +### Features + +* CUSTOM column type for data table ([#262](https://github.com/onecx/onecx-portal-ui-libs/issues/262)) ([c15aad3](https://github.com/onecx/onecx-portal-ui-libs/commit/c15aad3394ccbd698cb33016b2d48152dec3a707)) +* object details in page header can be styled ([#261](https://github.com/onecx/onecx-portal-ui-libs/issues/261)) ([ae72fc7](https://github.com/onecx/onecx-portal-ui-libs/commit/ae72fc7920c9890b9cfd1abee35588a76fac21e1)) + ## [4.26.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.25.1...v4.26.0) (2024-05-27) diff --git a/libs/accelerator/package.json b/libs/accelerator/package.json index 2e49c2c7..41d6ca63 100644 --- a/libs/accelerator/package.json +++ b/libs/accelerator/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/accelerator", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "tslib": "^2.3.0", "rxjs": "7.8.1" diff --git a/libs/angular-accelerator/package.json b/libs/angular-accelerator/package.json index 6cca5518..8ae7bf0b 100644 --- a/libs/angular-accelerator/package.json +++ b/libs/angular-accelerator/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-accelerator", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-auth/package.json b/libs/angular-auth/package.json index 859944b5..86e766c0 100644 --- a/libs/angular-auth/package.json +++ b/libs/angular-auth/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-auth", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-integration-interface/package.json b/libs/angular-integration-interface/package.json index 53414212..7b8b4943 100644 --- a/libs/angular-integration-interface/package.json +++ b/libs/angular-integration-interface/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-integration-interface", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", "@onecx/integration-interface": "~4", diff --git a/libs/angular-remote-components/package.json b/libs/angular-remote-components/package.json index 52f25fc4..1a616fba 100644 --- a/libs/angular-remote-components/package.json +++ b/libs/angular-remote-components/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-remote-components", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-testing/package.json b/libs/angular-testing/package.json index 7717fe61..238c95f7 100644 --- a/libs/angular-testing/package.json +++ b/libs/angular-testing/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-testing", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/cdk": "^15.2.7 || ^16.0.0 || ^17.0.0", "primeng": "^15.0.0 || ^16.0.0 || ^17.0.0" diff --git a/libs/integration-interface/package.json b/libs/integration-interface/package.json index 5e956522..1f2828d8 100644 --- a/libs/integration-interface/package.json +++ b/libs/integration-interface/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/integration-interface", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "tslib": "^2.3.0", "rxjs": "7.8.1", diff --git a/libs/keycloak-auth/package.json b/libs/keycloak-auth/package.json index 317f0496..2ef3a343 100644 --- a/libs/keycloak-auth/package.json +++ b/libs/keycloak-auth/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/keycloak-auth", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/portal-integration-angular/package.json b/libs/portal-integration-angular/package.json index 0ae38bd5..22159464 100644 --- a/libs/portal-integration-angular/package.json +++ b/libs/portal-integration-angular/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/portal-integration-angular", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/portal-layout-styles/package.json b/libs/portal-layout-styles/package.json index ed052d80..9f5b8c3f 100644 --- a/libs/portal-layout-styles/package.json +++ b/libs/portal-layout-styles/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/portal-layout-styles", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "tslib": "^2.5.0" }, diff --git a/libs/shell-core/package.json b/libs/shell-core/package.json index 60eeba68..0deac3e9 100644 --- a/libs/shell-core/package.json +++ b/libs/shell-core/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/shell-core", - "version": "4.26.0", + "version": "4.27.0", "peerDependencies": { "rxjs": "7.8.1", "@angular/animations": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/package.json b/package.json index 84b8ace7..908190c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/onecx-portal-ui-libs", - "version": "4.26.0", + "version": "4.27.0", "license": "Apache-2.0", "scripts": { "sass": "npx sass libs/portal-integration-angular/assets/styles.scss libs/portal-integration-angular/assets/output.css", From 4e717090a122cac12c3b1b33ad9dd56eee52b4cf Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Wed, 29 May 2024 11:07:26 +0200 Subject: [PATCH 06/10] fix: paginator All option displayed only for one element (#263) --- .../data-table/data-table.component.html | 5 +--- .../data-table/data-table.component.spec.ts | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html index bf607440..4bedd4b1 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.html @@ -89,15 +89,12 @@ [rows]="pageSize" [showCurrentPageReport]="true" currentPageReportTemplate="{{ (totalRecordsOnServer ? currentPageShowingWithTotalOnServerKey : currentPageShowingKey) | translate:params }}" - [rowsPerPageOptions]="[10, 25, 50, rows?.length]" + [rowsPerPageOptions]="[10, 25, 50, { showAll: ('OCX_DATA_TABLE.ALL' | translate)}]" id="dataTable_{{name}}" (selectionChange)="onSelectionChange($event)" [selection]="(selectedRows$ | async) || []" [scrollable]="true" > - - {{ item.value === rows?.length ? ("OCX_DATA_TABLE.ALL" | translate) : item.value }} - diff --git a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts index 0f6c6a65..4be80c68 100644 --- a/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts +++ b/libs/angular-accelerator/src/lib/components/data-table/data-table.component.spec.ts @@ -279,7 +279,7 @@ describe('DataTableComponent', () => { const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness) const paginator = await dataTable.getPaginator() const rowsPerPageOptions = await paginator.getRowsPerPageOptions() - const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(3) + const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0) expect(rowsPerPageOptionsText).toEqual('Alle') }) @@ -289,11 +289,33 @@ describe('DataTableComponent', () => { const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness) const paginator = await dataTable.getPaginator() const rowsPerPageOptions = await paginator.getRowsPerPageOptions() - const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(3) + const rowsPerPageOptionsText = await rowsPerPageOptions.selectedDropdownItemText(0) expect(rowsPerPageOptionsText).toEqual('All') }) }) + it('should display 10 rows by default for 1000 rows', async () => { + component.rows = Array.from(Array(1000).keys()).map((number) => { + return { + id: number, + name: number, + } + }) + component.columns = [ + { + columnType: ColumnType.NUMBER, + id: 'name', + nameKey: 'COLUMN_HEADER_NAME.NAME', + }, + ] + component.paginator = true + fixture.detectChanges() + + const dataTable = await TestbedHarnessEnvironment.harnessForFixture(fixture, DataTableHarness) + const rows = await dataTable.getRows() + expect(rows.length).toBe(10) + }) + describe('Table row selection', () => { it('should initially show a table without selection checkboxes', async () => { expect(dataTable).toBeTruthy() From 22b8bcf89f07e6940d15110214efa39f16ed0c3b Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:20:40 +0200 Subject: [PATCH 07/10] feat: topic message id for message ordering (#265) * feat: topics now use message ids * feat: topic next message tests * fix: lint * refactor: tests and topic adjusted --- libs/accelerator/src/lib/topic/message.ts | 10 ++ .../src/lib/topic/topic-message.ts | 16 +-- libs/accelerator/src/lib/topic/topic.spec.ts | 128 ++++++++++++++++++ libs/accelerator/src/lib/topic/topic.ts | 26 +++- 4 files changed, 165 insertions(+), 15 deletions(-) diff --git a/libs/accelerator/src/lib/topic/message.ts b/libs/accelerator/src/lib/topic/message.ts index 6e1756e4..63e488d1 100644 --- a/libs/accelerator/src/lib/topic/message.ts +++ b/libs/accelerator/src/lib/topic/message.ts @@ -1,7 +1,17 @@ +declare global { + interface Window { + onecxMessageId: number + } +} + +window['onecxMessageId'] = 0 + export class Message { timestamp: number + id: number // id can be undefined while used via old implementation constructor(public type: string) { this.timestamp = window.performance.now() + this.id = window['onecxMessageId']++ } } diff --git a/libs/accelerator/src/lib/topic/topic-message.ts b/libs/accelerator/src/lib/topic/topic-message.ts index 33496277..1cb87734 100644 --- a/libs/accelerator/src/lib/topic/topic-message.ts +++ b/libs/accelerator/src/lib/topic/topic-message.ts @@ -1,12 +1,8 @@ -import { Message } from "./message"; -import { TopicMessageType } from "./topic-message-type"; +import { Message } from './message' +import { TopicMessageType } from './topic-message-type' export class TopicMessage extends Message { - constructor( - type: TopicMessageType, - public name: string, - public version: number - ) { - super(type); - } - } \ No newline at end of file + constructor(type: TopicMessageType, public name: string, public version: number) { + super(type) + } +} diff --git a/libs/accelerator/src/lib/topic/topic.spec.ts b/libs/accelerator/src/lib/topic/topic.spec.ts index 4c89a887..b6c006ea 100644 --- a/libs/accelerator/src/lib/topic/topic.spec.ts +++ b/libs/accelerator/src/lib/topic/topic.spec.ts @@ -8,6 +8,8 @@ import { map } from 'rxjs' import { Topic } from './topic' +import { TopicMessageType } from './topic-message-type' +import { TopicDataMessage } from './topic-data-message' describe('Topic', () => { const origAddEventListener = window.addEventListener @@ -155,4 +157,130 @@ describe('Topic', () => { done() }) }) + + describe('integration with older versions of library', () => { + let previousMessage: TopicDataMessage + let incomingMessage: MessageEvent> + + beforeEach(() => { + previousMessage = { + type: TopicMessageType.TopicNext, + name: testTopic1.name, + version: testTopic1.version, + data: '', + timestamp: 0, + id: 0, + } + incomingMessage = { + data: { + type: TopicMessageType.TopicNext, + name: testTopic1.name, + version: testTopic1.version, + data: '', + timestamp: 0, + id: 0, + }, + } as any + + // initialize topic + testTopic1.publish('initMsg') + }) + + it('should have value if incoming id is greater than previous id', () => { + previousMessage.data = 'msg1' + previousMessage.id = 0 + incomingMessage.data.data = 'msg2' + incomingMessage.data.id = 1 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1', 'msg2']) + }) + + it('should have value if incoming timestamp is greater than previous timestamp with no ids provided', () => { + previousMessage.data = 'msg1' + ;(previousMessage).id = undefined + previousMessage.timestamp = 1 + incomingMessage.data.data = 'msg2' + ;(incomingMessage.data).id = undefined + incomingMessage.data.timestamp = 3 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1', 'msg2']) + }) + + it('should have value if incoming timestamp is greater than previous timestamp when current message has id', () => { + previousMessage.data = 'msg1' + previousMessage.id = 1 + previousMessage.timestamp = 1 + incomingMessage.data.data = 'msg2' + ;(incomingMessage.data).id = undefined + incomingMessage.data.timestamp = 3 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1', 'msg2']) + }) + + it('should have value if incoming timestamp is greater than previous timestamp when incoming message has id', () => { + previousMessage.data = 'msg1' + ;(previousMessage).id = undefined + previousMessage.timestamp = 1 + incomingMessage.data.data = 'msg2' + incomingMessage.data.id = 1 + incomingMessage.data.timestamp = 3 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1', 'msg2']) + }) + + it('should have no value if incoming timestamp is equal to the previous timestamp with no ids provided', () => { + previousMessage.data = 'msg1' + ;(previousMessage).id = undefined + previousMessage.timestamp = 3 + incomingMessage.data.data = 'msg2' + ;(incomingMessage.data).id = undefined + incomingMessage.data.timestamp = 3 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1']) + }) + + it('should have no value if incoming timestamp is equal to the previous timestamp when current message has id', () => { + jest.spyOn(console, 'warn') + previousMessage.data = 'msg1' + previousMessage.id = 1 + previousMessage.timestamp = 3 + incomingMessage.data.data = 'msg2' + ;(incomingMessage.data).id = undefined + incomingMessage.data.timestamp = 3 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1']) + expect(console.warn).toHaveBeenLastCalledWith( + 'Message was dropped because of equal timestamps, because there was an old style message in the system. Please upgrade all libraries to the latest version.' + ) + }) + + it('should have no value if incoming timestamp is equal to previous timestamp when incoming message has id', () => { + jest.spyOn(console, 'warn') + previousMessage.data = 'msg1' + ;(previousMessage).id = undefined + previousMessage.timestamp = 3 + incomingMessage.data.data = 'msg2' + incomingMessage.data.id = 1 + incomingMessage.data.timestamp = 3 + ;(testTopic1).data.next(previousMessage) + ;(testTopic1).onMessage(incomingMessage) + + expect(values1).toEqual(['initMsg', 'msg1']) + expect(console.warn).toHaveBeenLastCalledWith( + 'Message was dropped because of equal timestamps, because there was an old style message in the system. Please upgrade all libraries to the latest version.' + ) + }) + }) }) diff --git a/libs/accelerator/src/lib/topic/topic.ts b/libs/accelerator/src/lib/topic/topic.ts index d958a421..e5aa5822 100644 --- a/libs/accelerator/src/lib/topic/topic.ts +++ b/libs/accelerator/src/lib/topic/topic.ts @@ -23,7 +23,7 @@ export class Topic extends TopicPublisher implements Subscribable { constructor(name: string, version: number, sendGetMessage = true) { super(name, version) - + this.isInitializedPromise = new Promise((resolve) => { this.resolveInitPromise = resolve }) @@ -34,7 +34,7 @@ export class Topic extends TopicPublisher implements Subscribable { window.postMessage(message, '*') } } - + get isInitialized(): Promise { return this.isInitializedPromise } @@ -145,10 +145,17 @@ export class Topic extends TopicPublisher implements Subscribable { private onMessage(m: MessageEvent): any { switch (m.data.type) { case TopicMessageType.TopicNext: + if (m.data.name !== this.name || m.data.version !== this.version) { + break + } + if ( - m.data.name === this.name && - m.data.version === this.version && - (!this.data.value || (this.isInit && (m.data).timestamp > this.data.value.timestamp)) + !this.data.value || + (this.isInit && + (m.data).id !== undefined && + this.data.value.id !== undefined && + (m.data).id > this.data.value.id) || + (this.isInit && (m.data).timestamp > this.data.value.timestamp) ) { this.isInit = true this.data.next(>m.data) @@ -158,6 +165,15 @@ export class Topic extends TopicPublisher implements Subscribable { publishPromiseResolver() delete this.publishPromiseResolver[m.data.timestamp] } + } else if ( + this.data.value && + this.isInit && + (m.data).timestamp === this.data.value.timestamp && + ((m.data).id || this.data.value.id) + ) { + console.warn( + 'Message was dropped because of equal timestamps, because there was an old style message in the system. Please upgrade all libraries to the latest version.' + ) } break case TopicMessageType.TopicGet: From 1075efb08299946fbcf68eccb0555782d9e41d84 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 3 Jun 2024 12:32:30 +0000 Subject: [PATCH 08/10] chore(release): -v4.28.0 [skip ci] ## [4.28.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.27.0...v4.28.0) (2024-06-03) ### Features * topic message id for message ordering ([#265](https://github.com/onecx/onecx-portal-ui-libs/issues/265)) ([22b8bcf](https://github.com/onecx/onecx-portal-ui-libs/commit/22b8bcf89f07e6940d15110214efa39f16ed0c3b)) ### Bug Fixes * paginator All option displayed only for one element ([#263](https://github.com/onecx/onecx-portal-ui-libs/issues/263)) ([4e71709](https://github.com/onecx/onecx-portal-ui-libs/commit/4e717090a122cac12c3b1b33ad9dd56eee52b4cf)) --- CHANGELOG.md | 12 ++++++++++++ libs/accelerator/package.json | 2 +- libs/angular-accelerator/package.json | 2 +- libs/angular-auth/package.json | 2 +- libs/angular-integration-interface/package.json | 2 +- libs/angular-remote-components/package.json | 2 +- libs/angular-testing/package.json | 2 +- libs/integration-interface/package.json | 2 +- libs/keycloak-auth/package.json | 2 +- libs/portal-integration-angular/package.json | 2 +- libs/portal-layout-styles/package.json | 2 +- libs/shell-core/package.json | 2 +- package.json | 2 +- 13 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dc803c1..22585149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [4.28.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.27.0...v4.28.0) (2024-06-03) + + +### Features + +* topic message id for message ordering ([#265](https://github.com/onecx/onecx-portal-ui-libs/issues/265)) ([22b8bcf](https://github.com/onecx/onecx-portal-ui-libs/commit/22b8bcf89f07e6940d15110214efa39f16ed0c3b)) + + +### Bug Fixes + +* paginator All option displayed only for one element ([#263](https://github.com/onecx/onecx-portal-ui-libs/issues/263)) ([4e71709](https://github.com/onecx/onecx-portal-ui-libs/commit/4e717090a122cac12c3b1b33ad9dd56eee52b4cf)) + ## [4.27.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.26.0...v4.27.0) (2024-05-28) diff --git a/libs/accelerator/package.json b/libs/accelerator/package.json index 41d6ca63..398ab31f 100644 --- a/libs/accelerator/package.json +++ b/libs/accelerator/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/accelerator", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "tslib": "^2.3.0", "rxjs": "7.8.1" diff --git a/libs/angular-accelerator/package.json b/libs/angular-accelerator/package.json index 8ae7bf0b..f4445549 100644 --- a/libs/angular-accelerator/package.json +++ b/libs/angular-accelerator/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-accelerator", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-auth/package.json b/libs/angular-auth/package.json index 86e766c0..cd742fce 100644 --- a/libs/angular-auth/package.json +++ b/libs/angular-auth/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-auth", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-integration-interface/package.json b/libs/angular-integration-interface/package.json index 7b8b4943..f07eaee8 100644 --- a/libs/angular-integration-interface/package.json +++ b/libs/angular-integration-interface/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-integration-interface", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", "@onecx/integration-interface": "~4", diff --git a/libs/angular-remote-components/package.json b/libs/angular-remote-components/package.json index 1a616fba..700b8c13 100644 --- a/libs/angular-remote-components/package.json +++ b/libs/angular-remote-components/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-remote-components", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/angular-testing/package.json b/libs/angular-testing/package.json index 238c95f7..29414ba9 100644 --- a/libs/angular-testing/package.json +++ b/libs/angular-testing/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/angular-testing", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/cdk": "^15.2.7 || ^16.0.0 || ^17.0.0", "primeng": "^15.0.0 || ^16.0.0 || ^17.0.0" diff --git a/libs/integration-interface/package.json b/libs/integration-interface/package.json index 1f2828d8..7414be12 100644 --- a/libs/integration-interface/package.json +++ b/libs/integration-interface/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/integration-interface", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "tslib": "^2.3.0", "rxjs": "7.8.1", diff --git a/libs/keycloak-auth/package.json b/libs/keycloak-auth/package.json index 2ef3a343..b91f8c0c 100644 --- a/libs/keycloak-auth/package.json +++ b/libs/keycloak-auth/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/keycloak-auth", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/portal-integration-angular/package.json b/libs/portal-integration-angular/package.json index 22159464..edf1f8ea 100644 --- a/libs/portal-integration-angular/package.json +++ b/libs/portal-integration-angular/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/portal-integration-angular", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "@angular/common": "^15.2.7 || ^16.0.0 || ^17.0.0", "@angular/core": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/libs/portal-layout-styles/package.json b/libs/portal-layout-styles/package.json index 9f5b8c3f..749225e0 100644 --- a/libs/portal-layout-styles/package.json +++ b/libs/portal-layout-styles/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/portal-layout-styles", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "tslib": "^2.5.0" }, diff --git a/libs/shell-core/package.json b/libs/shell-core/package.json index 0deac3e9..cd4bfea0 100644 --- a/libs/shell-core/package.json +++ b/libs/shell-core/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/shell-core", - "version": "4.27.0", + "version": "4.28.0", "peerDependencies": { "rxjs": "7.8.1", "@angular/animations": "^15.2.7 || ^16.0.0 || ^17.0.0", diff --git a/package.json b/package.json index 908190c6..116f77c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onecx/onecx-portal-ui-libs", - "version": "4.27.0", + "version": "4.28.0", "license": "Apache-2.0", "scripts": { "sass": "npx sass libs/portal-integration-angular/assets/styles.scss libs/portal-integration-angular/assets/output.css", From 13635a18e545136b475a550c2a88baa2b29492ed Mon Sep 17 00:00:00 2001 From: Annika Nowak <139357202+anninowak@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:03:49 +0200 Subject: [PATCH 09/10] feat: renaming of the slots (#266) --- .../portal-footer/portal-footer.component.html | 10 ++++++++-- .../components/portal-header/header.component.html | 12 ++++++------ .../portal-viewport/portal-viewport.component.html | 10 +++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libs/shell-core/src/lib/components/portal-footer/portal-footer.component.html b/libs/shell-core/src/lib/components/portal-footer/portal-footer.component.html index 7f5ea926..95b79ab8 100644 --- a/libs/shell-core/src/lib/components/portal-footer/portal-footer.component.html +++ b/libs/shell-core/src/lib/components/portal-footer/portal-footer.component.html @@ -1,8 +1,14 @@
- logo + logo
© {{copyrightMsg$ | async}}
- +
{{versionInfo$ | async}}
diff --git a/libs/shell-core/src/lib/components/portal-header/header.component.html b/libs/shell-core/src/lib/components/portal-header/header.component.html index 7147a918..4093a656 100644 --- a/libs/shell-core/src/lib/components/portal-header/header.component.html +++ b/libs/shell-core/src/lib/components/portal-header/header.component.html @@ -49,12 +49,12 @@
- - -
- -
-
+ + +
+ +
+
    diff --git a/libs/shell-core/src/lib/components/portal-viewport/portal-viewport.component.html b/libs/shell-core/src/lib/components/portal-viewport/portal-viewport.component.html index 1bd753e9..7aa9e0b6 100644 --- a/libs/shell-core/src/lib/components/portal-viewport/portal-viewport.component.html +++ b/libs/shell-core/src/lib/components/portal-viewport/portal-viewport.component.html @@ -11,13 +11,13 @@ >
    - +
    -
    +
    @@ -26,9 +26,9 @@