@thoughtspot/visual-embed-sdk 1.41.0 → 1.42.0
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/README.md +2 -4
- package/cjs/package.json +8 -8
- package/cjs/src/authToken.d.ts +1 -0
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +13 -3
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/authToken.spec.js +29 -0
- package/cjs/src/authToken.spec.js.map +1 -1
- package/cjs/src/css-variables.d.ts +54 -15
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/app.d.ts +16 -0
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +4 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +10 -0
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.d.ts +1 -0
- package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/cjs/src/embed/bodyless-conversation.js +7 -3
- package/cjs/src/embed/bodyless-conversation.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +3 -2
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +7 -2
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +33 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +13 -2
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +98 -11
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +1 -0
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +10 -6
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +20 -10
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts +1 -0
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +11 -7
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts +1 -0
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +7 -8
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +10 -10
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +7 -5
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +26 -9
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.d.ts +1 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +1 -0
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/react/all-types-export.spec.js +1 -1
- package/cjs/src/react/all-types-export.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +2 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +1 -1
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/react/util.js.map +1 -1
- package/cjs/src/react/util.spec.d.ts +2 -0
- package/cjs/src/react/util.spec.d.ts.map +1 -0
- package/cjs/src/react/util.spec.js +78 -0
- package/cjs/src/react/util.spec.js.map +1 -0
- package/cjs/src/types.d.ts +64 -9
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +59 -4
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils.d.ts +14 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +22 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +10 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-B_mxAan8.js → index-BpSohedu.js} +1 -1
- package/dist/src/authToken.d.ts +1 -0
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/css-variables.d.ts +54 -15
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +16 -0
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/bodyless-conversation.d.ts +1 -0
- package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +3 -2
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +33 -0
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +1 -0
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +1 -0
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +1 -0
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +7 -5
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/util.spec.d.ts +2 -0
- package/dist/src/react/util.spec.d.ts.map +1 -0
- package/dist/src/types.d.ts +64 -9
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +14 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +180 -47
- package/dist/tsembed-react.js +179 -46
- package/dist/tsembed.es.js +178 -46
- package/dist/tsembed.js +177 -45
- package/dist/visual-embed-sdk-react-full.d.ts +9312 -9842
- package/dist/visual-embed-sdk-react.d.ts +9184 -9848
- package/dist/visual-embed-sdk.d.ts +9351 -9459
- package/lib/package.json +8 -8
- package/lib/src/authToken.d.ts +1 -0
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +11 -2
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/authToken.spec.js +30 -1
- package/lib/src/authToken.spec.js.map +1 -1
- package/lib/src/css-variables.d.ts +54 -15
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/app.d.ts +16 -0
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +4 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +10 -0
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.d.ts +1 -0
- package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/lib/src/embed/bodyless-conversation.js +7 -3
- package/lib/src/embed/bodyless-conversation.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +3 -2
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +7 -2
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +33 -0
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +13 -2
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +98 -11
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/sage.d.ts +1 -0
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +10 -6
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/sage.spec.js +20 -10
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +1 -0
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +11 -7
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +1 -0
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +7 -8
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +11 -11
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +7 -5
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +26 -9
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +1 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +1 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/react/all-types-export.spec.js +1 -1
- package/lib/src/react/all-types-export.spec.js.map +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +2 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +1 -1
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/react/util.js.map +1 -1
- package/lib/src/react/util.spec.d.ts +2 -0
- package/lib/src/react/util.spec.d.ts.map +1 -0
- package/lib/src/react/util.spec.js +76 -0
- package/lib/src/react/util.spec.js.map +1 -0
- package/lib/src/types.d.ts +64 -9
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +59 -4
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils.d.ts +14 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +20 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +11 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +8 -8
- package/src/authToken.spec.ts +48 -1
- package/src/authToken.ts +13 -2
- package/src/css-variables.ts +55 -17
- package/src/embed/app.spec.ts +14 -0
- package/src/embed/app.ts +23 -1
- package/src/embed/bodyless-conversation.ts +8 -3
- package/src/embed/conversation.ts +19 -4
- package/src/embed/liveboard.spec.ts +126 -14
- package/src/embed/liveboard.ts +72 -24
- package/src/embed/sage.spec.ts +24 -10
- package/src/embed/sage.ts +14 -9
- package/src/embed/search-bar.tsx +14 -7
- package/src/embed/search.spec.ts +13 -14
- package/src/embed/search.ts +19 -8
- package/src/embed/ts-embed.spec.ts +1 -1
- package/src/embed/ts-embed.ts +35 -13
- package/src/errors.ts +1 -0
- package/src/react/all-types-export.spec.ts +1 -1
- package/src/react/index.spec.tsx +1 -1
- package/src/react/index.tsx +4 -2
- package/src/react/util.spec.tsx +88 -0
- package/src/react/util.ts +3 -3
- package/src/types.ts +125 -69
- package/src/utils.spec.ts +18 -0
- package/src/utils.ts +21 -0
- package/lib/src/visual-embed-sdk.d.ts +0 -9705
package/src/embed/sage.spec.ts
CHANGED
|
@@ -18,7 +18,7 @@ const defaultConfig: SageViewConfig = {
|
|
|
18
18
|
hideAutocompleteSuggestions: false,
|
|
19
19
|
hideSampleQuestions: false,
|
|
20
20
|
isProductTour: false,
|
|
21
|
-
dataPanelV2:
|
|
21
|
+
dataPanelV2: true,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const thoughtSpotHost = 'tshost';
|
|
@@ -43,7 +43,7 @@ describe('Sage embed tests', () => {
|
|
|
43
43
|
await executeAfterWait(() => {
|
|
44
44
|
expectUrlMatch(
|
|
45
45
|
getIFrameSrc(),
|
|
46
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
46
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
47
47
|
);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
@@ -54,7 +54,7 @@ describe('Sage embed tests', () => {
|
|
|
54
54
|
await executeAfterWait(() => {
|
|
55
55
|
expectUrlMatch(
|
|
56
56
|
getIFrameSrc(),
|
|
57
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
57
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=true&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
58
58
|
);
|
|
59
59
|
});
|
|
60
60
|
});
|
|
@@ -68,7 +68,7 @@ describe('Sage embed tests', () => {
|
|
|
68
68
|
await executeAfterWait(() => {
|
|
69
69
|
expectUrlMatch(
|
|
70
70
|
getIFrameSrc(),
|
|
71
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
71
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=true&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
72
72
|
);
|
|
73
73
|
});
|
|
74
74
|
});
|
|
@@ -82,7 +82,7 @@ describe('Sage embed tests', () => {
|
|
|
82
82
|
await executeAfterWait(() => {
|
|
83
83
|
expectUrlMatch(
|
|
84
84
|
getIFrameSrc(),
|
|
85
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
85
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=true&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
86
86
|
);
|
|
87
87
|
});
|
|
88
88
|
});
|
|
@@ -96,7 +96,7 @@ describe('Sage embed tests', () => {
|
|
|
96
96
|
await executeAfterWait(() => {
|
|
97
97
|
expectUrlMatch(
|
|
98
98
|
getIFrameSrc(),
|
|
99
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
99
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=true&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
100
100
|
);
|
|
101
101
|
});
|
|
102
102
|
});
|
|
@@ -110,7 +110,7 @@ describe('Sage embed tests', () => {
|
|
|
110
110
|
await executeAfterWait(() => {
|
|
111
111
|
expectUrlMatch(
|
|
112
112
|
getIFrameSrc(),
|
|
113
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
113
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=true&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
114
114
|
);
|
|
115
115
|
});
|
|
116
116
|
});
|
|
@@ -137,7 +137,7 @@ describe('Sage embed tests', () => {
|
|
|
137
137
|
await executeAfterWait(() => {
|
|
138
138
|
expectUrlMatch(
|
|
139
139
|
getIFrameSrc(),
|
|
140
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
140
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka?worksheet=worksheet-id`,
|
|
141
141
|
);
|
|
142
142
|
});
|
|
143
143
|
});
|
|
@@ -154,7 +154,7 @@ describe('Sage embed tests', () => {
|
|
|
154
154
|
await executeAfterWait(() => {
|
|
155
155
|
expectUrlMatch(
|
|
156
156
|
getIFrameSrc(),
|
|
157
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
157
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka?worksheet=worksheet-id&query=test%20query`,
|
|
158
158
|
);
|
|
159
159
|
});
|
|
160
160
|
});
|
|
@@ -171,7 +171,7 @@ describe('Sage embed tests', () => {
|
|
|
171
171
|
await executeAfterWait(() => {
|
|
172
172
|
expectUrlMatch(
|
|
173
173
|
getIFrameSrc(),
|
|
174
|
-
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=
|
|
174
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=true&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&hideAction=%5B%22reportError%22%5D#/embed/eureka?executeSearch=true&query=test-query`,
|
|
175
175
|
);
|
|
176
176
|
});
|
|
177
177
|
});
|
|
@@ -189,4 +189,18 @@ describe('Sage embed tests', () => {
|
|
|
189
189
|
);
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
|
+
|
|
193
|
+
test('should set enableDataPanelV2 to false if data panel v2 flag is false', async () => {
|
|
194
|
+
const sageEmbed = new SageEmbed(getRootEl(), {
|
|
195
|
+
...defaultConfig,
|
|
196
|
+
dataPanelV2: false,
|
|
197
|
+
});
|
|
198
|
+
await sageEmbed.render();
|
|
199
|
+
await executeAfterWait(() => {
|
|
200
|
+
expectUrlMatch(
|
|
201
|
+
getIFrameSrc(),
|
|
202
|
+
`http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
192
206
|
});
|
package/src/embed/sage.ts
CHANGED
|
@@ -153,12 +153,7 @@ export class SageEmbed extends V1Embed {
|
|
|
153
153
|
super(domSelector, viewConfig);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
* Constructs a map of parameters to be passed on to the
|
|
158
|
-
* embedded Eureka or Sage search page.
|
|
159
|
-
* @returns {string} query string
|
|
160
|
-
*/
|
|
161
|
-
protected getEmbedParams(): string {
|
|
156
|
+
protected getEmbedParamsObject() {
|
|
162
157
|
const {
|
|
163
158
|
disableWorksheetChange,
|
|
164
159
|
hideWorksheetSelector,
|
|
@@ -184,6 +179,16 @@ export class SageEmbed extends V1Embed {
|
|
|
184
179
|
params[Param.IsProductTour] = !!isProductTour;
|
|
185
180
|
params[Param.HideSageAnswerHeader] = !!hideSageAnswerHeader;
|
|
186
181
|
|
|
182
|
+
return params;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Constructs a map of parameters to be passed on to the
|
|
187
|
+
* embedded Eureka or Sage search page.
|
|
188
|
+
* @returns {string} query string
|
|
189
|
+
*/
|
|
190
|
+
protected getEmbedParams(): string {
|
|
191
|
+
const params = this.getEmbedParamsObject();
|
|
187
192
|
return getQueryParamString(params, true);
|
|
188
193
|
}
|
|
189
194
|
|
|
@@ -194,15 +199,15 @@ export class SageEmbed extends V1Embed {
|
|
|
194
199
|
*/
|
|
195
200
|
public getIFrameSrc(): string {
|
|
196
201
|
const path = 'eureka';
|
|
197
|
-
const postHashObj = {};
|
|
202
|
+
const postHashObj: Record<string, any> = {};
|
|
198
203
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams();
|
|
199
204
|
const {
|
|
200
205
|
dataSource, searchOptions,
|
|
201
206
|
} = this.viewConfig;
|
|
202
207
|
|
|
203
|
-
if (dataSource) postHashObj[Param.WorksheetId] = dataSource;
|
|
208
|
+
if (dataSource) (postHashObj as any)[Param.WorksheetId] = dataSource;
|
|
204
209
|
if (searchOptions?.searchQuery && searchOptions.executeSearch) {
|
|
205
|
-
postHashObj[Param.executeSearch] = true;
|
|
210
|
+
(postHashObj as any)[Param.executeSearch] = true;
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
let sagePostHashParams = new URLSearchParams(postHashObj).toString();
|
package/src/embed/search-bar.tsx
CHANGED
|
@@ -118,12 +118,7 @@ export class SearchBarEmbed extends TsEmbed {
|
|
|
118
118
|
this.viewConfig = viewConfig;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
* Construct the URL of the embedded ThoughtSpot search to be
|
|
123
|
-
* loaded in the iframe
|
|
124
|
-
* @param dataSources A list of data source GUIDs
|
|
125
|
-
*/
|
|
126
|
-
private getIFrameSrc() {
|
|
121
|
+
protected getEmbedParamsObject() {
|
|
127
122
|
const {
|
|
128
123
|
searchOptions,
|
|
129
124
|
dataSource,
|
|
@@ -131,7 +126,6 @@ export class SearchBarEmbed extends TsEmbed {
|
|
|
131
126
|
useLastSelectedSources = false,
|
|
132
127
|
excludeSearchTokenStringFromURL,
|
|
133
128
|
} = this.viewConfig;
|
|
134
|
-
const path = 'search-bar-embed';
|
|
135
129
|
const queryParams = this.getBaseQueryParams();
|
|
136
130
|
|
|
137
131
|
queryParams[Param.HideActions] = [...(queryParams[Param.HideActions] ?? [])];
|
|
@@ -159,6 +153,19 @@ export class SearchBarEmbed extends TsEmbed {
|
|
|
159
153
|
queryParams[Param.UseLastSelectedDataSource] = false;
|
|
160
154
|
}
|
|
161
155
|
queryParams[Param.searchEmbed] = true;
|
|
156
|
+
|
|
157
|
+
return queryParams;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Construct the URL of the embedded ThoughtSpot search to be
|
|
162
|
+
* loaded in the iframe
|
|
163
|
+
* @param dataSources A list of data source GUIDs
|
|
164
|
+
*/
|
|
165
|
+
private getIFrameSrc() {
|
|
166
|
+
const queryParams = this.getEmbedParamsObject();
|
|
167
|
+
const path = 'search-bar-embed';
|
|
168
|
+
|
|
162
169
|
let query = '';
|
|
163
170
|
const queryParamsString = getQueryParamString(queryParams, true);
|
|
164
171
|
if (queryParamsString) {
|
package/src/embed/search.spec.ts
CHANGED
|
@@ -6,9 +6,7 @@ import {
|
|
|
6
6
|
} from './search';
|
|
7
7
|
import * as authInstance from '../auth';
|
|
8
8
|
import { init } from '../index';
|
|
9
|
-
import {
|
|
10
|
-
Action, AuthType, EmbedEvent, RuntimeFilterOp,
|
|
11
|
-
} from '../types';
|
|
9
|
+
import { Action, AuthType, EmbedEvent, RuntimeFilterOp } from '../types';
|
|
12
10
|
import {
|
|
13
11
|
executeAfterWait,
|
|
14
12
|
getDocumentBody,
|
|
@@ -58,7 +56,7 @@ describe('Search embed tests', () => {
|
|
|
58
56
|
await executeAfterWait(() => {
|
|
59
57
|
expectUrlMatchesWithParams(
|
|
60
58
|
getIFrameSrc(),
|
|
61
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableDataPanelV2=
|
|
59
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableDataPanelV2=true&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
62
60
|
);
|
|
63
61
|
});
|
|
64
62
|
});
|
|
@@ -444,7 +442,7 @@ describe('Search embed tests', () => {
|
|
|
444
442
|
await executeAfterWait(() => {
|
|
445
443
|
expectUrlMatchesWithParams(
|
|
446
444
|
getIFrameSrc(),
|
|
447
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=
|
|
445
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=true${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
448
446
|
);
|
|
449
447
|
});
|
|
450
448
|
});
|
|
@@ -459,7 +457,7 @@ describe('Search embed tests', () => {
|
|
|
459
457
|
await executeAfterWait(() => {
|
|
460
458
|
expectUrlMatchesWithParams(
|
|
461
459
|
getIFrameSrc(),
|
|
462
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&enableDataPanelV2=
|
|
460
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
463
461
|
);
|
|
464
462
|
});
|
|
465
463
|
});
|
|
@@ -474,7 +472,7 @@ describe('Search embed tests', () => {
|
|
|
474
472
|
await executeAfterWait(() => {
|
|
475
473
|
expectUrlMatchesWithParams(
|
|
476
474
|
getIFrameSrc(),
|
|
477
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&enableDataPanelV2=
|
|
475
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
478
476
|
);
|
|
479
477
|
});
|
|
480
478
|
});
|
|
@@ -505,7 +503,7 @@ describe('Search embed tests', () => {
|
|
|
505
503
|
await executeAfterWait(() => {
|
|
506
504
|
expectUrlMatchesWithParams(
|
|
507
505
|
getIFrameSrc(),
|
|
508
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=
|
|
506
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false&hideSearchBar=true${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
509
507
|
);
|
|
510
508
|
});
|
|
511
509
|
});
|
|
@@ -528,13 +526,14 @@ describe('Search embed tests', () => {
|
|
|
528
526
|
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
529
527
|
...defaultViewConfig,
|
|
530
528
|
// eslint-disable-next-line max-len
|
|
531
|
-
dataPanelCustomGroupsAccordionInitialState:
|
|
529
|
+
dataPanelCustomGroupsAccordionInitialState:
|
|
530
|
+
DataPanelCustomColumnGroupsAccordionState.EXPAND_FIRST,
|
|
532
531
|
});
|
|
533
532
|
searchEmbed.render();
|
|
534
533
|
await executeAfterWait(() => {
|
|
535
534
|
expectUrlMatchesWithParams(
|
|
536
535
|
getIFrameSrc(),
|
|
537
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=
|
|
536
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_FIRST${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
538
537
|
);
|
|
539
538
|
});
|
|
540
539
|
});
|
|
@@ -566,7 +565,7 @@ describe('Search embed tests', () => {
|
|
|
566
565
|
await executeAfterWait(() => {
|
|
567
566
|
expectUrlMatchesWithParams(
|
|
568
567
|
getIFrameSrc(),
|
|
569
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=
|
|
568
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
570
569
|
);
|
|
571
570
|
});
|
|
572
571
|
|
|
@@ -612,7 +611,7 @@ describe('Search embed tests', () => {
|
|
|
612
611
|
await executeAfterWait(() => {
|
|
613
612
|
expectUrlMatchesWithParams(
|
|
614
613
|
getIFrameSrc(),
|
|
615
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&executeSearch=true&dataSourceMode=expand&enableDataPanelV2=
|
|
614
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&executeSearch=true&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
616
615
|
);
|
|
617
616
|
});
|
|
618
617
|
|
|
@@ -640,7 +639,7 @@ describe('Search embed tests', () => {
|
|
|
640
639
|
await executeAfterWait(() => {
|
|
641
640
|
expectUrlMatchesWithParams(
|
|
642
641
|
getIFrameSrc(),
|
|
643
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=
|
|
642
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false&searchTokenString=[commit date][revenue]${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
644
643
|
);
|
|
645
644
|
});
|
|
646
645
|
});
|
|
@@ -660,7 +659,7 @@ describe('Search embed tests', () => {
|
|
|
660
659
|
await executeAfterWait(() => {
|
|
661
660
|
expectUrlMatchesWithParams(
|
|
662
661
|
getIFrameSrc(),
|
|
663
|
-
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=
|
|
662
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false&searchTokenString=[commit date][revenue]${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
664
663
|
);
|
|
665
664
|
});
|
|
666
665
|
|
package/src/embed/search.ts
CHANGED
|
@@ -331,7 +331,7 @@ export const HiddenActionItemByDefaultForSearchEmbed = [
|
|
|
331
331
|
];
|
|
332
332
|
|
|
333
333
|
export interface SearchAppInitData extends DefaultAppInitData {
|
|
334
|
-
|
|
334
|
+
searchOptions?: SearchOptions;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
/**
|
|
@@ -381,7 +381,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
381
381
|
return { ...defaultAppInitData, ...this.getSearchInitData() };
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
protected
|
|
384
|
+
protected getEmbedParamsObject() {
|
|
385
385
|
const {
|
|
386
386
|
hideResults,
|
|
387
387
|
enableSearchAssist,
|
|
@@ -392,13 +392,13 @@ export class SearchEmbed extends TsEmbed {
|
|
|
392
392
|
dataSources,
|
|
393
393
|
excludeRuntimeFiltersfromURL,
|
|
394
394
|
hideSearchBar,
|
|
395
|
-
dataPanelV2 =
|
|
395
|
+
dataPanelV2 = true,
|
|
396
396
|
useLastSelectedSources = false,
|
|
397
397
|
runtimeParameters,
|
|
398
398
|
collapseSearchBarInitially = false,
|
|
399
399
|
enableCustomColumnGroups = false,
|
|
400
400
|
isOnBeforeGetVizDataInterceptEnabled = false,
|
|
401
|
-
|
|
401
|
+
|
|
402
402
|
dataPanelCustomGroupsAccordionInitialState = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL,
|
|
403
403
|
focusSearchBarOnRender = true,
|
|
404
404
|
excludeRuntimeParametersfromURL,
|
|
@@ -443,7 +443,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
if (isOnBeforeGetVizDataInterceptEnabled) {
|
|
446
|
-
|
|
446
|
+
|
|
447
447
|
queryParams[Param.IsOnBeforeGetVizDataInterceptEnabled] = isOnBeforeGetVizDataInterceptEnabled;
|
|
448
448
|
}
|
|
449
449
|
|
|
@@ -460,7 +460,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
queryParams[Param.searchEmbed] = true;
|
|
463
|
-
|
|
463
|
+
|
|
464
464
|
queryParams[Param.CollapseSearchBarInitially] = collapseSearchBarInitially || collapseSearchBar;
|
|
465
465
|
queryParams[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
|
|
466
466
|
if (dataPanelCustomGroupsAccordionInitialState
|
|
@@ -468,12 +468,23 @@ export class SearchEmbed extends TsEmbed {
|
|
|
468
468
|
|| dataPanelCustomGroupsAccordionInitialState
|
|
469
469
|
=== DataPanelCustomColumnGroupsAccordionState.EXPAND_FIRST
|
|
470
470
|
) {
|
|
471
|
-
|
|
471
|
+
|
|
472
472
|
queryParams[Param.DataPanelCustomGroupsAccordionInitialState] = dataPanelCustomGroupsAccordionInitialState;
|
|
473
473
|
} else {
|
|
474
|
-
|
|
474
|
+
|
|
475
475
|
queryParams[Param.DataPanelCustomGroupsAccordionInitialState] = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL;
|
|
476
476
|
}
|
|
477
|
+
return queryParams;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
protected getEmbedParams() {
|
|
481
|
+
const {
|
|
482
|
+
runtimeParameters,
|
|
483
|
+
runtimeFilters,
|
|
484
|
+
excludeRuntimeParametersfromURL,
|
|
485
|
+
excludeRuntimeFiltersfromURL,
|
|
486
|
+
} = this.viewConfig;
|
|
487
|
+
const queryParams = this.getEmbedParamsObject();
|
|
477
488
|
let query = '';
|
|
478
489
|
const queryParamsString = getQueryParamString(queryParams, true);
|
|
479
490
|
if (queryParamsString) {
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -199,11 +199,11 @@ export class TsEmbed {
|
|
|
199
199
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
|
|
200
200
|
...viewConfig,
|
|
201
201
|
});
|
|
202
|
+
const embedConfig = getEmbedConfig();
|
|
203
|
+
this.embedConfig = embedConfig;
|
|
204
|
+
|
|
202
205
|
this.hostEventClient = new HostEventClient(this.iFrame);
|
|
203
|
-
|
|
204
206
|
this.isReadyForRenderPromise = getInitPromise().then(async () => {
|
|
205
|
-
const embedConfig = getEmbedConfig();
|
|
206
|
-
this.embedConfig = embedConfig;
|
|
207
207
|
if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
|
|
208
208
|
this.embedConfig.authTriggerContainer = domSelector;
|
|
209
209
|
}
|
|
@@ -494,10 +494,10 @@ export class TsEmbed {
|
|
|
494
494
|
this.on(EmbedEvent.APP_INIT, this.appInitCb, { start: false }, true);
|
|
495
495
|
this.on(EmbedEvent.AuthExpire, this.updateAuthToken, { start: false }, true);
|
|
496
496
|
this.on(EmbedEvent.IdleSessionTimeout, this.idleSessionTimeout, { start: false }, true);
|
|
497
|
-
|
|
498
|
-
const embedListenerReadyHandler = this.createEmbedContainerHandler(EmbedEvent.EmbedListenerReady);
|
|
497
|
+
|
|
498
|
+
const embedListenerReadyHandler = this.createEmbedContainerHandler(EmbedEvent.EmbedListenerReady);
|
|
499
499
|
this.on(EmbedEvent.EmbedListenerReady, embedListenerReadyHandler, { start: false }, true);
|
|
500
|
-
|
|
500
|
+
|
|
501
501
|
const authInitHandler = this.createEmbedContainerHandler(EmbedEvent.AuthInit);
|
|
502
502
|
this.on(EmbedEvent.AuthInit, authInitHandler, { start: false }, true);
|
|
503
503
|
};
|
|
@@ -520,6 +520,12 @@ export class TsEmbed {
|
|
|
520
520
|
return `${basePath}#`;
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
protected getUpdateEmbedParamsObject() {
|
|
524
|
+
let queryParams = this.getEmbedParamsObject();
|
|
525
|
+
queryParams = { ...this.viewConfig, ...queryParams };
|
|
526
|
+
return queryParams;
|
|
527
|
+
}
|
|
528
|
+
|
|
523
529
|
/**
|
|
524
530
|
* Common query params set for all the embed modes.
|
|
525
531
|
* @param queryParams
|
|
@@ -702,10 +708,15 @@ export class TsEmbed {
|
|
|
702
708
|
}
|
|
703
709
|
|
|
704
710
|
protected getEmbedParams() {
|
|
705
|
-
const queryParams = this.
|
|
711
|
+
const queryParams = this.getEmbedParamsObject();
|
|
706
712
|
return getQueryParamString(queryParams);
|
|
707
713
|
}
|
|
708
714
|
|
|
715
|
+
protected getEmbedParamsObject() {
|
|
716
|
+
const params = this.getBaseQueryParams();
|
|
717
|
+
return params;
|
|
718
|
+
}
|
|
719
|
+
|
|
709
720
|
protected getRootIframeSrc() {
|
|
710
721
|
const query = this.getEmbedParams();
|
|
711
722
|
return this.getEmbedBasePath(query);
|
|
@@ -1140,12 +1151,12 @@ export class TsEmbed {
|
|
|
1140
1151
|
}
|
|
1141
1152
|
}
|
|
1142
1153
|
|
|
1143
|
-
|
|
1154
|
+
/**
|
|
1144
1155
|
* @hidden
|
|
1145
1156
|
* Internal state to track if the embed container is loaded.
|
|
1146
1157
|
* This is used to trigger events after the embed container is loaded.
|
|
1147
1158
|
*/
|
|
1148
|
-
|
|
1159
|
+
public isEmbedContainerLoaded = false;
|
|
1149
1160
|
|
|
1150
1161
|
/**
|
|
1151
1162
|
* @hidden
|
|
@@ -1191,7 +1202,7 @@ export class TsEmbed {
|
|
|
1191
1202
|
} else {
|
|
1192
1203
|
logger.debug('pushing callback to embedContainerReadyCallbacks', callback);
|
|
1193
1204
|
this.embedContainerReadyCallbacks.push(callback);
|
|
1194
|
-
|
|
1205
|
+
}
|
|
1195
1206
|
}
|
|
1196
1207
|
|
|
1197
1208
|
protected createEmbedContainerHandler = (source: EmbedEvent.AuthInit | EmbedEvent.EmbedListenerReady) => () => {
|
|
@@ -1279,13 +1290,20 @@ export class TsEmbed {
|
|
|
1279
1290
|
* Creates the preRender shell
|
|
1280
1291
|
* @param showPreRenderByDefault - Show the preRender after render, hidden by default
|
|
1281
1292
|
*/
|
|
1282
|
-
|
|
1293
|
+
|
|
1294
|
+
public async preRender(showPreRenderByDefault = false, replaceExistingPreRender = false): Promise<TsEmbed> {
|
|
1283
1295
|
if (!this.viewConfig.preRenderId) {
|
|
1284
1296
|
logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
|
|
1285
1297
|
return this;
|
|
1286
1298
|
}
|
|
1287
1299
|
this.isPreRendered = true;
|
|
1288
1300
|
this.showPreRenderByDefault = showPreRenderByDefault;
|
|
1301
|
+
|
|
1302
|
+
const isAlreadyRendered = this.connectPreRendered();
|
|
1303
|
+
if (isAlreadyRendered && !replaceExistingPreRender) {
|
|
1304
|
+
return this;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1289
1307
|
return this.handleRenderForPrerender();
|
|
1290
1308
|
}
|
|
1291
1309
|
|
|
@@ -1407,8 +1425,14 @@ export class TsEmbed {
|
|
|
1407
1425
|
return this.preRender(true);
|
|
1408
1426
|
}
|
|
1409
1427
|
this.validatePreRenderViewConfig(this.viewConfig);
|
|
1428
|
+
logger.debug('triggering UpdateEmbedParams', this.viewConfig);
|
|
1429
|
+
this.executeAfterEmbedContainerLoaded(() => {
|
|
1430
|
+
this.trigger(HostEvent.UpdateEmbedParams, this.getUpdateEmbedParamsObject());
|
|
1431
|
+
});
|
|
1410
1432
|
}
|
|
1411
1433
|
|
|
1434
|
+
this.beforePrerenderVisible();
|
|
1435
|
+
|
|
1412
1436
|
if (this.el) {
|
|
1413
1437
|
this.syncPreRenderStyle();
|
|
1414
1438
|
if (!this.viewConfig.doNotTrackPreRenderSize) {
|
|
@@ -1426,8 +1450,6 @@ export class TsEmbed {
|
|
|
1426
1450
|
}
|
|
1427
1451
|
}
|
|
1428
1452
|
|
|
1429
|
-
this.beforePrerenderVisible();
|
|
1430
|
-
|
|
1431
1453
|
removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
|
|
1432
1454
|
|
|
1433
1455
|
this.subscribeToEvents();
|
package/src/errors.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const ERROR_MESSAGE = {
|
|
|
10
10
|
SDK_NOT_INITIALIZED: 'SDK not initialized',
|
|
11
11
|
SESSION_INFO_FAILED: 'Failed to get session information',
|
|
12
12
|
INVALID_TOKEN_ERROR: 'Received invalid token from getAuthToken callback or authToken endpoint.',
|
|
13
|
+
INVALID_TOKEN_TYPE_ERROR: 'Expected getAuthToken to return a string, but received a {invalidType}.',
|
|
13
14
|
MIXPANEL_TOKEN_NOT_FOUND: 'Mixpanel token not found in session info',
|
|
14
15
|
PRERENDER_ID_MISSING: 'PreRender ID is required for preRender',
|
|
15
16
|
SYNC_STYLE_CALLED_BEFORE_RENDER: 'PreRender should be called before using syncPreRenderStyle',
|
|
@@ -6,6 +6,6 @@ describe('Exports', () => {
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
it('should not have undefined exports', () => {
|
|
9
|
-
Object.
|
|
9
|
+
Object.entries(Exports).forEach(([, exportValue]) => {expect(Boolean(exportValue)).toBe(true);});
|
|
10
10
|
});
|
|
11
11
|
});
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -56,7 +56,7 @@ describe('React Components', () => {
|
|
|
56
56
|
),
|
|
57
57
|
).toBe(true);
|
|
58
58
|
expect(getIFrameSrc(container)).toBe(
|
|
59
|
-
`http://${thoughtSpotHost}/?embedApp=true&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&preAuthCache=true&overrideConsoleLogs=true&clientLogLevel=ERROR&enableDataPanelV2=
|
|
59
|
+
`http://${thoughtSpotHost}/?embedApp=true&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&preAuthCache=true&overrideConsoleLogs=true&clientLogLevel=ERROR&enableDataPanelV2=true&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true&collapseSearchBarInitially=true&enableCustomColumnGroups=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_ALL#/embed/answer`,
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
62
|
|
package/src/react/index.tsx
CHANGED
|
@@ -94,10 +94,12 @@ const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V exte
|
|
|
94
94
|
};
|
|
95
95
|
}, [viewConfig, listeners]);
|
|
96
96
|
|
|
97
|
+
const preRenderStyles = isPreRenderedComponent ? { display: 'none' } : {};
|
|
98
|
+
|
|
97
99
|
return viewConfig.insertAsSibling ? (
|
|
98
|
-
<span data-testid="tsEmbed" ref={ref} style={{ position: 'absolute' }}></span>
|
|
100
|
+
<span data-testid="tsEmbed" ref={ref} style={{ position: 'absolute', ...preRenderStyles }}></span>
|
|
99
101
|
) : (
|
|
100
|
-
<div data-testid="tsEmbed" ref={ref} style={style} className={`ts-embed-container ${className}`}></div>
|
|
102
|
+
<div data-testid="tsEmbed" ref={ref} style={{ ...style, ...preRenderStyles }} className={`ts-embed-container ${className}`}></div>
|
|
101
103
|
);
|
|
102
104
|
},
|
|
103
105
|
);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { getViewPropsAndListeners } from './util';
|
|
2
|
+
import { EmbedEvent, MessageCallback } from '../types';
|
|
3
|
+
|
|
4
|
+
describe('React util functions', () => {
|
|
5
|
+
describe('getViewPropsAndListeners', () => {
|
|
6
|
+
test('should return empty viewConfig and listeners for empty props', () => {
|
|
7
|
+
const props = {};
|
|
8
|
+
const result = getViewPropsAndListeners(props);
|
|
9
|
+
|
|
10
|
+
expect(result.viewConfig).toEqual({});
|
|
11
|
+
expect(result.listeners).toEqual({});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('should separate view config properties from props', () => {
|
|
15
|
+
const props = {
|
|
16
|
+
frameParams: { width: 100, height: 200 },
|
|
17
|
+
showLiveboardTitle: true,
|
|
18
|
+
liveboardId: 'test-liveboard-id',
|
|
19
|
+
vizId: 'test-viz-id',
|
|
20
|
+
className: 'test-class',
|
|
21
|
+
style: { color: 'red' },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const result = getViewPropsAndListeners(props);
|
|
25
|
+
|
|
26
|
+
expect(result.viewConfig).toEqual({
|
|
27
|
+
frameParams: { width: 100, height: 200 },
|
|
28
|
+
showLiveboardTitle: true,
|
|
29
|
+
liveboardId: 'test-liveboard-id',
|
|
30
|
+
vizId: 'test-viz-id',
|
|
31
|
+
className: 'test-class',
|
|
32
|
+
style: { color: 'red' },
|
|
33
|
+
});
|
|
34
|
+
expect(result.listeners).toEqual({});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('should separate event handlers from props', () => {
|
|
38
|
+
const onInit: MessageCallback = jest.fn();
|
|
39
|
+
const onLoad: MessageCallback = jest.fn();
|
|
40
|
+
const onData: MessageCallback = jest.fn();
|
|
41
|
+
|
|
42
|
+
const props = {
|
|
43
|
+
onInit,
|
|
44
|
+
onLoad,
|
|
45
|
+
onData,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const result = getViewPropsAndListeners(props);
|
|
49
|
+
|
|
50
|
+
expect(result.viewConfig).toEqual({});
|
|
51
|
+
expect(result.listeners).toEqual({
|
|
52
|
+
[EmbedEvent.Init]: onInit,
|
|
53
|
+
[EmbedEvent.Load]: onLoad,
|
|
54
|
+
[EmbedEvent.Data]: onData,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('should handle both view config and event handlers', () => {
|
|
59
|
+
const onInit: MessageCallback = jest.fn();
|
|
60
|
+
const onAuthInit: MessageCallback = jest.fn();
|
|
61
|
+
const onQueryChanged: MessageCallback = jest.fn();
|
|
62
|
+
|
|
63
|
+
const props = {
|
|
64
|
+
liveboardId: 'test-liveboard-id',
|
|
65
|
+
showLiveboardTitle: false,
|
|
66
|
+
frameParams: { height: 500 },
|
|
67
|
+
onInit,
|
|
68
|
+
onAuthInit,
|
|
69
|
+
onQueryChanged,
|
|
70
|
+
className: 'embed-container',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const result = getViewPropsAndListeners(props);
|
|
74
|
+
|
|
75
|
+
expect(result.viewConfig).toEqual({
|
|
76
|
+
liveboardId: 'test-liveboard-id',
|
|
77
|
+
showLiveboardTitle: false,
|
|
78
|
+
frameParams: { height: 500 },
|
|
79
|
+
className: 'embed-container',
|
|
80
|
+
});
|
|
81
|
+
expect(result.listeners).toEqual({
|
|
82
|
+
[EmbedEvent.Init]: onInit,
|
|
83
|
+
[EmbedEvent.AuthInit]: onAuthInit,
|
|
84
|
+
[EmbedEvent.QueryChanged]: onQueryChanged,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|