Search code examples
typescriptapinodesactionalfresco

How to get nodeID from custom contextMenu button ( alfresco content app )


I am looking for alternative for alfresco share custom buttons on the files and folders. I am create in app.extenstion.json new contextMenu button with this tutorial: https://alfresco-content-app.netlify.app/#/tutorials/dialog-actions but there is only way for show some dialog, not for call repo websript with actual nodeRef in parametr. How can I do that ? :)

I have custom contextMenu button in ACA appliacation and I need get nodeID from clicked folder or document.

import { ActivatedRoute, Params } from "@angular/router";
import { Component, OnInit } from "@angular/core";

@Component({
  selector: "aca-my-extension-dialog",
  templateUrl: "./my-extension-dialog.component.html",
  styleUrls: ["./my-extension-dialog.component.scss"],
})
export class MyExtensionDialogComponent implements OnInit {
  content: string = null;

  constructor(private route: ActivatedRoute) {}

  ngOnInit() {
    this.route.params.subscribe(({ nodeId }: Params) => {
      alert("node: " + nodeId);
    });
  }
}

image

image

Many thanks for all help. :)


Solution

  • For context menu you can access nodeId from selection in store. AppState class contains the list of selected elements selection. that contains the property nodes: NodeEntry[]; Node entry contains node that contains nodeId.

    Path to that property is

    AppStore.app.selection.nodes

    to gain access to the store on you component add it to the constructor.

      constructor(   
        private store: Store<AppStore>,
      ) {
    

    cheers!