Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: prepare release #687

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@ the detailed section referring to by linking pull requests or issues.

#### Minor

- Broker UI: Added query params for the connector endpoints filter

#### Patch

#### Deployment Migration Notes

## [v2.5.0] - 2024-02-28

### Overview

Enable better integration of Broker UI and Authority Portal

### Detailed Changes

#### Minor

- Broker UI: Added query params for the connector endpoints filter

#### Deployment Migration Notes

_No special deployment migration steps required_

## [v2.4.0] 2024-02-14

### Overview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '../../../../component-library/catalog/view-selection/view-mode-enum';
import {BrokerServerApiService} from '../../../../core/services/api/broker-server-api.service';
import {FilterBoxItem} from '../filter-box/filter-box-item';
import {FilterBoxModel} from '../filter-box/filter-box-model';
import {FilterBoxVisibleState} from '../filter-box/filter-box-visible-state';
import {CatalogActiveFilterPill} from '../state/catalog-active-filter-pill';
import {CatalogPage} from '../state/catalog-page-actions';
Expand Down Expand Up @@ -57,13 +56,25 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
) {}

ngOnInit(): void {
this.store.dispatch(CatalogPage.Reset);
this.setConnectorEndpointFiltersFromQueryParamsOnce();
this.initializePage();
this.startListeningToStore();
this.startEmittingSearchText();
this.startEmittingSortBy();
}

private initializePage() {
const endpoints = this.parseConnectorEndpoints(
this.route.snapshot.queryParams,
);
this.store.dispatch(new CatalogPage.Reset(endpoints));

if (endpoints.length) {
this.expandedFilterId = 'connectorEndpoint';
// remove query params from url
this.router.navigate([]);
}
}

private startListeningToStore() {
this.store
.select<CatalogPageStateModel>(CatalogPageState)
Expand Down Expand Up @@ -103,24 +114,6 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
});
}

private setConnectorEndpointFiltersFromQueryParamsOnce() {
const connectorEndpoints = this.parseConnectorEndpoints(
this.route.snapshot.queryParams,
);
if (!connectorEndpoints?.length) {
return;
}

this.store.dispatch(
new CatalogPage.AddFilterBox(
this.buildConnectorEndpointFilterBoxModel(connectorEndpoints),
),
);
this.expandedFilterId = 'connectorEndpoint';
// remove query params from url
this.router.navigate([]);
}

private parseConnectorEndpoints(params: Params): string[] {
if (!('connectorEndpoint' in params)) {
return [];
Expand All @@ -129,23 +122,6 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
return Array.isArray(endpoints) ? [...new Set(endpoints)] : [endpoints];
}

private buildConnectorEndpointFilterBoxModel(
endpoints: string[],
): FilterBoxModel {
const items: FilterBoxItem[] = endpoints.map((x) => ({
type: 'ITEM',
id: x,
label: x,
}));
return {
id: 'connectorEndpoint',
title: 'Connector',
selectedItems: items,
availableItems: items,
searchText: '',
};
}

onDataOfferClick(dataOffer: CatalogDataOfferMapped) {
const data =
this.assetDetailDialogDataService.brokerDataOfferDetails(dataOffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export namespace CatalogPage {

export class Reset {
static readonly type = `[${tag}] Reset`;

constructor(public initialConnectorEndpoints?: string[]) {}
}

export class NeedFetch {
Expand Down
62 changes: 42 additions & 20 deletions src/app/routes/broker-ui/catalog-page/state/catalog-page-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ export class CatalogPageState implements OnDestroy {
}

@Action(CatalogPage.Reset)
onReset(ctx: Ctx) {
onReset(ctx: Ctx, action: CatalogPage.Reset) {
let state = ctx.getState();
state.fetchSubscription?.unsubscribe();
state = DEFAULT_CATALOG_PAGE_STATE_MODEL;
if (action.initialConnectorEndpoints?.length) {
state = this._addFilterBoxes(state, [
this._buildConnectorEndpointFilterBoxModel(
action.initialConnectorEndpoints,
),
]);
}
ctx.setState(state);
ctx.dispatch(CatalogPage.NeedFetch);
}
Expand Down Expand Up @@ -102,25 +109,6 @@ export class CatalogPageState implements OnDestroy {
ctx.dispatch(CatalogPage.NeedFetch);
}

@Action(CatalogPage.AddFilterBox)
onAddFilterBox(ctx: Ctx, action: CatalogPage.AddFilterBox) {
const state = ctx.getState();
if (action.filterBox.id in state.filters) {
return;
}
ctx.setState(
this._recalculateActiveFilterItems({
...state,
filters: {
...state.filters,
[action.filterBox.id]: FilterBoxVisibleState.buildVisibleState(
action.filterBox,
),
},
}),
);
}

@Action(CatalogPage.UpdateFilterSelectedItems)
onUpdateFilterSelectedItems(
ctx: Ctx,
Expand Down Expand Up @@ -176,6 +164,40 @@ export class CatalogPageState implements OnDestroy {
}
}

private _buildConnectorEndpointFilterBoxModel(
endpoints: string[],
): FilterBoxModel {
const items: FilterBoxItem[] = endpoints.map((x) => ({
type: 'ITEM',
id: x,
label: x,
}));
return {
id: 'connectorEndpoint',
title: 'Connector',
selectedItems: items,
availableItems: items,
searchText: '',
};
}

private _addFilterBoxes(
state: CatalogPageStateModel,
filterBoxes: FilterBoxModel[],
): CatalogPageStateModel {
return this._recalculateActiveFilterItems({
...state,
filters: {
...state.filters,
...associateAsObj(
filterBoxes,
(x) => x.id,
(x) => FilterBoxVisibleState.buildVisibleState(x),
),
},
});
}

private _resetPage(state: CatalogPageStateModel): CatalogPageStateModel {
return {...state, pageZeroBased: 0, paginationDisabled: true};
}
Expand Down
Loading