ACS-8251: migrate Extensions library to Standalone (#9842)

This commit is contained in:
Denys Vuika
2024-06-20 08:52:30 -04:00
committed by GitHub
parent 45e921a382
commit 9a544307d4
32 changed files with 465 additions and 572 deletions

View File

@@ -32,7 +32,8 @@ import { ExtensionService } from '../../services/extension.service';
@Component({
selector: 'adf-dynamic-column',
template: ` <ng-container #content></ng-container> `,
standalone: true,
template: `<ng-container #content></ng-container>`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'adf-dynamic-column' },

View File

@@ -26,6 +26,7 @@ import { HttpClientModule } from '@angular/common/http';
@Component({
selector: 'test-component',
standalone: true,
template: '<div data-automation-id="found-me">Hey I am the mighty test component!</div>'
})
export class TestComponent implements OnChanges {
@@ -47,8 +48,7 @@ describe('DynamicExtensionComponent', () => {
componentRegister.setComponents({ 'test-component': TestComponent });
TestBed.configureTestingModule({
imports: [HttpClientModule],
declarations: [DynamicExtensionComponent, TestComponent],
imports: [HttpClientModule, DynamicExtensionComponent, TestComponent],
providers: [{ provide: ComponentRegisterService, useValue: componentRegister }]
});

View File

@@ -22,6 +22,7 @@ import { ExtensionComponent } from '../../services/component-register.service';
// cSpell:words lifecycle
@Component({
selector: 'adf-dynamic-component',
standalone: true,
template: `<div #content></div>`
})
export class DynamicExtensionComponent implements OnChanges, OnDestroy {

View File

@@ -21,6 +21,7 @@ import { ExtensionService } from '../../services/extension.service';
@Component({
selector: 'adf-dynamic-tab',
standalone: true,
template: `<div #content></div>`
})
export class DynamicTabComponent implements OnInit, OnChanges, OnDestroy {

View File

@@ -20,7 +20,8 @@ import { ExtensionService } from '../../services/extension.service';
@Component({
selector: 'adf-preview-extension',
template: ` <div #content></div> `
standalone: true,
template: `<div #content></div>`
})
export class PreviewExtensionComponent implements OnInit, OnChanges, OnDestroy {
@ViewChild('content', { read: ViewContainerRef, static: true })

View File

@@ -23,19 +23,12 @@ import { NgModule, ModuleWithProviders, APP_INITIALIZER } from '@angular/core';
import { AppExtensionService } from './services/app-extension.service';
import { setupExtensions } from './services/startup-extension-factory';
export const EXTENSION_DIRECTIVES = [DynamicExtensionComponent, DynamicTabComponent, DynamicColumnComponent, PreviewExtensionComponent] as const;
/** @deprecated import EXTENSION_DIRECTIVES or standalone components instead */
@NgModule({
declarations: [
DynamicExtensionComponent,
DynamicTabComponent,
DynamicColumnComponent,
PreviewExtensionComponent
],
exports: [
DynamicExtensionComponent,
DynamicTabComponent,
DynamicColumnComponent,
PreviewExtensionComponent
]
imports: [...EXTENSION_DIRECTIVES],
exports: [...EXTENSION_DIRECTIVES]
})
export class ExtensionsModule {
static forRoot(): ModuleWithProviders<ExtensionsModule> {
@@ -51,10 +44,4 @@ export class ExtensionsModule {
]
};
}
static forChild(): ModuleWithProviders<ExtensionsModule> {
return {
ngModule: ExtensionsModule
};
}
}

View File

@@ -1,37 +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 { ExtensionRef } from '../config/extension.config';
import { Observable, BehaviorSubject } from 'rxjs';
import { ViewerExtensionRef } from '../config/viewer.extensions';
@Injectable({
providedIn: 'root'
})
export class AppExtensionServiceMock {
references$: Observable<ExtensionRef[]>;
private _references = new BehaviorSubject<ExtensionRef[]>([]);
constructor() {
this.references$ = this._references.asObservable();
}
getViewerExtensions(): ViewerExtensionRef[] {
return [];
}
}

View File

@@ -1,18 +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 * from './app-extension.service.mock';

View File

@@ -41,5 +41,3 @@ export * from './lib/store/states/repository.state';
export * from './lib/components/public-api';
export * from './lib/extensions.module';
export * from './lib/mock/public-api';