@thoughtspot/visual-embed-sdk 1.9.0-alpha.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +50 -20
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/liveboard.d.ts +7 -0
- package/dist/src/embed/search.d.ts +4 -0
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/react/index.d.ts +7 -5
- package/dist/src/react/util.d.ts +1 -1
- package/dist/src/types.d.ts +18 -9
- package/dist/tsembed.es.js +24 -12
- package/dist/tsembed.js +24 -12
- package/lib/package.json +1 -1
- package/lib/src/auth.js +1 -1
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +5 -5
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.js +1 -1
- package/lib/src/embed/liveboard.d.ts +7 -0
- package/lib/src/embed/liveboard.js +4 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +11 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +4 -0
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/react/index.d.ts +7 -5
- package/lib/src/react/index.js +10 -3
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +34 -5
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/react/util.d.ts +1 -1
- package/lib/src/react/util.js.map +1 -1
- package/lib/src/types.d.ts +18 -9
- package/lib/src/types.js +16 -7
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +31 -11
- package/package.json +1 -1
- package/src/auth.spec.ts +15 -5
- package/src/auth.ts +1 -1
- package/src/embed/base.ts +1 -1
- package/src/embed/liveboard.spec.ts +13 -0
- package/src/embed/liveboard.ts +11 -0
- package/src/embed/search.ts +5 -0
- package/src/embed/ts-embed.ts +1 -1
- package/src/react/index.spec.tsx +46 -4
- package/src/react/index.tsx +33 -22
- package/src/react/util.ts +2 -1
- package/src/types.ts +16 -7
|
@@ -134,7 +134,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
|
|
|
134
134
|
*/
|
|
135
135
|
export const prefetch: (url?: string) => void;
|
|
136
136
|
/**
|
|
137
|
-
* Initialize the ThoughtSpot embed
|
|
137
|
+
* Initialize the ThoughtSpot embed SDK globally and perform
|
|
138
138
|
* authentication if applicable.
|
|
139
139
|
* @param embedConfig The configuration object containing ThoughtSpot host,
|
|
140
140
|
* authentication mechanism and so on.
|
|
@@ -203,6 +203,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
203
203
|
* Liveboard page will be read-only (no X buttons)
|
|
204
204
|
*/
|
|
205
205
|
preventLiveboardFilterRemoval?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Array of viz ids which should be visible when the liveboard
|
|
208
|
+
* first renders. This can be changed by triggering the "SetVisibleVizs"
|
|
209
|
+
* event.
|
|
210
|
+
* @version 1.9.1 or later
|
|
211
|
+
*/
|
|
212
|
+
visibleVizs?: string[];
|
|
206
213
|
/**
|
|
207
214
|
* To support backward compatibilty
|
|
208
215
|
* @hidden
|
|
@@ -277,6 +284,10 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
277
284
|
* using raw answer data.
|
|
278
285
|
*/
|
|
279
286
|
hideResults?: boolean;
|
|
287
|
+
/**
|
|
288
|
+
* If set to true, expands all the data sources panel.
|
|
289
|
+
*/
|
|
290
|
+
expandAllDataSource?: boolean;
|
|
280
291
|
/**
|
|
281
292
|
* If set to true, the Search Assist feature is enabled.
|
|
282
293
|
*/
|
|
@@ -589,7 +600,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
589
600
|
/**
|
|
590
601
|
* One or more data columns have been selected.
|
|
591
602
|
* @return columnIds - the list of columns
|
|
592
|
-
* @version SDK: 1.
|
|
603
|
+
* @version SDK: 1.10.0 | ThoughtSpot: 8.2.0.cl
|
|
593
604
|
*/
|
|
594
605
|
AddRemoveColumns = "addRemoveColumns",
|
|
595
606
|
/**
|
|
@@ -661,7 +672,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
661
672
|
* Emitted when any modal is closed in the app
|
|
662
673
|
* @version 1.6.0 or later
|
|
663
674
|
*/
|
|
664
|
-
DialogClose = "dialog-close"
|
|
675
|
+
DialogClose = "dialog-close",
|
|
676
|
+
/**
|
|
677
|
+
* Emitted when a liveboard has completed rendering,
|
|
678
|
+
* this event can be used as a hook to trigger events on the
|
|
679
|
+
* rendered liveboard
|
|
680
|
+
* @version 1.9.1 or later
|
|
681
|
+
*/
|
|
682
|
+
LiveboardRendered = "PinboardRendered"
|
|
665
683
|
}
|
|
666
684
|
/**
|
|
667
685
|
* Event types that can be triggered by the host application
|
|
@@ -707,7 +725,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
707
725
|
* Update the runtime filters. The runtime filters passed here are extended
|
|
708
726
|
* on to the existing runtime filters if they exist.
|
|
709
727
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
710
|
-
* @version 1.
|
|
728
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
711
729
|
*/
|
|
712
730
|
UpdateRuntimeFilters = "UpdateRuntimeFilters"
|
|
713
731
|
}
|
|
@@ -736,6 +754,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
736
754
|
export enum Param {
|
|
737
755
|
DataSources = "dataSources",
|
|
738
756
|
DataSourceMode = "dataSourceMode",
|
|
757
|
+
ExpandAllDataSource = "expandAllDataSource",
|
|
739
758
|
DisableActions = "disableAction",
|
|
740
759
|
DisableActionReason = "disableHint",
|
|
741
760
|
ForceTable = "forceTable",
|
|
@@ -758,7 +777,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
758
777
|
ViewPortHeight = "viewPortHeight",
|
|
759
778
|
ViewPortWidth = "viewPortWidth",
|
|
760
779
|
VisibleActions = "visibleAction",
|
|
761
|
-
CustomCSSUrl = "customCssUrl"
|
|
780
|
+
CustomCSSUrl = "customCssUrl",
|
|
781
|
+
visibleVizs = "pinboardVisibleVizs"
|
|
762
782
|
}
|
|
763
783
|
/**
|
|
764
784
|
* The list of actions that can be performed on visual ThoughtSpot
|
|
@@ -826,23 +846,23 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
826
846
|
RequestAccess = "requestAccess",
|
|
827
847
|
QueryDetailsButtons = "queryDetailsButtons",
|
|
828
848
|
/**
|
|
829
|
-
* @version SDK: 1.
|
|
849
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
830
850
|
*/
|
|
831
851
|
Monitor = "createMonitor",
|
|
832
852
|
/**
|
|
833
|
-
* @version SDK: 1.
|
|
853
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
834
854
|
*/
|
|
835
855
|
AnswerDelete = "onDeleteAnswer",
|
|
836
856
|
/**
|
|
837
|
-
* @version SDK: 1.
|
|
857
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
838
858
|
*/
|
|
839
859
|
AnswerChartSwitcher = "answerChartSwitcher",
|
|
840
860
|
/**
|
|
841
|
-
* @version SDK: 1.
|
|
861
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
842
862
|
*/
|
|
843
863
|
AddToFavorites = "addToFavorites",
|
|
844
864
|
/**
|
|
845
|
-
* @version SDK: 1.
|
|
865
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
846
866
|
*/
|
|
847
867
|
EditDetails = "editDetails"
|
|
848
868
|
}
|
|
@@ -937,7 +957,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
937
957
|
* This is an object (key/val) of override flags which will be applied
|
|
938
958
|
* to the internal embedded object. This can be used to add any
|
|
939
959
|
* URL flag.
|
|
940
|
-
* @version 1.8.0
|
|
960
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
941
961
|
*/
|
|
942
962
|
additionalFlags?: {
|
|
943
963
|
[key: string]: string | number | boolean;
|
package/package.json
CHANGED
package/src/auth.spec.ts
CHANGED
|
@@ -119,11 +119,15 @@ describe('Unit test for auth', () => {
|
|
|
119
119
|
jest.spyOn(
|
|
120
120
|
authService,
|
|
121
121
|
'fetchAuthTokenService',
|
|
122
|
-
).mockImplementation(() => ({ text: () =>
|
|
122
|
+
).mockImplementation(() => ({ text: () => Promise.resolve('abc') }));
|
|
123
123
|
jest.spyOn(authService, 'fetchAuthService');
|
|
124
124
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess);
|
|
125
125
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
126
|
-
expect(authService.fetchAuthService).
|
|
126
|
+
expect(authService.fetchAuthService).toBeCalledWith(
|
|
127
|
+
thoughtSpotHost,
|
|
128
|
+
username,
|
|
129
|
+
'authToken',
|
|
130
|
+
);
|
|
127
131
|
});
|
|
128
132
|
|
|
129
133
|
test('doTokenAuth: when user is not loggedIn & getAuthToken not present, isLoggedIn should called', async () => {
|
|
@@ -133,15 +137,21 @@ describe('Unit test for auth', () => {
|
|
|
133
137
|
jest.spyOn(
|
|
134
138
|
authService,
|
|
135
139
|
'fetchAuthTokenService',
|
|
136
|
-
).mockImplementation(() =>
|
|
140
|
+
).mockImplementation(() =>
|
|
141
|
+
Promise.resolve({ text: () => Promise.resolve('abc') }),
|
|
142
|
+
);
|
|
137
143
|
jest.spyOn(authService, 'fetchAuthService');
|
|
138
144
|
await authInstance.doTokenAuth(
|
|
139
145
|
embedConfig.doTokenAuthFailureWithoutGetAuthToken,
|
|
140
146
|
);
|
|
141
|
-
executeAfterWait(() => {
|
|
147
|
+
await executeAfterWait(() => {
|
|
142
148
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
143
149
|
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
144
|
-
expect(authService.fetchAuthService).
|
|
150
|
+
expect(authService.fetchAuthService).toBeCalledWith(
|
|
151
|
+
thoughtSpotHost,
|
|
152
|
+
username,
|
|
153
|
+
'abc',
|
|
154
|
+
);
|
|
145
155
|
});
|
|
146
156
|
});
|
|
147
157
|
|
package/src/auth.ts
CHANGED
|
@@ -102,7 +102,7 @@ export const doTokenAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
102
102
|
authToken = await getAuthToken();
|
|
103
103
|
} else {
|
|
104
104
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
105
|
-
authToken = response.text();
|
|
105
|
+
authToken = await response.text();
|
|
106
106
|
}
|
|
107
107
|
await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
108
108
|
loggedInStatus = false;
|
package/src/embed/base.ts
CHANGED
|
@@ -52,7 +52,7 @@ export const prefetch = (url?: string): void => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Initialize the ThoughtSpot embed
|
|
55
|
+
* Initialize the ThoughtSpot embed SDK globally and perform
|
|
56
56
|
* authentication if applicable.
|
|
57
57
|
* @param embedConfig The configuration object containing ThoughtSpot host,
|
|
58
58
|
* authentication mechanism and so on.
|
|
@@ -196,4 +196,17 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
196
196
|
);
|
|
197
197
|
});
|
|
198
198
|
});
|
|
199
|
+
test('Should set the visible vizs', async () => {
|
|
200
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
201
|
+
...defaultViewConfig,
|
|
202
|
+
liveboardId,
|
|
203
|
+
visibleVizs: ['abcd', 'pqrs'],
|
|
204
|
+
} as LiveboardViewConfig);
|
|
205
|
+
liveboardEmbed.render();
|
|
206
|
+
await executeAfterWait(() => {
|
|
207
|
+
expect(getIFrameSrc()).toBe(
|
|
208
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}&pinboardVisibleVizs=[%22abcd%22,%22pqrs%22]${prefixParams}#/embed/viz/${liveboardId}`,
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
199
212
|
});
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -62,6 +62,13 @@ export interface LiveboardViewConfig extends ViewConfig {
|
|
|
62
62
|
* Liveboard page will be read-only (no X buttons)
|
|
63
63
|
*/
|
|
64
64
|
preventLiveboardFilterRemoval?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Array of viz ids which should be visible when the liveboard
|
|
67
|
+
* first renders. This can be changed by triggering the "SetVisibleVizs"
|
|
68
|
+
* event.
|
|
69
|
+
* @version 1.9.1 or later
|
|
70
|
+
*/
|
|
71
|
+
visibleVizs?: string[];
|
|
65
72
|
/**
|
|
66
73
|
* To support backward compatibilty
|
|
67
74
|
* @hidden
|
|
@@ -93,6 +100,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
93
100
|
enableVizTransformations,
|
|
94
101
|
fullHeight,
|
|
95
102
|
defaultHeight,
|
|
103
|
+
visibleVizs,
|
|
96
104
|
} = this.viewConfig;
|
|
97
105
|
|
|
98
106
|
const preventLiveboardFilterRemoval =
|
|
@@ -113,6 +121,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
113
121
|
if (preventLiveboardFilterRemoval) {
|
|
114
122
|
params[Param.preventLiveboardFilterRemoval] = true;
|
|
115
123
|
}
|
|
124
|
+
if (visibleVizs) {
|
|
125
|
+
params[Param.visibleVizs] = visibleVizs;
|
|
126
|
+
}
|
|
116
127
|
params[Param.livedBoardEmbed] = true;
|
|
117
128
|
const queryParams = getQueryParamString(params, true);
|
|
118
129
|
|
package/src/embed/search.ts
CHANGED
|
@@ -49,6 +49,10 @@ export interface SearchViewConfig extends ViewConfig {
|
|
|
49
49
|
* using raw answer data.
|
|
50
50
|
*/
|
|
51
51
|
hideResults?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* If set to true, expands all the data sources panel.
|
|
54
|
+
*/
|
|
55
|
+
expandAllDataSource?: boolean;
|
|
52
56
|
/**
|
|
53
57
|
* If set to true, the Search Assist feature is enabled.
|
|
54
58
|
*/
|
|
@@ -126,6 +130,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
126
130
|
private getIFrameSrc(answerId: string, dataSources?: string[]) {
|
|
127
131
|
const {
|
|
128
132
|
hideResults,
|
|
133
|
+
expandAllDataSource,
|
|
129
134
|
enableSearchAssist,
|
|
130
135
|
forceTable,
|
|
131
136
|
searchOptions,
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -114,7 +114,7 @@ export interface ViewConfig {
|
|
|
114
114
|
* This is an object (key/val) of override flags which will be applied
|
|
115
115
|
* to the internal embedded object. This can be used to add any
|
|
116
116
|
* URL flag.
|
|
117
|
-
* @version 1.8.0
|
|
117
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
118
118
|
*/
|
|
119
119
|
additionalFlags?: { [key: string]: string | number | boolean };
|
|
120
120
|
}
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -3,13 +3,14 @@ import '@testing-library/jest-dom';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import { cleanup, fireEvent, render, waitFor } from '@testing-library/react';
|
|
5
5
|
import {
|
|
6
|
+
executeAfterWait,
|
|
6
7
|
getIFrameEl,
|
|
7
8
|
getIFrameSrc,
|
|
8
9
|
postMessageToParent,
|
|
9
10
|
} from '../test/test-utils';
|
|
10
|
-
import { SearchEmbed, AppEmbed,
|
|
11
|
+
import { SearchEmbed, AppEmbed, LiveboardEmbed, useEmbedRef } from './index';
|
|
11
12
|
import { AuthType, init } from '../index';
|
|
12
|
-
import { EmbedEvent } from '../types';
|
|
13
|
+
import { EmbedEvent, HostEvent } from '../types';
|
|
13
14
|
import { version } from '../../package.json';
|
|
14
15
|
|
|
15
16
|
const thoughtSpotHost = 'localhost';
|
|
@@ -35,7 +36,7 @@ describe('React Components', () => {
|
|
|
35
36
|
);
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
it('Should attach event listeners', async () => {
|
|
39
|
+
it('Should attach event listeners', async (done) => {
|
|
39
40
|
const userGUID = 'absfdfgd';
|
|
40
41
|
const { container } = render(
|
|
41
42
|
<SearchEmbed
|
|
@@ -44,6 +45,7 @@ describe('React Components', () => {
|
|
|
44
45
|
}}
|
|
45
46
|
onAuthInit={(e) => {
|
|
46
47
|
expect(e.data.userGUID).toEqual(userGUID);
|
|
48
|
+
done();
|
|
47
49
|
}}
|
|
48
50
|
/>,
|
|
49
51
|
);
|
|
@@ -63,7 +65,47 @@ describe('React Components', () => {
|
|
|
63
65
|
//
|
|
64
66
|
});
|
|
65
67
|
|
|
66
|
-
describe('
|
|
68
|
+
describe('LiveboardEmbed', () => {
|
|
67
69
|
//
|
|
70
|
+
it('Should be able to trigger events on the embed using refs', async () => {
|
|
71
|
+
const TestComponent = () => {
|
|
72
|
+
const embedRef = useEmbedRef();
|
|
73
|
+
const onLiveboardRendered = () => {
|
|
74
|
+
embedRef.current.trigger(HostEvent.SetVisibleVizs, [
|
|
75
|
+
'viz1',
|
|
76
|
+
'viz2',
|
|
77
|
+
]);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<LiveboardEmbed
|
|
82
|
+
ref={embedRef}
|
|
83
|
+
liveboardId="abcd"
|
|
84
|
+
onLiveboardRendered={onLiveboardRendered}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const { container } = render(<TestComponent />);
|
|
90
|
+
|
|
91
|
+
await waitFor(() => getIFrameEl(container));
|
|
92
|
+
const iframe = getIFrameEl(container);
|
|
93
|
+
jest.spyOn(iframe.contentWindow, 'postMessage');
|
|
94
|
+
postMessageToParent(iframe.contentWindow, {
|
|
95
|
+
type: EmbedEvent.LiveboardRendered,
|
|
96
|
+
data: {
|
|
97
|
+
userGUID: 'abcd',
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
await executeAfterWait(() => {
|
|
101
|
+
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(
|
|
102
|
+
{
|
|
103
|
+
type: HostEvent.SetVisibleVizs,
|
|
104
|
+
data: ['viz1', 'viz2'],
|
|
105
|
+
},
|
|
106
|
+
`http://${thoughtSpotHost}`,
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
68
110
|
});
|
|
69
111
|
});
|
package/src/react/index.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '../embed/liveboard';
|
|
8
8
|
import { TsEmbed, ViewConfig } from '../embed/ts-embed';
|
|
9
9
|
|
|
10
|
-
import { EmbedEvent
|
|
10
|
+
import { EmbedEvent } from '../types';
|
|
11
11
|
import { EmbedProps, getViewPropsAndListeners } from './util';
|
|
12
12
|
|
|
13
13
|
const componentFactory = <
|
|
@@ -16,28 +16,35 @@ const componentFactory = <
|
|
|
16
16
|
V extends ViewConfig
|
|
17
17
|
>(
|
|
18
18
|
EmbedConstructor: T,
|
|
19
|
-
) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
eventName
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
) =>
|
|
20
|
+
React.forwardRef<TsEmbed, U>(
|
|
21
|
+
(props: U, forwardedRef: React.MutableRefObject<TsEmbed>) => {
|
|
22
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
23
|
+
const { className, ...embedProps } = props;
|
|
24
|
+
const { viewConfig, listeners } = getViewPropsAndListeners<
|
|
25
|
+
Omit<U, 'className'>,
|
|
26
|
+
V
|
|
27
|
+
>(embedProps);
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
const tsEmbed = new EmbedConstructor(ref!.current, {
|
|
30
|
+
...viewConfig,
|
|
31
|
+
});
|
|
32
|
+
Object.keys(listeners).forEach((eventName) => {
|
|
33
|
+
tsEmbed.on(
|
|
34
|
+
eventName as EmbedEvent,
|
|
35
|
+
listeners[eventName as EmbedEvent],
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
tsEmbed.render();
|
|
39
|
+
if (forwardedRef) {
|
|
40
|
+
// eslint-disable-next-line no-param-reassign
|
|
41
|
+
forwardedRef.current = tsEmbed;
|
|
42
|
+
}
|
|
43
|
+
}, [embedProps]);
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
}
|
|
45
|
+
return <div data-testid="tsEmbed" ref={ref}></div>;
|
|
46
|
+
},
|
|
47
|
+
);
|
|
41
48
|
|
|
42
49
|
interface SearchProps extends EmbedProps, SearchViewConfig {}
|
|
43
50
|
|
|
@@ -68,3 +75,7 @@ export const PinboardEmbed = componentFactory<
|
|
|
68
75
|
LiveboardProps,
|
|
69
76
|
LiveboardViewConfig
|
|
70
77
|
>(_LiveboardEmbed);
|
|
78
|
+
|
|
79
|
+
export const useEmbedRef = (): React.MutableRefObject<TsEmbed> => {
|
|
80
|
+
return React.useRef<TsEmbed>(null);
|
|
81
|
+
};
|
package/src/react/util.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { EmbedEvent, MessageCallback } from '../types';
|
|
|
2
2
|
import { ViewConfig } from '../embed/ts-embed';
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line prettier/prettier
|
|
5
|
-
export type EmbedEventHandlers = { [key in EmbedEvent as `on${Capitalize<key>}`]?: MessageCallback };
|
|
5
|
+
export type EmbedEventHandlers = { [key in keyof typeof EmbedEvent as `on${Capitalize<key>}`]?: MessageCallback };
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
export interface EmbedProps extends ViewConfig, EmbedEventHandlers {
|
|
8
9
|
className?: string;
|
package/src/types.ts
CHANGED
|
@@ -291,7 +291,7 @@ export enum EmbedEvent {
|
|
|
291
291
|
/**
|
|
292
292
|
* One or more data columns have been selected.
|
|
293
293
|
* @return columnIds - the list of columns
|
|
294
|
-
* @version SDK: 1.
|
|
294
|
+
* @version SDK: 1.10.0 | ThoughtSpot: 8.2.0.cl
|
|
295
295
|
*/
|
|
296
296
|
AddRemoveColumns = 'addRemoveColumns',
|
|
297
297
|
/**
|
|
@@ -364,6 +364,13 @@ export enum EmbedEvent {
|
|
|
364
364
|
* @version 1.6.0 or later
|
|
365
365
|
*/
|
|
366
366
|
DialogClose = 'dialog-close',
|
|
367
|
+
/**
|
|
368
|
+
* Emitted when a liveboard has completed rendering,
|
|
369
|
+
* this event can be used as a hook to trigger events on the
|
|
370
|
+
* rendered liveboard
|
|
371
|
+
* @version 1.9.1 or later
|
|
372
|
+
*/
|
|
373
|
+
LiveboardRendered = 'PinboardRendered',
|
|
367
374
|
}
|
|
368
375
|
|
|
369
376
|
/**
|
|
@@ -411,7 +418,7 @@ export enum HostEvent {
|
|
|
411
418
|
* Update the runtime filters. The runtime filters passed here are extended
|
|
412
419
|
* on to the existing runtime filters if they exist.
|
|
413
420
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
414
|
-
* @version 1.
|
|
421
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
415
422
|
*/
|
|
416
423
|
UpdateRuntimeFilters = 'UpdateRuntimeFilters',
|
|
417
424
|
}
|
|
@@ -444,6 +451,7 @@ export enum DataSourceVisualMode {
|
|
|
444
451
|
export enum Param {
|
|
445
452
|
DataSources = 'dataSources',
|
|
446
453
|
DataSourceMode = 'dataSourceMode',
|
|
454
|
+
ExpandAllDataSource = 'expandAllDataSource',
|
|
447
455
|
DisableActions = 'disableAction',
|
|
448
456
|
DisableActionReason = 'disableHint',
|
|
449
457
|
ForceTable = 'forceTable',
|
|
@@ -467,6 +475,7 @@ export enum Param {
|
|
|
467
475
|
ViewPortWidth = 'viewPortWidth',
|
|
468
476
|
VisibleActions = 'visibleAction',
|
|
469
477
|
CustomCSSUrl = 'customCssUrl',
|
|
478
|
+
visibleVizs = 'pinboardVisibleVizs',
|
|
470
479
|
}
|
|
471
480
|
|
|
472
481
|
/**
|
|
@@ -536,23 +545,23 @@ export enum Action {
|
|
|
536
545
|
RequestAccess = 'requestAccess',
|
|
537
546
|
QueryDetailsButtons = 'queryDetailsButtons',
|
|
538
547
|
/**
|
|
539
|
-
* @version SDK: 1.
|
|
548
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
540
549
|
*/
|
|
541
550
|
Monitor = 'createMonitor',
|
|
542
551
|
/**
|
|
543
|
-
* @version SDK: 1.
|
|
552
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
544
553
|
*/
|
|
545
554
|
AnswerDelete = 'onDeleteAnswer',
|
|
546
555
|
/**
|
|
547
|
-
* @version SDK: 1.
|
|
556
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
548
557
|
*/
|
|
549
558
|
AnswerChartSwitcher = 'answerChartSwitcher',
|
|
550
559
|
/**
|
|
551
|
-
* @version SDK: 1.
|
|
560
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
552
561
|
*/
|
|
553
562
|
AddToFavorites = 'addToFavorites',
|
|
554
563
|
/**
|
|
555
|
-
* @version SDK: 1.
|
|
564
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
556
565
|
*/
|
|
557
566
|
EditDetails = 'editDetails',
|
|
558
567
|
}
|