I am building a Google Workspace Add-On and want to use the dot menu to dynamically display a "Sign Out" option after a user has logged in.
I found out that the menu options are defined in the deployment resource of an Add-on (also called manifest) as an array called "universalActions". For example like this:
"universalActions": [{
"label": "Settings",
"openLink": "https://myapp.com/settings"
},{
"label": "Sign Out",
"openLink": "https://myapp.com/logout"
}]
But I can't find a way to change the "universalActions" after deployment.
In the example below you see the Evernote Add-on before login and after login.
On the second picture, so after the login, you see the additional menu options "Einstellungen" (meaning settings) and "Abmelden" (meaning logout). How can I achieve displaying these options after login only?
CodePudding user response:
The feature I was looking for is called CardActions. If you define a "CardAction", it will be placed in the header bar menu (what I referred to as "dot menu").
As JSON-Object, you can put it like that:
"action": {
"navigations": [
{
"pushCard": {
"cardActions": [
{
"actionLabel": "Logout",
"onClick": {
"openDynamicLinkAction": {
"function": "https://dummy-function-from-resources.net/openLinkCallback"
}
}
}...
CodePudding user response:
Universal actions, according to Apps Script documentation are:
[...] menu item elements that allow a user to open a new web page, display new UI cards, or run a specific Apps Script function when selected. In operation they are very similar to card actions, except that universal actions are always placed on every card in your add-on, regardless of the current add-on context.
Indeed, using a card action seems like the appropriate choice for this, however, you might also consider checking the other widgets options available, as they allow the add-on to do something based on the user interaction:
DateTime pickers;
Image button;
Selection input;
Switch;
Text button;
Text input;
Grid;