[ACA-3897] Extendable viewer navigation (#2109)

* [ACA-3897] Extendable viewer navigation

* Update app.extensions.json
This commit is contained in:
Dharan 2021-05-07 15:54:18 +05:30 committed by GitHub
parent cd5ccc4c4d
commit 6700830c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 0 deletions

View File

@ -569,6 +569,11 @@ export interface ViewerRules {
* Checks if user can preview the node.
*/
canPreview?: string;
/**
* Shows navigation options
*/
showNavigation?: string;
}
```

View File

@ -780,6 +780,10 @@
"canPreview": {
"description": "Controls whether preview is enabled for particular node",
"type": "string"
},
"showNavigation": {
"description": "Controls viewer navigation options",
"type": "string"
}
}
},

View File

@ -28,4 +28,9 @@ export interface ViewerRules {
* Checks if user can preview the node.
*/
canPreview?: string;
/**
* Shows navigation options
*/
showNavigation?: string;
}

View File

@ -497,4 +497,17 @@ export class AppExtensionService implements RuleContext {
return true;
}
canShowViewerNavigation(node: NodeEntry) {
const rules = this.viewerRules;
if (this.isRuleDefined(rules.showNavigation)) {
const showNavigation = this.evaluateRule(rules.showNavigation, node);
if (!showNavigation) {
return false;
}
}
return true;
}
}

View File

@ -214,6 +214,12 @@ export class AppViewerComponent implements OnInit, OnDestroy {
this.node = await this.contentApi.getNodeInfo(nodeId).toPromise();
this.canUpdateNode = this.content.canUpdateNode(this.node);
this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }]));
this.navigateMultiple = this.extensions.canShowViewerNavigation({ entry: this.node });
if (!this.navigateMultiple) {
this.nodeId = this.node.id;
this.fileName = this.node.name + this.node?.properties?.['cm:versionLabel'];
return;
}
if (this.node && this.node.isFile) {
const nearest = await this.getNearestNodes(this.node.id, this.node.parentId);