-
Notifications
You must be signed in to change notification settings - Fork 8
[SCAL-284563] Added Margin value check #374
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
base: main
Are you sure you want to change the base?
Changes from all commits
e72e2c0
5fa76fa
37b3d6c
bb43cf6
24be201
1dc20bb
da0a85d
8ac4896
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2247,7 +2247,8 @@ export enum EmbedEvent { | |||||||||
| */ | ||||||||||
| ALL = '*', | ||||||||||
| /** | ||||||||||
| * Emitted when an Answer is saved in the app | ||||||||||
| * Emitted when an Answer is saved in the app. | ||||||||||
| * Use start:true to subscribe to when save is initiated, or end:true to subscribe to when save is completed. Default is end:true. | ||||||||||
| * @Version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2282,6 +2283,7 @@ export enum EmbedEvent { | |||||||||
| Download = 'download', | ||||||||||
| /** | ||||||||||
| * Emitted when the download action is triggered on an Answer. | ||||||||||
| * Use start:true to subscribe to when download is initiated, or end:true to subscribe to when download is completed. Default is end:true. | ||||||||||
| * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.4.0.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2296,6 +2298,7 @@ export enum EmbedEvent { | |||||||||
| DownloadAsPng = 'downloadAsPng', | ||||||||||
| /** | ||||||||||
| * Emitted when the Download as PDF action is triggered on an Answer | ||||||||||
| * Use start:true to subscribe to when download as PDF is initiated, or end:true to subscribe to when download as PDF is completed. Default is end:true. | ||||||||||
|
Comment on lines
2300
to
+2301
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for
Suggested change
|
||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2310,6 +2313,7 @@ export enum EmbedEvent { | |||||||||
| DownloadAsPdf = 'downloadAsPdf', | ||||||||||
| /** | ||||||||||
| * Emitted when the Download as CSV action is triggered on an Answer. | ||||||||||
| * Use start:true to subscribe to when download as CSV is initiated, or end:true to subscribe to when download as CSV is completed. Default is end:true. | ||||||||||
|
Comment on lines
2315
to
+2316
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for
Suggested change
|
||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2324,6 +2328,7 @@ export enum EmbedEvent { | |||||||||
| DownloadAsCsv = 'downloadAsCsv', | ||||||||||
| /** | ||||||||||
| * Emitted when the Download as XLSX action is triggered on an Answer. | ||||||||||
| * Use start:true to subscribe to when download as XLSX is initiated, or end:true to subscribe to when download as XLSX is completed. Default is end:true. | ||||||||||
|
Comment on lines
2330
to
+2331
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for
Suggested change
|
||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2338,6 +2343,7 @@ export enum EmbedEvent { | |||||||||
| DownloadAsXlsx = 'downloadAsXlsx', | ||||||||||
| /** | ||||||||||
| * Emitted when an Answer is deleted in the app | ||||||||||
| * Use start:true to subscribe to when delete is initiated, or end:true to subscribe to when delete is completed. Default is end:true. | ||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2364,6 +2370,7 @@ export enum EmbedEvent { | |||||||||
| /** | ||||||||||
| * Emitted when a user initiates the Pin action to | ||||||||||
| * add an Answer to a Liveboard. | ||||||||||
| * Use start:true to subscribe to when pin is initiated, or end:true to subscribe to when pin is completed. Default is end:true. | ||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2477,6 +2484,7 @@ export enum EmbedEvent { | |||||||||
| /** | ||||||||||
| * Emitted when the **Export TML** action is triggered on an | ||||||||||
| * an embedded object in the app | ||||||||||
| * Use start:true to subscribe to when export is initiated, or end:true to subscribe to when export is completed. Default is end:true. | ||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
@@ -2502,6 +2510,7 @@ export enum EmbedEvent { | |||||||||
| SaveAsView = 'saveAsView', | ||||||||||
| /** | ||||||||||
| * Emitted when the user creates a copy of an Answer. | ||||||||||
| * Use start:true to subscribe to when copy and edit is initiated, or end:true to subscribe to when copy and edit is completed. Default is end:true. | ||||||||||
|
Comment on lines
2512
to
+2513
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for
Suggested change
|
||||||||||
| * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw | ||||||||||
| * @example | ||||||||||
| *```js | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -132,6 +132,23 @@ export const getCssDimension = (value: number | string): string => { | |||||||||||||||||||||||||||||||||||||||||||||||
| return value; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||
| * Validates if a string is a valid CSS margin value. | ||||||||||||||||||||||||||||||||||||||||||||||||
| * @param value - The string to validate | ||||||||||||||||||||||||||||||||||||||||||||||||
| * @returns true if the value is a valid CSS margin value, false otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| export const isValidCssMargin = (value: string): boolean => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof value !== 'string' || value.trim() === '') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Check for CSS length values (e.g., "10px", "1em", "50%") | ||||||||||||||||||||||||||||||||||||||||||||||||
| const cssLengthPattern = /^\d+(\.\d+)?(px|em|rem|%|vh|vw)$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
| const parts = value.trim().split(/\s+/); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| return parts.length <= 4 && parts.every(part => cssLengthPattern.test(part.trim())); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+140
to
+150
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CSS margin validation can be improved to support negative values and unitless zero, which are valid in CSS. For example, I've also removed a redundant empty line for better code style.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export const getSSOMarker = (markerId: string) => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const encStringToAppend = encodeURIComponent(markerId); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return `tsSSOMarker=${encStringToAppend}`; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This validation logic has a few areas for improvement:
lazyLoadingMarginis not provided (i.e.,undefined). It's better to only log an error when an invalid value is explicitly provided.loggerutility, which is already imported in this file. For consistency,logger.errorshould be used instead ofconsole.error.src/embed/liveboard.ts. Consider extracting it into a shared utility function insrc/utils.tsto improve maintainability.Here's a suggested refactoring that addresses these points.