diff --git a/package-lock.json b/package-lock.json index 9673e28a..eaaf1026 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@thoughtspot/visual-embed-sdk", - "version": "1.42.1", + "version": "1.42.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@thoughtspot/visual-embed-sdk", - "version": "1.42.1", + "version": "1.42.2", "license": "ThoughtSpot Development Tools End User License Agreement", "dependencies": { "classnames": "^2.3.1", diff --git a/package.json b/package.json index c205d9fd..eef7f003 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thoughtspot/visual-embed-sdk", - "version": "1.42.1", + "version": "1.42.2", "description": "ThoughtSpot Embed SDK", "module": "lib/src/index.js", "main": "dist/tsembed.js", diff --git a/src/react/all-types-export.ts b/src/react/all-types-export.ts index 2f487202..edf35b59 100644 --- a/src/react/all-types-export.ts +++ b/src/react/all-types-export.ts @@ -59,4 +59,6 @@ export { resetCachedAuthToken, UIPassthroughEvent, DataPanelCustomColumnGroupsAccordionState, + CustomActionsPosition, + CustomActionTarget, } from '../index'; diff --git a/src/utils/custom-actions.spec.ts b/src/utils/custom-actions.spec.ts index dd53f02d..2e075012 100644 --- a/src/utils/custom-actions.spec.ts +++ b/src/utils/custom-actions.spec.ts @@ -428,4 +428,26 @@ describe('getCustomActions function', () => { expect(result.errors[0]).toContain("Position 'PRIMARY' is not supported for spotter-level custom actions. Supported positions: MENU, CONTEXTMENU"); }); }); + + describe('Warnings', () => { + test('should warn when action name length exceeds 30 characters', () => { + // Arrange + const longName = 'A'.repeat(31); + const action: CustomAction = { + id: 'long-name-id', + name: longName, + target: CustomActionTarget.LIVEBOARD, + position: CustomActionsPosition.PRIMARY, + }; + + // Act + const result = getCustomActions([action]); + + // Assert + expect(result.actions).toHaveLength(1); + expect(logger.warn).toHaveBeenCalledWith([ + `Custom action name '${longName}' exceeds 30 characters. This may cause display or truncation issues in the UI.` + ]); + }); + }); }); diff --git a/src/utils/custom-actions.ts b/src/utils/custom-actions.ts index 60549382..149b2699 100644 --- a/src/utils/custom-actions.ts +++ b/src/utils/custom-actions.ts @@ -2,6 +2,7 @@ import { CustomAction, CustomActionsPosition, CustomActionTarget } from '../type import { arrayIncludesString } from '../utils'; import sortBy from 'lodash/sortBy'; import { CUSTOM_ACTIONS_ERROR_MESSAGE } from '../errors'; +import { logger } from './logger'; export interface CustomActionsValidationResult { actions: CustomAction[]; @@ -208,6 +209,16 @@ export const getCustomActions = (customActions: CustomAction[]): CustomActionsVa } }); + // Step 4: Collect warnings for long custom action names + const MAX_ACTION_NAME_LENGTH = 30; + const warnings = finalValidActions + .filter(action => action.name.length > MAX_ACTION_NAME_LENGTH) + .map(action => `Custom action name '${action.name}' exceeds ${MAX_ACTION_NAME_LENGTH} characters. This may cause display or truncation issues in the UI.`); + + if (warnings.length > 0) { + logger.warn(warnings); + } + const sortedActions = sortBy(finalValidActions, (a) => a.name.toLocaleLowerCase()); return {