Skip to content

Commit

Permalink
GROK-16940: Possibility to configure properties of balloon in js-api
Browse files Browse the repository at this point in the history
  • Loading branch information
PavloPolovyi committed Oct 25, 2024
1 parent 80e0195 commit 416a5a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion js-api/src/api/grok_api.g.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface IDartApi {
grok_Get_Sidebar(): any;
grok_Get_DockManager(): any;
grok_Tools_SetHoverVisibility(e: any, items: any): any;
grok_Balloon(messageOrElement: any, [type]: any): any;
grok_Balloon(messageOrElement: any, type: String, options: any): any;
grok_Balloon_CloseAll(): any;
grok_CurrentTable(): any;
grok_Get_CurrentView(): any;
Expand Down
25 changes: 18 additions & 7 deletions js-api/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class AppBuildInfo {
server: ComponentBuildInfo = new ComponentBuildInfo();
}

export interface BalloonOptions {
oneTimeKey?: string // the messages with the same oneTimeKey will only be shown once
copyText?: string; // will be copied to the clipboard when user clicks on the "copy to clipboard" icon
autoHide?: boolean; // auto hide icon after timeout, default is true
timeout?: number; // timeout in seconds after which balloon will be automatically hidden, default is 5
}

/**
* Grok visual shell, use it to get access to top-level views, tables, methods, etc.
* @example
Expand Down Expand Up @@ -118,21 +125,25 @@ export class Shell {
}

/** Shows information message (green background)
* @param {string} x - message */
info(x: any): void {
api.grok_Balloon(typeof x == "string" || x instanceof HTMLElement ? x : JSON.stringify(x), 'info');
* @param {string} x - message
* @param options */
info(x: any, options?: BalloonOptions): void {
api.grok_Balloon(typeof x == "string" || x instanceof HTMLElement ? x : JSON.stringify(x),
'info', toDart(options ?? {}));
}

/** Shows information message (red background)
* @param options
* @param {string} s - message */
error(s: string | HTMLElement): void {
api.grok_Balloon(s, 'error');
error(s: string | HTMLElement, options?: BalloonOptions): void {
api.grok_Balloon(s, 'error', toDart(options ?? {}));
}

/** Shows warning message (yellow background)
* @param options
* @param {string} s - message */
warning(s: string | HTMLElement): void {
api.grok_Balloon(s, 'warning');
warning(s: string | HTMLElement, options?: BalloonOptions): void {
api.grok_Balloon(s, 'warning', toDart(options ?? {}));
}

/** Docks element in a separate window.
Expand Down
4 changes: 2 additions & 2 deletions js-api/src/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1019,12 +1019,12 @@ export class Balloon {

/** Shows information message (green background) */
info(s: string | HTMLElement): void {
api.grok_Balloon(s, 'info');
api.grok_Balloon(s, 'info', {});
}

/** Shows information message (red background) */
error(s: string | HTMLElement): void {
api.grok_Balloon(s, 'error');
api.grok_Balloon(s, 'error', {});
}

/** Closes all balloons currently shown */
Expand Down

0 comments on commit 416a5a2

Please sign in to comment.