ACS-7680: cleanup About components (#9848)

This commit is contained in:
Denys Vuika 2024-06-21 10:03:42 -04:00 committed by GitHub
parent cef413f7c8
commit 3fee18c251
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 29 additions and 391 deletions

View File

@ -1,14 +0,0 @@
<div class="adf-github-link-container">
<header data-automation-id="adf-github-source-code-title">{{ 'ABOUT.SOURCE_CODE.TITLE' | translate }}</header>
<mat-card class="mat-elevation-z0">
<h3 data-automation-id="adf-github-app-title">{{application}}</h3>
<p *ngIf="version" data-automation-id="adf-github-version">{{ 'ABOUT.VERSION' | translate }}: {{ version }}</p>
<div *ngIf="url">
<small>{{ 'ABOUT.SOURCE_CODE.DESCRIPTION' | translate }}</small>
<div data-automation-id="adf-github-url">
<a [href]="url" target="_blank">{{url}}</a>
</div>
</div>
</mat-card>
</div>

View File

@ -1,3 +0,0 @@
.adf-github-link-container {
padding: 10px;
}

View File

@ -1,71 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { AboutGithubLinkComponent } from './about-github-link.component';
import { aboutGithubDetails } from '../about.mock';
describe('AboutGithubLinkComponent', () => {
let fixture: ComponentFixture<AboutGithubLinkComponent>;
let component: AboutGithubLinkComponent;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule]
});
fixture = TestBed.createComponent(AboutGithubLinkComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
afterEach(() => {
fixture.destroy();
});
it('Should fetch appName for app.config and display as title', async () => {
component.application = 'mock-application-name';
fixture.detectChanges();
await fixture.whenStable();
const titleElement = fixture.nativeElement.querySelector('[data-automation-id="adf-github-app-title"]');
expect(titleElement === null).toBeFalsy();
expect(titleElement.innerText).toEqual('mock-application-name');
});
it('should display version', async () => {
component.version = aboutGithubDetails.version;
fixture.detectChanges();
await fixture.whenStable();
const version = fixture.nativeElement.querySelector('[data-automation-id="adf-github-version"]');
expect(version.innerText).toEqual('ABOUT.VERSION: 0.0.7');
});
it('should display adf github link as default if url is not specified', async () => {
fixture.detectChanges();
await fixture.whenStable();
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
expect(githubUrl.innerText).toEqual(aboutGithubDetails.defaultUrl);
});
it('should display the github link', async () => {
component.url = aboutGithubDetails.url;
fixture.detectChanges();
await fixture.whenStable();
const githubUrl = fixture.nativeElement.querySelector('[data-automation-id="adf-github-url"]');
expect(githubUrl.innerText).toEqual(aboutGithubDetails.url);
});
});

View File

@ -1,44 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Input, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { MatCardModule } from '@angular/material/card';
@Component({
selector: 'adf-about-github-link',
templateUrl: './about-github-link.component.html',
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [CommonModule, TranslateModule, MatCardModule]
})
export class AboutGithubLinkComponent {
/** Commit corresponding to the version of ADF to be used. */
@Input()
url = 'https://github.com/Alfresco/alfresco-ng2-components/commits/';
/** Current version of the app running */
@Input()
version: string = '';
/** Title of app running */
@Input()
application: string = '';
constructor() {}
}

View File

@ -1,45 +0,0 @@
<ng-container *ngIf="process">
<article>
<div>{{ 'ABOUT.VERSIONS.PROCESS_SERVICE' | translate }}</div>
<p>
{{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ process.majorVersion }}.{{process.minorVersion }}.{{ process.revisionVersion }}
</p>
</article>
</ng-container>
<ng-container *ngIf="repository">
<article>
<div>{{ 'ABOUT.VERSIONS.CONTENT_SERVICE' | translate }}</div>
<p>{{ 'ABOUT.VERSIONS.LABELS.EDITION' | translate }}: {{ repository.edition }}</p>
<p>{{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ repository.version.display }}</p>
</article>
</ng-container>
<ng-container *ngIf="modeling$ | async as modeling">
<article>
<div>{{ 'ABOUT.VERSIONS.MODELING_SERVICE' | translate }}</div>
<p>{{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ modeling.version }}</p>
</article>
</ng-container>
<ng-container *ngIf="deployment$| async as deployment">
<article>
<div>{{ 'ABOUT.VERSIONS.DEPLOYMENT_SERVICE' | translate }}</div>
<p>{{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ deployment.version }}</p>
</article>
</ng-container>
<ng-container *ngIf="rb$ | async as rb">
<article>
<div>{{ 'ABOUT.VERSIONS.RB' | translate }}</div>
<p>{{ 'ABOUT.VERSIONS.LABELS.EDITION' | translate }}: {{ rb.artifact }}</p>
<p>{{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ rb.version }}</p>
</article>
</ng-container>
<ng-container *ngIf="query$ | async as query">
<article>
<div>{{ 'ABOUT.VERSIONS.QUERY_SERVICE' | translate }}</div>
<p>{{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ query.version }}</p>
</article>
</ng-container>

View File

@ -1,78 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Input, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs';
import { BpmProductVersionModel } from '../../models/product-version.model';
import { AaeInfoService, ActivitiDependencyInfo } from '../services/aae-info.service';
import { AppConfigService } from '../../app-config/app-config.service';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
interface VersionInfo {
display: string;
}
interface RepositoryInfo {
edition: string;
version: VersionInfo;
}
@Component({
selector: 'adf-about-platform-version',
templateUrl: './about-platform-version.component.html',
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [CommonModule, TranslateModule]
})
export class AboutPlatformVersionComponent {
/** repository info. */
@Input()
repository: RepositoryInfo = null;
/** process info. */
@Input()
process: BpmProductVersionModel = null;
modeling$: Observable<ActivitiDependencyInfo>;
deployment$: Observable<ActivitiDependencyInfo>;
rb$: Observable<ActivitiDependencyInfo>;
query$: Observable<ActivitiDependencyInfo>;
constructor(private aaeInfoService: AaeInfoService, private appConfigService: AppConfigService) {
this.modelingInfo();
this.deploymentInfo();
this.rbInfo();
}
modelingInfo() {
this.modeling$ = this.aaeInfoService.getServiceVersion('modeling-service');
}
deploymentInfo() {
this.deployment$ = this.aaeInfoService.getServiceVersion('deployment-service');
}
rbInfo() {
this.rb$ = this.aaeInfoService.getServiceVersion(`${this.appConfigService.get('oauth2.clientId')}/rb`);
}
queryInfo() {
this.query$ = this.aaeInfoService.getServiceVersion(`${this.appConfigService.get('oauth2.clientId')}/query`);
}
}

View File

@ -19,7 +19,15 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { AboutServerSettingsComponent } from './about-server-settings.component';
import { AppConfigService } from '../../app-config/app-config.service';
import { aboutGithubDetails } from '../about.mock';
const aboutGithubDetails = {
url: 'https://github.com/componany/repository/commits/',
defaultUrl: 'https://github.com/Alfresco/alfresco-ng2-components/commits/',
version: '0.0.7',
ecmHost: 'https://mock.ecmhost.com',
bpmHost: 'https://mock.bpmhost.com',
appName: 'mock-application-name'
};
describe('AboutServerSettingsComponent', () => {
let fixture: ComponentFixture<AboutServerSettingsComponent>;

View File

@ -17,7 +17,7 @@
import { Meta, moduleMetadata, Story } from '@storybook/angular';
import { AboutComponent } from './about.component';
import { AboutModule } from './about.module';
import { ABOUT_DIRECTIVES } from './about.module';
import { AuthenticationService } from '../auth/services/authentication.service';
import { AuthenticationMock } from '../auth/mock/authentication.service.mock';
import { AppExtensionService, ExtensionRef, ViewerExtensionRef } from '@alfresco/adf-extensions';
@ -48,7 +48,7 @@ export default {
title: 'Core/About/About',
decorators: [
moduleMetadata({
imports: [CoreStoryModule, AboutModule],
imports: [CoreStoryModule, ...ABOUT_DIRECTIVES],
providers: [
{ provide: AuthenticationService, useClass: AuthenticationMock },
{ provide: AppExtensionService, useClass: AppExtensionServiceMock },

View File

@ -1,25 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const aboutGithubDetails = {
url: 'https://github.com/componany/repository/commits/',
defaultUrl: 'https://github.com/Alfresco/alfresco-ng2-components/commits/',
version: '0.0.7',
ecmHost: 'https://mock.ecmhost.com',
bpmHost: 'https://mock.bpmhost.com',
appName: 'mock-application-name'
};

View File

@ -16,44 +16,31 @@
*/
import { NgModule } from '@angular/core';
import { AboutGithubLinkComponent } from './about-github-link/about-github-link.component';
import { AboutServerSettingsComponent } from './about-server-settings/about-server-settings.component';
import { AboutExtensionListComponent } from './about-extension-list/about-extension-list.component';
import { AboutLicenseListComponent } from './about-license-list/about-license-list.component';
import { PackageListComponent } from './about-package/package-list.component';
import { AboutStatusListComponent } from './about-status-list/about-status-list.component';
import { ModuleListComponent } from './about-module-list/module-list.component';
import { AboutPlatformVersionComponent } from './about-platform-version/about-platform-version.component';
import { AboutComponent } from './about.component';
import { AboutPanelDirective } from './about-panel.directive';
import { AboutRepositoryInfoComponent } from './about-repository-info/about-repository-info.component';
export const ABOUT_DIRECTIVES = [
AboutExtensionListComponent,
AboutLicenseListComponent,
ModuleListComponent,
AboutRepositoryInfoComponent,
PackageListComponent,
AboutStatusListComponent,
AboutServerSettingsComponent,
AboutPanelDirective,
AboutComponent
] as const;
/** @deprecated import `ABOUT_DIRECTIVES` or standalone components instead */
@NgModule({
imports: [
AboutExtensionListComponent,
AboutGithubLinkComponent,
AboutLicenseListComponent,
ModuleListComponent,
AboutRepositoryInfoComponent,
AboutPlatformVersionComponent,
PackageListComponent,
AboutStatusListComponent,
AboutServerSettingsComponent,
AboutPanelDirective,
AboutComponent
],
exports: [
AboutComponent,
AboutPanelDirective,
AboutRepositoryInfoComponent,
AboutPlatformVersionComponent,
AboutGithubLinkComponent,
AboutServerSettingsComponent,
AboutExtensionListComponent,
AboutLicenseListComponent,
PackageListComponent,
AboutStatusListComponent,
ModuleListComponent
]
imports: [...ABOUT_DIRECTIVES],
exports: [...ABOUT_DIRECTIVES]
})
export class AboutModule {}

View File

@ -16,11 +16,9 @@
*/
export * from './about-extension-list/about-extension-list.component';
export * from './about-github-link/about-github-link.component';
export * from './about-license-list/about-license-list.component';
export * from './about-module-list/module-list.component';
export * from './about-package/package-list.component';
export * from './about-platform-version/about-platform-version.component';
export * from './about-server-settings/about-server-settings.component';
export * from './about-status-list/about-status-list.component';
export * from './about.component';

View File

@ -1,55 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { AppConfigService } from '../../app-config/app-config.service';
export interface ActivitiDependencyInfo {
artifact: string;
version: string;
activiti: string;
}
@Injectable({
providedIn: 'root'
})
export class AaeInfoService {
contextRoot = '';
constructor(protected httpClient: HttpClient, protected appConfigService: AppConfigService) {
this.contextRoot = appConfigService.get('bpmHost', '');
}
getServiceVersion(serviceName: string): Observable<ActivitiDependencyInfo> {
return this.httpClient.get<any>(`${this.contextRoot}/${serviceName}/actuator/info`).pipe(
map((response: any) => {
let activitiVersion = 'N/A';
if (response.build.activiti) {
activitiVersion = response.build.activiti.version;
}
return {
artifact: response.build.artifact,
version: response.build.version,
activiti: activitiVersion
};
})
);
}
}

View File

@ -21,7 +21,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TranslateModule, TranslateLoader, TranslateStore, TranslateService } from '@ngx-translate/core';
import { MaterialModule } from './material.module';
import { AboutModule } from './about/about.module';
import { ABOUT_DIRECTIVES } from './about/about.module';
import { CardViewModule } from './card-view/card-view.module';
import { ContextMenuModule } from './context-menu/context-menu.module';
import { DataTableModule } from './datatable/datatable.module';
@ -73,7 +73,7 @@ import { DynamicChipListModule } from './dynamic-chip-list';
imports: [
TranslateModule,
ExtensionsModule,
AboutModule,
...ABOUT_DIRECTIVES,
ViewerModule,
SidenavLayoutModule,
PipeModule,
@ -111,7 +111,7 @@ import { DynamicChipListModule } from './dynamic-chip-list';
})
],
exports: [
AboutModule,
...ABOUT_DIRECTIVES,
ViewerModule,
SidenavLayoutModule,
PipeModule,

View File

@ -515,26 +515,6 @@
"PROCESS_SERVICE_HOST": "Alfresco Process Services URL: {{ value }}"
},
"REPOSITORY": "Repository",
"VERSIONS": {
"TITLE": "Product Versions",
"CONTENT_SERVICE": "Content Services",
"PROCESS_SERVICE": "Process Services",
"MODELING_SERVICE": "Modeling Services",
"DEPLOYMENT_SERVICE": "Deployment Services",
"QUERY_SERVICE": "Deployment Services",
"RB": "Runtime",
"LABELS": {
"EDITION": "Edition",
"VERSION": "Version",
"LICENSE": "License",
"STATUS": "Status",
"MODULES": "Modules"
}
},
"SOURCE_CODE": {
"TITLE": "Source code",
"DESCRIPTION": "You are running the project based on the following commit:"
},
"PACKAGES": {
"TITLE": "Packages",
"NAME": "Name",