Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/embed/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
defaultParamsForPinboardEmbed,
defaultParamsWithoutHiddenActions,
expectUrlMatchesWithParams,
expectUrlToHaveParamsWithValues,
} from '../test/test-utils';
import { version } from '../../package.json';
import * as config from '../config';
Expand Down Expand Up @@ -580,6 +581,33 @@ describe('App embed tests', () => {
});
});

test('should set spotterFileUploadEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
spotterChatConfig: { spotterFileUploadEnabled: true },
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&spotterFileUploadEnabled=true${defaultParamsPost}#/home`,
);
});
});

test('should set spotterFileUploadFileTypes in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
spotterChatConfig: { spotterFileUploadFileTypes: { types: ['image/png', 'application/pdf'] } },
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlToHaveParamsWithValues(getIFrameSrc(), {
spotterFileUploadFileTypes: JSON.stringify({ types: ['image/png', 'application/pdf'] }),
});
});
});

test('should set isLiveboardXLSXCSVDownloadEnabled to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
Expand Down
8 changes: 8 additions & 0 deletions src/embed/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@
isPNGInScheduledEmailsEnabled?: boolean;

/**
* Enables the 'what you see is what you get' PDF export for Liveboards. Each tab is rendered on a single page

Check warning on line 590 in src/embed/app.ts

View workflow job for this annotation

GitHub Actions / build

Comments may not exceed 90 characters
* following the exact UI layout, instead of splitting visualizations across multiple A4 pages.
* This feature is GA from version 26.5.0.cl and is enabled by default on embed deployments.
*
Expand Down Expand Up @@ -950,10 +950,18 @@
const {
hideToolResponseCardBranding,
toolResponseCardBrandingLabel,
spotterFileUploadEnabled,
spotterFileUploadFileTypes,
} = spotterChatConfig;

setParamIfDefined(params, Param.HideToolResponseCardBranding, hideToolResponseCardBranding, true);
setParamIfDefined(params, Param.ToolResponseCardBrandingLabel, toolResponseCardBrandingLabel);
if (spotterFileUploadEnabled !== undefined) {
params[Param.SpotterFileUploadEnabled] = spotterFileUploadEnabled;
}
if (spotterFileUploadFileTypes !== undefined) {
params[Param.SpotterFileUploadFileTypes] = JSON.stringify(spotterFileUploadFileTypes);
}
}

if (hideObjectSearch) {
Expand Down Expand Up @@ -1124,7 +1132,7 @@

private sendFullHeightLazyLoadData = () => {
const data = calculateVisibleElementData(this.iFrame);
// this should be fired only if the lazyLoadingForFullHeight and fullHeight are true

Check warning on line 1135 in src/embed/app.ts

View workflow job for this annotation

GitHub Actions / build

Comments may not exceed 80 characters
if(this.viewConfig.lazyLoadingForFullHeight && this.viewConfig.fullHeight){
this.trigger(HostEvent.VisibleEmbedCoordinates, data);
}
Expand Down
34 changes: 34 additions & 0 deletions src/embed/conversation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getRootEl,
defaultParamsWithoutHiddenActions as defaultParams,
expectUrlMatchesWithParams,
expectUrlToHaveParamsWithValues,
postMessageToParent,
executeAfterWait,
} from '../test/test-utils';
Expand Down Expand Up @@ -351,6 +352,39 @@ describe('ConversationEmbed', () => {
);
});

it('should render the conversation embed with spotterFileUploadEnabled', async () => {
const viewConfig: SpotterEmbedViewConfig = {
worksheetId: 'worksheetId',
searchOptions: {
searchQuery: 'searchQuery',
},
spotterChatConfig: { spotterFileUploadEnabled: true },
};

const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
await conversationEmbed.render();
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&spotterFileUploadEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
);
});

it('should render the conversation embed with spotterFileUploadFileTypes', async () => {
const viewConfig: SpotterEmbedViewConfig = {
worksheetId: 'worksheetId',
searchOptions: {
searchQuery: 'searchQuery',
},
spotterChatConfig: { spotterFileUploadFileTypes: { types: ['image/png', 'application/pdf'] } },
};

const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
await conversationEmbed.render();
expectUrlToHaveParamsWithValues(getIFrameSrc(), {
spotterFileUploadFileTypes: JSON.stringify({ types: ['image/png', 'application/pdf'] }),
});
});

it('should ensure deprecated ConversationEmbed class maintains same functionality as SpotterEmbed', async () => {
const viewConfig: SpotterEmbedViewConfig = {
worksheetId: 'worksheetId',
Expand Down
23 changes: 22 additions & 1 deletion src/embed/conversation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isUndefined from 'lodash/isUndefined';
import { ERROR_MESSAGE } from '../errors';
import { Param, BaseViewConfig, RuntimeFilter, RuntimeParameter, ErrorDetailsTypes, EmbedErrorCodes, DefaultAppInitData } from '../types';
import { Param, BaseViewConfig, RuntimeFilter, RuntimeParameter, ErrorDetailsTypes, EmbedErrorCodes, DefaultAppInitData, SpotterFileUploadFileTypes } from '../types';
import { TsEmbed } from './ts-embed';
import { buildSpotterSidebarAppInitData } from './spotter-utils';
import { getQueryParamString, getFilterQuery, getRuntimeParameters, setParamIfDefined } from '../utils';
Expand Down Expand Up @@ -113,6 +113,21 @@ export interface SpotterChatViewConfig {
* External MCP tool branding is not affected.
*/
toolResponseCardBrandingLabel?: string;
/**
* Enables file upload in the Spotter chat interface.
*
* Supported embed types: `SpotterEmbed`, `LiveboardEmbed`, `AppEmbed`
* @version SDK: 1.49.0 | ThoughtSpot: 26.6.0.cl
* @default false
*/
spotterFileUploadEnabled?: boolean;
/**
* Restricts the allowed file types for Spotter file upload.
*
* Supported embed types: `SpotterEmbed`, `LiveboardEmbed`, `AppEmbed`
* @version SDK: 1.49.0 | ThoughtSpot: 26.6.0.cl
*/
spotterFileUploadFileTypes?: SpotterFileUploadFileTypes;
}

/**
Expand Down Expand Up @@ -449,10 +464,16 @@ export class SpotterEmbed extends TsEmbed {
const {
hideToolResponseCardBranding,
toolResponseCardBrandingLabel,
spotterFileUploadEnabled,
spotterFileUploadFileTypes,
} = spotterChatConfig;

setParamIfDefined(queryParams, Param.HideToolResponseCardBranding, hideToolResponseCardBranding, true);
setParamIfDefined(queryParams, Param.ToolResponseCardBrandingLabel, toolResponseCardBrandingLabel);
setParamIfDefined(queryParams, Param.SpotterFileUploadEnabled, spotterFileUploadEnabled, true);
if (spotterFileUploadFileTypes !== undefined) {
queryParams[Param.SpotterFileUploadFileTypes] = JSON.stringify(spotterFileUploadFileTypes);
}
}

return queryParams;
Expand Down
29 changes: 29 additions & 0 deletions src/embed/liveboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,35 @@ describe('Liveboard/viz embed tests', () => {
});
});

test('should set spotterFileUploadEnabled parameter in url params', async () => {
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
...defaultViewConfig,
liveboardId,
spotterChatConfig: { spotterFileUploadEnabled: true },
} as LiveboardViewConfig);
await liveboardEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}${prefixParams}&spotterFileUploadEnabled=true#/embed/viz/${liveboardId}`,
);
});
});

test('should set spotterFileUploadFileTypes parameter in url params', async () => {
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
...defaultViewConfig,
liveboardId,
spotterChatConfig: { spotterFileUploadFileTypes: { types: ['image/png', 'application/pdf'] } },
} as LiveboardViewConfig);
await liveboardEmbed.render();
await executeAfterWait(() => {
expectUrlToHaveParamsWithValues(getIFrameSrc(), {
spotterFileUploadFileTypes: JSON.stringify({ types: ['image/png', 'application/pdf'] }),
});
});
});

test('should render the liveboard embed with updatedSpotterChatPrompt', async () => {
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
...defaultViewConfig,
Expand Down
8 changes: 8 additions & 0 deletions src/embed/liveboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
*/
isPNGInScheduledEmailsEnabled?: boolean;
/**
* Enables the 'what you see is what you get' PDF export for Liveboards. Each tab is rendered on a single page

Check warning on line 391 in src/embed/liveboard.ts

View workflow job for this annotation

GitHub Actions / build

Comments may not exceed 90 characters
* following the exact UI layout, instead of splitting visualizations across multiple A4 pages.
* This feature is GA from version 26.5.0.cl and is enabled by default on embed deployments.
*
Expand Down Expand Up @@ -735,10 +735,18 @@
const {
hideToolResponseCardBranding,
toolResponseCardBrandingLabel,
spotterFileUploadEnabled,
spotterFileUploadFileTypes,
} = spotterChatConfig;

setParamIfDefined(params, Param.HideToolResponseCardBranding, hideToolResponseCardBranding, true);
setParamIfDefined(params, Param.ToolResponseCardBrandingLabel, toolResponseCardBrandingLabel);
if (spotterFileUploadEnabled !== undefined) {
params[Param.SpotterFileUploadEnabled] = spotterFileUploadEnabled;
}
if (spotterFileUploadFileTypes !== undefined) {
params[Param.SpotterFileUploadFileTypes] = JSON.stringify(spotterFileUploadFileTypes);
}
}

if (isLinkParametersEnabled !== undefined) {
Expand Down Expand Up @@ -826,7 +834,7 @@

private sendFullHeightLazyLoadData = () => {
const data = calculateVisibleElementData(this.iFrame);
// this should be fired only if the lazyLoadingForFullHeight and fullHeight are true

Check warning on line 837 in src/embed/liveboard.ts

View workflow job for this annotation

GitHub Actions / build

Comments may not exceed 80 characters
if(this.viewConfig.lazyLoadingForFullHeight && this.viewConfig.fullHeight){
this.trigger(HostEvent.VisibleEmbedCoordinates, data);
}
Expand Down
10 changes: 10 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3666,9 +3666,9 @@
EmbedPageContextChanged = 'EmbedPageContextChanged',

/**
* Represents a special embed event that is triggered whenever any host event is subscribed.

Check warning on line 3669 in src/types.ts

View workflow job for this annotation

GitHub Actions / build

Comments may not exceed 90 characters
*
* You can listen to this event when you need to dispatch a host event during load or render,

Check warning on line 3671 in src/types.ts

View workflow job for this annotation

GitHub Actions / build

Comments may not exceed 90 characters
* particularly in situations where timing issues may occur.
*
* @example
Expand Down Expand Up @@ -5955,8 +5955,18 @@
ToolResponseCardBrandingLabel = 'toolResponseCardBrandingLabel',
EnableHomepageAnnouncement = 'enableHomepageAnnouncement',
EnableLiveboardDataCache = 'enableLiveboardDataCache',
SpotterFileUploadEnabled = 'spotterFileUploadEnabled',
SpotterFileUploadFileTypes = 'spotterFileUploadFileTypes',
}

/**
* Configuration for allowed file types in Spotter file upload.
* @group Embed components
*/
export type SpotterFileUploadFileTypes = {
types?: string[];
};

/**
* ThoughtSpot application pages include actions and menu commands
* for various user-initiated operations. These actions are represented
Expand Down
Loading