@thoughtspot/visual-embed-sdk 1.6.2 → 1.7.0-alpha.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/dist/src/auth.d.ts +3 -3
- package/dist/src/embed/pinboard.d.ts +85 -0
- package/dist/src/embed/search.d.ts +2 -5
- package/dist/src/test/test-utils.d.ts +1 -0
- package/dist/src/types.d.ts +4 -4
- package/dist/tsembed.es.js +22 -13
- package/dist/tsembed.js +22 -13
- package/lib/package.json +1 -2
- package/lib/src/auth.d.ts +3 -3
- package/lib/src/auth.js +7 -7
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +2 -2
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/pinboard.d.ts +85 -0
- package/lib/src/embed/pinboard.js +107 -0
- package/lib/src/embed/pinboard.js.map +1 -0
- package/lib/src/embed/search.d.ts +2 -5
- package/lib/src/embed/search.js +11 -2
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +32 -20
- package/lib/src/embed/search.spec.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/test/test-utils.d.ts +1 -0
- package/lib/src/test/test-utils.js +3 -0
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +4 -4
- package/lib/src/types.js +4 -4
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/fetchAnswers.d.ts +3 -0
- package/lib/src/utils/fetchAnswers.js +49 -0
- package/lib/src/utils/fetchAnswers.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +6 -9
- package/package.json +1 -2
- package/src/auth.spec.ts +2 -2
- package/src/auth.ts +7 -7
- package/src/embed/search.spec.ts +38 -19
- package/src/embed/search.ts +12 -6
- package/src/react/index.spec.tsx +1 -1
- package/src/test/test-utils.ts +4 -0
- package/src/types.ts +4 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OperationType } from '../types';
|
|
2
|
+
function FetchAnswers(session, query, operation, thoughtSpotHost) {
|
|
3
|
+
let variable;
|
|
4
|
+
const fetchQuery = async (variables) => {
|
|
5
|
+
try {
|
|
6
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operation}`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: {
|
|
9
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
10
|
+
'x-requested-by': 'ThoughtSpot',
|
|
11
|
+
accept: '*/*',
|
|
12
|
+
'accept-language': 'en-us',
|
|
13
|
+
},
|
|
14
|
+
body: JSON.stringify({
|
|
15
|
+
operationName: operation,
|
|
16
|
+
query,
|
|
17
|
+
variables,
|
|
18
|
+
}),
|
|
19
|
+
credentials: 'include'
|
|
20
|
+
});
|
|
21
|
+
const result = await response.json();
|
|
22
|
+
return result.data;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
return error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getAnswer = (offset, batchSize) => {
|
|
29
|
+
if (operation === OperationType.GetChartWithData) {
|
|
30
|
+
variable = { batchSize, offset };
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
variable = {
|
|
34
|
+
dataPaginationParams: {
|
|
35
|
+
isClientPaginated: true,
|
|
36
|
+
offset,
|
|
37
|
+
size: batchSize,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return fetchQuery({
|
|
42
|
+
session,
|
|
43
|
+
...variable,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return getAnswer;
|
|
47
|
+
}
|
|
48
|
+
export default FetchAnswers;
|
|
49
|
+
//# sourceMappingURL=fetchAnswers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAnswers.js","sourceRoot":"","sources":["../../../src/utils/fetchAnswers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D,SAAS,YAAY,CACjB,OAAyB,EACzB,KAAa,EACb,SAAiB,EACjB,eAAuB;IAEvB,IAAI,QAAa,CAAC;IAElB,MAAM,UAAU,GAAG,KAAK,EAAE,SAAc,EAAE,EAAE;QACxC,IAAI;YACA,MAAM,QAAQ,GAAG,MAAM,KAAK,CACxB,GAAG,eAAe,cAAc,SAAS,EAAE,EAC3C;gBACI,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACL,cAAc,EAAE,gCAAgC;oBAChD,gBAAgB,EAAE,aAAa;oBAC/B,MAAM,EAAE,KAAK;oBACb,iBAAiB,EAAE,OAAO;iBAC7B;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACjB,aAAa,EAAE,SAAS;oBACxB,KAAK;oBACL,SAAS;iBACZ,CAAC;gBACF,WAAW,EAAE,SAAS;aACzB,CACA,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACrC,OAAO,MAAM,CAAC,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAE,EAAE;QACpD,IAAI,SAAS,KAAK,aAAa,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;SACpC;aAAM;YACH,QAAQ,GAAG;gBACP,oBAAoB,EAAE;oBAClB,iBAAiB,EAAE,IAAI;oBACvB,MAAM;oBACN,IAAI,EAAE,SAAS;iBAClB;aACJ,CAAC;SACL;QACD,OAAO,UAAU,CAAC;YACd,OAAO;YACP,GAAG,QAAQ;SACd,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -237,7 +237,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
237
237
|
* @summary Search embed
|
|
238
238
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
239
239
|
*/
|
|
240
|
-
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
|
|
240
|
+
import { DOMSelector, Action } from '@thoughtspot/visual-embed-sdk/types';
|
|
241
241
|
import { ViewConfig, TsEmbed } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
|
|
242
242
|
/**
|
|
243
243
|
* Configuration for search options
|
|
@@ -275,10 +275,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
275
275
|
* using raw answer data.
|
|
276
276
|
*/
|
|
277
277
|
hideResults?: boolean;
|
|
278
|
-
/**
|
|
279
|
-
* If set to true, expands all the data sources panel.
|
|
280
|
-
*/
|
|
281
|
-
expandAllDataSource?: boolean;
|
|
282
278
|
/**
|
|
283
279
|
* If set to true, the Search Assist feature is enabled.
|
|
284
280
|
*/
|
|
@@ -306,6 +302,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
306
302
|
*/
|
|
307
303
|
answerId?: string;
|
|
308
304
|
}
|
|
305
|
+
export const HiddenActionItemByDefaultForSearchEmbed: Action[];
|
|
309
306
|
/**
|
|
310
307
|
* Embed ThoughtSpot search
|
|
311
308
|
*
|
|
@@ -340,9 +337,9 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
340
337
|
*/
|
|
341
338
|
SSO = "SSO_SAML",
|
|
342
339
|
/**
|
|
343
|
-
* SSO using
|
|
340
|
+
* SSO using OIDC
|
|
344
341
|
*/
|
|
345
|
-
|
|
342
|
+
OIDC = "SSO_OIDC",
|
|
346
343
|
/**
|
|
347
344
|
* Trusted authentication server
|
|
348
345
|
*/
|
|
@@ -715,7 +712,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
715
712
|
export enum Param {
|
|
716
713
|
DataSources = "dataSources",
|
|
717
714
|
DataSourceMode = "dataSourceMode",
|
|
718
|
-
ExpandAllDataSource = "expandAllDataSource",
|
|
719
715
|
DisableActions = "disableAction",
|
|
720
716
|
DisableActionReason = "disableHint",
|
|
721
717
|
ForceTable = "forceTable",
|
|
@@ -752,7 +748,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
752
748
|
EditACopy = "editACopy",
|
|
753
749
|
CopyLink = "embedDocument",
|
|
754
750
|
ResetLayout = "resetLayout",
|
|
755
|
-
Schedule = "
|
|
751
|
+
Schedule = "subscription",
|
|
756
752
|
SchedulesList = "schedule-list",
|
|
757
753
|
Share = "share",
|
|
758
754
|
AddFilter = "addFilter",
|
|
@@ -801,6 +797,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
801
797
|
DrillInclude = "context-menu-item-include",
|
|
802
798
|
DrillExclude = "context-menu-item-exclude",
|
|
803
799
|
CopyToClipboard = "context-menu-item-copy-to-clipboard",
|
|
800
|
+
CopyAndEdit = "context-menu-item-copy-and-edit",
|
|
804
801
|
DrillEdit = "context-menu-item-edit",
|
|
805
802
|
EditMeasure = "context-menu-item-edit-measure",
|
|
806
803
|
Separator = "context-menu-item-separator",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-alpha.2",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"asciidoctor": "^2.2.1",
|
|
66
66
|
"babel-jest": "^26.6.3",
|
|
67
67
|
"babel-preset-gatsby": "^1.10.0",
|
|
68
|
-
"classnames": "^2.3.1",
|
|
69
68
|
"command-line-args": "^5.1.1",
|
|
70
69
|
"coveralls": "^3.1.0",
|
|
71
70
|
"dts-bundle": "0.7.3",
|
package/src/auth.spec.ts
CHANGED
|
@@ -74,8 +74,8 @@ describe('Unit test for auth', () => {
|
|
|
74
74
|
global.fetch = window.fetch;
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
test('endpoints,
|
|
78
|
-
const ssoTemplateUrl = authInstance.EndPoints.
|
|
77
|
+
test('endpoints, SAML_LOGIN_TEMPLATE', () => {
|
|
78
|
+
const ssoTemplateUrl = authInstance.EndPoints.SAML_LOGIN_TEMPLATE(
|
|
79
79
|
thoughtSpotHost,
|
|
80
80
|
);
|
|
81
81
|
expect(ssoTemplateUrl).toBe(
|
package/src/auth.ts
CHANGED
|
@@ -23,9 +23,9 @@ export const SSO_REDIRECTION_MARKER_GUID =
|
|
|
23
23
|
|
|
24
24
|
export const EndPoints = {
|
|
25
25
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
26
|
-
|
|
26
|
+
SAML_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
27
27
|
`/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
28
|
-
|
|
28
|
+
OIDC_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
29
29
|
`/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
30
30
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
31
31
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
@@ -213,14 +213,14 @@ export const doSamlAuth = async (embedConfig: EmbedConfig) => {
|
|
|
213
213
|
: appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
|
|
214
214
|
|
|
215
215
|
// bring back the page to the same URL
|
|
216
|
-
const ssoEndPoint = `${EndPoints.
|
|
216
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(
|
|
217
217
|
encodeURIComponent(ssoRedirectUrl),
|
|
218
218
|
)}`;
|
|
219
219
|
|
|
220
220
|
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
221
221
|
};
|
|
222
222
|
|
|
223
|
-
export const
|
|
223
|
+
export const doOIDCAuth = async (embedConfig: EmbedConfig) => {
|
|
224
224
|
const { thoughtSpotHost } = embedConfig;
|
|
225
225
|
// redirect for SSO, when the SSO authentication is done, this page will be loaded
|
|
226
226
|
// again and the same JS will execute again.
|
|
@@ -229,7 +229,7 @@ export const doIODCAuth = async (embedConfig: EmbedConfig) => {
|
|
|
229
229
|
: appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
|
|
230
230
|
|
|
231
231
|
// bring back the page to the same URL
|
|
232
|
-
const ssoEndPoint = `${EndPoints.
|
|
232
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(
|
|
233
233
|
encodeURIComponent(ssoRedirectUrl),
|
|
234
234
|
)}`;
|
|
235
235
|
|
|
@@ -245,8 +245,8 @@ export const authenticate = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
245
245
|
switch (authType) {
|
|
246
246
|
case AuthType.SSO:
|
|
247
247
|
return doSamlAuth(embedConfig);
|
|
248
|
-
case AuthType.
|
|
249
|
-
return
|
|
248
|
+
case AuthType.OIDC:
|
|
249
|
+
return doOIDCAuth(embedConfig);
|
|
250
250
|
case AuthType.AuthServer:
|
|
251
251
|
return doTokenAuth(embedConfig);
|
|
252
252
|
case AuthType.Basic:
|
package/src/embed/search.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SearchEmbed } from './search';
|
|
1
|
+
import { SearchEmbed, HiddenActionItemByDefaultForSearchEmbed } from './search';
|
|
2
2
|
import { init } from '../index';
|
|
3
3
|
import { Action, AuthType } from '../types';
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getDocumentBody,
|
|
7
7
|
getIFrameSrc,
|
|
8
8
|
getRootEl,
|
|
9
|
+
fixedEncodeURI,
|
|
9
10
|
} from '../test/test-utils';
|
|
10
11
|
import { version } from '../../package.json';
|
|
11
12
|
|
|
@@ -18,6 +19,10 @@ const defaultViewConfig = {
|
|
|
18
19
|
const answerId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
|
|
19
20
|
const thoughtSpotHost = 'tshost';
|
|
20
21
|
const defaultParams = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
22
|
+
const hideBydefault = `&hideAction=${fixedEncodeURI(
|
|
23
|
+
JSON.stringify(HiddenActionItemByDefaultForSearchEmbed),
|
|
24
|
+
)}`;
|
|
25
|
+
const defaultParamsWithHiddenActions = defaultParams + hideBydefault;
|
|
21
26
|
|
|
22
27
|
beforeAll(() => {
|
|
23
28
|
init({
|
|
@@ -36,7 +41,7 @@ describe('Search embed tests', () => {
|
|
|
36
41
|
searchEmbed.render();
|
|
37
42
|
await executeAfterWait(() => {
|
|
38
43
|
expect(getIFrameSrc()).toBe(
|
|
39
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
44
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
40
45
|
);
|
|
41
46
|
});
|
|
42
47
|
});
|
|
@@ -50,7 +55,7 @@ describe('Search embed tests', () => {
|
|
|
50
55
|
searchEmbed.render();
|
|
51
56
|
await executeAfterWait(() => {
|
|
52
57
|
expect(getIFrameSrc()).toBe(
|
|
53
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
58
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
54
59
|
);
|
|
55
60
|
});
|
|
56
61
|
});
|
|
@@ -68,7 +73,7 @@ describe('Search embed tests', () => {
|
|
|
68
73
|
searchEmbed.render();
|
|
69
74
|
await executeAfterWait(() => {
|
|
70
75
|
expect(getIFrameSrc()).toBe(
|
|
71
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
76
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
72
77
|
);
|
|
73
78
|
});
|
|
74
79
|
});
|
|
@@ -86,7 +91,7 @@ describe('Search embed tests', () => {
|
|
|
86
91
|
searchEmbed.render();
|
|
87
92
|
await executeAfterWait(() => {
|
|
88
93
|
expect(getIFrameSrc()).toBe(
|
|
89
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
94
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
90
95
|
);
|
|
91
96
|
});
|
|
92
97
|
|
|
@@ -101,7 +106,7 @@ describe('Search embed tests', () => {
|
|
|
101
106
|
searchEmbed.render();
|
|
102
107
|
await executeAfterWait(() => {
|
|
103
108
|
expect(getIFrameSrc()).toBe(
|
|
104
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
109
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&executeSearch=true&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
105
110
|
);
|
|
106
111
|
});
|
|
107
112
|
});
|
|
@@ -120,7 +125,7 @@ describe('Search embed tests', () => {
|
|
|
120
125
|
searchEmbed.render();
|
|
121
126
|
await executeAfterWait(() => {
|
|
122
127
|
expect(getIFrameSrc()).toBe(
|
|
123
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
128
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=collapse&useLastSelectedSources=false#/embed/answer`,
|
|
124
129
|
);
|
|
125
130
|
});
|
|
126
131
|
});
|
|
@@ -139,7 +144,7 @@ describe('Search embed tests', () => {
|
|
|
139
144
|
searchEmbed.render();
|
|
140
145
|
await executeAfterWait(() => {
|
|
141
146
|
expect(getIFrameSrc()).toBe(
|
|
142
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
147
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=hide&useLastSelectedSources=false#/embed/answer`,
|
|
143
148
|
);
|
|
144
149
|
});
|
|
145
150
|
});
|
|
@@ -159,7 +164,7 @@ describe('Search embed tests', () => {
|
|
|
159
164
|
searchEmbed.render();
|
|
160
165
|
await executeAfterWait(() => {
|
|
161
166
|
expect(getIFrameSrc()).toBe(
|
|
162
|
-
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22download%22,%22edit%22]&disableHint=Permission%20denied&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
167
|
+
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22download%22,%22edit%22]&disableHint=Permission%20denied${hideBydefault}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
163
168
|
);
|
|
164
169
|
});
|
|
165
170
|
});
|
|
@@ -172,41 +177,55 @@ describe('Search embed tests', () => {
|
|
|
172
177
|
searchEmbed.render();
|
|
173
178
|
await executeAfterWait(() => {
|
|
174
179
|
expect(getIFrameSrc()).toBe(
|
|
175
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
180
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableSearchAssist=true&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
176
181
|
);
|
|
177
182
|
});
|
|
178
183
|
});
|
|
179
184
|
|
|
180
185
|
test('should hide actions', async () => {
|
|
186
|
+
const hiddenActionsForSearch = [
|
|
187
|
+
Action.DownloadAsCsv,
|
|
188
|
+
Action.DownloadAsPdf,
|
|
189
|
+
Action.DownloadAsXlsx,
|
|
190
|
+
];
|
|
181
191
|
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
182
|
-
hiddenActions:
|
|
183
|
-
Action.DownloadAsCsv,
|
|
184
|
-
Action.DownloadAsPdf,
|
|
185
|
-
Action.DownloadAsXlsx,
|
|
186
|
-
],
|
|
192
|
+
hiddenActions: hiddenActionsForSearch,
|
|
187
193
|
...defaultViewConfig,
|
|
188
194
|
answerId,
|
|
189
195
|
});
|
|
190
196
|
searchEmbed.render();
|
|
197
|
+
const hideActionUrl = fixedEncodeURI(
|
|
198
|
+
JSON.stringify([
|
|
199
|
+
...hiddenActionsForSearch,
|
|
200
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
201
|
+
]),
|
|
202
|
+
);
|
|
191
203
|
await executeAfterWait(() => {
|
|
192
204
|
expect(getIFrameSrc()).toBe(
|
|
193
|
-
`http://${thoughtSpotHost}/v2/?${defaultParams}&hideAction
|
|
205
|
+
`http://${thoughtSpotHost}/v2/?${defaultParams}&hideAction=${hideActionUrl}&dataSourceMode=expand&useLastSelectedSources=false#/embed/saved-answer/${answerId}`,
|
|
194
206
|
);
|
|
195
207
|
});
|
|
196
208
|
});
|
|
197
209
|
|
|
198
210
|
test('should disable and hide actions', async () => {
|
|
211
|
+
const hiddenActionsForSearch = [Action.DownloadAsCsv];
|
|
199
212
|
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
200
213
|
disabledActions: [Action.DownloadAsXlsx],
|
|
201
|
-
hiddenActions:
|
|
214
|
+
hiddenActions: hiddenActionsForSearch,
|
|
202
215
|
disabledActionReason: 'Access denied',
|
|
203
216
|
...defaultViewConfig,
|
|
204
217
|
answerId,
|
|
205
218
|
});
|
|
206
219
|
searchEmbed.render();
|
|
220
|
+
const hideActionUrl = fixedEncodeURI(
|
|
221
|
+
JSON.stringify([
|
|
222
|
+
...hiddenActionsForSearch,
|
|
223
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
224
|
+
]),
|
|
225
|
+
);
|
|
207
226
|
await executeAfterWait(() => {
|
|
208
227
|
expect(getIFrameSrc()).toBe(
|
|
209
|
-
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22downloadAsXLSX%22]&disableHint=Access%20denied&hideAction
|
|
228
|
+
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22downloadAsXLSX%22]&disableHint=Access%20denied&hideAction=${hideActionUrl}&dataSourceMode=expand&useLastSelectedSources=false#/embed/saved-answer/${answerId}`,
|
|
210
229
|
);
|
|
211
230
|
});
|
|
212
231
|
});
|
|
@@ -219,7 +238,7 @@ describe('Search embed tests', () => {
|
|
|
219
238
|
searchEmbed.render();
|
|
220
239
|
await executeAfterWait(() => {
|
|
221
240
|
expect(getIFrameSrc()).toBe(
|
|
222
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
241
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false#/embed/saved-answer/${answerId}`,
|
|
223
242
|
);
|
|
224
243
|
});
|
|
225
244
|
});
|
package/src/embed/search.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { DataSourceVisualMode, DOMSelector, Param } from '../types';
|
|
10
|
+
import { DataSourceVisualMode, DOMSelector, Param, Action } from '../types';
|
|
11
11
|
import { getQueryParamString } from '../utils';
|
|
12
12
|
import { ViewConfig, TsEmbed } from './ts-embed';
|
|
13
13
|
import { version } from '../../package.json';
|
|
@@ -49,10 +49,6 @@ 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;
|
|
56
52
|
/**
|
|
57
53
|
* If set to true, the Search Assist feature is enabled.
|
|
58
54
|
*/
|
|
@@ -81,6 +77,11 @@ export interface SearchViewConfig extends ViewConfig {
|
|
|
81
77
|
answerId?: string;
|
|
82
78
|
}
|
|
83
79
|
|
|
80
|
+
export const HiddenActionItemByDefaultForSearchEmbed = [
|
|
81
|
+
Action.EditACopy,
|
|
82
|
+
Action.SaveAsView,
|
|
83
|
+
];
|
|
84
|
+
|
|
84
85
|
/**
|
|
85
86
|
* Embed ThoughtSpot search
|
|
86
87
|
*
|
|
@@ -122,13 +123,18 @@ export class SearchEmbed extends TsEmbed {
|
|
|
122
123
|
private getIFrameSrc(answerId: string, dataSources?: string[]) {
|
|
123
124
|
const {
|
|
124
125
|
hideResults,
|
|
125
|
-
expandAllDataSource,
|
|
126
126
|
enableSearchAssist,
|
|
127
127
|
forceTable,
|
|
128
128
|
searchOptions,
|
|
129
129
|
} = this.viewConfig;
|
|
130
130
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
131
131
|
const queryParams = this.getBaseQueryParams();
|
|
132
|
+
|
|
133
|
+
queryParams[Param.HideActions] = [
|
|
134
|
+
...(queryParams[Param.HideActions] ?? []),
|
|
135
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
136
|
+
];
|
|
137
|
+
|
|
132
138
|
if (dataSources && dataSources.length) {
|
|
133
139
|
queryParams[Param.DataSources] = JSON.stringify(dataSources);
|
|
134
140
|
}
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -31,7 +31,7 @@ describe('React Components', () => {
|
|
|
31
31
|
await waitFor(() => getIFrameEl(container));
|
|
32
32
|
|
|
33
33
|
expect(getIFrameSrc(container)).toBe(
|
|
34
|
-
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&dataSourceMode=hide&useLastSelectedSources=false#/embed/answer`,
|
|
34
|
+
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&hideAction=[%22editACopy%22,%22saveAsView%22]&dataSourceMode=hide&useLastSelectedSources=false#/embed/answer`,
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
|
package/src/test/test-utils.ts
CHANGED
|
@@ -66,3 +66,7 @@ export const executeAfterWait = (
|
|
|
66
66
|
* Time (in milliseconds) to wait for async events to be triggered
|
|
67
67
|
*/
|
|
68
68
|
export const EVENT_WAIT_TIME = 1000;
|
|
69
|
+
|
|
70
|
+
export function fixedEncodeURI(str: string) {
|
|
71
|
+
return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');
|
|
72
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -22,9 +22,9 @@ export enum AuthType {
|
|
|
22
22
|
*/
|
|
23
23
|
SSO = 'SSO_SAML',
|
|
24
24
|
/**
|
|
25
|
-
* SSO using
|
|
25
|
+
* SSO using OIDC
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
OIDC = 'SSO_OIDC',
|
|
28
28
|
/**
|
|
29
29
|
* Trusted authentication server
|
|
30
30
|
*/
|
|
@@ -422,7 +422,6 @@ export enum DataSourceVisualMode {
|
|
|
422
422
|
export enum Param {
|
|
423
423
|
DataSources = 'dataSources',
|
|
424
424
|
DataSourceMode = 'dataSourceMode',
|
|
425
|
-
ExpandAllDataSource = 'expandAllDataSource',
|
|
426
425
|
DisableActions = 'disableAction',
|
|
427
426
|
DisableActionReason = 'disableHint',
|
|
428
427
|
ForceTable = 'forceTable',
|
|
@@ -461,7 +460,7 @@ export enum Action {
|
|
|
461
460
|
EditACopy = 'editACopy',
|
|
462
461
|
CopyLink = 'embedDocument',
|
|
463
462
|
ResetLayout = 'resetLayout',
|
|
464
|
-
Schedule = '
|
|
463
|
+
Schedule = 'subscription',
|
|
465
464
|
SchedulesList = 'schedule-list',
|
|
466
465
|
Share = 'share',
|
|
467
466
|
AddFilter = 'addFilter',
|
|
@@ -510,6 +509,7 @@ export enum Action {
|
|
|
510
509
|
DrillInclude = 'context-menu-item-include',
|
|
511
510
|
DrillExclude = 'context-menu-item-exclude',
|
|
512
511
|
CopyToClipboard = 'context-menu-item-copy-to-clipboard',
|
|
512
|
+
CopyAndEdit = 'context-menu-item-copy-and-edit',
|
|
513
513
|
DrillEdit = 'context-menu-item-edit',
|
|
514
514
|
EditMeasure = 'context-menu-item-edit-measure',
|
|
515
515
|
Separator = 'context-menu-item-separator',
|