Only show "Share" option in context menu

Hi,


I'm aware of the "Share" Application Privilege setting in the user config, and I've enabled that and disabled most other stuff in there, but the "Share" option only appears when I right-click in certain parts of the dashboard (I haven't been able to find a pattern for this yet). It seems empty spaces on the dashboard mostly give me a "Share" option on right-click (but not always), and areas with charts don't (but again, not always).


Is there a way of setting up a user/dashboard combination such that for that user a right click always produces a context menu which only has the "Share" option in it, regardless of where the click event occurs? Our users will not be using any of the other context menu options, but they will need to export their dashboards either for print or as csv for further analysis. All they need is the "Share" option, anything else will just be confusing.


Thanks


Adam

Adam,


There are two places to check for Disabled Application Privileges:

1: On the main area (the place where you put everything, to get to its properties click on a blank space. The name in the properties should be the name of the Dashboard) There is a features section there for disabled Application Privileges. This should do it for everything put on that dasboard.

2. Each item you put on the dashboard has this as well.


Sound like to me you have disabled eveything (including share) on each item you put on.


Well that what I woudl check first if I was there.


Lets us know if that was it or not.

Hi,


Thanks for the reply. I don't see a features section anywhere in the properties, for anything I've selected so far, including the dashboard itself. I have tabs for Main, Look, Layout and Text, but nowhere in any of them is there an option to disable any Application Privileges. Can you be more specific about where to look? I can say with certainty that I haven't disabled any application privileges within the dashboard anywhere. I didn't know you could. The only Application Privileges I've found have been in the account settings.

The right-click is a context menu, so anything involving data should produce a menu relevant to that control. Everything else should produce the generic menu, which includes the Share option.


I think for your case the easiest solution would be to add another layer with a rectangle component covering the whole canvas (you can remove the stroke and the fill to make it invisible). This way the context menu will always be the same, including the Share option.


If you want it to be a bit more flexible and only apply this to certain users, you can add a script that will hide the layer based on the user at the Ready event of the dashboard. We can delve deeper into this possibility if you want.

Thanks. I'm not sure either option there is quite what we want, since users do interact with the visualisations in other ways (sorting tables, for example) and we wouldn't want to lose that. I'll feed back your response and see what our stakeholders want to do.


Thanks again.

So you want to limit the interactivity to only left-clicks?

In that case, the only option would be to create an override for the context menu. It should be doable, but I have to look into a few details. I'll get back to you on this shortly.

Is there any way to hook the Share functionality up to a button control or something? Is it accessible via script?

You can find examples of creating a button for any of the share options in the script library. Alternatively, you can add a script to the button click, which will open the Share context menu.


As for your original idea, here is an example for customizing the context menu, or you can follow the related article instead. Note that the menu is different for each data control, so you will have to place the scripts for each of them in the Context Menu Showing action.


I will have to spend some time with the actual scripts, so let me know which direction you want to go.

That's great, thank you. I'll give it a read and see which approach people here prefer. Thanks!

Hi, thanks for the help so far, it's been really useful. I've decided that customizing the context menu is probably the way to go. It will keep the user experience as we expected it to be in the first place, so it's the lowest impact solution for us. I understand the modifications to the context menu, I've got some proof of concept stuff working there and I can see the new item I've added and click it, but I now need to know how to display the Share submenu from a script.


The way I see it, my new context menu item will appear as the only entry in the context menu, and it will be labelled either "Share" or possibly "Export" (I haven't decided yet). What I would like to happen is that when you click that menu item, you then see the usual Share options (Link, Image, PDF, etc). I'm hoping there's a way to do that with scripting, but I haven't been able to figure it out on my own as yet.


Any hints?

Multi-levelled menu options are created as subCommands. The following is a sample script that creates the Share Command with a PDF subCommand:



// Get the commands from the event.
var commands = e.originalEvent.commands;
for (i = commands.length-1; i>=0; i--)
{
// Remove the original items
commands.splice(i,1);
}

// define new commands and push to the commands array

var parentMenuItem = new dundas.Command({
caption: "Share",
categoryName: "Share",
action: function () {
// Do cool stuff here
}.bind(this),
subCommands: [
new dundas.Command({
id: dundas.Utility.createGuid(),
caption: "PDF",
categoryName: "Export to PDF",
description: 'Export to PDF',
editModeOnly:false,
action: function () {
var share = new dundas.controls.ExportDialog(dundas.constants.STANDARD_PDF_EXPORT_PROVIDER_ID);
var sharePanel = share.show();
}.bind(this)
}),
]
});

commands.push(parentMenuItem);

Perfect, thank you!

Sorry to be a pain, I've got everything working great for all the other exports, but I've come across a problem with the Link export. It doesn't seem to follow the same pattern as the others. There's no constant for it in dundas.constants. The script library link you posted earlier has an entry for a "short url", but I don't think that's what I'm looking for. How do I include an entry in the context menu that will pop up the configuration panel for the Link export?


Apologies for asking for help again, I just never seem to be able to distill this stuff into something I can put in a search box, and when I can I never seem to find what I need.

I can see why this would be confusing. The reason you needed the constants for the other options is because it's the same ExportDialog and you pre-select an export option. The Link option uses a different one, ShareDialog, and doesn't require any constants.


The subCommand for the link option will look as follows:


new dundas.Command({
id: dundas.Utility.createGuid(),
caption: "Link",
categoryName: "Export as a link",
description: 'Export as a link',
editModeOnly:false,
action: function () {
var share = new dundas.controls.ShareDialog();
var sharePanel = share.show();
}.bind(this)
}),

Brilliant. Thank you!

Hi Elia,
Would you happen to have the script for showing the share context menu on a button click? This is exactly what I am looking for.

Thanks

Hey @carlos.fares, for your reference (and anyone else who’s interested), the script has been published here: Show the context menu on button click