Skip to content

Commit 8c53525

Browse files
committed
Example raiseIntent
1 parent 22d8e99 commit 8c53525

File tree

6 files changed

+73
-16
lines changed

6 files changed

+73
-16
lines changed

frameworks/react/workspace-platform-starter/README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# React Wrapper for Workspace Platform Starter
22

3-
This project provides a React wrapper for the [workspace-platform-starter](https://github.com/built-on-openfin/workspace-starter/tree/main/how-to/workspace-platform-starter) for teams
4-
who prefer to use the build tooling available in the React ecosystem such as hot reloading.
3+
This project provides a React wrapper for the [workspace-platform-starter](https://github.com/built-on-openfin/workspace-starter/tree/main/how-to/workspace-platform-starter) for teams who prefer to use the build tooling available in the React ecosystem for a familiar development experience.
54

6-
The workspace platform starter source files are for demonstration purposes and to help get started building your own project. Once the source is added to your project, consider it your
7-
source code to manage for your production build. Once initial setup is complete, you should review the features you need and turn off many of the modules in the manifest.fin.json, and
8-
remove many of the app endpoints listed in "appProvider" / "endpointIds".
5+
To use this project, the source files are manually copied into the project from the [workspace-platform-starter](https://github.com/built-on-openfin/workspace-starter/tree/main/how-to/workspace-platform-starter) project. A simple React-based provider demonstrates how to bootstrap a platform.
6+
7+
This can then form the basis of your own OpenFin platform. The source within the /openfin folder becomes your source code to customize as you need to.
8+
9+
Once setup, see the next steps section below.
910

1011
## Prerequsites
1112

@@ -21,20 +22,20 @@ Clone the main workspace-starter repo:
2122
git clone https://github.com/built-on-openfin/workspace-starter.git --depth=1
2223
```
2324

24-
Manually copy the following folders from the **how-to/workspace-platform-starter** directory:
25+
Manually copy the following folders from the **how-to/workspace-platform-starter** directory into the openfin folder:
2526

2627
```
27-
client/src/framework
28-
client/src/modules
29-
public/common
28+
client/src/framework -> openfin/framework
29+
client/src/modules -> openfin/modules
30+
public/common -> openfin/common
3031
```
3132

32-
And paste them into the **/openfin** folder in this project so that you have:
33+
The **/openfin** folder in this project should then look like:
3334

3435
```
35-
/openfin/common
3636
/openfin/framework
3737
/openfin/modules
38+
/openfin/common
3839
```
3940

4041
### Develop
@@ -62,5 +63,12 @@ npm run preview
6263
```
6364
Launch [fin://localhost:8080/manifest.fin.json](fin://localhost:8080/manifest.fin.json)
6465

66+
## Next steps
6567

68+
- Remove or disable modules you don't need in public/manifest.fin.json
69+
- If necessary, remove modules from the build step in rollup.config.mjs
70+
- Remove the example app endpoints listed in "appProvider" / "endpointIds" in manifest.fin.json
71+
- Define your apps in /public/apps.json
72+
- Customize your theme in the themeProvider section of the manifest.fin.json
73+
- Follow the [how-to](https://github.com/built-on-openfin/workspace-starter/tree/main/how-to/workspace-platform-starter/docs) documentation to further customize your platform
6674

frameworks/react/workspace-platform-starter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "workspace-platform-starter",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
77
"prestart": "npm run build:openfin",

frameworks/react/workspace-platform-starter/public/apps.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"manifest": {
88
"name": "view-1",
99
"url": "http://localhost:8080/view1",
10-
"autoShow": false
10+
"autoShow": false,
11+
"fdc3InteropApi": "2.0"
1112
},
1213
"manifestType": "inline-view",
1314
"icons": [{ "src": "http://localhost:8080/favicon.png" }],
@@ -23,12 +24,21 @@
2324
"manifest": {
2425
"name": "view-2",
2526
"url": "http://localhost:8080/view2",
26-
"autoShow": false
27+
"autoShow": false,
28+
"fdc3InteropApi": "2.0"
2729
},
2830
"manifestType": "inline-view",
2931
"icons": [{ "src": "http://localhost:8080/favicon.png" }],
3032
"contactEmail": "[email protected]",
3133
"supportEmail": "[email protected]",
32-
"publisher": "OpenFin"
34+
"publisher": "OpenFin",
35+
"intents": [
36+
{
37+
"name": "ViewQuote",
38+
"displayName": "View Quote",
39+
"contexts": ["custom.instrument"],
40+
"customConfig": {}
41+
}
42+
]
3343
}
3444
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { type Context } from '@finos/fdc3';
2+
import { useCallback } from 'react';
3+
4+
export function useRaiseIntent() {
5+
return useCallback((intentName: string, context: Context) => {
6+
if (window.fdc3) {
7+
return window.fdc3.raiseIntent(intentName, context);
8+
} else {
9+
console.log('fdc3 not found');
10+
}
11+
}, []);
12+
}

frameworks/react/workspace-platform-starter/src/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ h1 {
3939
line-height: 1.1;
4040
}
4141

42+
.flex-col {
43+
display: flex;
44+
flex-direction: column;
45+
}
46+
4247
button {
4348
border-radius: 8px;
4449
border: 1px solid transparent;
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
import { useRaiseIntent } from '../hooks/useRaiseIntent';
2+
13
export function View1() {
2-
return <div>View 1</div>;
4+
const raiseIntent = useRaiseIntent();
5+
6+
const handleViewContact = () => {
7+
raiseIntent('ViewContact', { type: 'fdc3.contact' })
8+
}
9+
10+
const handleViewQuote = () => {
11+
raiseIntent('ViewQuote', { type: 'custom.instrument' })
12+
}
13+
14+
15+
return (
16+
<div className="flex-col">
17+
<button type="button" onClick={handleViewContact}>
18+
View Contact
19+
</button>
20+
<button type="button" onClick={handleViewQuote}>
21+
View Quote
22+
</button>
23+
</div>
24+
);
325
}

0 commit comments

Comments
 (0)