From d2b3b241dad59831a971fe0ac5ded6f4fbf92fb1 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 24 Jan 2024 18:03:42 +0000 Subject: [PATCH] Update the developer menu module (#675) Update the hook that we look for use CloseTab instead of print. Add an option to copy the url which can be useful for developers. --- .../workspace-platform-starter/CHANGELOG.md | 1 + .../modules/composite/developer/actions.ts | 25 +++++++++++++++++++ .../src/modules/composite/developer/menus.ts | 20 +++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/how-to/workspace-platform-starter/CHANGELOG.md b/how-to/workspace-platform-starter/CHANGELOG.md index e9df19a313..369c5a5096 100644 --- a/how-to/workspace-platform-starter/CHANGELOG.md +++ b/how-to/workspace-platform-starter/CHANGELOG.md @@ -29,6 +29,7 @@ - Fixed - when launching multiple instances of an inline app asset it is possible to try and re-download an app asset that has just been downloaded or exists. We now fetch the app asset info to see if the platform already has the app asset and if it is the required version. - Added util getCommandLineArgs to extract multiple command line arguments from a string into an array. Snap accepts an array of arguments and app assets and external apps take a string as an args parameter. This lets you specify arguments that cover scenarios where snap is disabled and enabled. Added tests to verify getCommandLineArgs behavior. - Updated identity returned when launching a native app or app asset (either normally or through snap). The UUID is the app id if the app has been marked as instanceMode = "single" otherwise the uuid is appId/guid (guid being an instanceId). The name is the same as the UUID (as name is not specified in app asset/external process options). If your app supports having multiple instances and it registers intent handlers then we recommend passing the created UUID for your app instance using {OF-EXT-UUD} as part of the command line args so that the uuid can be used when you connect to the OpenFin runtime. When you then connect to the workspace platform interop broker (as the platform will be waiting on that connection to fire an intent against it) it will use the expected UUID as it's connection id. +- Update developer composite menu to use the Close menu option instead of Print as the positioning hook. Add Copy Url to the developer view context menu options. ## v16 diff --git a/how-to/workspace-platform-starter/client/src/modules/composite/developer/actions.ts b/how-to/workspace-platform-starter/client/src/modules/composite/developer/actions.ts index a83e3f6863..be5c70390a 100644 --- a/how-to/workspace-platform-starter/client/src/modules/composite/developer/actions.ts +++ b/how-to/workspace-platform-starter/client/src/modules/composite/developer/actions.ts @@ -135,6 +135,31 @@ export class DeveloperActions implements Actions { } }; + actionMap["copy-url"] = async (payload: CustomActionPayload): Promise => { + if (payload.callerType === CustomActionCallerType.ViewTabContextMenu) { + const urls: string[] = []; + for (let i = 0; i < payload.selectedViews.length; i++) { + const viewIdentity = payload.selectedViews[i]; + try { + const view = fin.View.wrapSync(viewIdentity); + const info = await view.getInfo(); + urls.push(info.url); + } catch (error) { + this._logger?.error( + `Error while trying to capture view url for view ${viewIdentity.name}`, + error + ); + } + } + if (urls.length > 0) { + const url = urls.join("\n"); + await fin.Clipboard.writeText({ + data: url + }); + } + } + }; + return actionMap; } } diff --git a/how-to/workspace-platform-starter/client/src/modules/composite/developer/menus.ts b/how-to/workspace-platform-starter/client/src/modules/composite/developer/menus.ts index 759473df2d..b1b549b0d6 100644 --- a/how-to/workspace-platform-starter/client/src/modules/composite/developer/menus.ts +++ b/how-to/workspace-platform-starter/client/src/modules/composite/developer/menus.ts @@ -99,8 +99,8 @@ export class DeveloperMenus implements Menus { } }, position: { - operation: "after", - type: "Print" + operation: "before", + type: "CloseTab" }, separator: "before" }, @@ -118,6 +118,22 @@ export class DeveloperMenus implements Menus { type: "Custom", customId: "developer-inspect" } + }, + { + include: true, + label: "Copy Url", + data: { + type: "Custom", + action: { + id: "copy-url" + } + }, + position: { + operation: "after", + type: "Custom", + customId: "raise-create-app-definition-intent" + }, + separator: "after" } ]; }