unified format for viewer sub-menus (#901)

* unified format for viewer sub-menus

* fix tests

* update prettier
This commit is contained in:
Denys Vuika 2019-01-20 11:13:55 +00:00 committed by GitHub
parent d2e0f688e8
commit da3527b0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 976 additions and 947 deletions

View File

@ -30,7 +30,6 @@ All the customizations are stored in the `features` section of the configuration
"contextMenu": [], "contextMenu": [],
"viewer": { "viewer": {
"toolbarActions:": [], "toolbarActions:": [],
"toolbarMoreMenu:": [],
"openWith": [], "openWith": [],
"content": [] "content": []
}, },
@ -243,7 +242,7 @@ on how to register your own entries to be re-used at runtime.
### Tab properties ### Tab properties
| Name | Description | | Name | Description |
| ------------- | ----------------------------------------------------------- | | ------------- | ----------------------------------------------------------------- |
| **id** | Unique identifier. | | **id** | Unique identifier. |
| **component** | The main [component](/extending/components) to use for the route. | | **component** | The main [component](/extending/components) to use for the route. |
| **title** | Tab title or resource key. | | **title** | Tab title or resource key. |
@ -378,7 +377,6 @@ Viewer component in ACA supports the following extension points:
"viewer": { "viewer": {
"content": [], "content": [],
"toolbarActions:": [], "toolbarActions:": [],
"toolbarMoreMenu:": [],
"openWith": [] "openWith": []
} }
} }
@ -451,15 +449,13 @@ New viewer toolbar actions can also be added from the extensions config:
"visible": "app.toolbar.versions" "visible": "app.toolbar.versions"
} }
} }
], ]
"toolbarMoreMenu": [...]
} }
} }
} }
``` ```
The ADF Viewer component allows you to provide custom entries for the `More` menu button on the toolbar. You can also provide sub-menus:
The ACA provides an extension point for this menu that you can utilize to populate custom menu items:
```json ```json
{ {
@ -469,8 +465,14 @@ The ACA provides an extension point for this menu that you can utilize to popula
"features": { "features": {
"viewer": { "viewer": {
"toolbarActions": [...], "toolbarActions": [
"toolbarMoreMenu": [ {
"id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.share", "id": "app.viewer.share",
"order": 300, "order": 300,
@ -485,6 +487,8 @@ The ACA provides an extension point for this menu that you can utilize to popula
} }
] ]
} }
]
}
} }
} }
``` ```
@ -547,16 +551,19 @@ In order to modify or disable existing entries, you need to know the id of the
</p> </p>
Your extensions can perform the following actions at runtime: Your extensions can perform the following actions at runtime:
* Add new presets items.
* Add new items to existing presets at any level. - Add new presets items.
* Disable specific items down to the aspect level. - Add new items to existing presets at any level.
* Modify any existing item based on id. - Disable specific items down to the aspect level.
- Modify any existing item based on id.
Regarding properties, you can either: Regarding properties, you can either:
* Add new properties to existing aspect, or
* Redefine the properties of an aspect. - Add new properties to existing aspect, or
- Redefine the properties of an aspect.
Review this code snippet to see how you can overwrite the properties for `exif:exif` aspect from an external plugin: Review this code snippet to see how you can overwrite the properties for `exif:exif` aspect from an external plugin:
```json ```json
{ {
"$schema": "../../../extension.schema.json", "$schema": "../../../extension.schema.json",
@ -593,8 +600,10 @@ Review this code snippet to see how you can overwrite the properties for `exif:e
} }
} }
``` ```
This external plugin disables the initial `exif:exif` aspect already defined in the `app.extensions.json` and defines other properties for the `exif:exif` aspect. This external plugin disables the initial `exif:exif` aspect already defined in the `app.extensions.json` and defines other properties for the `exif:exif` aspect.
Here is the initial setting from `app.extension.json`: Here is the initial setting from `app.extension.json`:
```json ```json
... ...
"content-metadata-presets": [ "content-metadata-presets": [
@ -631,6 +640,7 @@ Here is the initial setting from `app.extension.json`:
... ...
``` ```
<p class="tip"> <p class="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. 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.
Having ids allows external plugins to extend the current setting. Having ids allows external plugins to extend the current setting.

View File

@ -759,9 +759,14 @@
"rules": { "rules": {
"visible": "app.toolbar.canViewFile" "visible": "app.toolbar.canViewFile"
} }
} },
], {
"toolbarMoreMenu": [ "id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -865,6 +870,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {

View File

@ -692,9 +692,14 @@
"rules": { "rules": {
"visible": "app.toolbar.canViewFile" "visible": "app.toolbar.canViewFile"
} }
} },
], {
"toolbarMoreMenu": [ "id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -798,6 +803,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {

View File

@ -674,9 +674,14 @@
"rules": { "rules": {
"visible": "app.toolbar.canViewFile" "visible": "app.toolbar.canViewFile"
} }
} },
], {
"toolbarMoreMenu": [ "id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -783,6 +788,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {

View File

@ -710,9 +710,14 @@
"rules": { "rules": {
"visible": "app.toolbar.canViewFile" "visible": "app.toolbar.canViewFile"
} }
} },
], {
"toolbarMoreMenu": [ "id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -819,6 +824,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {

View File

@ -709,9 +709,14 @@
"rules": { "rules": {
"visible": "app.toolbar.canViewFile" "visible": "app.toolbar.canViewFile"
} }
} },
], {
"toolbarMoreMenu": [ "id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -818,6 +823,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {

View File

@ -689,9 +689,14 @@
"rules": { "rules": {
"visible": "app.toolbar.canViewFile" "visible": "app.toolbar.canViewFile"
} }
} },
], {
"toolbarMoreMenu": [ "id": "app.toolbar.more",
"type": "menu",
"order": 10000,
"icon": "more_vert",
"title": "APP.ACTIONS.MORE",
"children": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -811,6 +816,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {

View File

@ -674,12 +674,6 @@
"items": { "$ref": "#/definitions/contentActionRef" }, "items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1 "minItems": 1
}, },
"toolbarMoreMenu": {
"description": "Toolbar entries from the More actions menu",
"type": "array",
"items": { "$ref": "#/definitions/contentActionRef" },
"minItems": 1
},
"toolbarActions": { "toolbarActions": {
"description": "Toolbar entries from outside the More menu", "description": "Toolbar entries from outside the More menu",
"type": "array", "type": "array",

51
package-lock.json generated
View File

@ -3100,6 +3100,7 @@
"resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
"integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"kind-of": "^3.0.2", "kind-of": "^3.0.2",
"longest": "^1.0.1", "longest": "^1.0.1",
@ -6443,7 +6444,8 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -6467,13 +6469,15 @@
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -6490,19 +6494,22 @@
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -6633,7 +6640,8 @@
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -6647,6 +6655,7 @@
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -6663,6 +6672,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -6671,13 +6681,15 @@
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -6698,6 +6710,7 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -6786,7 +6799,8 @@
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -6800,6 +6814,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -6895,7 +6910,8 @@
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -6937,6 +6953,7 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -6958,6 +6975,7 @@
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -7006,13 +7024,15 @@
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
"dev": true "dev": true,
"optional": true
} }
} }
}, },
@ -10366,7 +10386,8 @@
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
"integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=",
"dev": true "dev": true,
"optional": true
}, },
"loose-envify": { "loose-envify": {
"version": "1.4.0", "version": "1.4.0",
@ -12665,9 +12686,9 @@
"dev": true "dev": true
}, },
"prettier": { "prettier": {
"version": "1.15.3", "version": "1.16.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.3.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.0.tgz",
"integrity": "sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==", "integrity": "sha512-MCBCYeAuZfejUPdEpkleLWvpRBwLii/Sp5jQs0eb8Ul/drGIDjkL6tAU24tk6yCGf0KPV5rhPPPlczfBmN2pWQ==",
"dev": true "dev": true
}, },
"pretty-format": { "pretty-format": {

View File

@ -20,7 +20,7 @@
"e2e:docker": "npm run start:docker && npm run e2e && npm run stop:docker", "e2e:docker": "npm run start:docker && npm run e2e && npm run stop:docker",
"spellcheck": "cspell 'src/**/*.ts' 'e2e/**/*.ts' 'projects/**/*.ts'", "spellcheck": "cspell 'src/**/*.ts' 'e2e/**/*.ts' 'projects/**/*.ts'",
"inspect.bundle": "ng build app --prod --stats-json && npx webpack-bundle-analyzer dist/app/stats.json", "inspect.bundle": "ng build app --prod --stats-json && npx webpack-bundle-analyzer dist/app/stats.json",
"format:check": "prettier --list-different \"src/{app,environments}/**/*.{ts,js,css,scss,html}\"", "format:check": "prettier --check \"src/{app,environments}/**/*.{ts,js,css,scss,html}\"",
"format:fix": "prettier --write \"src/{app,environments}/**/*.{ts,js,css,scss,html}\"", "format:fix": "prettier --write \"src/{app,environments}/**/*.{ts,js,css,scss,html}\"",
"build.tomcat": "npm run build -- --base-href ./ && jar -cvf docker/tomcat/artifacts/content-app.war -C dist/app/ .", "build.tomcat": "npm run build -- --base-href ./ && jar -cvf docker/tomcat/artifacts/content-app.war -C dist/app/ .",
"build.tomcat.e2e": "./build-tomcat-e2e.sh", "build.tomcat.e2e": "./build-tomcat-e2e.sh",
@ -93,7 +93,7 @@
"lint-staged": "^8.1.0", "lint-staged": "^8.1.0",
"ng-packagr": "^4.4.0", "ng-packagr": "^4.4.0",
"pre-commit": "^1.2.2", "pre-commit": "^1.2.2",
"prettier": "^1.15.3", "prettier": "^1.16.0",
"protractor": "^5.4.0", "protractor": "^5.4.0",
"rimraf": "2.6.2", "rimraf": "2.6.2",
"rxjs-tslint-rules": "^4.11.0", "rxjs-tslint-rules": "^4.11.0",

View File

@ -59,7 +59,6 @@ export abstract class PageComponent implements OnInit, OnDestroy {
sharedPreviewUrl$: Observable<string>; sharedPreviewUrl$: Observable<string>;
actions: Array<ContentActionRef> = []; actions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = []; viewerToolbarActions: Array<ContentActionRef> = [];
viewerToolbarMoreActions: Array<ContentActionRef> = [];
canUpdateNode = false; canUpdateNode = false;
canUpload = false; canUpload = false;
@ -101,7 +100,6 @@ export abstract class PageComponent implements OnInit, OnDestroy {
this.selection = selection; this.selection = selection;
this.actions = this.extensions.getAllowedToolbarActions(); this.actions = this.extensions.getAllowedToolbarActions();
this.viewerToolbarActions = this.extensions.getViewerToolbarActions(); this.viewerToolbarActions = this.extensions.getViewerToolbarActions();
this.viewerToolbarMoreActions = this.extensions.getViewerToolbarMoreActions();
this.canUpdateNode = this.canUpdateNode =
this.selection.count === 1 && this.selection.count === 1 &&
this.content.canUpdateNode(selection.first); this.content.canUpdateNode(selection.first);

View File

@ -32,17 +32,6 @@
</ng-container> </ng-container>
</adf-viewer-toolbar-actions> </adf-viewer-toolbar-actions>
<adf-viewer-more-actions *ngIf="viewerToolbarMoreActions.length">
<ng-container
*ngFor="
let action of viewerToolbarMoreActions;
trackBy: trackByActionId
"
>
<app-toolbar-menu-item [actionRef]="action"></app-toolbar-menu-item>
</ng-container>
</adf-viewer-more-actions>
<ng-container *ngFor="let ext of contentExtensions"> <ng-container *ngFor="let ext of contentExtensions">
<adf-viewer-extension [supportedExtensions]="[ext.fileExtension]"> <adf-viewer-extension [supportedExtensions]="[ext.fileExtension]">
<ng-template let-url="urlFileContent" let-extension="extension"> <ng-template let-url="urlFileContent" let-extension="extension">

View File

@ -3,22 +3,16 @@
height: 100%; height: 100%;
} }
.hide-last-divider .adf-viewer-toolbar .mat-toolbar { .adf-viewer-toolbar .adf-toolbar-divider {
> adf-toolbar-divider:last-of-type {
display: none; display: none;
} }
> button:last-of-type {
right: 40px;
}
}
#adf-viewer-moreactions {
right: -40px;
}
.adf-viewer-toolbar-actions { .adf-viewer-toolbar-actions {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
.adf-toolbar-divider {
display: inline;
}
} }

View File

@ -586,7 +586,7 @@ describe('AppExtensionService', () => {
}); });
it('should filter out all disabled items', () => { it('should filter out all disabled items', () => {
const items = [ const items: any[] = [
{ id: '1', disabled: true }, { id: '1', disabled: true },
{ {
id: '2', id: '2',

View File

@ -71,7 +71,6 @@ export class AppExtensionService implements RuleContext {
headerActions: Array<ContentActionRef> = []; headerActions: Array<ContentActionRef> = [];
toolbarActions: Array<ContentActionRef> = []; toolbarActions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = []; viewerToolbarActions: Array<ContentActionRef> = [];
viewerToolbarMoreActions: Array<ContentActionRef> = [];
viewerContentExtensions: Array<ViewerExtensionRef> = []; viewerContentExtensions: Array<ViewerExtensionRef> = [];
contextMenuActions: Array<ContentActionRef> = []; contextMenuActions: Array<ContentActionRef> = [];
openWithActions: Array<ContentActionRef> = []; openWithActions: Array<ContentActionRef> = [];
@ -148,10 +147,6 @@ export class AppExtensionService implements RuleContext {
config, config,
'features.viewer.toolbarActions' 'features.viewer.toolbarActions'
); );
this.viewerToolbarMoreActions = this.loader.getContentActions(
config,
'features.viewer.toolbarMoreMenu'
);
this.viewerContentExtensions = this.loader.getElements<ViewerExtensionRef>( this.viewerContentExtensions = this.loader.getElements<ViewerExtensionRef>(
config, config,
'features.viewer.content' 'features.viewer.content'
@ -295,7 +290,7 @@ export class AppExtensionService implements RuleContext {
return { presets }; return { presets };
} }
filterDisabled(object) { filterDisabled(object: Array<{ disabled: boolean }> | { disabled: boolean }) {
if (Array.isArray(object)) { if (Array.isArray(object)) {
return object return object
.filter(item => !item.disabled) .filter(item => !item.disabled)
@ -398,45 +393,8 @@ export class AppExtensionService implements RuleContext {
return actionRef; return actionRef;
} }
// evaluates content actions for the selection and parent folder node private getAllowedActions(actions: ContentActionRef[]): ContentActionRef[] {
getAllowedToolbarActions(): Array<ContentActionRef> { return (actions || [])
return this.toolbarActions
.filter(action => this.filterByRules(action))
.map(action => {
if (action.type === ContentActionType.menu) {
const copy = this.copyAction(action);
if (copy.children && copy.children.length > 0) {
copy.children = copy.children
.filter(childAction => this.filterByRules(childAction))
.sort(sortByOrder)
.reduce(reduceSeparators, []);
}
return copy;
}
return action;
})
.reduce(reduceEmptyMenus, [])
.reduce(reduceSeparators, []);
}
getViewerToolbarActions(): Array<ContentActionRef> {
return this.viewerToolbarActions.filter(action =>
this.filterByRules(action)
);
}
getHeaderActions(): Array<ContentActionRef> {
return this.headerActions.filter(action => this.filterByRules(action));
}
getViewerToolbarMoreActions(): Array<ContentActionRef> {
return this.viewerToolbarMoreActions.filter(action =>
this.filterByRules(action)
);
}
getAllowedContextMenuActions(): Array<ContentActionRef> {
return this.contextMenuActions
.filter(action => this.filterByRules(action)) .filter(action => this.filterByRules(action))
.map(action => { .map(action => {
if (action.type === ContentActionType.menu) { if (action.type === ContentActionType.menu) {
@ -456,6 +414,22 @@ export class AppExtensionService implements RuleContext {
.reduce(reduceSeparators, []); .reduce(reduceSeparators, []);
} }
getAllowedToolbarActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.toolbarActions);
}
getViewerToolbarActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.viewerToolbarActions);
}
getHeaderActions(): Array<ContentActionRef> {
return this.headerActions.filter(action => this.filterByRules(action));
}
getAllowedContextMenuActions(): Array<ContentActionRef> {
return this.getAllowedActions(this.contextMenuActions);
}
copyAction(action: ContentActionRef): ContentActionRef { copyAction(action: ContentActionRef): ContentActionRef {
return { return {
...action, ...action,

View File

@ -850,6 +850,47 @@
], ],
"viewer": { "viewer": {
"toolbarActions": [ "toolbarActions": [
{
"id": "app.viewer.fullscreen",
"order": 100,
"title": "APP.ACTIONS.FULLSCREEN",
"icon": "fullscreen",
"actions": {
"click": "FULLSCREEN_VIEWER"
},
"rules": {
"visible": "app.toolbar.canViewFile"
}
},
{
"id": "app.viewer.separator.1",
"type": "separator",
"order": 180
},
{
"id": "app.viewer.share",
"order": 200,
"title": "APP.ACTIONS.SHARE",
"icon": "link",
"actions": {
"click": "SHARE_NODE"
},
"rules": {
"visible": "app.toolbar.canShare"
}
},
{
"id": "app.viewer.share.edit",
"order": 250,
"title": "APP.ACTIONS.SHARE_EDIT",
"icon": "link",
"actions": {
"click": "SHARE_NODE"
},
"rules": {
"visible": "app.selection.file.isShared"
}
},
{ {
"id": "app.viewer.download", "id": "app.viewer.download",
"order": 300, "order": 300,
@ -875,48 +916,12 @@
} }
}, },
{ {
"id": "app.viewer.share", "id": "app.viewer.toolbar.more",
"order": 200, "type": "menu",
"title": "APP.ACTIONS.SHARE", "order": 10000,
"icon": "link", "icon": "more_vert",
"actions": { "title": "APP.ACTIONS.MORE",
"click": "SHARE_NODE" "children": [
},
"rules": {
"visible": "app.toolbar.canShare"
}
},
{
"id": "app.viewer.share.edit",
"order": 201,
"title": "APP.ACTIONS.SHARE_EDIT",
"icon": "link",
"actions": {
"click": "SHARE_NODE"
},
"rules": {
"visible": "app.selection.file.isShared"
}
},
{
"id": "app.viewer.fullscreen",
"order": 100,
"title": "APP.ACTIONS.FULLSCREEN",
"icon": "fullscreen",
"actions": {
"click": "FULLSCREEN_VIEWER"
},
"rules": {
"visible": "app.toolbar.canViewFile"
}
},
{
"id": "app.viewer.separator.1",
"type": "separator",
"order": 180
}
],
"toolbarMoreMenu": [
{ {
"id": "app.viewer.favorite.add", "id": "app.viewer.favorite.add",
"order": 100, "order": 100,
@ -1021,6 +1026,8 @@
"visible": "app.toolbar.permissions" "visible": "app.toolbar.permissions"
} }
} }
]
}
], ],
"content": [ "content": [
{ {