Skip to content

Commit cb0605f

Browse files
Add warning if CA names length is greater than 30 characters (#335)
1 parent c2da3fd commit cb0605f

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thoughtspot/visual-embed-sdk",
3-
"version": "1.42.1",
3+
"version": "1.42.2",
44
"description": "ThoughtSpot Embed SDK",
55
"module": "lib/src/index.js",
66
"main": "dist/tsembed.js",

src/react/all-types-export.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ export {
5959
resetCachedAuthToken,
6060
UIPassthroughEvent,
6161
DataPanelCustomColumnGroupsAccordionState,
62+
CustomActionsPosition,
63+
CustomActionTarget,
6264
} from '../index';

src/utils/custom-actions.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,26 @@ describe('getCustomActions function', () => {
428428
expect(result.errors[0]).toContain("Position 'PRIMARY' is not supported for spotter-level custom actions. Supported positions: MENU, CONTEXTMENU");
429429
});
430430
});
431+
432+
describe('Warnings', () => {
433+
test('should warn when action name length exceeds 30 characters', () => {
434+
// Arrange
435+
const longName = 'A'.repeat(31);
436+
const action: CustomAction = {
437+
id: 'long-name-id',
438+
name: longName,
439+
target: CustomActionTarget.LIVEBOARD,
440+
position: CustomActionsPosition.PRIMARY,
441+
};
442+
443+
// Act
444+
const result = getCustomActions([action]);
445+
446+
// Assert
447+
expect(result.actions).toHaveLength(1);
448+
expect(logger.warn).toHaveBeenCalledWith([
449+
`Custom action name '${longName}' exceeds 30 characters. This may cause display or truncation issues in the UI.`
450+
]);
451+
});
452+
});
431453
});

src/utils/custom-actions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CustomAction, CustomActionsPosition, CustomActionTarget } from '../type
22
import { arrayIncludesString } from '../utils';
33
import sortBy from 'lodash/sortBy';
44
import { CUSTOM_ACTIONS_ERROR_MESSAGE } from '../errors';
5+
import { logger } from './logger';
56

67
export interface CustomActionsValidationResult {
78
actions: CustomAction[];
@@ -208,6 +209,16 @@ export const getCustomActions = (customActions: CustomAction[]): CustomActionsVa
208209
}
209210
});
210211

212+
// Step 4: Collect warnings for long custom action names
213+
const MAX_ACTION_NAME_LENGTH = 30;
214+
const warnings = finalValidActions
215+
.filter(action => action.name.length > MAX_ACTION_NAME_LENGTH)
216+
.map(action => `Custom action name '${action.name}' exceeds ${MAX_ACTION_NAME_LENGTH} characters. This may cause display or truncation issues in the UI.`);
217+
218+
if (warnings.length > 0) {
219+
logger.warn(warnings);
220+
}
221+
211222
const sortedActions = sortBy(finalValidActions, (a) => a.name.toLocaleLowerCase());
212223

213224
return {

0 commit comments

Comments
 (0)