Skip to content

CBCA (In progress) #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions src/embed/ts-embed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -382,6 +383,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -424,6 +426,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [HomepageModule.MyLibrary, HomepageModule.Learning],
hiddenListColumns: [],
customActions: [],
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
},
Expand Down Expand Up @@ -462,6 +465,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
},
Expand Down Expand Up @@ -503,6 +507,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
reorderedHomepageModules:
[HomepageModule.MyLibrary, HomepageModule.Watchlist],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -547,6 +552,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -592,6 +598,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -636,6 +643,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -681,6 +689,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
Expand Down Expand Up @@ -725,6 +734,7 @@ describe('Unit test case for ts embed', () => {
[HomeLeftNavItem.Home, HomeLeftNavItem.MonitorSubscription],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
reorderedHomepageModules: [],
customVariablesForThirdPartyTools,
},
Expand Down Expand Up @@ -893,6 +903,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools: {},
Expand Down Expand Up @@ -977,6 +988,7 @@ describe('Unit test case for ts embed', () => {
hiddenHomeLeftNavItems: [],
hiddenHomepageModules: [],
hiddenListColumns: [],
customActions: [],
hostConfig: undefined,
reorderedHomepageModules: [],
customVariablesForThirdPartyTools: {},
Expand Down
2 changes: 2 additions & 0 deletions src/embed/ts-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
setStyleProperties,
removeStyleProperties,
isUndefined,
getCustomActions,
} from '../utils';
import {
getThoughtSpotHost,
Expand Down Expand Up @@ -379,6 +380,7 @@ export class TsEmbed {
customVariablesForThirdPartyTools:
this.embedConfig.customVariablesForThirdPartyTools || {},
hiddenListColumns: this.viewConfig.hiddenListColumns || [],
customActions: getCustomActions(this.viewConfig.customActions || []),
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
VizPoint,
CustomActionPayload,
ListPageColumns,
CustomActionsPosition,
} from './types';
import { CustomCssVariables } from './css-variables';
import { SageEmbed, SageViewConfig } from './embed/sage';
Expand Down Expand Up @@ -144,6 +145,7 @@ export {
CustomActionPayload,
UIPassthroughEvent,
ListPageColumns,
CustomActionsPosition,
};

export { resetCachedAuthToken } from './authToken';
1 change: 1 addition & 0 deletions src/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Embed.preRender() method instead of the usual render method, and it will
// not be destroyed when the component is unmounted.
isPreRenderedComponent = false,
) => React.forwardRef<InstanceType<T>, U>(

Check warning on line 27 in src/react/index.tsx

View workflow job for this annotation

GitHub Actions / build

Component definition is missing display name
(props: U, forwardedRef: React.MutableRefObject<InstanceType<T>>) => {
const ref = React.useRef<HTMLDivElement>(null);
const { className, style, ...embedProps } = props;
Expand Down Expand Up @@ -534,4 +534,5 @@
LogLevel,
getSessionInfo,
ListPageColumns,
CustomActionsPosition,
} from '../index';
33 changes: 33 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,11 @@ export interface BaseViewConfig {
* @private
*/
insertInToSlide?: boolean;
/**
* Custom actions are a way to add custom actions to the embedded view which
* can be used to trigger custom logic when the action is clicked.
*/
customActions?: CustomAction[];
}

/**
Expand Down Expand Up @@ -5207,6 +5212,33 @@ export interface CustomActionPayload {
vizId?: string;
}

export interface CustomAction {
name: string;
id: string;
position: CustomActionsPosition;
callback: (payload: any) => void; // give a proper type for the payload
metadataIds?: {
answerIds?: string[];
liveboardIds?: string[];
vizIds?: string[];
};
dataModelIds?: {
modelIds?: string[];
modelColumnNames?: string[];
}
orgIds?: string[];
groupIds?: string[];
// we might have spotter parameters as well
}

export enum CustomActionsPosition {
ANSWERMENU = 'ANSWERMENU',
ANSWERPRIMARY = 'ANSWERPRIMARY',
ANSWERCONTEXTMENU='ANSWERCONTEXTMENU',
LIVEBOARDPRIMARY = 'LIVEBOARDPRIMARY',
LIVEBOARDMENU = 'LIVEBOARDMENU',
}

/**
* Enum options to show or suppress Visual Embed SDK and
* ThoughtSpot application logs in the console output.
Expand Down Expand Up @@ -5304,4 +5336,5 @@ export interface DefaultAppInitData {
hiddenHomeLeftNavItems: string[];
customVariablesForThirdPartyTools: Record<string, any>;
hiddenListColumns: ListPageColumns[];
customActions: CustomAction[];
}
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
DOMSelector,
RuntimeParameter,
AllEmbedViewConfig,
CustomAction,
} from './types';
import { logger } from './utils/logger';

Expand Down Expand Up @@ -243,6 +244,10 @@ export const getCustomisations = (
return customizations;
};

export const getCustomActions = (customActions: CustomAction[]): CustomAction[] => {
return customActions;
};

export const getRuntimeFilters = (runtimefilters: any) => getFilterQuery(runtimefilters || []);

/**
Expand Down
Loading