@trops/dash-core 0.1.239 → 0.1.241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6358,7 +6358,7 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6358
6358
  _context2.prev = 1;
6359
6359
  _state$customization = state.customization, name = _state$customization.name, menuId = _state$customization.menuId, theme = _state$customization.theme;
6360
6360
  if (!(isPrebuilt && state.selectedDashboard)) {
6361
- _context2.next = 7;
6361
+ _context2.next = 9;
6362
6362
  break;
6363
6363
  }
6364
6364
  if (!onInstallDashboard) {
@@ -6375,19 +6375,25 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6375
6375
  });
6376
6376
  case 2:
6377
6377
  result = _context2.sent;
6378
- _context2.next = 6;
6378
+ _context2.next = 8;
6379
6379
  break;
6380
6380
  case 3:
6381
- if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.registry) !== null && _window$mainApi !== void 0 && _window$mainApi.installDashboard)) {
6382
- _context2.next = 6;
6381
+ if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.dashboardConfig) !== null && _window$mainApi !== void 0 && _window$mainApi.installDashboardFromRegistry)) {
6382
+ _context2.next = 8;
6383
6383
  break;
6384
6384
  }
6385
6385
  _context2.next = 4;
6386
- return window.mainApi.registry.installDashboard(appId, state.selectedDashboard.name || state.selectedDashboard.key);
6386
+ return window.mainApi.dashboardConfig.installDashboardFromRegistry(appId, state.selectedDashboard.name || state.selectedDashboard.key);
6387
6387
  case 4:
6388
6388
  installResult = _context2.sent;
6389
+ if (!(installResult !== null && installResult !== void 0 && installResult.authRequired)) {
6390
+ _context2.next = 5;
6391
+ break;
6392
+ }
6393
+ throw new Error(installResult.error || "Sign in to install this dashboard.");
6394
+ case 5:
6389
6395
  if (!(installResult !== null && installResult !== void 0 && installResult.workspace)) {
6390
- _context2.next = 6;
6396
+ _context2.next = 7;
6391
6397
  break;
6392
6398
  }
6393
6399
  updatedWorkspace = _objectSpread$B(_objectSpread$B({}, installResult.workspace), {}, {
@@ -6395,87 +6401,95 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6395
6401
  menuId: menuId || 1,
6396
6402
  themeKey: theme
6397
6403
  });
6398
- _context2.next = 5;
6404
+ _context2.next = 6;
6399
6405
  return window.mainApi.workspace.saveWorkspaceForApplication(appId, updatedWorkspace);
6400
- case 5:
6406
+ case 6:
6401
6407
  result = {
6402
6408
  success: true,
6403
6409
  workspace: updatedWorkspace
6404
6410
  };
6405
- case 6:
6406
- _context2.next = 25;
6411
+ _context2.next = 8;
6407
6412
  break;
6408
6413
  case 7:
6414
+ if (!(installResult !== null && installResult !== void 0 && installResult.error)) {
6415
+ _context2.next = 8;
6416
+ break;
6417
+ }
6418
+ throw new Error(installResult.error);
6419
+ case 8:
6420
+ _context2.next = 27;
6421
+ break;
6422
+ case 9:
6409
6423
  // Build-your-own path: create layout from template + place widgets
6410
6424
  template = layoutTemplates.find(function (t) {
6411
6425
  return t.id === state.layout.templateKey;
6412
6426
  });
6413
6427
  if (template) {
6414
- _context2.next = 8;
6428
+ _context2.next = 10;
6415
6429
  break;
6416
6430
  }
6417
6431
  throw new Error("No layout template selected.");
6418
- case 8:
6432
+ case 10:
6419
6433
  if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.widgets)) {
6420
- _context2.next = 18;
6434
+ _context2.next = 20;
6421
6435
  break;
6422
6436
  }
6423
- _context2.next = 9;
6437
+ _context2.next = 11;
6424
6438
  return window.mainApi.widgets.list();
6425
- case 9:
6439
+ case 11:
6426
6440
  _t = _context2.sent;
6427
6441
  if (_t) {
6428
- _context2.next = 10;
6442
+ _context2.next = 12;
6429
6443
  break;
6430
6444
  }
6431
6445
  _t = [];
6432
- case 10:
6446
+ case 12:
6433
6447
  installedList = _t;
6434
6448
  installedNames = new Set(installedList.map(function (w) {
6435
6449
  return w.name;
6436
6450
  }));
6437
6451
  _iterator = _createForOfIteratorHelper$e(state.selectedWidgets);
6438
- _context2.prev = 11;
6452
+ _context2.prev = 13;
6439
6453
  _iterator.s();
6440
- case 12:
6454
+ case 14:
6441
6455
  if ((_step = _iterator.n()).done) {
6442
- _context2.next = 15;
6456
+ _context2.next = 17;
6443
6457
  break;
6444
6458
  }
6445
6459
  widget = _step.value;
6446
6460
  if (widget.isRegistry) {
6447
- _context2.next = 13;
6461
+ _context2.next = 15;
6448
6462
  break;
6449
6463
  }
6450
- return _context2.abrupt("continue", 14);
6451
- case 13:
6464
+ return _context2.abrupt("continue", 16);
6465
+ case 15:
6452
6466
  scopedId = widget.packageScope ? "@".concat(widget.packageScope.replace(/^@/, ""), "/").concat(widget.packageName) : widget.packageName;
6453
6467
  if (!(!installedNames.has(scopedId) && !installedNames.has(widget.packageName))) {
6454
- _context2.next = 14;
6468
+ _context2.next = 16;
6455
6469
  break;
6456
6470
  }
6457
6471
  resolvedUrl = (widget.downloadUrl || "").replace(/\{version\}/g, widget.packageVersion || "").replace(/\{name\}/g, widget.packageName || "");
6458
6472
  if (!resolvedUrl) {
6459
- _context2.next = 14;
6473
+ _context2.next = 16;
6460
6474
  break;
6461
6475
  }
6462
- _context2.next = 14;
6476
+ _context2.next = 16;
6463
6477
  return window.mainApi.widgets.install(scopedId, resolvedUrl);
6464
- case 14:
6465
- _context2.next = 12;
6478
+ case 16:
6479
+ _context2.next = 14;
6466
6480
  break;
6467
- case 15:
6468
- _context2.next = 17;
6481
+ case 17:
6482
+ _context2.next = 19;
6469
6483
  break;
6470
- case 16:
6471
- _context2.prev = 16;
6472
- _t2 = _context2["catch"](11);
6484
+ case 18:
6485
+ _context2.prev = 18;
6486
+ _t2 = _context2["catch"](13);
6473
6487
  _iterator.e(_t2);
6474
- case 17:
6475
- _context2.prev = 17;
6488
+ case 19:
6489
+ _context2.prev = 19;
6476
6490
  _iterator.f();
6477
- return _context2.finish(17);
6478
- case 18:
6491
+ return _context2.finish(19);
6492
+ case 20:
6479
6493
  layoutObj = createLayoutFromTemplate(template, menuId || 1); // Place widgets into grid cells as proper layout items
6480
6494
  widgetOrder = state.layout.widgetOrder || [];
6481
6495
  cells = template.cells.filter(function (c) {
@@ -6512,31 +6526,31 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6512
6526
  }, _loop);
6513
6527
  });
6514
6528
  i = 0;
6515
- case 19:
6529
+ case 21:
6516
6530
  if (!(i < widgetOrder.length && i < cells.length)) {
6517
- _context2.next = 21;
6531
+ _context2.next = 23;
6518
6532
  break;
6519
6533
  }
6520
- return _context2.delegateYield(_loop(i), "t0", 20);
6521
- case 20:
6534
+ return _context2.delegateYield(_loop(i), "t0", 22);
6535
+ case 22:
6522
6536
  i++;
6523
- _context2.next = 19;
6537
+ _context2.next = 21;
6524
6538
  break;
6525
- case 21:
6539
+ case 23:
6526
6540
  fullLayout = [layoutObj].concat(widgetItems);
6527
6541
  if (!onCreateWorkspace) {
6528
- _context2.next = 23;
6542
+ _context2.next = 25;
6529
6543
  break;
6530
6544
  }
6531
- _context2.next = 22;
6545
+ _context2.next = 24;
6532
6546
  return onCreateWorkspace(fullLayout, theme, name.trim());
6533
- case 22:
6547
+ case 24:
6534
6548
  result = _context2.sent;
6535
- _context2.next = 25;
6549
+ _context2.next = 27;
6536
6550
  break;
6537
- case 23:
6551
+ case 25:
6538
6552
  if (!((_window$mainApi3 = window.mainApi) !== null && _window$mainApi3 !== void 0 && (_window$mainApi3 = _window$mainApi3.workspace) !== null && _window$mainApi3 !== void 0 && _window$mainApi3.saveWorkspaceForApplication)) {
6539
- _context2.next = 25;
6553
+ _context2.next = 27;
6540
6554
  break;
6541
6555
  }
6542
6556
  workspace = {
@@ -6545,32 +6559,32 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6545
6559
  themeKey: theme,
6546
6560
  layout: fullLayout
6547
6561
  };
6548
- _context2.next = 24;
6562
+ _context2.next = 26;
6549
6563
  return window.mainApi.workspace.saveWorkspaceForApplication(appId, workspace);
6550
- case 24:
6564
+ case 26:
6551
6565
  result = {
6552
6566
  success: true,
6553
6567
  workspace: workspace
6554
6568
  };
6555
- case 25:
6569
+ case 27:
6556
6570
  if (result) {
6557
6571
  setCreatedDashboard(result.workspace || result);
6558
6572
  }
6559
- _context2.next = 27;
6573
+ _context2.next = 29;
6560
6574
  break;
6561
- case 26:
6562
- _context2.prev = 26;
6575
+ case 28:
6576
+ _context2.prev = 28;
6563
6577
  _t3 = _context2["catch"](1);
6564
6578
  setError(_t3.message || "Failed to create dashboard.");
6565
- case 27:
6566
- _context2.prev = 27;
6579
+ case 29:
6580
+ _context2.prev = 29;
6567
6581
  setCreating(false);
6568
- return _context2.finish(27);
6569
- case 28:
6582
+ return _context2.finish(29);
6583
+ case 30:
6570
6584
  case "end":
6571
6585
  return _context2.stop();
6572
6586
  }
6573
- }, _callee, null, [[1, 26, 27, 28], [11, 16, 17, 18]]);
6587
+ }, _callee, null, [[1, 28, 29, 30], [13, 18, 19, 20]]);
6574
6588
  })), [state, isPrebuilt, onInstallDashboard, onCreateWorkspace, appId]);
6575
6589
 
6576
6590
  // Expose handleCreate and creating state to parent via ref (DASH-183)