Commit 9cafa7072107c55a01e0f99c6a57631c41c19ad9

Authored by Igor Kulikov
Committed by GitHub
2 parents 03457a35 149a1dc9

Merge pull request #3950 from vvlladd28/improvement/widget-action/open-dashboard

[3.2.1] UI: Added a new settings "Open in a new browser tab" in the widget action
@@ -112,6 +112,12 @@ @@ -112,6 +112,12 @@
112 {{ 'widget-action.open-right-layout' | translate }} 112 {{ 'widget-action.open-right-layout' | translate }}
113 </mat-checkbox> 113 </mat-checkbox>
114 </ng-template> 114 </ng-template>
  115 + <ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
  116 + widgetActionFormGroup.get('type').value : ''">
  117 + <mat-checkbox formControlName="openNewBrowserTab">
  118 + {{ 'widget-action.open-new-browser-tab' | translate }}
  119 + </mat-checkbox>
  120 + </ng-template>
115 <ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState || 121 <ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState ||
116 widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState || 122 widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ||
117 widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ? 123 widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
@@ -145,6 +145,10 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia @@ -145,6 +145,10 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
145 ); 145 );
146 if (type === WidgetActionType.openDashboard) { 146 if (type === WidgetActionType.openDashboard) {
147 this.actionTypeFormGroup.addControl( 147 this.actionTypeFormGroup.addControl(
  148 + 'openNewBrowserTab',
  149 + this.fb.control(action ? action.openNewBrowserTab : false, [])
  150 + );
  151 + this.actionTypeFormGroup.addControl(
148 'targetDashboardId', 152 'targetDashboardId',
149 this.fb.control(action ? action.targetDashboardId : null, 153 this.fb.control(action ? action.targetDashboardId : null,
150 [Validators.required]) 154 [Validators.required])
@@ -1029,7 +1029,11 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI @@ -1029,7 +1029,11 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1029 } else { 1029 } else {
1030 url = `/dashboards/${targetDashboardId}?state=${state}`; 1030 url = `/dashboards/${targetDashboardId}?state=${state}`;
1031 } 1031 }
1032 - this.router.navigateByUrl(url); 1032 + if (descriptor.openNewBrowserTab) {
  1033 + window.open(url, '_blank');
  1034 + } else {
  1035 + this.router.navigateByUrl(url);
  1036 + }
1033 break; 1037 break;
1034 case WidgetActionType.custom: 1038 case WidgetActionType.custom:
1035 const customFunction = descriptor.customFunction; 1039 const customFunction = descriptor.customFunction;
@@ -344,6 +344,7 @@ export interface WidgetActionDescriptor extends CustomActionDescriptor { @@ -344,6 +344,7 @@ export interface WidgetActionDescriptor extends CustomActionDescriptor {
344 targetDashboardId?: string; 344 targetDashboardId?: string;
345 targetDashboardStateId?: string; 345 targetDashboardStateId?: string;
346 openRightLayout?: boolean; 346 openRightLayout?: boolean;
  347 + openNewBrowserTab?: boolean;
347 setEntityId?: boolean; 348 setEntityId?: boolean;
348 stateEntityParamName?: string; 349 stateEntityParamName?: string;
349 } 350 }
@@ -2257,7 +2257,8 @@ @@ -2257,7 +2257,8 @@
2257 "target-dashboard-state-required": "Target dashboard state is required", 2257 "target-dashboard-state-required": "Target dashboard state is required",
2258 "set-entity-from-widget": "Set entity from widget", 2258 "set-entity-from-widget": "Set entity from widget",
2259 "target-dashboard": "Target dashboard", 2259 "target-dashboard": "Target dashboard",
2260 - "open-right-layout": "Open right dashboard layout (mobile view)" 2260 + "open-right-layout": "Open right dashboard layout (mobile view)",
  2261 + "open-new-browser-tab": "Open in a new browser tab"
2261 }, 2262 },
2262 "widgets-bundle": { 2263 "widgets-bundle": {
2263 "current": "Current bundle", 2264 "current": "Current bundle",