@trops/dash-core 0.1.109 → 0.1.111

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
@@ -37980,6 +37980,13 @@ var AuthenticatedView = function AuthenticatedView(_ref3) {
37980
37980
  return p.name === updatedPkg.name && p.scope === updatedPkg.scope ? _objectSpread$2(_objectSpread$2({}, p), updatedPkg) : p;
37981
37981
  });
37982
37982
  });
37983
+ },
37984
+ onPackageDeleted: function onPackageDeleted(deletedPkg) {
37985
+ setPackages(function (prev) {
37986
+ return prev.filter(function (p) {
37987
+ return !(p.name === deletedPkg.name && p.scope === deletedPkg.scope);
37988
+ });
37989
+ });
37983
37990
  }
37984
37991
  })]
37985
37992
  });
@@ -38120,7 +38127,8 @@ var ProfileCard = function ProfileCard(_ref4) {
38120
38127
  var PackagesList = function PackagesList(_ref5) {
38121
38128
  var packages = _ref5.packages,
38122
38129
  loading = _ref5.loading,
38123
- onPackageUpdated = _ref5.onPackageUpdated;
38130
+ onPackageUpdated = _ref5.onPackageUpdated,
38131
+ onPackageDeleted = _ref5.onPackageDeleted;
38124
38132
  var _useState1 = React.useState(null),
38125
38133
  _useState10 = _slicedToArray(_useState1, 2),
38126
38134
  editingPkg = _useState10[0],
@@ -38160,6 +38168,10 @@ var PackagesList = function PackagesList(_ref5) {
38160
38168
  onSaved: function onSaved(updated) {
38161
38169
  setEditingPkg(null);
38162
38170
  onPackageUpdated(updated);
38171
+ },
38172
+ onDeleted: function onDeleted() {
38173
+ setEditingPkg(null);
38174
+ onPackageDeleted(pkg);
38163
38175
  }
38164
38176
  }, "".concat(pkg.scope, "/").concat(pkg.name));
38165
38177
  })
@@ -38171,7 +38183,8 @@ var PackageItem = function PackageItem(_ref6) {
38171
38183
  isEditing = _ref6.isEditing,
38172
38184
  onEdit = _ref6.onEdit,
38173
38185
  onCancel = _ref6.onCancel,
38174
- onSaved = _ref6.onSaved;
38186
+ onSaved = _ref6.onSaved,
38187
+ onDeleted = _ref6.onDeleted;
38175
38188
  var _useState11 = React.useState({
38176
38189
  displayName: pkg.displayName || "",
38177
38190
  description: pkg.description || "",
@@ -38186,6 +38199,14 @@ var PackageItem = function PackageItem(_ref6) {
38186
38199
  _useState14 = _slicedToArray(_useState13, 2),
38187
38200
  saving = _useState14[0],
38188
38201
  setSaving = _useState14[1];
38202
+ var _useState15 = React.useState(false),
38203
+ _useState16 = _slicedToArray(_useState15, 2),
38204
+ confirmingDelete = _useState16[0],
38205
+ setConfirmingDelete = _useState16[1];
38206
+ var _useState17 = React.useState(false),
38207
+ _useState18 = _slicedToArray(_useState17, 2),
38208
+ deleting = _useState18[0],
38209
+ setDeleting = _useState18[1];
38189
38210
  function handleSave() {
38190
38211
  return _handleSave2.apply(this, arguments);
38191
38212
  }
@@ -38230,6 +38251,42 @@ var PackageItem = function PackageItem(_ref6) {
38230
38251
  }));
38231
38252
  return _handleSave2.apply(this, arguments);
38232
38253
  }
38254
+ function handleDelete() {
38255
+ return _handleDelete.apply(this, arguments);
38256
+ }
38257
+ function _handleDelete() {
38258
+ _handleDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
38259
+ var _window$mainApi4, result;
38260
+ return _regeneratorRuntime.wrap(function (_context4) {
38261
+ while (1) switch (_context4.prev = _context4.next) {
38262
+ case 0:
38263
+ setDeleting(true);
38264
+ _context4.prev = 1;
38265
+ _context4.next = 2;
38266
+ return (_window$mainApi4 = window.mainApi) === null || _window$mainApi4 === void 0 || (_window$mainApi4 = _window$mainApi4.registryAuth) === null || _window$mainApi4 === void 0 ? void 0 : _window$mainApi4.deletePackage(pkg.scope, pkg.name);
38267
+ case 2:
38268
+ result = _context4.sent;
38269
+ if (result) {
38270
+ onDeleted === null || onDeleted === void 0 || onDeleted();
38271
+ }
38272
+ _context4.next = 4;
38273
+ break;
38274
+ case 3:
38275
+ _context4.prev = 3;
38276
+ _context4["catch"](1);
38277
+ case 4:
38278
+ _context4.prev = 4;
38279
+ setDeleting(false);
38280
+ setConfirmingDelete(false);
38281
+ return _context4.finish(4);
38282
+ case 5:
38283
+ case "end":
38284
+ return _context4.stop();
38285
+ }
38286
+ }, _callee4, null, [[1, 3, 4, 5]]);
38287
+ }));
38288
+ return _handleDelete.apply(this, arguments);
38289
+ }
38233
38290
  var updatedAt = pkg.updatedAt ? new Date(pkg.updatedAt).toLocaleDateString() : null;
38234
38291
  if (isEditing) {
38235
38292
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -38291,24 +38348,53 @@ var PackageItem = function PackageItem(_ref6) {
38291
38348
  })]
38292
38349
  })]
38293
38350
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
38294
- className: "flex gap-2",
38295
- children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
38296
- title: saving ? "Saving..." : "Save",
38297
- onClick: handleSave,
38298
- disabled: saving
38299
- }), /*#__PURE__*/jsxRuntime.jsx("button", {
38300
- type: "button",
38301
- onClick: onCancel,
38302
- className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38303
- children: "Cancel"
38351
+ className: "flex items-center justify-between",
38352
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
38353
+ children: confirmingDelete ? /*#__PURE__*/jsxRuntime.jsxs("div", {
38354
+ className: "flex items-center gap-2",
38355
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
38356
+ type: "button",
38357
+ onClick: handleDelete,
38358
+ disabled: deleting,
38359
+ className: "text-xs text-red-400 hover:text-red-300 cursor-pointer font-medium",
38360
+ children: deleting ? "Deleting..." : "Confirm Delete"
38361
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
38362
+ type: "button",
38363
+ onClick: function onClick() {
38364
+ return setConfirmingDelete(false);
38365
+ },
38366
+ className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38367
+ children: "Cancel"
38368
+ })]
38369
+ }) : /*#__PURE__*/jsxRuntime.jsx("button", {
38370
+ type: "button",
38371
+ onClick: function onClick() {
38372
+ return setConfirmingDelete(true);
38373
+ },
38374
+ className: "text-xs text-red-400/70 hover:text-red-400 cursor-pointer",
38375
+ children: "Delete"
38376
+ })
38377
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
38378
+ className: "flex items-center gap-2",
38379
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
38380
+ type: "button",
38381
+ onClick: onCancel,
38382
+ className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38383
+ children: "Cancel"
38384
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
38385
+ title: saving ? "Saving..." : "Save",
38386
+ onClick: handleSave,
38387
+ disabled: saving
38388
+ })]
38304
38389
  })]
38305
38390
  })]
38306
38391
  });
38307
38392
  }
38308
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
38309
- className: "bg-white/5 rounded-lg p-3 flex items-start justify-between",
38310
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
38311
- className: "flex-1 min-w-0 space-y-1",
38393
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
38394
+ onClick: onEdit,
38395
+ className: "bg-white/5 rounded-lg p-3 cursor-pointer hover:bg-white/10 transition-colors",
38396
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
38397
+ className: "space-y-1",
38312
38398
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
38313
38399
  className: "flex items-center gap-2",
38314
38400
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
@@ -38328,12 +38414,7 @@ var PackageItem = function PackageItem(_ref6) {
38328
38414
  className: "text-[10px] opacity-40",
38329
38415
  children: ["Updated ", updatedAt]
38330
38416
  })]
38331
- }), /*#__PURE__*/jsxRuntime.jsx("button", {
38332
- type: "button",
38333
- onClick: onEdit,
38334
- className: "flex-shrink-0 ml-2 text-xs opacity-40 hover:opacity-80 cursor-pointer",
38335
- children: "Edit"
38336
- })]
38417
+ })
38337
38418
  });
38338
38419
  };
38339
38420
  var EditField = function EditField(_ref7) {
@@ -39038,17 +39119,22 @@ var DashSidebar = function DashSidebar(_ref) {
39038
39119
  menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
39039
39120
  _ref$activeTabId = _ref.activeTabId,
39040
39121
  activeTabId = _ref$activeTabId === void 0 ? null : _ref$activeTabId,
39122
+ _ref$recentDashboards = _ref.recentDashboards,
39123
+ recentDashboards = _ref$recentDashboards === void 0 ? [] : _ref$recentDashboards,
39124
+ _ref$authStatus = _ref.authStatus,
39125
+ authStatus = _ref$authStatus === void 0 ? "loading" : _ref$authStatus,
39126
+ _ref$authProfile = _ref.authProfile,
39127
+ authProfile = _ref$authProfile === void 0 ? null : _ref$authProfile,
39041
39128
  onOpenWorkspace = _ref.onOpenWorkspace,
39042
39129
  onNewDashboard = _ref.onNewDashboard,
39043
- onGoHome = _ref.onGoHome,
39044
- onOpenProviders = _ref.onOpenProviders,
39045
- onOpenThemeManager = _ref.onOpenThemeManager,
39046
- onOpenFolders = _ref.onOpenFolders,
39047
39130
  onOpenSettings = _ref.onOpenSettings,
39048
- onOpenCommandPalette = _ref.onOpenCommandPalette;
39131
+ onOpenCommandPalette = _ref.onOpenCommandPalette,
39132
+ onSignIn = _ref.onSignIn,
39133
+ onSignOut = _ref.onSignOut;
39049
39134
  var _useContext = React.useContext(DashReact.ThemeContext),
39050
39135
  themeVariant = _useContext.themeVariant,
39051
39136
  changeThemeVariant = _useContext.changeThemeVariant;
39137
+ _useContext.currentTheme;
39052
39138
  var workspacesForFolder = function workspacesForFolder(folderId) {
39053
39139
  return workspaces.filter(function (ws) {
39054
39140
  return ws.menuId === folderId;
@@ -39059,6 +39145,13 @@ var DashSidebar = function DashSidebar(_ref) {
39059
39145
  return mi.id === ws.menuId;
39060
39146
  });
39061
39147
  });
39148
+
39149
+ // Filter recents: only show workspaces that still exist, max 5
39150
+ var visibleRecents = recentDashboards.filter(function (r) {
39151
+ return workspaces.some(function (ws) {
39152
+ return ws.id === r.workspaceId;
39153
+ });
39154
+ }).slice(0, 5);
39062
39155
  return /*#__PURE__*/jsxRuntime.jsxs(DashReact.Sidebar, {
39063
39156
  collapsed: collapsed,
39064
39157
  onCollapsedChange: onCollapsedChange,
@@ -39074,57 +39167,32 @@ var DashSidebar = function DashSidebar(_ref) {
39074
39167
  })
39075
39168
  }), /*#__PURE__*/jsxRuntime.jsxs(DashReact.Sidebar.Content, {
39076
39169
  children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39077
- icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39078
- icon: "home",
39079
- className: "h-3.5 w-3.5"
39080
- }),
39081
- active: activeTabId === null,
39082
- onClick: onGoHome,
39083
- children: "Home"
39084
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39085
39170
  icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39086
39171
  icon: "magnifying-glass",
39087
39172
  className: "h-3.5 w-3.5"
39088
39173
  }),
39089
39174
  onClick: onOpenCommandPalette,
39090
39175
  children: "Search"
39091
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39092
- icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39093
- icon: "plug",
39094
- className: "h-3.5 w-3.5"
39095
- }),
39096
- onClick: onOpenProviders,
39097
- children: "Providers"
39098
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39099
- icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39100
- icon: "palette",
39101
- className: "h-3.5 w-3.5"
39102
- }),
39103
- onClick: onOpenThemeManager,
39104
- children: "Themes"
39105
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39106
- icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39107
- icon: "folder",
39108
- className: "h-3.5 w-3.5"
39109
- }),
39110
- onClick: onOpenFolders,
39111
- children: "Folders"
39112
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39113
- icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39114
- icon: "cog",
39115
- className: "h-3.5 w-3.5"
39116
- }),
39117
- onClick: onOpenSettings,
39118
- children: "Settings"
39119
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39120
- icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39121
- icon: themeVariant === "dark" ? "sun" : "moon",
39122
- className: "h-3.5 w-3.5"
39123
- }),
39124
- onClick: function onClick() {
39125
- return changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
39126
- },
39127
- children: themeVariant === "dark" ? "Light Mode" : "Dark Mode"
39176
+ }), !collapsed && visibleRecents.length > 0 && /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Group, {
39177
+ label: "Recents",
39178
+ children: visibleRecents.map(function (recent) {
39179
+ var ws = workspaces.find(function (w) {
39180
+ return w.id === recent.workspaceId;
39181
+ });
39182
+ return /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
39183
+ icon: /*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39184
+ icon: "clock-rotate-left",
39185
+ className: "h-3.5 w-3.5"
39186
+ }),
39187
+ active: recent.workspaceId === activeTabId,
39188
+ onClick: function onClick() {
39189
+ return ws && onOpenWorkspace(ws);
39190
+ },
39191
+ children: (recent.name || "Untitled").replace(/^./, function (c) {
39192
+ return c.toUpperCase();
39193
+ })
39194
+ }, recent.workspaceId);
39195
+ })
39128
39196
  }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Group, {
39129
39197
  label: "Dashboards",
39130
39198
  children: /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Item, {
@@ -39177,6 +39245,107 @@ var DashSidebar = function DashSidebar(_ref) {
39177
39245
  })
39178
39246
  })]
39179
39247
  })]
39248
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Sidebar.Footer, {
39249
+ children: /*#__PURE__*/jsxRuntime.jsx(FooterPopover, {
39250
+ collapsed: collapsed,
39251
+ themeVariant: themeVariant,
39252
+ changeThemeVariant: changeThemeVariant,
39253
+ authStatus: authStatus,
39254
+ authProfile: authProfile,
39255
+ onOpenSettings: onOpenSettings,
39256
+ onSignIn: onSignIn,
39257
+ onSignOut: onSignOut
39258
+ })
39259
+ })]
39260
+ });
39261
+ };
39262
+ var FooterPopover = function FooterPopover(_ref2) {
39263
+ var collapsed = _ref2.collapsed,
39264
+ themeVariant = _ref2.themeVariant,
39265
+ changeThemeVariant = _ref2.changeThemeVariant,
39266
+ authStatus = _ref2.authStatus,
39267
+ authProfile = _ref2.authProfile,
39268
+ onOpenSettings = _ref2.onOpenSettings,
39269
+ onSignIn = _ref2.onSignIn,
39270
+ onSignOut = _ref2.onSignOut;
39271
+ var displayName = authStatus === "authenticated" && authProfile ? authProfile.displayName || authProfile.username : "Account";
39272
+ return /*#__PURE__*/jsxRuntime.jsx(react.Popover, {
39273
+ className: "relative",
39274
+ children: function children(_ref3) {
39275
+ var close = _ref3.close;
39276
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
39277
+ children: [/*#__PURE__*/jsxRuntime.jsxs(react.Popover.Button, {
39278
+ className: "flex items-center w-full gap-2 px-3 py-2 rounded-md text-sm opacity-80 hover:opacity-100 transition-colors duration-150 cursor-pointer hover:bg-white/5 focus:outline-none",
39279
+ title: collapsed ? displayName : undefined,
39280
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39281
+ icon: authStatus === "authenticated" ? "circle-user" : "user",
39282
+ className: "h-3.5 w-3.5 flex-shrink-0"
39283
+ }), !collapsed && /*#__PURE__*/jsxRuntime.jsx("span", {
39284
+ className: "flex-1 text-left truncate",
39285
+ children: displayName
39286
+ })]
39287
+ }), /*#__PURE__*/jsxRuntime.jsx(react.Transition, {
39288
+ enter: "transition ease-out duration-100",
39289
+ enterFrom: "transform opacity-0 scale-95",
39290
+ enterTo: "transform opacity-100 scale-100",
39291
+ leave: "transition ease-in duration-75",
39292
+ leaveFrom: "transform opacity-100 scale-100",
39293
+ leaveTo: "transform opacity-0 scale-95",
39294
+ children: /*#__PURE__*/jsxRuntime.jsx(react.Popover.Panel, {
39295
+ className: "absolute bottom-full left-0 mb-2 w-52 rounded-lg border border-white/10 bg-neutral-900 shadow-xl z-50",
39296
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
39297
+ className: "p-1.5 space-y-0.5",
39298
+ children: [/*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
39299
+ icon: "cog",
39300
+ label: "Settings",
39301
+ onClick: function onClick() {
39302
+ onOpenSettings();
39303
+ close();
39304
+ }
39305
+ }), /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
39306
+ icon: themeVariant === "dark" ? "sun" : "moon",
39307
+ label: themeVariant === "dark" ? "Light Mode" : "Dark Mode",
39308
+ onClick: function onClick() {
39309
+ changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
39310
+ close();
39311
+ }
39312
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
39313
+ className: "border-t border-white/10 my-1"
39314
+ }), authStatus === "authenticated" ? /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
39315
+ icon: "right-from-bracket",
39316
+ label: "Sign Out",
39317
+ onClick: function onClick() {
39318
+ onSignOut();
39319
+ close();
39320
+ }
39321
+ }) : /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
39322
+ icon: "right-to-bracket",
39323
+ label: "Sign In",
39324
+ onClick: function onClick() {
39325
+ onSignIn();
39326
+ close();
39327
+ }
39328
+ })]
39329
+ })
39330
+ })
39331
+ })]
39332
+ });
39333
+ }
39334
+ });
39335
+ };
39336
+ var PopoverItem = function PopoverItem(_ref4) {
39337
+ var icon = _ref4.icon,
39338
+ label = _ref4.label,
39339
+ onClick = _ref4.onClick;
39340
+ return /*#__PURE__*/jsxRuntime.jsxs("button", {
39341
+ type: "button",
39342
+ onClick: onClick,
39343
+ className: "flex items-center w-full gap-2 px-3 py-2 rounded-md text-sm text-white/80 hover:text-white hover:bg-white/10 transition-colors duration-150 cursor-pointer",
39344
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39345
+ icon: icon,
39346
+ className: "h-3.5 w-3.5 flex-shrink-0"
39347
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
39348
+ children: label
39180
39349
  })]
39181
39350
  });
39182
39351
  };
@@ -39931,6 +40100,23 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
39931
40100
  widgetSidebarCollapsed = _useState0[0],
39932
40101
  setWidgetSidebarCollapsed = _useState0[1];
39933
40102
 
40103
+ // ─── Recents + Session ──────────────────────────────────────────
40104
+ var _useState1 = React.useState([]),
40105
+ _useState10 = _slicedToArray(_useState1, 2),
40106
+ recentDashboards = _useState10[0],
40107
+ setRecentDashboards = _useState10[1];
40108
+ var sessionRestored = React.useRef(false);
40109
+
40110
+ // ─── Registry Auth (for sidebar) ────────────────────────────────
40111
+ var _useState11 = React.useState("loading"),
40112
+ _useState12 = _slicedToArray(_useState11, 2),
40113
+ authStatus = _useState12[0],
40114
+ setAuthStatus = _useState12[1];
40115
+ var _useState13 = React.useState(null),
40116
+ _useState14 = _slicedToArray(_useState13, 2),
40117
+ authProfile = _useState14[0],
40118
+ setAuthProfile = _useState14[1];
40119
+
39934
40120
  // Derive workspaceSelected from active tab
39935
40121
  var workspaceSelected = activeTabId ? (_openTabs$find$worksp = (_openTabs$find = openTabs.find(function (tab) {
39936
40122
  return tab.id === activeTabId;
@@ -39939,66 +40125,92 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
39939
40125
  /**
39940
40126
  * @param {Boolean} previewMode this is a toggle telling the dash we are editing
39941
40127
  */
39942
- var _useState1 = React.useState(preview),
39943
- _useState10 = _slicedToArray(_useState1, 2),
39944
- previewMode = _useState10[0],
39945
- setPreviewMode = _useState10[1];
40128
+ var _useState15 = React.useState(preview),
40129
+ _useState16 = _slicedToArray(_useState15, 2),
40130
+ previewMode = _useState16[0],
40131
+ setPreviewMode = _useState16[1];
39946
40132
 
39947
40133
  /**
39948
40134
  * @param {String["layout", "workspace", "widget"]} editMode this is the actual mode we are in
39949
40135
  */
39950
- var _useState11 = React.useState("all"),
39951
- _useState12 = _slicedToArray(_useState11, 1),
39952
- editMode = _useState12[0]; // for the time being use "all" as our "old" way
40136
+ var _useState17 = React.useState("all"),
40137
+ _useState18 = _slicedToArray(_useState17, 1),
40138
+ editMode = _useState18[0]; // for the time being use "all" as our "old" way
39953
40139
 
39954
40140
  // Workspace Management (loading)
39955
- var _useState13 = React.useState(false),
39956
- _useState14 = _slicedToArray(_useState13, 2),
39957
- isLoadingWorkspaces = _useState14[0],
39958
- setIsLoadingWorkspaces = _useState14[1];
39959
- var _useState15 = React.useState(false),
39960
- _useState16 = _slicedToArray(_useState15, 2),
39961
- isLoadingMenuItems = _useState16[0],
39962
- setIsLoadingMenuItems = _useState16[1];
39963
- var _useState17 = React.useState([]),
39964
- _useState18 = _slicedToArray(_useState17, 2),
39965
- menuItems = _useState18[0],
39966
- setMenuItems = _useState18[1];
39967
- var _useState19 = React.useState([]),
40141
+ var _useState19 = React.useState(false),
39968
40142
  _useState20 = _slicedToArray(_useState19, 2),
39969
- workspaceConfig = _useState20[0],
39970
- setWorkspaceConfig = _useState20[1];
39971
-
39972
- // Modal state
40143
+ isLoadingWorkspaces = _useState20[0],
40144
+ setIsLoadingWorkspaces = _useState20[1];
39973
40145
  var _useState21 = React.useState(false),
39974
40146
  _useState22 = _slicedToArray(_useState21, 2),
39975
- isThemeManagerOpen = _useState22[0],
39976
- setIsThemeManagerOpen = _useState22[1];
39977
- var _useState23 = React.useState(false),
40147
+ isLoadingMenuItems = _useState22[0],
40148
+ setIsLoadingMenuItems = _useState22[1];
40149
+ var _useState23 = React.useState([]),
39978
40150
  _useState24 = _slicedToArray(_useState23, 2),
39979
- isDashboardLoaderOpen = _useState24[0],
39980
- setIsDashboardLoaderOpen = _useState24[1];
39981
- var _useState25 = React.useState(false),
40151
+ menuItems = _useState24[0],
40152
+ setMenuItems = _useState24[1];
40153
+ var _useState25 = React.useState([]),
39982
40154
  _useState26 = _slicedToArray(_useState25, 2),
39983
- isLayoutPickerOpen = _useState26[0],
39984
- setIsLayoutPickerOpen = _useState26[1];
40155
+ workspaceConfig = _useState26[0],
40156
+ setWorkspaceConfig = _useState26[1];
39985
40157
 
39986
- // Unified App Settings Modal
40158
+ // Modal state
39987
40159
  var _useState27 = React.useState(false),
39988
40160
  _useState28 = _slicedToArray(_useState27, 2),
39989
- isAppSettingsOpen = _useState28[0],
39990
- setIsAppSettingsOpen = _useState28[1];
39991
- var _useState29 = React.useState("dashboards"),
40161
+ isThemeManagerOpen = _useState28[0],
40162
+ setIsThemeManagerOpen = _useState28[1];
40163
+ var _useState29 = React.useState(false),
39992
40164
  _useState30 = _slicedToArray(_useState29, 2),
39993
- appSettingsInitialSection = _useState30[0],
39994
- setAppSettingsInitialSection = _useState30[1];
40165
+ isDashboardLoaderOpen = _useState30[0],
40166
+ setIsDashboardLoaderOpen = _useState30[1];
40167
+ var _useState31 = React.useState(false),
40168
+ _useState32 = _slicedToArray(_useState31, 2),
40169
+ isLayoutPickerOpen = _useState32[0],
40170
+ setIsLayoutPickerOpen = _useState32[1];
40171
+
40172
+ // Unified App Settings Modal
40173
+ var _useState33 = React.useState(false),
40174
+ _useState34 = _slicedToArray(_useState33, 2),
40175
+ isAppSettingsOpen = _useState34[0],
40176
+ setIsAppSettingsOpen = _useState34[1];
40177
+ var _useState35 = React.useState("dashboards"),
40178
+ _useState36 = _slicedToArray(_useState35, 2),
40179
+ appSettingsInitialSection = _useState36[0],
40180
+ setAppSettingsInitialSection = _useState36[1];
39995
40181
  function openAppSettings() {
39996
- var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "dashboards";
40182
+ var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "general";
39997
40183
  setAppSettingsInitialSection(section);
39998
40184
  setIsAppSettingsOpen(true);
39999
40185
  }
40000
-
40001
- // Ref to access LayoutBuilder's current workspace without re-render cascades
40186
+ function handleProfileUpdated() {
40187
+ return _handleProfileUpdated.apply(this, arguments);
40188
+ } // Ref to access LayoutBuilder's current workspace without re-render cascades
40189
+ function _handleProfileUpdated() {
40190
+ _handleProfileUpdated = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
40191
+ var _window$mainApi11, profile;
40192
+ return _regeneratorRuntime.wrap(function (_context2) {
40193
+ while (1) switch (_context2.prev = _context2.next) {
40194
+ case 0:
40195
+ _context2.prev = 0;
40196
+ _context2.next = 1;
40197
+ return (_window$mainApi11 = window.mainApi) === null || _window$mainApi11 === void 0 || (_window$mainApi11 = _window$mainApi11.registryAuth) === null || _window$mainApi11 === void 0 ? void 0 : _window$mainApi11.getProfile();
40198
+ case 1:
40199
+ profile = _context2.sent;
40200
+ if (profile) setAuthProfile(profile);
40201
+ _context2.next = 3;
40202
+ break;
40203
+ case 2:
40204
+ _context2.prev = 2;
40205
+ _context2["catch"](0);
40206
+ case 3:
40207
+ case "end":
40208
+ return _context2.stop();
40209
+ }
40210
+ }, _callee2, null, [[0, 2]]);
40211
+ }));
40212
+ return _handleProfileUpdated.apply(this, arguments);
40213
+ }
40002
40214
  var currentWorkspaceRef = React.useRef(null);
40003
40215
 
40004
40216
  // Snapshot of the workspace before editing — used to restore on Cancel
@@ -40044,6 +40256,114 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40044
40256
  // eslint-disable-next-line react-hooks/exhaustive-deps
40045
40257
  }, [popout]);
40046
40258
 
40259
+ // ─── Load recents on mount ───────────────────────────────────────
40260
+ React.useEffect(function () {
40261
+ var _window$mainApi4;
40262
+ if (popout) return;
40263
+ (_window$mainApi4 = window.mainApi) === null || _window$mainApi4 === void 0 || (_window$mainApi4 = _window$mainApi4.session) === null || _window$mainApi4 === void 0 || _window$mainApi4.getRecents().then(function (recents) {
40264
+ if (recents) setRecentDashboards(recents);
40265
+ });
40266
+ }, [popout]);
40267
+
40268
+ // ─── Session save (continuous) ──────────────────────────────────
40269
+ React.useEffect(function () {
40270
+ var _window$mainApi5;
40271
+ if (popout) return;
40272
+ var tabIds = openTabs.map(function (t) {
40273
+ return t.id;
40274
+ });
40275
+ (_window$mainApi5 = window.mainApi) === null || _window$mainApi5 === void 0 || (_window$mainApi5 = _window$mainApi5.session) === null || _window$mainApi5 === void 0 || _window$mainApi5.saveState(tabIds, activeTabId);
40276
+ }, [openTabs, activeTabId, popout]);
40277
+
40278
+ // ─── Session restore on launch ─────────────────────────────────
40279
+ React.useEffect(function () {
40280
+ var _window$mainApi6;
40281
+ if (popout || workspaceConfig.length === 0 || sessionRestored.current) return;
40282
+ sessionRestored.current = true;
40283
+ (_window$mainApi6 = window.mainApi) === null || _window$mainApi6 === void 0 || (_window$mainApi6 = _window$mainApi6.session) === null || _window$mainApi6 === void 0 || _window$mainApi6.getState().then(function (state) {
40284
+ var _state$openTabIds, _window$mainApi7;
40285
+ if (!(state !== null && state !== void 0 && (_state$openTabIds = state.openTabIds) !== null && _state$openTabIds !== void 0 && _state$openTabIds.length)) return;
40286
+ state.openTabIds.forEach(function (wsId) {
40287
+ var ws = workspaceConfig.find(function (w) {
40288
+ return w.id === wsId;
40289
+ });
40290
+ if (ws) handleOpenTab(ws);
40291
+ });
40292
+ if (state.activeTabId) setActiveTabId(state.activeTabId);
40293
+ (_window$mainApi7 = window.mainApi) === null || _window$mainApi7 === void 0 || (_window$mainApi7 = _window$mainApi7.session) === null || _window$mainApi7 === void 0 || _window$mainApi7.clearState();
40294
+ });
40295
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40296
+ }, [workspaceConfig, popout]);
40297
+
40298
+ // ─── Auth status check (for sidebar) ────────────────────────────
40299
+ React.useEffect(function () {
40300
+ if (popout) return;
40301
+ var cancelled = false;
40302
+ function checkAuth() {
40303
+ return _checkAuth.apply(this, arguments);
40304
+ }
40305
+ function _checkAuth() {
40306
+ _checkAuth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
40307
+ var _window$mainApi8, status, _window$mainApi9, profile;
40308
+ return _regeneratorRuntime.wrap(function (_context) {
40309
+ while (1) switch (_context.prev = _context.next) {
40310
+ case 0:
40311
+ _context.prev = 0;
40312
+ _context.next = 1;
40313
+ return (_window$mainApi8 = window.mainApi) === null || _window$mainApi8 === void 0 || (_window$mainApi8 = _window$mainApi8.registryAuth) === null || _window$mainApi8 === void 0 ? void 0 : _window$mainApi8.getStatus();
40314
+ case 1:
40315
+ status = _context.sent;
40316
+ if (!cancelled) {
40317
+ _context.next = 2;
40318
+ break;
40319
+ }
40320
+ return _context.abrupt("return");
40321
+ case 2:
40322
+ if (!(status !== null && status !== void 0 && status.authenticated)) {
40323
+ _context.next = 5;
40324
+ break;
40325
+ }
40326
+ _context.next = 3;
40327
+ return (_window$mainApi9 = window.mainApi) === null || _window$mainApi9 === void 0 || (_window$mainApi9 = _window$mainApi9.registryAuth) === null || _window$mainApi9 === void 0 ? void 0 : _window$mainApi9.getProfile();
40328
+ case 3:
40329
+ profile = _context.sent;
40330
+ if (!cancelled) {
40331
+ _context.next = 4;
40332
+ break;
40333
+ }
40334
+ return _context.abrupt("return");
40335
+ case 4:
40336
+ if (profile) {
40337
+ setAuthProfile(profile);
40338
+ setAuthStatus("authenticated");
40339
+ } else {
40340
+ setAuthStatus("unauthenticated");
40341
+ }
40342
+ _context.next = 6;
40343
+ break;
40344
+ case 5:
40345
+ setAuthStatus("unauthenticated");
40346
+ case 6:
40347
+ _context.next = 8;
40348
+ break;
40349
+ case 7:
40350
+ _context.prev = 7;
40351
+ _context["catch"](0);
40352
+ if (!cancelled) setAuthStatus("unauthenticated");
40353
+ case 8:
40354
+ case "end":
40355
+ return _context.stop();
40356
+ }
40357
+ }, _callee, null, [[0, 7]]);
40358
+ }));
40359
+ return _checkAuth.apply(this, arguments);
40360
+ }
40361
+ checkAuth();
40362
+ return function () {
40363
+ cancelled = true;
40364
+ };
40365
+ }, [popout]);
40366
+
40047
40367
  // ─── Tab Handlers ─────────────────────────────────────────────────
40048
40368
 
40049
40369
  function handleOpenTab(workspaceItem) {
@@ -40076,6 +40396,14 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40076
40396
  }
40077
40397
  setPreviewMode(true);
40078
40398
  setSidebarCollapsed(true);
40399
+
40400
+ // Track in recents
40401
+ if (!popout) {
40402
+ var _window$mainApi0;
40403
+ (_window$mainApi0 = window.mainApi) === null || _window$mainApi0 === void 0 || (_window$mainApi0 = _window$mainApi0.session) === null || _window$mainApi0 === void 0 || _window$mainApi0.addRecent(workspaceItem.id, workspaceItem.name || "Untitled").then(function (updated) {
40404
+ if (updated) setRecentDashboards(updated);
40405
+ });
40406
+ }
40079
40407
  }
40080
40408
  function handleCloseTab(tabId) {
40081
40409
  setOpenTabs(function (prev) {
@@ -40428,15 +40756,113 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40428
40756
  function handleToggleThemeVariant() {
40429
40757
  changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
40430
40758
  }
40759
+ function handleSidebarSignIn() {
40760
+ return _handleSidebarSignIn.apply(this, arguments);
40761
+ }
40762
+ function _handleSidebarSignIn() {
40763
+ _handleSidebarSignIn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
40764
+ var flow, interval, poll;
40765
+ return _regeneratorRuntime.wrap(function (_context4) {
40766
+ while (1) switch (_context4.prev = _context4.next) {
40767
+ case 0:
40768
+ _context4.prev = 0;
40769
+ _context4.next = 1;
40770
+ return window.mainApi.registryAuth.initiateLogin();
40771
+ case 1:
40772
+ flow = _context4.sent;
40773
+ if (flow.verificationUrlComplete) {
40774
+ window.mainApi.shell.openExternal(flow.verificationUrlComplete);
40775
+ }
40776
+ interval = (flow.interval || 5) * 1000;
40777
+ poll = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
40778
+ var result, profile;
40779
+ return _regeneratorRuntime.wrap(function (_context3) {
40780
+ while (1) switch (_context3.prev = _context3.next) {
40781
+ case 0:
40782
+ _context3.prev = 0;
40783
+ _context3.next = 1;
40784
+ return window.mainApi.registryAuth.pollToken(flow.deviceCode);
40785
+ case 1:
40786
+ result = _context3.sent;
40787
+ if (!(result.status === "authorized")) {
40788
+ _context3.next = 3;
40789
+ break;
40790
+ }
40791
+ clearInterval(poll);
40792
+ _context3.next = 2;
40793
+ return window.mainApi.registryAuth.getProfile();
40794
+ case 2:
40795
+ profile = _context3.sent;
40796
+ setAuthProfile(profile);
40797
+ setAuthStatus("authenticated");
40798
+ _context3.next = 4;
40799
+ break;
40800
+ case 3:
40801
+ if (result.status === "expired") {
40802
+ clearInterval(poll);
40803
+ }
40804
+ case 4:
40805
+ _context3.next = 6;
40806
+ break;
40807
+ case 5:
40808
+ _context3.prev = 5;
40809
+ _context3["catch"](0);
40810
+ clearInterval(poll);
40811
+ case 6:
40812
+ case "end":
40813
+ return _context3.stop();
40814
+ }
40815
+ }, _callee3, null, [[0, 5]]);
40816
+ })), interval);
40817
+ _context4.next = 3;
40818
+ break;
40819
+ case 2:
40820
+ _context4.prev = 2;
40821
+ _context4["catch"](0);
40822
+ case 3:
40823
+ case "end":
40824
+ return _context4.stop();
40825
+ }
40826
+ }, _callee4, null, [[0, 2]]);
40827
+ }));
40828
+ return _handleSidebarSignIn.apply(this, arguments);
40829
+ }
40830
+ function handleSidebarSignOut() {
40831
+ return _handleSidebarSignOut.apply(this, arguments);
40832
+ }
40833
+ function _handleSidebarSignOut() {
40834
+ _handleSidebarSignOut = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
40835
+ return _regeneratorRuntime.wrap(function (_context5) {
40836
+ while (1) switch (_context5.prev = _context5.next) {
40837
+ case 0:
40838
+ _context5.prev = 0;
40839
+ _context5.next = 1;
40840
+ return window.mainApi.registryAuth.logout();
40841
+ case 1:
40842
+ setAuthStatus("unauthenticated");
40843
+ setAuthProfile(null);
40844
+ _context5.next = 3;
40845
+ break;
40846
+ case 2:
40847
+ _context5.prev = 2;
40848
+ _context5["catch"](0);
40849
+ case 3:
40850
+ case "end":
40851
+ return _context5.stop();
40852
+ }
40853
+ }, _callee5, null, [[0, 2]]);
40854
+ }));
40855
+ return _handleSidebarSignOut.apply(this, arguments);
40856
+ }
40431
40857
  function handlePopout() {
40432
- var _window$mainApi4;
40433
- if (workspaceSelected && (_window$mainApi4 = window.mainApi) !== null && _window$mainApi4 !== void 0 && (_window$mainApi4 = _window$mainApi4.popout) !== null && _window$mainApi4 !== void 0 && _window$mainApi4.open) {
40858
+ var _window$mainApi1;
40859
+ if (workspaceSelected && (_window$mainApi1 = window.mainApi) !== null && _window$mainApi1 !== void 0 && (_window$mainApi1 = _window$mainApi1.popout) !== null && _window$mainApi1 !== void 0 && _window$mainApi1.open) {
40434
40860
  window.mainApi.popout.open(workspaceSelected.id);
40435
40861
  }
40436
40862
  }
40437
40863
  function handleWidgetPopout(widgetId) {
40438
- var _window$mainApi5;
40439
- if (workspaceSelected && (_window$mainApi5 = window.mainApi) !== null && _window$mainApi5 !== void 0 && (_window$mainApi5 = _window$mainApi5.widgetPopout) !== null && _window$mainApi5 !== void 0 && _window$mainApi5.open) {
40864
+ var _window$mainApi10;
40865
+ if (workspaceSelected && (_window$mainApi10 = window.mainApi) !== null && _window$mainApi10 !== void 0 && (_window$mainApi10 = _window$mainApi10.widgetPopout) !== null && _window$mainApi10 !== void 0 && _window$mainApi10.open) {
40440
40866
  window.mainApi.widgetPopout.open(workspaceSelected.id, widgetId);
40441
40867
  }
40442
40868
  }
@@ -40458,26 +40884,21 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40458
40884
  workspaces: workspaceConfig,
40459
40885
  menuItems: menuItems,
40460
40886
  activeTabId: activeTabId,
40887
+ recentDashboards: recentDashboards,
40888
+ authStatus: authStatus,
40889
+ authProfile: authProfile,
40461
40890
  onOpenWorkspace: handleOpenTab,
40462
40891
  onNewDashboard: function onNewDashboard() {
40463
40892
  return setIsLayoutPickerOpen(true);
40464
40893
  },
40465
- onGoHome: function onGoHome() {
40466
- return activeTabId && handleCloseTab(activeTabId);
40467
- },
40468
- onOpenProviders: function onOpenProviders() {
40469
- return openAppSettings("providers");
40470
- },
40471
- onOpenThemeManager: handleOpenThemeManager,
40472
- onOpenFolders: function onOpenFolders() {
40473
- return openAppSettings("folders");
40474
- },
40475
40894
  onOpenSettings: function onOpenSettings() {
40476
40895
  return openAppSettings("general");
40477
40896
  },
40478
40897
  onOpenCommandPalette: function onOpenCommandPalette() {
40479
40898
  return setIsCommandPaletteOpen(true);
40480
- }
40899
+ },
40900
+ onSignIn: handleSidebarSignIn,
40901
+ onSignOut: handleSidebarSignOut
40481
40902
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
40482
40903
  className: "flex flex-col flex-1 min-w-0 overflow-hidden",
40483
40904
  children: workspaceSelected !== null ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -40551,7 +40972,12 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40551
40972
  onOpenThemeEditor: function onOpenThemeEditor() {
40552
40973
  setIsAppSettingsOpen(false);
40553
40974
  setIsThemeManagerOpen(true);
40554
- }
40975
+ },
40976
+ authStatus: authStatus,
40977
+ authProfile: authProfile,
40978
+ onSignIn: handleSidebarSignIn,
40979
+ onSignOut: handleSidebarSignOut,
40980
+ onProfileUpdated: handleProfileUpdated
40555
40981
  }), /*#__PURE__*/jsxRuntime.jsx(ThemeManagerModal, {
40556
40982
  open: isThemeManagerOpen,
40557
40983
  setIsOpen: function setIsOpen() {