reduce duplication and code improvements (#1707)

* reduce code duplication

* reduce duplication, fix license headers

* simplify code

* typings fixes

* update tests

* minor fixes

* markdown fixes

* revert changes
This commit is contained in:
Denys Vuika
2020-12-11 15:47:17 +00:00
committed by GitHub
parent b71e1530d1
commit 7a5350a06d
64 changed files with 482 additions and 744 deletions

View File

@@ -657,40 +657,39 @@ This external plugin disables the initial `exif:exif` aspect already defined in
Here is the initial setting from `app.extension.json`:
```json
...
"content-metadata-presets": [
{
"id": "app.content.metadata.custom",
"custom": [
{
"id": "app.content.metadata.customGroup",
"title": "APP.CONTENT_METADATA.EXIF_GROUP_TITLE",
"items": [
{
"id": "app.content.metadata.exifAspect",
"aspect": "exif:exif",
"properties": [
"exif:pixelXDimension",
"exif:pixelYDimension",
"exif:dateTimeOriginal",
"exif:exposureTime",
"exif:fNumber",
"exif:flash",
"exif:focalLength",
"exif:isoSpeedRatings",
"exif:orientation",
"exif:manufacturer",
"exif:model",
"exif:software"
]
}
]
}
]
}
]
...
{
"content-metadata-presets": [
{
"id": "app.content.metadata.custom",
"custom": [
{
"id": "app.content.metadata.customGroup",
"title": "APP.CONTENT_METADATA.EXIF_GROUP_TITLE",
"items": [
{
"id": "app.content.metadata.exifAspect",
"aspect": "exif:exif",
"properties": [
"exif:pixelXDimension",
"exif:pixelYDimension",
"exif:dateTimeOriginal",
"exif:exposureTime",
"exif:fNumber",
"exif:flash",
"exif:focalLength",
"exif:isoSpeedRatings",
"exif:orientation",
"exif:manufacturer",
"exif:model",
"exif:software"
]
}
]
}
]
}
]
}
```
**Tip:** In order to allow the content-metadata presets to be extended, the settings from `app.config.json` must be copied to the `app.extensions.json` file and its ids must be added to all the items.

View File

@@ -52,19 +52,15 @@ This registering can be done, using Angular's multi-provider capabilities:
import { EXTENSION_DATA_LOADERS } from '@alfresco/aca-shared';
@NgModule({
imports: [...],
declarations: [...],
providers: [
...
{
provide: EXTENSION_DATA_LOADERS,
multi: true,
useValue: myExtensionLoader
},
...
],
}
]
})
export class MyExtensionModule {
export class MyExtensionModule {}
```
1. `MyExtensionModule` is the extension's entry module, which needs to be imported by the extensions.module.ts.

View File

@@ -296,13 +296,11 @@ exposed by the application with a custom one coming with the plugin.
"create": [
{
"id": "app.create.folder",
"disabled": true,
...
"disabled": true
},
{
"id": "plugin1.create.folder",
"title": "Create Folder",
...
"title": "Create Folder"
}
]
}

View File

@@ -103,8 +103,6 @@ Update the root `package.json` file and append the following entry to the `scrip
```json
{
"scripts": {
...,
"build:my-extension":
"ng build my-extension && cpr projects/my-extension/assets dist/my-extension/assets --deleteFirst"
}
@@ -113,7 +111,7 @@ Update the root `package.json` file and append the following entry to the `scrip
You can now use that script to build the library and copy assets to the output folder.
**Tip:** It is good practice to provide installation instructions for your library in the `README.md` file.
**Tip:** It is good practice providing installation instructions for your library in the `README.md` file.
Be sure to mention that developers should have a build rule to copy your plugin definition file to the `assets/plugins` folder of the main application.
## Publishing library to NPM
@@ -174,13 +172,10 @@ Use the following rule if you are installing an extension from NPM:
In the main application, edit the `src/app/extensions.module.ts` file and append the module declaration as in the next example:
```typescript
...
import { MyExtensionModule } from 'my-extension';
@NgModule({
...
imports: [
...,
MyExtensionModule
]
})
@@ -194,7 +189,6 @@ Finally, update the `src/assets/app.extensions.json` file and add a reference to
```json
{
"$references": [
...,
"my-extension.json"
]
}

View File

@@ -17,7 +17,7 @@ and use the following snippet to register custom content:
import { ExtensionsModule, ExtensionService } from '@alfresco/adf-extensions';
@NgModule({
imports: [ ExtensionsModule ]
imports: [ ExtensionsModule ],
declarations: [ MyComponent1, MyLayout ]
})
export class MyExtensionModule {

View File

@@ -91,16 +91,18 @@ Extensions may register a routes that are children of some existing application
Imagine the situation when application has the following route structure:
```ts
{
path: 'files,
component: FilesComponent,
children: [
{
path: 'bin',
component: BinComponent,
},
],
}
export const APP_ROUTES: Routes = [
{
path: 'files',
component: FilesComponent,
children: [
{
path: 'bin',
component: BinComponent,
},
],
}
]
```
Within the extension, you can declare a route like:
@@ -113,7 +115,7 @@ Within the extension, you can declare a route like:
"parentRoute": "files",
"path": "my-path",
"layout": "app.layout.main",
"component": "your.component.id",
"component": "your.component.id"
}
]
}

View File

@@ -192,15 +192,11 @@ import { ShowMydDialogAction, SHOW_MY_DIALOG } from '../actions/app.actions';
@Injectable()
export class AppEffects {
constructor(...) {}
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {})
);
// ...
}
```
@@ -216,10 +212,7 @@ import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my
@Injectable()
export class AppEffects {
constructor(
...,
private dialog: MatDialog
) {}
constructor(private dialog: MatDialog) {}
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
@@ -228,9 +221,6 @@ export class AppEffects {
this.dialog.open(MyExtensionDialogComponent)
})
);
...
}
```
@@ -240,8 +230,6 @@ Update the `src/assets/app.extensions.json` file, and insert a new entry to the
```json
{
...,
"features": {
"toolbar": [
{
@@ -280,35 +268,35 @@ We need to add the custom route with our entry component and its child route for
```json
{
...
"routes": [{
"id": "start-process",
"path": "start-process",
"parentRoute": "",
"layout": "app.layout.main",
// The component we register to be our entry point for this particular route
"component": "myplugin.components.start-process",
"children": [
"routes": [
{
"id": "start-process",
"path": "start-process",
"parentRoute": "",
"layout": "app.layout.main",
// The component we register to be our entry point for this particular route
"component": "myplugin.components.start-process",
"children": [
{
"id": "start-process-preview",
// It can be accessed on the "/start-process(viewer:preview/nodeId)" route
"path": "preview/:nodeId",
"component": "app.components.preview",
"data": {
// Using history.back() when closing the preview
"navigateBackAsClose": true,
// Disabling complex action and buttons for the preview
"simplestMode": true
},
// We would like to target that named router outlet which is used for the viewer overlay
"outlet": "viewer"
"id": "start-process-preview",
// It can be accessed on the "/start-process(viewer:preview/nodeId)" route
"path": "preview/:nodeId",
"component": "app.components.preview",
"data": {
// Using history.back() when closing the preview
"navigateBackAsClose": true,
// Disabling complex action and buttons for the preview
"simplestMode": true
},
// We would like to target that named router outlet which is used for the viewer overlay
"outlet": "viewer"
}
]
}]
...
]
}
]
}
```
##### Dispatching the right action within our component to open the file preview
```ts
@@ -316,8 +304,6 @@ import { PluginPreviewAction } from '@alfresco/aca-shared/store';
@Component({...})
export class StartProcessComponent {
...
onFilePreview({ nodeId }) {
this.store.dispatch(new PluginPreviewAction('start-process-cloud', nodeId));
}