Skip to content

Commit 8b9c469

Browse files
authored
SDA-4770 Expose Openfin API - Adding setContext (#2308)
1 parent 2ffd498 commit 8b9c469

13 files changed

+37
-13
lines changed

config/Symphony.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"licenseKey": "",
5454
"runtimeVersion": "",
5555
"autoConnect": false,
56-
"channelName": "",
56+
"platformUuid": "",
5757
"connectionTimeout": "10000"
5858
}
5959
}

installer/mac/postinstall.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ if [ "$EUID" -ne 0 ]; then
126126
defaults write "$plistFilePath" uuid -string ""
127127
defaults write "$plistFilePath" licenseKey -string ""
128128
defaults write "$plistFilePath" runtimeVersion -string ""
129-
defaults write "$plistFilePath" channelName -string ""
129+
defaults write "$plistFilePath" platformUuid -string ""
130130
defaults write "$plistFilePath" autoConnect -bool false
131131
else
132132
sudo -u "$userName" defaults write "$plistFilePath" url -string "$pod_url"
@@ -176,7 +176,7 @@ else
176176
sudo -u "$userName" defaults write "$plistFilePath" uuid -string ""
177177
sudo -u "$userName" defaults write "$plistFilePath" licenseKey -string ""
178178
sudo -u "$userName" defaults write "$plistFilePath" runtimeVersion -string ""
179-
sudo -u "$userName" defaults write "$plistFilePath" channelName -string ""
179+
sudo -u "$userName" defaults write "$plistFilePath" platformUuid -string ""
180180
sudo -u "$userName" defaults write "$plistFilePath" autoConnect -bool false
181181
fi
182182

spec/mainApiHandler.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jest.mock('../src/app/config-handler', () => {
5757
uuid: 'some-uuid',
5858
licenseKey: 'some-license-key',
5959
runtimeVersion: 'some-runtime-version',
60-
channelName: 'some-channel-name',
60+
platformUuid: 'platform-uuid',
6161
connectionTimeout: '1000',
6262
},
6363
};

spec/openfinHandler.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jest.mock('../src/app/config-handler', () => ({
2828
uuid: 'mock-uuid',
2929
licenseKey: 'mock-license',
3030
runtimeVersion: 'mock-version',
31-
channelName: 'mock-channel',
31+
platformUuid: 'platform-uuid',
3232
connectionTimeout: '10000',
3333
},
3434
})),
@@ -76,7 +76,7 @@ describe('Openfin', () => {
7676
jest.useFakeTimers();
7777
const connectSyncSpy = jest
7878
.spyOn(connectMock.Interop, 'connectSync')
79-
.mockImplementationOnce((_channelName) => {
79+
.mockImplementationOnce((_platformUuid) => {
8080
return new Promise<void>((resolve) => {
8181
setTimeout(() => {
8282
resolve();
@@ -113,7 +113,7 @@ describe('Openfin', () => {
113113
jest.useFakeTimers();
114114
const connectSyncSpy = jest
115115
.spyOn(connectMock.Interop, 'connectSync')
116-
.mockImplementationOnce((_channelName) => {
116+
.mockImplementationOnce((_platformUuid) => {
117117
return new Promise<void>((resolve) => {
118118
setTimeout(() => {
119119
resolve();

spec/plistHandler.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('Plist Handler', () => {
9595
autoConnect: undefined,
9696
licenseKey: undefined,
9797
runtimeVersion: undefined,
98-
channelName: undefined,
98+
platformUuid: undefined,
9999
uuid: undefined,
100100
connectionTimeout: undefined,
101101
},

src/app/config-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export interface IOpenfin {
168168
uuid: string;
169169
licenseKey: string;
170170
runtimeVersion: string;
171-
channelName: string;
171+
platformUuid: string;
172172
autoConnect: boolean;
173173
connectionTimeout: string;
174174
}

src/app/main-api-handler.ts

+2
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ ipcMain.handle(
654654
return openfinHandler.fireIntentForContext(arg.context);
655655
case apiCmds.openfinRemoveFromContextGroup:
656656
return openfinHandler.removeFromContextGroup();
657+
case apiCmds.openfinSetContext:
658+
return openfinHandler.setContext(arg.context);
657659
default:
658660
break;
659661
}

src/app/openfin-handler.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export class OpenfinHandler {
6060
'openfin-handler: connection established to openfin runtime',
6161
);
6262
logger.info(
63-
`openfin-handler: starting connection to interop broker using channel ${openfin.channelName}...`,
63+
`openfin-handler: starting connection to interop broker using channel ${openfin.platformUuid}...`,
6464
);
6565

66-
this.interopClient = this.fin.Interop.connectSync(openfin.channelName);
66+
this.interopClient = this.fin.Interop.connectSync(openfin.platformUuid);
6767
this.isConnected = true;
6868
this.interopClient?.onDisconnection(this.disconnectionHandler);
6969

@@ -202,6 +202,14 @@ export class OpenfinHandler {
202202
return this.interopClient?.fireIntentForContext(context);
203203
}
204204

205+
/**
206+
* Sets a context for the context group of the current entity.
207+
* @param context
208+
*/
209+
public setContext(context: any) {
210+
return this.interopClient?.setContext(context);
211+
}
212+
205213
/**
206214
* Leaves current context group
207215
*/

src/app/plist-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const OPENFIN = {
6969
uuid: 'string',
7070
licenseKey: 'string',
7171
runtimeVersion: 'string',
72-
channelName: 'string',
72+
platformUuid: 'string',
7373
autoConnect: 'boolean',
7474
connectionTimeout: 'string',
7575
};

src/common/api-interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export enum apiCmds {
9797
openfinFireIntentForContext = 'openfin-fire-intent-for-context',
9898
openfinRemoveFromContextGroup = 'openfin-remove-from-context-group',
9999
openfinGetClientInfo = 'openfin-get-client-info',
100+
openfinSetContext = 'openfin-set-context',
100101
}
101102

102103
export enum apiName {

src/common/config-interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const ConfigFieldsDefaultValues: Partial<IConfig> = {
1212
uuid: '',
1313
licenseKey: '',
1414
runtimeVersion: '',
15-
channelName: '',
15+
platformUuid: '',
1616
autoConnect: false,
1717
connectionTimeout: '10000',
1818
},

src/renderer/preload-main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ if (ssfWindow.ssf) {
121121
fireIntentForContext: ssfWindow.ssf.openfinFireIntentForContext,
122122
removeFromContextGroup: ssfWindow.ssf.openfinRemoveFromContextGroup,
123123
getClientInfo: ssfWindow.ssf.openfinGetClientInfo,
124+
setContext: ssfWindow.ssf.openfinSetContext,
124125
});
125126
}
126127

src/renderer/ssf-api.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,18 @@ export class SSFApi {
11271127
return clients;
11281128
}
11291129

1130+
/**
1131+
* Sets a context for the context group of the current entity.
1132+
* @param context
1133+
*/
1134+
public async openfinSetContext(context: any) {
1135+
const response = await local.ipcRenderer.invoke(apiName.symphonyApi, {
1136+
cmd: apiCmds.openfinSetContext,
1137+
context,
1138+
});
1139+
return response;
1140+
}
1141+
11301142
/**
11311143
* Allows JS to register SDA for phone numbers clicks
11321144
* @param {Function} phoneNumberCallback callback function invoked when receiving a phone number for calls/sms

0 commit comments

Comments
 (0)