Skip to content

Conversation

@shivam-kumar-ts
Copy link
Contributor

  • Implement restricting navigation for blocked embed routes

@shivam-kumar-ts shivam-kumar-ts requested a review from a team as a code owner November 7, 2025 05:20
@mnk-blr
Copy link
Collaborator

mnk-blr commented Nov 7, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shivam-kumar-ts, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a significant feature for embedded ThoughtSpot applications, enabling granular control over user navigation. It allows developers to define specific routes that users are permitted to access within an embed, enhancing security and user experience by preventing navigation to unintended areas. The change includes new configuration parameters and a dedicated enum for managing these route restrictions.

Highlights

  • Route Restriction for Embeds: Introduced the capability to restrict navigation within embedded ThoughtSpot applications to a predefined set of routes.
  • New Configuration Options: Added allowedRoutes (an array of Path enum values) and accessDeniedMessage (a string) to the BaseViewConfig interface, allowing developers to specify permitted routes and a custom message for denied access.
  • Path Enum Definition: Created a new Path enum to explicitly define various navigable routes within the embedded application, including a wildcard Path.All for unrestricted access.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a feature to restrict navigation for embedded routes. It adds allowedRoutes and accessDeniedMessage configurations to control access. The implementation looks correct, with corresponding changes in type definitions, the main embed class, and test files. I've found a few minor issues in the JSDoc comments and code formatting in src/types.ts and have provided suggestions to fix them. Overall, this is a good addition.

Comment on lines 1101 to 1202
/**
* Array of routes that are allowed to be accessed in the embedded app.
* When specified, navigation will be restricted to only these routes.
* Use Path.All to allow all routes without restrictions.
*
* Supported embed types: `AppEmbed`, `LiveboardEmbed`, `SageEmbed`, `SearchEmbed`, `SpotterAgentEmbed`, `SpotterEmbed`, `SearchBarEmbed`
* @example
*
*
* // Replace <EmbedComponent> with embed component name. For example, AppEmbed, SearchEmbed, or LiveboardEmbed
* const embed = new AppEmbed('#tsEmbed', {
* ... // other embed view config
* allowedRoutes: [Path.Home, Path.Search, Path.Liveboards],
* accessDeniedMessage: 'You do not have access to this page'
* })
* *
*
* // Allow all routes
* const embed = new AppEmbed('#tsEmbed', {
* allowedRoutes: [Path.All]
* })
* */
allowedRoutes?: Path[];
/**
* Custom message to display when a user tries to access a route
* that is not in the allowedRoutes list.
*
* Supported embed types: `AppEmbed`, `LiveboardEmbed`, `SageEmbed`, `SearchEmbed`, `SpotterAgentEmbed`, `SpotterEmbed`, `SearchBarEmbed`
* @default 'Access Denied'
* @example
*
* const embed = new AppEmbed('#tsEmbed', {
* allowedRoutes: [Path.Home, Path.Liveboards],
* accessDeniedMessage: 'You do not have permission to access this page.
* Please contact your administrator.'
* })
* */
accessDeniedMessage?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JSDoc comments for allowedRoutes and accessDeniedMessage have some formatting issues and an incorrect example. Additionally, the indentation for these new properties is inconsistent with the rest of the BaseViewConfig interface. Properties in this interface are indented with 4 spaces, but the new properties use 8 spaces.

  1. There are some extra empty lines and stray asterisks (*) in the comment blocks which should be cleaned up.
  2. The example for accessDeniedMessage contains a multi-line string literal which is invalid in JavaScript. It should be a single line string.
  3. The indentation for allowedRoutes and accessDeniedMessage should be 4 spaces to match the existing properties in BaseViewConfig.
    /**
     * Array of routes that are allowed to be accessed in the embedded app.
     * When specified, navigation will be restricted to only these routes.
     * Use Path.All to allow all routes without restrictions.
     * 
     * Supported embed types: `AppEmbed`, `LiveboardEmbed`, `SageEmbed`, `SearchEmbed`, `SpotterAgentEmbed`, `SpotterEmbed`, `SearchBarEmbed`
     * @example
     *
     * // Replace <EmbedComponent> with embed component name. For example, AppEmbed, SearchEmbed, or LiveboardEmbed
     * const embed = new AppEmbed('#tsEmbed', {
     *    ... // other embed view config
     *    allowedRoutes: [Path.Home, Path.Search, Path.Liveboards],
     *    accessDeniedMessage: 'You do not have access to this page'
     * })
     *
     * // Allow all routes
     * const embed = new AppEmbed('#tsEmbed', {
     *    allowedRoutes: [Path.All]
     * })
     */
    allowedRoutes?: Path[];
    /**
     * Custom message to display when a user tries to access a route
     * that is not in the allowedRoutes list.
     * 
     * Supported embed types: `AppEmbed`, `LiveboardEmbed`, `SageEmbed`, `SearchEmbed`, `SpotterAgentEmbed`, `SpotterEmbed`, `SearchBarEmbed`
     * @default 'Access Denied'
     * @example
     *
     * const embed = new AppEmbed('#tsEmbed', {
     *    allowedRoutes: [Path.Home, Path.Liveboards],
     *    accessDeniedMessage: 'You do not have permission to access this page. Please contact your administrator.'
     * })
     */
    accessDeniedMessage?: string;

src/types.ts Outdated
* allowedRoutes: [Path.Home, Path.Search, Path.Liveboards],
* accessDeniedMessage: 'You do not have access to this page'
* })
* * @version SDK: 1.45.0 | ThoughtSpot: *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a formatting issue in the JSDoc for the Path enum. The @version tag has an extra asterisk at the beginning of the line, which might affect how documentation is generated.

 * @version SDK: 1.45.0 | ThoughtSpot: *

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/thoughtspot/visual-embed-sdk/@thoughtspot/visual-embed-sdk@344

commit: dc83a6c

@shivam-kumar-ts shivam-kumar-ts force-pushed the SCAL-239528 branch 21 times, most recently from 3c6f49a to bd559cd Compare November 10, 2025 16:54

// Pinboard/Liveboard
Pinboard = '/insights/pinboard/:pinboardId',
VizBoard = '/insights/pinboard/:pinboardId/:vizId',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have tabs keyword in the URL

message: customActionsResult.errors,
});
}
const blockedAndAllowedRoutesResult = getBlockedAndAllowedRoutes( this.viewConfig?.routeBlocking, { embedComponentType: (this.viewConfig as any).embedComponentType || '', liveboardId: (this.viewConfig as any).liveboardId, vizId: (this.viewConfig as any).vizId, activeTabId: (this.viewConfig as any).activeTabId, pageId: (this.viewConfig as any).pageId, path: (this.viewConfig as any).path });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you simplify this - also if possible remove any insteances.

message: customActionsResult.errors,
});
}
const blockedAndAllowedRoutesResult = getBlockedAndAllowedRoutes( this.viewConfig?.routeBlocking, { embedComponentType: (this.viewConfig as any).embedComponentType || '', liveboardId: (this.viewConfig as any).liveboardId, vizId: (this.viewConfig as any).vizId, activeTabId: (this.viewConfig as any).activeTabId, pageId: (this.viewConfig as any).pageId, path: (this.viewConfig as any).path });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do ?? can you please refactor this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAGIC

* ```
* @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
*/
export enum NavigationPath {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean up this, only put the most used pages here, that customer has access to in embed.

const { embedComponentType, liveboardId, vizId, activeTabId, pageId, path } = config;

switch (embedComponentType) {
case 'LiveboardEmbed': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no enum for this ?

path?: string;
}

const EMBED_COMPONENT_GENERIC_PATHS: Record<string, string[]> = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this should be part of the embed component

/**
* Generate specific allowed routes based on the embed configuration
*/
export const generateAutoAllowedRoutes = (config: RouteGenerationConfig): string[] => {
Copy link
Contributor

@yinstardev yinstardev Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it called autoAllowed? can you confirm.

const routes: string[] = [];

if (liveboardId) {
routes.push(`/embed/viz/${liveboardId}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be part of liveboard component

@shivam-kumar-ts shivam-kumar-ts force-pushed the SCAL-239528 branch 6 times, most recently from 4934fed to 3ca4890 Compare November 12, 2025 01:03
@sonar-prod-ts
Copy link

sonar-prod-ts bot commented Dec 9, 2025

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.4% 1.4% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants