Skip to content

Commit 9a2de9b

Browse files
committed
Merge branch '1549-workbench-stopped-working-in-1.2' of https://github.com/finos/FDC3 into 1549-workbench-stopped-working-in-1.2
2 parents a4a14b3 + 8d3572e commit 9a2de9b

9 files changed

Lines changed: 41 additions & 30 deletions

File tree

toolbox/fdc3-workbench/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Intents } from './components/Intents';
2323
import { AppChannels } from './components/AppChannels';
2424
import snackbarStore from './store/SnackbarStore';
2525
import './App.css';
26-
import { getAgent } from '@finos/fdc3';
26+
import { getWorkbenchAgent } from './utility/Fdc3Api';
2727

2828
const mainTheme = createTheme({
2929
palette: {
@@ -218,7 +218,7 @@ export const App = observer(() => {
218218
useEffect(() => {
219219
(async () => {
220220
try {
221-
await getAgent();
221+
await getWorkbenchAgent();
222222
setFdc3Available(true);
223223
} catch (e) {}
224224
})();

toolbox/fdc3-workbench/src/components/Header.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import React, { useEffect, useState } from 'react';
77
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
88
import { AppBar, Toolbar, Tooltip, Typography } from '@material-ui/core';
99
import WarningIcon from '@material-ui/icons/Warning';
10-
import { getAgent } from '@finos/fdc3';
11-
import { ImplementationMetadata } from '../utility/Fdc3Api';
10+
import { getWorkbenchAgent, ImplementationMetadata } from '../utility/Fdc3Api';
1211

1312
declare global {
1413
interface Window {
@@ -88,7 +87,7 @@ export const Header = (props: { fdc3Available: boolean }) => {
8887

8988
//Then if chosenVersion == "2.0" then implInfo = await implInfoPromise else implInfo = implInfoPromise (with handling for <1.2 where getInfo() doesn't exist at all.
9089
try {
91-
const implInfoPromise = getAgent().then(agent => agent.getInfo());
90+
const implInfoPromise = getWorkbenchAgent().then(agent => agent.getInfo());
9291
if (paramVersion == '1.2' && (implInfoPromise as unknown as ImplementationMetadata).fdc3Version) {
9392
//should not expect a promise if we're really working with 1.2
9493
implInfo = implInfoPromise as unknown as ImplementationMetadata;

toolbox/fdc3-workbench/src/components/Intents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ContextType,
1010
getTargetOptions,
1111
getTargetOptionsForContext,
12+
getWorkbenchAgent,
1213
IntentResolution,
1314
IntentTargetOption,
1415
} from '../utility/Fdc3Api';
@@ -48,7 +49,6 @@ import { FormControlLabel } from '@material-ui/core';
4849
import { RadioGroup } from '@material-ui/core';
4950
import { Alert, ToggleButton, ToggleButtonGroup } from '@material-ui/lab';
5051
import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';
51-
import { getAgent } from '@finos/fdc3';
5252

5353
// interface copied from lib @material-ui/lab/Autocomplete
5454
interface FilterOptionsState<T> {
@@ -528,7 +528,7 @@ export const Intents = observer(({ handleTabChange }: { handleTabChange: any })
528528
return;
529529
}
530530
setRaiseIntentError(false);
531-
let appIntents = await getAgent().then(agent => agent.findIntentsByContext(toJS(raiseIntentContext)));
531+
let appIntents = await getWorkbenchAgent().then(agent => agent.findIntentsByContext(toJS(raiseIntentContext)));
532532

533533
setUseTargets(false);
534534
clearTargets();

toolbox/fdc3-workbench/src/store/AppChannelStore.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Copyright FINOS FDC3 contributors - see NOTICE file
44
*/
55
import { makeObservable, observable, action, runInAction, toJS } from 'mobx';
6-
import { ContextType, Fdc3Listener } from '../utility/Fdc3Api';
6+
import { ContextType, Fdc3Listener, getWorkbenchAgent } from '../utility/Fdc3Api';
77
import systemLogStore from './SystemLogStore';
88
import { nanoid } from 'nanoid';
9-
import { Channel, getAgent } from '@finos/fdc3';
9+
import { Channel } from '@finos/fdc3';
1010

1111
interface ListenerOptionType {
1212
title: string;
@@ -42,7 +42,7 @@ class AppChannelStore {
4242

4343
async getOrCreateChannel(channelId: string) {
4444
try {
45-
const currentAppChannelObj = await getAgent().then(agent => agent.getOrCreateChannel(channelId));
45+
const currentAppChannelObj = await getWorkbenchAgent().then(agent => agent.getOrCreateChannel(channelId));
4646
if (currentAppChannelObj) {
4747
const record = {
4848
id: channelId,
@@ -131,7 +131,7 @@ class AppChannelStore {
131131

132132
async leaveChannel() {
133133
try {
134-
const agent = await getAgent();
134+
const agent = await getWorkbenchAgent();
135135
//check that we're on a channel
136136
let currentChannel = await agent.getCurrentChannel();
137137
if (!currentChannel) {

toolbox/fdc3-workbench/src/store/ChannelStore.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*/
55
import { makeObservable, observable, action, runInAction } from 'mobx';
66
import systemLogStore from './SystemLogStore';
7-
import { Channel, getAgent } from '@finos/fdc3';
7+
import { Channel } from '@finos/fdc3';
8+
import { getWorkbenchAgent } from '../utility/Fdc3Api';
89

910
class ChannelStore {
1011
userChannels: Channel[] = [];
@@ -25,7 +26,7 @@ class ChannelStore {
2526
}
2627

2728
async getCurrentUserChannel() {
28-
const agent = await getAgent();
29+
const agent = await getWorkbenchAgent();
2930
try {
3031
const userChannel = await agent.getCurrentChannel();
3132
runInAction(() => {
@@ -50,7 +51,7 @@ class ChannelStore {
5051
}
5152

5253
async getUserChannels() {
53-
const agent = await getAgent();
54+
const agent = await getWorkbenchAgent();
5455
//defer retrieving channels until fdc3 API is ready
5556
try {
5657
//backwards compatibility for FDC3 < 2.0
@@ -78,7 +79,7 @@ class ChannelStore {
7879
}
7980

8081
async joinUserChannel(channelId: string) {
81-
const agent = await getAgent();
82+
const agent = await getWorkbenchAgent();
8283
try {
8384
//backwards compatability for 1.2
8485
const joinUserChannel = agent.joinUserChannel ?? agent.joinChannel;
@@ -107,7 +108,7 @@ class ChannelStore {
107108
}
108109

109110
async leaveUserChannel() {
110-
const agent = await getAgent();
111+
const agent = await getWorkbenchAgent();
111112
try {
112113
//check that we're on a channel
113114
let currentUserChannel = await agent.getCurrentChannel();

toolbox/fdc3-workbench/src/store/ContextStore.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
* Copyright FINOS FDC3 contributors - see NOTICE file
44
*/
55
import { makeObservable, observable, runInAction, action, toJS } from 'mobx';
6-
import { ContextType, Fdc3Listener } from '../utility/Fdc3Api';
6+
import { ContextType, Fdc3Listener, getWorkbenchAgent } from '../utility/Fdc3Api';
77
import { nanoid } from 'nanoid';
88
import { contexts } from '../fixtures/contexts';
99
import systemLogStore from './SystemLogStore';
1010
import { v4 as uuidv4 } from 'uuid';
11-
import { getAgent } from '@finos/fdc3';
1211

1312
export type ContextItem = {
1413
id: string;
@@ -91,7 +90,7 @@ class ContextStore {
9190
}
9291

9392
async broadcast(context: ContextType) {
94-
const agent = await getAgent();
93+
const agent = await getWorkbenchAgent();
9594

9695
if (!context) {
9796
systemLogStore.addLog({
@@ -137,7 +136,7 @@ class ContextStore {
137136
if (typeof contextType === 'string') {
138137
const listenerId = nanoid();
139138

140-
const agent = await getAgent();
139+
const agent = await getWorkbenchAgent();
141140

142141
// TODO: remove window after fixing https://github.com/finos/FDC3/issues/435
143142
const contextListener = await agent.addContextListener(

toolbox/fdc3-workbench/src/store/IntentStore.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
* Copyright FINOS FDC3 contributors - see NOTICE file
44
*/
55
import { makeObservable, observable, action, runInAction, toJS } from 'mobx';
6-
import { ContextType, IntentResolution, Fdc3Listener, AppMetadata, PrivateChannel } from '../utility/Fdc3Api';
6+
import {
7+
ContextType,
8+
IntentResolution,
9+
Fdc3Listener,
10+
AppMetadata,
11+
PrivateChannel,
12+
getWorkbenchAgent,
13+
} from '../utility/Fdc3Api';
714
import { nanoid } from 'nanoid';
815
import { intentTypes } from '../fixtures/intentTypes';
916
import systemLogStore from './SystemLogStore';
1017
import appChannelStore from './AppChannelStore';
1118
import privateChannelStore from './PrivateChannelStore';
12-
import { Channel, getAgent, IntentResult } from '@finos/fdc3';
19+
import { Channel, IntentResult } from '@finos/fdc3';
1320

1421
type IntentItem = { title: string; value: string };
1522

@@ -40,7 +47,7 @@ class IntentStore {
4047
try {
4148
const listenerId = nanoid();
4249

43-
const agent = await getAgent();
50+
const agent = await getWorkbenchAgent();
4451

4552
const intentListener = await agent.addIntentListener(
4653
intent,
@@ -146,7 +153,7 @@ class IntentStore {
146153
}
147154

148155
async raiseIntent(intent: string, context: ContextType, app?: AppMetadata) {
149-
const agent = await getAgent();
156+
const agent = await getWorkbenchAgent();
150157

151158
if (!context) {
152159
systemLogStore.addLog({
@@ -187,7 +194,7 @@ class IntentStore {
187194
}
188195

189196
async raiseIntentForContext(context: ContextType, app?: AppMetadata) {
190-
const agent = await getAgent();
197+
const agent = await getWorkbenchAgent();
191198

192199
if (!context) {
193200
systemLogStore.addLog({

toolbox/fdc3-workbench/src/store/PrivateChannelStore.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { makeObservable, observable, action, runInAction, toJS } from 'mobx';
66
import { ContextType, Fdc3Listener, PrivateChannel } from '../utility/Fdc3Api';
77
import systemLogStore from './SystemLogStore';
88
import { nanoid } from 'nanoid';
9-
import { getAgent } from '@finos/fdc3';
10-
9+
import { getWorkbenchAgent } from '../utility/Fdc3Api';
1110
// interface ListenerOptionType {
1211
// title: string;
1312
// value: string;
@@ -37,7 +36,7 @@ class PrivateChannelStore {
3736

3837
async createPrivateChannel() {
3938
try {
40-
const currentPrivateChannel: any = await getAgent().then(agent => agent.createPrivateChannel());
39+
const currentPrivateChannel: any = await getWorkbenchAgent().then(agent => agent.createPrivateChannel());
4140
const isSuccess = currentPrivateChannel !== null;
4241
if (isSuccess) {
4342
this.privateChannelsList.push(currentPrivateChannel);

toolbox/fdc3-workbench/src/utility/Fdc3Api.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ export type IntentTargetOption = {
6767

6868
export type ContextTargetOption = { intent: string; targetOptions: IntentTargetOption[] };
6969

70+
export function getWorkbenchAgent(): Promise<fdc3_2.DesktopAgent> {
71+
return fdc3_2.getAgent({
72+
dontSetWindowFdc3: false,
73+
});
74+
}
75+
7076
export async function getTargetOptions(intent: string, context: ContextType): Promise<IntentTargetOption[]> {
71-
const agent = await fdc3_2.getAgent();
77+
const agent = await getWorkbenchAgent();
7278

7379
let appIntent = await agent.findIntent(intent, context);
7480
if (!appIntent?.apps) {
@@ -124,7 +130,7 @@ export async function getTargetOptions(intent: string, context: ContextType): Pr
124130
}
125131

126132
export async function getTargetOptionsForContext(context: ContextType): Promise<IntentTargetOption[]> {
127-
const agent = await fdc3_2.getAgent();
133+
const agent = await getWorkbenchAgent();
128134

129135
let appIntents = await agent.findIntentsByContext(context);
130136
if (appIntents.length === 0) {

0 commit comments

Comments
 (0)