Skip to content

Commit

Permalink
fix app title logic (#371)
Browse files Browse the repository at this point in the history
(cherry picked from commit e332338)
  • Loading branch information
illfixit authored and kamilczaja committed Dec 9, 2024
1 parent 3d883d4 commit c83afb6
Show file tree
Hide file tree
Showing 20 changed files with 193 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).
#### Patch

- Added documentation for roles and rights ([#334](https://github.com/sovity/authority-portal/issues/334))
- Fixed Website title not updating in some scenarios [#237](https://github.com/sovity/authority-portal/issues/237)

### Known issues

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
* sovity GmbH - initial implementation
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {Subject, interval} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {Store} from '@ngxs/store';
import {ConnectorOverviewEntryDto} from '@sovity.de/authority-portal-client';
import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {SlideOverService} from 'src/app/core/services/slide-over.service';
import {sliderOverNavigation} from 'src/app/core/utils/helper';
import {getConnectorsTypeClasses} from 'src/app/core/utils/ui-utils';
Expand Down Expand Up @@ -59,7 +61,13 @@ export class AuthorityConnectorListPageComponent implements OnInit, OnDestroy {
private store: Store,
private globalStateUtils: GlobalStateUtils,
private slideOverService: SlideOverService,
) {}
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS Connectors')
: this.titleService.setTitle('All Connectors');
}

ngOnInit() {
this.initializeHeaderBar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {MatDialog} from '@angular/material/dialog';
import {Title} from '@angular/platform-browser';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {Store} from '@ngxs/store';
Expand All @@ -20,6 +21,7 @@ import {
OrganizationRegistrationStatusDto,
UserRoleDto,
} from '@sovity.de/authority-portal-client';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {SlideOverService} from 'src/app/core/services/slide-over.service';
import {sliderOverNavigation} from 'src/app/core/utils/helper';
import {getOrganizationRegistrationStatusClasses} from 'src/app/core/utils/ui-utils';
Expand Down Expand Up @@ -73,7 +75,13 @@ export class AuthorityOrganizationListPageComponent
public dialog: MatDialog,
private slideOverService: SlideOverService,
private globalStateUtils: GlobalStateUtils,
) {}
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS Organizations')
: this.titleService.setTitle('Participant Management');
}

ngOnInit() {
this.initializeHeaderBar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@angular/core';
import {FormControl} from '@angular/forms';
import {PageEvent} from '@angular/material/paginator';
import {Title} from '@angular/platform-browser';
import {ActivatedRoute, Router} from '@angular/router';
import {Subject, distinctUntilChanged, of, switchMap, tap} from 'rxjs';
import {finalize, map, take, takeUntil} from 'rxjs/operators';
Expand Down Expand Up @@ -66,6 +67,8 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
// only tracked to prevent the component from resetting
expandedFilterId = '';

catalogType = this.route.snapshot.data.catalogType;

catalogSpelling = this.activeFeatureSet.usesBritishCatalogue()
? 'Catalogue'
: 'Catalog';
Expand All @@ -78,7 +81,10 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
private globalStateUtils: GlobalStateUtils,
private deploymentEnvironmentUrlSyncService: DeploymentEnvironmentUrlSyncService,
private activeFeatureSet: ActiveFeatureSet,
) {}
private titleService: Title,
) {
this.setTitle();
}

ngOnInit(): void {
this.deploymentEnvironmentUrlSyncService.updateFromUrlOnce(
Expand Down Expand Up @@ -181,6 +187,7 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
.pipe(
finalize(() => {
this.changeUrlToCatalogRoot();
this.setTitle();
}),
)
.subscribe();
Expand Down Expand Up @@ -270,4 +277,15 @@ export class CatalogPageComponent implements OnInit, OnDestroy {
headerActions: [],
};
}

private setTitle() {
let title;
this.catalogType === 'my-data-offers'
? this.titleService.setTitle('My Data Offers')
: this.titleService.setTitle(
`${this.activeFeatureSet.usesMdsId() ? 'MDS ' : ''}${
this.catalogSpelling
}`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
import {Component, HostBinding, OnDestroy, OnInit} from '@angular/core';
import {MatDialog} from '@angular/material/dialog';
import {Title} from '@angular/platform-browser';
import {Router} from '@angular/router';
import {Subject} from 'rxjs';
import {filter, takeUntil} from 'rxjs/operators';
Expand All @@ -21,6 +22,7 @@ import {
UserRoleDto,
} from '@sovity.de/authority-portal-client';
import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {HeaderBarConfig} from 'src/app/shared/common/header-bar/header-bar.model';
import {ConfirmationDialogComponent} from '../../../shared/common/confirmation-dialog/confirmation-dialog.component';
import {ConfirmationDialog} from '../../../shared/common/confirmation-dialog/confirmation-dialog.model';
Expand Down Expand Up @@ -54,7 +56,13 @@ export class CentralComponentListPageComponent implements OnInit, OnDestroy {
private globalStateUtils: GlobalStateUtils,
private router: Router,
private dialog: MatDialog,
) {}
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS Central Components')
: this.titleService.setTitle('Central Components');
}

ngOnInit() {
this.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
* sovity GmbH - initial implementation
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {ActivatedRoute} from '@angular/router';
import {Subject, takeUntil} from 'rxjs';
import {Store} from '@ngxs/store';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {Reset} from '../state/control-center-organization-member-detail-page-action';
import {
ControlCenterOrganizationMemberDetailPageState,
Expand All @@ -32,7 +34,16 @@ export class ControlCenterOrganizationMemberDetailPageComponent
state: ControlCenterOrganizationMemberDetailPageState =
DEFAULT_CONTROL_CENTER_ORGANIZATION_MEMBER_DETAIL_PAGE_STATE;

constructor(private store: Store, private activatedRoute: ActivatedRoute) {}
constructor(
private store: Store,
private activatedRoute: ActivatedRoute,
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS Member Details')
: this.titleService.setTitle('Member Details');
}

ngOnInit(): void {
this.startRefreshingOnRouteChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
* sovity GmbH - initial implementation
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {Router} from '@angular/router';
import {Subject, takeUntil} from 'rxjs';
import {Store} from '@ngxs/store';
import {MemberInfo} from '@sovity.de/authority-portal-client';
import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {BreadcrumbService} from '../../../shared/common/portal-layout/breadcrumb/breadcrumb.service';
import {Reset} from './state/control-center-organization-members-page-action';
import {
Expand All @@ -37,11 +40,19 @@ export class ControlCenterOrganizationMembersPageComponent
private store: Store,
private router: Router,
private breadcrumbService: BreadcrumbService,
) {}
private globalStateUtils: GlobalStateUtils,
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS Users and Roles')
: this.titleService.setTitle('Users and Roles');
}

ngOnInit(): void {
this.refresh();
this.startListeningToState();
this.startRefreshingOnEnvChange();
}

refresh(): void {
Expand Down Expand Up @@ -69,6 +80,15 @@ export class ControlCenterOrganizationMembersPageComponent
this.router.navigate(['control-center/users-and-roles', user.userId]);
}

startRefreshingOnEnvChange() {
this.globalStateUtils.onDeploymentEnvironmentChangeSkipFirst({
ngOnDestroy$: this.ngOnDestroy$,
onChanged: () => {
this.refresh();
},
});
}

ngOnDestroy$ = new Subject();
ngOnDestroy(): void {
this.ngOnDestroy$.next(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
* sovity GmbH - initial implementation
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {Subject, takeUntil} from 'rxjs';
import {Store} from '@ngxs/store';
import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {Reset} from '../state/control-center-organization-profile-page-action';
import {
ControlCenterOrganizationProfilePageState,
Expand All @@ -30,11 +33,21 @@ export class ControlCenterOrganizationProfilePageComponent
state: ControlCenterOrganizationProfilePageState =
DEFAULT_CONTROL_CENTER_ORGANIZATION_PROFILE_PAGE_STATE;

constructor(private store: Store) {}
constructor(
private store: Store,
private globalStateUtils: GlobalStateUtils,
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS My Organization')
: this.titleService.setTitle('My Organization');
}

ngOnInit(): void {
this.refresh();
this.startListeningToState();
this.startRefreshingOnEnvChange();
}

refresh(): void {
Expand All @@ -52,6 +65,15 @@ export class ControlCenterOrganizationProfilePageComponent
});
}

startRefreshingOnEnvChange() {
this.globalStateUtils.onDeploymentEnvironmentChangeSkipFirst({
ngOnDestroy$: this.ngOnDestroy$,
onChanged: () => {
this.refresh();
},
});
}

ngOnDestroy$ = new Subject();
ngOnDestroy(): void {
this.ngOnDestroy$.next(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
* sovity GmbH - initial implementation
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {Subject, takeUntil} from 'rxjs';
import {Store} from '@ngxs/store';
import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {Reset} from '../state/control-center-user-profile-page-action';
import {
ControlCenterUserProfilePageState,
Expand All @@ -30,11 +33,21 @@ export class ControlCenterUserProfilePageComponent
state: ControlCenterUserProfilePageState =
DEFAULT_CONTROL_CENTER_USER_PROFILE_PAGE_STATE;

constructor(private store: Store) {}
constructor(
private store: Store,
private globalStateUtils: GlobalStateUtils,
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS My Profile')
: this.titleService.setTitle('My Profile');
}

ngOnInit(): void {
this.refresh();
this.startListeningToState();
this.startRefreshingOnEnvChange();
}

refresh(): void {
Expand All @@ -52,6 +65,15 @@ export class ControlCenterUserProfilePageComponent
});
}

startRefreshingOnEnvChange() {
this.globalStateUtils.onDeploymentEnvironmentChangeSkipFirst({
ngOnDestroy$: this.ngOnDestroy$,
onChanged: () => {
this.refresh();
},
});
}

ngOnDestroy$ = new Subject();
ngOnDestroy(): void {
this.ngOnDestroy$.next(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* sovity GmbH - initial implementation
*/
import {Component, Inject, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {Subject} from 'rxjs';
import {map, switchMap, takeUntil} from 'rxjs/operators';
import {
Expand All @@ -19,6 +20,7 @@ import {
} from '@sovity.de/authority-portal-client';
import {ApiService} from 'src/app/core/api/api.service';
import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils';
import {ActiveFeatureSet} from 'src/app/core/services/config/active-feature-set';
import {APP_CONFIG, AppConfig} from 'src/app/core/services/config/app-config';
import {Fetched} from 'src/app/core/utils/fetched';
import {HeaderBarConfig} from 'src/app/shared/common/header-bar/header-bar.model';
Expand All @@ -43,7 +45,13 @@ export class DashboardPageComponent implements OnInit, OnDestroy {
@Inject(APP_CONFIG) public appConfig: AppConfig,
private globalStateUtils: GlobalStateUtils,
private apiService: ApiService,
) {}
private titleService: Title,
private activeFeatureSet: ActiveFeatureSet,
) {
this.activeFeatureSet.usesMdsId()
? this.titleService.setTitle('MDS Dashboard')
: this.titleService.setTitle('Dashboard');
}

ngOnInit(): void {
this.fetchDashboardPageData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* sovity GmbH - initial implementation
*/
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {Subject} from 'rxjs';
import {Store} from '@ngxs/store';
import {GlobalState} from 'src/app/core/global-state/global-state';
Expand All @@ -25,7 +26,9 @@ export class LoadingPageComponent implements OnInit, OnDestroy {

private ngOnDestroy$ = new Subject();

constructor(private store: Store) {}
constructor(private store: Store, private titleService: Title) {
this.titleService.setTitle('Error');
}

ngOnInit() {
this.startListeningToGlobalState();
Expand Down
Loading

0 comments on commit c83afb6

Please sign in to comment.