-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
306 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { getRuntime } from '../../index'; | ||
import { RuntimeMessage } from '../runtimeMessage'; | ||
import { DirectoryApp } from '../../types/FDC3Data'; | ||
import { TOPICS } from '../../constants'; | ||
|
||
export const resolveIntent = async (message: RuntimeMessage) => { | ||
const runtime = getRuntime(); | ||
|
||
//TODO: autojoin the new app to the channel which the 'open' call is sourced from | ||
|
||
if (!message.data.selected.instanceId) { | ||
const data: DirectoryApp = message.data.selected?.directoryData; | ||
|
||
//launch window | ||
const runtime = getRuntime(); | ||
if (runtime) { | ||
const win = runtime.createWorkspace(); | ||
const view = win.createView(data.start_url, { | ||
directoryData: data as DirectoryApp, | ||
}); | ||
|
||
//set pending intent and context | ||
view.setPendingIntent( | ||
message.data.intent, | ||
message.data.context, | ||
message.data.id, | ||
); | ||
} | ||
} else { | ||
const view = runtime.getView(message.data.selected?.instanceId); | ||
//send new intent | ||
if (view && view.parent) { | ||
view.content.webContents.send(TOPICS.FDC3_INTENT, { | ||
topic: 'intent', | ||
data: { intent: message.data.intent, context: message.data.context }, | ||
source: message.data.id, | ||
}); | ||
view.parent.setSelectedTab(view.id); | ||
} | ||
} | ||
|
||
//close the resolver | ||
const resolver = runtime.getResolver(); | ||
if (resolver) { | ||
resolver.close(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
import { ipcRenderer } from 'electron'; | ||
import { ipcRenderer, contextBridge } from 'electron'; | ||
import { Context } from '@finos/fdc3'; | ||
import { FDC3MessageData } from '../../../main/src/types/FDC3Message'; | ||
import { TOPICS } from '../../../main/src/constants'; | ||
import { RUNTIME_TOPICS } from '../../../main/src/handlers/runtime/topics'; | ||
|
||
let id: string | undefined = undefined; | ||
let intent: string | undefined = undefined; | ||
let context: Context | undefined = undefined; | ||
|
||
ipcRenderer.on(TOPICS.WINDOW_START, (event, args) => { | ||
ipcRenderer.on(RUNTIME_TOPICS.WINDOW_START, (event, args) => { | ||
console.log(event.type); | ||
id = args.id; | ||
intent = args.intent; | ||
context = args.context; | ||
|
||
document.dispatchEvent( | ||
new CustomEvent(TOPICS.RES_LOAD_INTENT_RESULTS, { detail: args }), | ||
new CustomEvent(RUNTIME_TOPICS.RES_LOAD_RESULTS, { detail: args }), | ||
); | ||
}); | ||
|
||
const resolveIntent = (data: FDC3MessageData) => { | ||
ipcRenderer.send(TOPICS.RES_RESOLVE_INTENT, { | ||
method: 'resolveIntent', | ||
const resolveIntent = (data: any) => { | ||
ipcRenderer.send(RUNTIME_TOPICS.RES_RESOLVE_INTENT, { | ||
id: id, | ||
intent: data.selectedIntent || intent, | ||
selected: data.selected && data.selected.details, | ||
context: context, | ||
data: { | ||
intent: data.selectedIntent || intent, | ||
selected: data.selected && data.selected.details, | ||
context: context, | ||
}, | ||
}); | ||
}; | ||
|
||
document.addEventListener(TOPICS.RES_RESOLVE_INTENT, ((event: CustomEvent) => { | ||
resolveIntent(event.detail); | ||
}) as EventListener); | ||
const api = { | ||
resolveIntent, | ||
}; | ||
|
||
contextBridge.exposeInMainWorld('agentResolver', api); |
Oops, something went wrong.