Skip to content

Commit

Permalink
reduce duplication and code improvements (#1707)
Browse files Browse the repository at this point in the history
* reduce code duplication

* reduce duplication, fix license headers

* simplify code

* typings fixes

* update tests

* minor fixes

* markdown fixes

* revert changes
  • Loading branch information
Denys Vuika authored Dec 11, 2020
1 parent b71e153 commit 7a5350a
Show file tree
Hide file tree
Showing 64 changed files with 482 additions and 744 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
1 change: 0 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"Redistributable",
"fullscreen",
"LGPL",
"Browserstack",
"mincount",
"QNAME",
"PNAME",
Expand Down
67 changes: 33 additions & 34 deletions docs/extending/application-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions docs/extending/custom-extension-loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions docs/extending/extension-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down
8 changes: 1 addition & 7 deletions docs/extending/redistributable-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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
Expand Down Expand Up @@ -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
]
})
Expand All @@ -194,7 +189,6 @@ Finally, update the `src/assets/app.extensions.json` file and add a reference to
```json
{
"$references": [
...,
"my-extension.json"
]
}
Expand Down
2 changes: 1 addition & 1 deletion docs/extending/registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 13 additions & 11 deletions docs/extending/routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
}
]
}
Expand Down
66 changes: 26 additions & 40 deletions docs/extending/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {})
);

// ...
}
```

Expand All @@ -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(
Expand All @@ -228,9 +221,6 @@ export class AppEffects {
this.dialog.open(MyExtensionDialogComponent)
})
);

...

}
```

Expand All @@ -240,8 +230,6 @@ Update the `src/assets/app.extensions.json` file, and insert a new entry to the

```json
{
...,

"features": {
"toolbar": [
{
Expand Down Expand Up @@ -280,44 +268,42 @@ 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
import { PluginPreviewAction } from '@alfresco/aca-shared/store';

@Component({...})
export class StartProcessComponent {
...

onFilePreview({ nodeId }) {
this.store.dispatch(new PluginPreviewAction('start-process-cloud', nodeId));
}
Expand Down
42 changes: 21 additions & 21 deletions docs/features/file-viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ export interface ViewNodeExtras {

```typescript
// app.routes.ts
...
{
path: 'custom-path',
children: [
{
path: '',
component: CustomComponent
},
{
path: 'view/:nodeId',
outlet: 'viewer',
children: [
{
path: '',
loadChildren: './components/viewer/viewer.module#AppViewerModule'
}
]
}
]
}
...
export const APP_ROUTES: Routes = [
{
path: 'custom-path',
children: [
{
path: '',
component: CustomComponent
},
{
path: 'view/:nodeId',
outlet: 'viewer',
children: [
{
path: '',
loadChildren: './components/viewer/viewer.module#AppViewerModule'
}
]
}
]
}
]
```

```typescript
Expand Down
Loading

0 comments on commit 7a5350a

Please sign in to comment.