diff --git a/how-to/integrate-with-snap-basic/README.md b/how-to/integrate-with-snap-basic/README.md index 30f8b3dfa0..ccc85197d4 100644 --- a/how-to/integrate-with-snap-basic/README.md +++ b/how-to/integrate-with-snap-basic/README.md @@ -12,7 +12,7 @@ This example demonstrates connecting to and using layouts with Snap. The package utilized by this example is [@openfin/snap-sdk](https://www.npmjs.com/package/@openfin/snap-sdk). -> The **@openfin/snap-sdk** is currently in beta, this sample requires the Snap Asset Url for the Snap Server. Please ask OpenFin for the url and then replace the `SNAP_ASSET_URL` in `manifest.fin.json` with it. +> The **@openfin/snap-sdk** is currently in beta. The version of the Snap SDK is referenced in package.json and the app asset defined in `manifest.fin.json`. ## Getting Started diff --git a/how-to/integrate-with-snap-basic/public/manifest.fin.json b/how-to/integrate-with-snap-basic/public/manifest.fin.json index 0675c13ff0..8a78e2d3b7 100644 --- a/how-to/integrate-with-snap-basic/public/manifest.fin.json +++ b/how-to/integrate-with-snap-basic/public/manifest.fin.json @@ -44,7 +44,7 @@ }, "appAssets": [ { - "src": "SNAP_ASSET_URL", + "src": "https://cdn.openfin.co/release/snap/0.2.0/snap.zip", "alias": "openfin-snap", "version": "0.2.0", "target": "OpenFinSnap.exe", diff --git a/how-to/integrate-with-snap/README.md b/how-to/integrate-with-snap/README.md index d4fe5c9add..d5014b2c86 100644 --- a/how-to/integrate-with-snap/README.md +++ b/how-to/integrate-with-snap/README.md @@ -12,7 +12,7 @@ This example demonstrates saving and restoring native applications as part of a The package utilized by this example is [@openfin/snap-sdk](https://www.npmjs.com/package/@openfin/snap-sdk). -> The **@openfin/snap-sdk** is currently in beta, this sample requires the Snap Asset Url for the Snap Server. Please ask OpenFin for the url and then replace the `SNAP_ASSET_URL` in `manifest.fin.json` with it. +> The **@openfin/snap-sdk** is currently in beta. The version of the Snap SDK is referenced in package.json and the app asset defined in `manifest.fin.json`. ## Getting Started diff --git a/how-to/integrate-with-snap/public/manifest.fin.json b/how-to/integrate-with-snap/public/manifest.fin.json index db9537e96e..ad407cd1ae 100644 --- a/how-to/integrate-with-snap/public/manifest.fin.json +++ b/how-to/integrate-with-snap/public/manifest.fin.json @@ -47,7 +47,7 @@ }, "appAssets": [ { - "src": "SNAP_ASSET_URL", + "src": "https://cdn.openfin.co/release/snap/0.2.0/snap.zip", "alias": "openfin-snap", "version": "0.2.0", "target": "OpenFinSnap.exe", diff --git a/how-to/register-with-dock-basic/client/src/dock.ts b/how-to/register-with-dock-basic/client/src/dock.ts index 7f617fb19f..34c9976927 100644 --- a/how-to/register-with-dock-basic/client/src/dock.ts +++ b/how-to/register-with-dock-basic/client/src/dock.ts @@ -1,8 +1,11 @@ import { Dock, DockButtonNames, + type DockButton, type RegistrationMetaInfo, - type WorkspaceButtonsConfig + type DockProviderRegistration, + type WorkspaceButtonsConfig, + type DockProviderConfig } from "@openfin/workspace"; import { CustomActionCallerType, @@ -11,6 +14,11 @@ import { type CustomActionsMap } from "@openfin/workspace-platform"; +let platformTitle: string | undefined; +let platformIcon: string | undefined; +let customIconUrl: string | undefined; +let customOpenUrl: string | undefined; +let registration: DockProviderRegistration | undefined; /** * Register the dock provider. * @param id The id to register the provider with. @@ -37,7 +45,11 @@ export async function register( console.log("Initializing the dock provider."); try { - const metaInfo = await Dock.register({ + platformTitle = title; + platformIcon = icon; + customIconUrl = options.customIconUrl; + customOpenUrl = options.customOpenUrl; + registration = await Dock.register({ id, title, icon, @@ -90,9 +102,9 @@ export async function register( } ] }); - console.log(metaInfo); + console.log(registration); console.log("Dock provider initialized."); - return metaInfo; + return registration; } catch (err) { console.error("An error was encountered while trying to register the content dock provider", err); } @@ -132,3 +144,79 @@ export function dockGetCustomActions(): CustomActionsMap { } }; } + +/** + * Create the configuration for the dock, including a drop down for favorites if there are any. Normally, you would pass this into the initial + * register method above, but this is only for demonstrating the ability to change the dock dynamically. + * @param isEnabled Passes a boolean accounting for buttons in the dock being usable or not. + * @returns The dock configuration. + */ +function buildDockConfiguration(isEnabled: boolean): DockProviderConfig { + const buttons: DockButton[] = [ + { + tooltip: "Google", + iconUrl: "https://www.google.com/favicon.ico", + action: { + id: "launch-google" + }, + disabled: !isEnabled + }, + { + tooltip: "Bing", + iconUrl: "https://www.bing.com/favicon.ico", + action: { + id: "launch-bing" + }, + disabled: !isEnabled + }, + { + tooltip: "Custom", + iconUrl: customIconUrl, + action: { + id: "launch-custom", + customData: customOpenUrl + }, + disabled: !isEnabled + }, + { + type: DockButtonNames.DropdownButton, + tooltip: "Social", + iconUrl: "http://localhost:8080/assets/spanner.svg", + options: [ + { + tooltip: "Twitter", + action: { + id: "launch-tools", + customData: "twitter" + } + }, + { + tooltip: "Facebook", + action: { + id: "launch-tools", + customData: "facebook" + } + } + ], + disabled: !isEnabled + } + ]; + + return { + title: platformTitle ?? "", + icon: platformIcon ?? "", + workspaceComponents: ["home", "notifications", "store", "switchWorkspace"], + disableUserRearrangement: false, + buttons + }; +} + +/** + * Update the dock when something has changed. + * @param isEnabled Tells us whether or not the Dock buttons should be clickable. + */ +export async function updateDock(isEnabled: boolean): Promise { + if (registration) { + await registration.updateDockProviderConfig(buildDockConfiguration(isEnabled)); + } +} diff --git a/how-to/register-with-dock-basic/client/src/provider.ts b/how-to/register-with-dock-basic/client/src/provider.ts index 17a1d60cbf..922fe80c20 100644 --- a/how-to/register-with-dock-basic/client/src/provider.ts +++ b/how-to/register-with-dock-basic/client/src/provider.ts @@ -7,12 +7,14 @@ import { type WorkspaceButton } from "@openfin/workspace"; import { init } from "@openfin/workspace-platform"; -import { dockGetCustomActions, register } from "./dock"; +import { dockGetCustomActions, register, updateDock } from "./dock"; let registerButton: HTMLButtonElement | null; let showButton: HTMLButtonElement | null; let minimizeButton: HTMLButtonElement | null; let deregisterButton: HTMLButtonElement | null; +let enableButton: HTMLButtonElement | null; +let disableButton: HTMLButtonElement | null; let showHomeButton: HTMLInputElement | null; let showNotificationButton: HTMLInputElement | null; let showStorefrontButton: HTMLInputElement | null; @@ -114,8 +116,10 @@ async function initializeDOM(): Promise { enableRearrangementButton = document.querySelector("#enableRearrangement"); customIconUrlInput = document.querySelector("#customIconUrl"); customOpenUrlInput = document.querySelector("#customOpenUrl"); + enableButton = document.querySelector("#enable"); + disableButton = document.querySelector("#disable"); - if (registerButton && deregisterButton && showButton && minimizeButton) { + if (registerButton && deregisterButton && showButton && minimizeButton && enableButton && disableButton) { setStates(false); registerButton.addEventListener("click", async () => { @@ -163,6 +167,16 @@ async function initializeDOM(): Promise { minimizeButton.addEventListener("click", async () => { await Dock.minimize(); }); + + enableButton.addEventListener("click", async () => { + console.log("Enable Clicked!"); + await updateDock(true); + }); + + disableButton.addEventListener("click", async () => { + console.log("Disable Clicked!"); + await updateDock(false); + }); } } @@ -176,6 +190,8 @@ function setStates(isRegistered: boolean | null): void { deregisterButton && showButton && minimizeButton && + enableButton && + disableButton && showHomeButton && showNotificationButton && showStorefrontButton && @@ -188,6 +204,8 @@ function setStates(isRegistered: boolean | null): void { deregisterButton.disabled = isRegistered === null || !isRegistered; showButton.disabled = isRegistered === null || !isRegistered; minimizeButton.disabled = isRegistered === null || !isRegistered; + enableButton.disabled = isRegistered === null || !isRegistered; + disableButton.disabled = isRegistered === null || !isRegistered; showHomeButton.disabled = isRegistered === null || isRegistered; showNotificationButton.disabled = isRegistered === null || isRegistered; showStorefrontButton.disabled = isRegistered === null || isRegistered; diff --git a/how-to/register-with-dock-basic/public/manifest.fin.json b/how-to/register-with-dock-basic/public/manifest.fin.json index bec40d69d3..cba3a4fb93 100644 --- a/how-to/register-with-dock-basic/public/manifest.fin.json +++ b/how-to/register-with-dock-basic/public/manifest.fin.json @@ -10,7 +10,9 @@ "icon": "http://localhost:8080/favicon.ico", "autoShow": true, "providerUrl": "http://localhost:8080/platform/provider.html", - "preventQuitOnLastWindowClosed": true + "preventQuitOnLastWindowClosed": true, + "minWidth": 750, + "defaultWidth": 750 }, "shortcut": { "company": "OpenFin", diff --git a/how-to/register-with-dock-basic/public/platform/provider.html b/how-to/register-with-dock-basic/public/platform/provider.html index 57faaa62bb..32f9fb1144 100644 --- a/how-to/register-with-dock-basic/public/platform/provider.html +++ b/how-to/register-with-dock-basic/public/platform/provider.html @@ -33,6 +33,8 @@

Demonstrate basic dock interactions.

+ +

Options

diff --git a/how-to/workspace-platform-starter/CHANGELOG.md b/how-to/workspace-platform-starter/CHANGELOG.md index 2121f8b830..b6175d2da2 100644 --- a/how-to/workspace-platform-starter/CHANGELOG.md +++ b/how-to/workspace-platform-starter/CHANGELOG.md @@ -10,7 +10,7 @@ - Docs - Added a document showing [How To Add A Service](./docs/how-to-add-a-service.md) - Improved launchPreference so that now args for a native app (app asset or external) can be specified via launchPreference. Launch preference can also be configured to allow args to be specified dynamically when the launch request is made. Please see [how to define app launch preference](./docs/how-to-define-app-launch-preference.md). - Improved launchPreference so additional options such as url, interop, customData can be specified. Modules can now pass a launchPreference when launching an app by appId. They can see if the app supports being updated by getting the app by id and checking for the updatable setting under launchPreference.options. Only inline-view/view and inline-window/window support updatable launch preferences. Please see [how to define app launch preference](./docs/how-to-define-app-launch-preference.md). -- Added support for Snap, enable by setting `customSettings.snapProvider.enabled` to true. Configure the `customSettings.snapProvider.serverAssetInfo` to point to the `SNAP_ASSET_URL`. Enable the Snap debugging window by setting `customSettings.snapProvider.showDebugWindow` to true. +- Added support for Snap, enable by setting `customSettings.snapProvider.enabled` to true. Enable the Snap debugging window by setting `customSettings.snapProvider.showDebugWindow` to true. - Added new module type `content-creation`, these modules can be used to define content creation rules and handle the associated events. Modules are added in `customSettings.contentCreationProvider` section in manifest. - Added example content creation module which interrogates the `features` property from `window.open` to determine where to place a view in relation to where it was launched from. An example app `Content Creation Example` demonstrates this in use. - Added CustomActionCallerType enum to actions-shapes, use these in preference to the workspace-platform CustomActionCallerType type to avoid importing the whole npm package into your modules. diff --git a/how-to/workspace-platform-starter/docs/how-to-configure-snap.md b/how-to/workspace-platform-starter/docs/how-to-configure-snap.md index 4da8502925..63163fe2df 100644 --- a/how-to/workspace-platform-starter/docs/how-to-configure-snap.md +++ b/how-to/workspace-platform-starter/docs/how-to-configure-snap.md @@ -7,7 +7,7 @@ The OpenFin Snap SDK provides the ability to snap windows together, include native applications. For more detailed information see [OpenFin Snap SDK](https://developers.openfin.co/of-docs/docs/snap) -To enable snap support in your platform you can add the following in your manifest.fin.json. As the Snap SDK is currently in beta you must contact OpenFin to get the real url for the `SNAP_ASSET_URL` +To enable snap support in your platform you can add the following in your manifest.fin.json. ```json { @@ -17,7 +17,7 @@ To enable snap support in your platform you can add the following in your manife "enabled": true, "id": "workspace-platform-starter", "serverAssetInfo": { - "src": "SNAP_ASSET_URL", + "src": "https://cdn.openfin.co/release/snap/0.2.0/snap.zip", "alias": "openfin-snap", "version": "0.2.0", "target": "OpenFinSnap.exe" diff --git a/how-to/workspace-platform-starter/public/manifest.fin.json b/how-to/workspace-platform-starter/public/manifest.fin.json index 1642eed70b..822bf43f16 100644 --- a/how-to/workspace-platform-starter/public/manifest.fin.json +++ b/how-to/workspace-platform-starter/public/manifest.fin.json @@ -1661,7 +1661,7 @@ "enabled": false, "id": "workspace-platform-starter", "serverAssetInfo": { - "src": "SNAP_ASSET_URL", + "src": "https://cdn.openfin.co/release/snap/0.2.0/snap.zip", "alias": "openfin-snap", "version": "0.2.0", "target": "OpenFinSnap.exe" diff --git a/how-to/workspace-platform-starter/public/pack.manifest.fin.json b/how-to/workspace-platform-starter/public/pack.manifest.fin.json index a741105eab..f92b57bd87 100644 --- a/how-to/workspace-platform-starter/public/pack.manifest.fin.json +++ b/how-to/workspace-platform-starter/public/pack.manifest.fin.json @@ -859,7 +859,7 @@ "enabled": false, "id": "workspace-platform-starter", "serverAssetInfo": { - "src": "SNAP_ASSET_URL", + "src": "https://cdn.openfin.co/release/snap/0.2.0/snap.zip", "alias": "openfin-snap", "version": "0.2.0", "target": "OpenFinSnap.exe"