@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.esm.js CHANGED
@@ -13,7 +13,7 @@ import _createClass from '@babel/runtime/helpers/createClass';
13
13
  import * as jsxRuntime from 'react/jsx-runtime';
14
14
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
15
15
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
16
- import { Menu, Transition, Dialog, Disclosure } from '@headlessui/react';
16
+ import { Menu, Transition, Popover, Dialog, Disclosure } from '@headlessui/react';
17
17
  import { EllipsisVerticalIcon } from '@heroicons/react/20/solid';
18
18
  import clsx from 'clsx';
19
19
  import { DndProvider, useDrag, useDrop } from 'react-dnd';
@@ -37961,6 +37961,13 @@ var AuthenticatedView = function AuthenticatedView(_ref3) {
37961
37961
  return p.name === updatedPkg.name && p.scope === updatedPkg.scope ? _objectSpread$2(_objectSpread$2({}, p), updatedPkg) : p;
37962
37962
  });
37963
37963
  });
37964
+ },
37965
+ onPackageDeleted: function onPackageDeleted(deletedPkg) {
37966
+ setPackages(function (prev) {
37967
+ return prev.filter(function (p) {
37968
+ return !(p.name === deletedPkg.name && p.scope === deletedPkg.scope);
37969
+ });
37970
+ });
37964
37971
  }
37965
37972
  })]
37966
37973
  });
@@ -38101,7 +38108,8 @@ var ProfileCard = function ProfileCard(_ref4) {
38101
38108
  var PackagesList = function PackagesList(_ref5) {
38102
38109
  var packages = _ref5.packages,
38103
38110
  loading = _ref5.loading,
38104
- onPackageUpdated = _ref5.onPackageUpdated;
38111
+ onPackageUpdated = _ref5.onPackageUpdated,
38112
+ onPackageDeleted = _ref5.onPackageDeleted;
38105
38113
  var _useState1 = useState(null),
38106
38114
  _useState10 = _slicedToArray(_useState1, 2),
38107
38115
  editingPkg = _useState10[0],
@@ -38141,6 +38149,10 @@ var PackagesList = function PackagesList(_ref5) {
38141
38149
  onSaved: function onSaved(updated) {
38142
38150
  setEditingPkg(null);
38143
38151
  onPackageUpdated(updated);
38152
+ },
38153
+ onDeleted: function onDeleted() {
38154
+ setEditingPkg(null);
38155
+ onPackageDeleted(pkg);
38144
38156
  }
38145
38157
  }, "".concat(pkg.scope, "/").concat(pkg.name));
38146
38158
  })
@@ -38152,7 +38164,8 @@ var PackageItem = function PackageItem(_ref6) {
38152
38164
  isEditing = _ref6.isEditing,
38153
38165
  onEdit = _ref6.onEdit,
38154
38166
  onCancel = _ref6.onCancel,
38155
- onSaved = _ref6.onSaved;
38167
+ onSaved = _ref6.onSaved,
38168
+ onDeleted = _ref6.onDeleted;
38156
38169
  var _useState11 = useState({
38157
38170
  displayName: pkg.displayName || "",
38158
38171
  description: pkg.description || "",
@@ -38167,6 +38180,14 @@ var PackageItem = function PackageItem(_ref6) {
38167
38180
  _useState14 = _slicedToArray(_useState13, 2),
38168
38181
  saving = _useState14[0],
38169
38182
  setSaving = _useState14[1];
38183
+ var _useState15 = useState(false),
38184
+ _useState16 = _slicedToArray(_useState15, 2),
38185
+ confirmingDelete = _useState16[0],
38186
+ setConfirmingDelete = _useState16[1];
38187
+ var _useState17 = useState(false),
38188
+ _useState18 = _slicedToArray(_useState17, 2),
38189
+ deleting = _useState18[0],
38190
+ setDeleting = _useState18[1];
38170
38191
  function handleSave() {
38171
38192
  return _handleSave2.apply(this, arguments);
38172
38193
  }
@@ -38211,6 +38232,42 @@ var PackageItem = function PackageItem(_ref6) {
38211
38232
  }));
38212
38233
  return _handleSave2.apply(this, arguments);
38213
38234
  }
38235
+ function handleDelete() {
38236
+ return _handleDelete.apply(this, arguments);
38237
+ }
38238
+ function _handleDelete() {
38239
+ _handleDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
38240
+ var _window$mainApi4, result;
38241
+ return _regeneratorRuntime.wrap(function (_context4) {
38242
+ while (1) switch (_context4.prev = _context4.next) {
38243
+ case 0:
38244
+ setDeleting(true);
38245
+ _context4.prev = 1;
38246
+ _context4.next = 2;
38247
+ 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);
38248
+ case 2:
38249
+ result = _context4.sent;
38250
+ if (result) {
38251
+ onDeleted === null || onDeleted === void 0 || onDeleted();
38252
+ }
38253
+ _context4.next = 4;
38254
+ break;
38255
+ case 3:
38256
+ _context4.prev = 3;
38257
+ _context4["catch"](1);
38258
+ case 4:
38259
+ _context4.prev = 4;
38260
+ setDeleting(false);
38261
+ setConfirmingDelete(false);
38262
+ return _context4.finish(4);
38263
+ case 5:
38264
+ case "end":
38265
+ return _context4.stop();
38266
+ }
38267
+ }, _callee4, null, [[1, 3, 4, 5]]);
38268
+ }));
38269
+ return _handleDelete.apply(this, arguments);
38270
+ }
38214
38271
  var updatedAt = pkg.updatedAt ? new Date(pkg.updatedAt).toLocaleDateString() : null;
38215
38272
  if (isEditing) {
38216
38273
  return /*#__PURE__*/jsxs("div", {
@@ -38272,24 +38329,53 @@ var PackageItem = function PackageItem(_ref6) {
38272
38329
  })]
38273
38330
  })]
38274
38331
  }), /*#__PURE__*/jsxs("div", {
38275
- className: "flex gap-2",
38276
- children: [/*#__PURE__*/jsx(Button, {
38277
- title: saving ? "Saving..." : "Save",
38278
- onClick: handleSave,
38279
- disabled: saving
38280
- }), /*#__PURE__*/jsx("button", {
38281
- type: "button",
38282
- onClick: onCancel,
38283
- className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38284
- children: "Cancel"
38332
+ className: "flex items-center justify-between",
38333
+ children: [/*#__PURE__*/jsx("div", {
38334
+ children: confirmingDelete ? /*#__PURE__*/jsxs("div", {
38335
+ className: "flex items-center gap-2",
38336
+ children: [/*#__PURE__*/jsx("button", {
38337
+ type: "button",
38338
+ onClick: handleDelete,
38339
+ disabled: deleting,
38340
+ className: "text-xs text-red-400 hover:text-red-300 cursor-pointer font-medium",
38341
+ children: deleting ? "Deleting..." : "Confirm Delete"
38342
+ }), /*#__PURE__*/jsx("button", {
38343
+ type: "button",
38344
+ onClick: function onClick() {
38345
+ return setConfirmingDelete(false);
38346
+ },
38347
+ className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38348
+ children: "Cancel"
38349
+ })]
38350
+ }) : /*#__PURE__*/jsx("button", {
38351
+ type: "button",
38352
+ onClick: function onClick() {
38353
+ return setConfirmingDelete(true);
38354
+ },
38355
+ className: "text-xs text-red-400/70 hover:text-red-400 cursor-pointer",
38356
+ children: "Delete"
38357
+ })
38358
+ }), /*#__PURE__*/jsxs("div", {
38359
+ className: "flex items-center gap-2",
38360
+ children: [/*#__PURE__*/jsx("button", {
38361
+ type: "button",
38362
+ onClick: onCancel,
38363
+ className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38364
+ children: "Cancel"
38365
+ }), /*#__PURE__*/jsx(Button, {
38366
+ title: saving ? "Saving..." : "Save",
38367
+ onClick: handleSave,
38368
+ disabled: saving
38369
+ })]
38285
38370
  })]
38286
38371
  })]
38287
38372
  });
38288
38373
  }
38289
- return /*#__PURE__*/jsxs("div", {
38290
- className: "bg-white/5 rounded-lg p-3 flex items-start justify-between",
38291
- children: [/*#__PURE__*/jsxs("div", {
38292
- className: "flex-1 min-w-0 space-y-1",
38374
+ return /*#__PURE__*/jsx("div", {
38375
+ onClick: onEdit,
38376
+ className: "bg-white/5 rounded-lg p-3 cursor-pointer hover:bg-white/10 transition-colors",
38377
+ children: /*#__PURE__*/jsxs("div", {
38378
+ className: "space-y-1",
38293
38379
  children: [/*#__PURE__*/jsxs("div", {
38294
38380
  className: "flex items-center gap-2",
38295
38381
  children: [/*#__PURE__*/jsx("span", {
@@ -38309,12 +38395,7 @@ var PackageItem = function PackageItem(_ref6) {
38309
38395
  className: "text-[10px] opacity-40",
38310
38396
  children: ["Updated ", updatedAt]
38311
38397
  })]
38312
- }), /*#__PURE__*/jsx("button", {
38313
- type: "button",
38314
- onClick: onEdit,
38315
- className: "flex-shrink-0 ml-2 text-xs opacity-40 hover:opacity-80 cursor-pointer",
38316
- children: "Edit"
38317
- })]
38398
+ })
38318
38399
  });
38319
38400
  };
38320
38401
  var EditField = function EditField(_ref7) {
@@ -39019,17 +39100,22 @@ var DashSidebar = function DashSidebar(_ref) {
39019
39100
  menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
39020
39101
  _ref$activeTabId = _ref.activeTabId,
39021
39102
  activeTabId = _ref$activeTabId === void 0 ? null : _ref$activeTabId,
39103
+ _ref$recentDashboards = _ref.recentDashboards,
39104
+ recentDashboards = _ref$recentDashboards === void 0 ? [] : _ref$recentDashboards,
39105
+ _ref$authStatus = _ref.authStatus,
39106
+ authStatus = _ref$authStatus === void 0 ? "loading" : _ref$authStatus,
39107
+ _ref$authProfile = _ref.authProfile,
39108
+ authProfile = _ref$authProfile === void 0 ? null : _ref$authProfile,
39022
39109
  onOpenWorkspace = _ref.onOpenWorkspace,
39023
39110
  onNewDashboard = _ref.onNewDashboard,
39024
- onGoHome = _ref.onGoHome,
39025
- onOpenProviders = _ref.onOpenProviders,
39026
- onOpenThemeManager = _ref.onOpenThemeManager,
39027
- onOpenFolders = _ref.onOpenFolders,
39028
39111
  onOpenSettings = _ref.onOpenSettings,
39029
- onOpenCommandPalette = _ref.onOpenCommandPalette;
39112
+ onOpenCommandPalette = _ref.onOpenCommandPalette,
39113
+ onSignIn = _ref.onSignIn,
39114
+ onSignOut = _ref.onSignOut;
39030
39115
  var _useContext = useContext(ThemeContext),
39031
39116
  themeVariant = _useContext.themeVariant,
39032
39117
  changeThemeVariant = _useContext.changeThemeVariant;
39118
+ _useContext.currentTheme;
39033
39119
  var workspacesForFolder = function workspacesForFolder(folderId) {
39034
39120
  return workspaces.filter(function (ws) {
39035
39121
  return ws.menuId === folderId;
@@ -39040,6 +39126,13 @@ var DashSidebar = function DashSidebar(_ref) {
39040
39126
  return mi.id === ws.menuId;
39041
39127
  });
39042
39128
  });
39129
+
39130
+ // Filter recents: only show workspaces that still exist, max 5
39131
+ var visibleRecents = recentDashboards.filter(function (r) {
39132
+ return workspaces.some(function (ws) {
39133
+ return ws.id === r.workspaceId;
39134
+ });
39135
+ }).slice(0, 5);
39043
39136
  return /*#__PURE__*/jsxs(Sidebar, {
39044
39137
  collapsed: collapsed,
39045
39138
  onCollapsedChange: onCollapsedChange,
@@ -39055,57 +39148,32 @@ var DashSidebar = function DashSidebar(_ref) {
39055
39148
  })
39056
39149
  }), /*#__PURE__*/jsxs(Sidebar.Content, {
39057
39150
  children: [/*#__PURE__*/jsx(Sidebar.Item, {
39058
- icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39059
- icon: "home",
39060
- className: "h-3.5 w-3.5"
39061
- }),
39062
- active: activeTabId === null,
39063
- onClick: onGoHome,
39064
- children: "Home"
39065
- }), /*#__PURE__*/jsx(Sidebar.Item, {
39066
39151
  icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39067
39152
  icon: "magnifying-glass",
39068
39153
  className: "h-3.5 w-3.5"
39069
39154
  }),
39070
39155
  onClick: onOpenCommandPalette,
39071
39156
  children: "Search"
39072
- }), /*#__PURE__*/jsx(Sidebar.Item, {
39073
- icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39074
- icon: "plug",
39075
- className: "h-3.5 w-3.5"
39076
- }),
39077
- onClick: onOpenProviders,
39078
- children: "Providers"
39079
- }), /*#__PURE__*/jsx(Sidebar.Item, {
39080
- icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39081
- icon: "palette",
39082
- className: "h-3.5 w-3.5"
39083
- }),
39084
- onClick: onOpenThemeManager,
39085
- children: "Themes"
39086
- }), /*#__PURE__*/jsx(Sidebar.Item, {
39087
- icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39088
- icon: "folder",
39089
- className: "h-3.5 w-3.5"
39090
- }),
39091
- onClick: onOpenFolders,
39092
- children: "Folders"
39093
- }), /*#__PURE__*/jsx(Sidebar.Item, {
39094
- icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39095
- icon: "cog",
39096
- className: "h-3.5 w-3.5"
39097
- }),
39098
- onClick: onOpenSettings,
39099
- children: "Settings"
39100
- }), /*#__PURE__*/jsx(Sidebar.Item, {
39101
- icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39102
- icon: themeVariant === "dark" ? "sun" : "moon",
39103
- className: "h-3.5 w-3.5"
39104
- }),
39105
- onClick: function onClick() {
39106
- return changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
39107
- },
39108
- children: themeVariant === "dark" ? "Light Mode" : "Dark Mode"
39157
+ }), !collapsed && visibleRecents.length > 0 && /*#__PURE__*/jsx(Sidebar.Group, {
39158
+ label: "Recents",
39159
+ children: visibleRecents.map(function (recent) {
39160
+ var ws = workspaces.find(function (w) {
39161
+ return w.id === recent.workspaceId;
39162
+ });
39163
+ return /*#__PURE__*/jsx(Sidebar.Item, {
39164
+ icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
39165
+ icon: "clock-rotate-left",
39166
+ className: "h-3.5 w-3.5"
39167
+ }),
39168
+ active: recent.workspaceId === activeTabId,
39169
+ onClick: function onClick() {
39170
+ return ws && onOpenWorkspace(ws);
39171
+ },
39172
+ children: (recent.name || "Untitled").replace(/^./, function (c) {
39173
+ return c.toUpperCase();
39174
+ })
39175
+ }, recent.workspaceId);
39176
+ })
39109
39177
  }), /*#__PURE__*/jsx(Sidebar.Group, {
39110
39178
  label: "Dashboards",
39111
39179
  children: /*#__PURE__*/jsx(Sidebar.Item, {
@@ -39158,6 +39226,107 @@ var DashSidebar = function DashSidebar(_ref) {
39158
39226
  })
39159
39227
  })]
39160
39228
  })]
39229
+ }), /*#__PURE__*/jsx(Sidebar.Footer, {
39230
+ children: /*#__PURE__*/jsx(FooterPopover, {
39231
+ collapsed: collapsed,
39232
+ themeVariant: themeVariant,
39233
+ changeThemeVariant: changeThemeVariant,
39234
+ authStatus: authStatus,
39235
+ authProfile: authProfile,
39236
+ onOpenSettings: onOpenSettings,
39237
+ onSignIn: onSignIn,
39238
+ onSignOut: onSignOut
39239
+ })
39240
+ })]
39241
+ });
39242
+ };
39243
+ var FooterPopover = function FooterPopover(_ref2) {
39244
+ var collapsed = _ref2.collapsed,
39245
+ themeVariant = _ref2.themeVariant,
39246
+ changeThemeVariant = _ref2.changeThemeVariant,
39247
+ authStatus = _ref2.authStatus,
39248
+ authProfile = _ref2.authProfile,
39249
+ onOpenSettings = _ref2.onOpenSettings,
39250
+ onSignIn = _ref2.onSignIn,
39251
+ onSignOut = _ref2.onSignOut;
39252
+ var displayName = authStatus === "authenticated" && authProfile ? authProfile.displayName || authProfile.username : "Account";
39253
+ return /*#__PURE__*/jsx(Popover, {
39254
+ className: "relative",
39255
+ children: function children(_ref3) {
39256
+ var close = _ref3.close;
39257
+ return /*#__PURE__*/jsxs(Fragment, {
39258
+ children: [/*#__PURE__*/jsxs(Popover.Button, {
39259
+ 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",
39260
+ title: collapsed ? displayName : undefined,
39261
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
39262
+ icon: authStatus === "authenticated" ? "circle-user" : "user",
39263
+ className: "h-3.5 w-3.5 flex-shrink-0"
39264
+ }), !collapsed && /*#__PURE__*/jsx("span", {
39265
+ className: "flex-1 text-left truncate",
39266
+ children: displayName
39267
+ })]
39268
+ }), /*#__PURE__*/jsx(Transition, {
39269
+ enter: "transition ease-out duration-100",
39270
+ enterFrom: "transform opacity-0 scale-95",
39271
+ enterTo: "transform opacity-100 scale-100",
39272
+ leave: "transition ease-in duration-75",
39273
+ leaveFrom: "transform opacity-100 scale-100",
39274
+ leaveTo: "transform opacity-0 scale-95",
39275
+ children: /*#__PURE__*/jsx(Popover.Panel, {
39276
+ className: "absolute bottom-full left-0 mb-2 w-52 rounded-lg border border-white/10 bg-neutral-900 shadow-xl z-50",
39277
+ children: /*#__PURE__*/jsxs("div", {
39278
+ className: "p-1.5 space-y-0.5",
39279
+ children: [/*#__PURE__*/jsx(PopoverItem, {
39280
+ icon: "cog",
39281
+ label: "Settings",
39282
+ onClick: function onClick() {
39283
+ onOpenSettings();
39284
+ close();
39285
+ }
39286
+ }), /*#__PURE__*/jsx(PopoverItem, {
39287
+ icon: themeVariant === "dark" ? "sun" : "moon",
39288
+ label: themeVariant === "dark" ? "Light Mode" : "Dark Mode",
39289
+ onClick: function onClick() {
39290
+ changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
39291
+ close();
39292
+ }
39293
+ }), /*#__PURE__*/jsx("div", {
39294
+ className: "border-t border-white/10 my-1"
39295
+ }), authStatus === "authenticated" ? /*#__PURE__*/jsx(PopoverItem, {
39296
+ icon: "right-from-bracket",
39297
+ label: "Sign Out",
39298
+ onClick: function onClick() {
39299
+ onSignOut();
39300
+ close();
39301
+ }
39302
+ }) : /*#__PURE__*/jsx(PopoverItem, {
39303
+ icon: "right-to-bracket",
39304
+ label: "Sign In",
39305
+ onClick: function onClick() {
39306
+ onSignIn();
39307
+ close();
39308
+ }
39309
+ })]
39310
+ })
39311
+ })
39312
+ })]
39313
+ });
39314
+ }
39315
+ });
39316
+ };
39317
+ var PopoverItem = function PopoverItem(_ref4) {
39318
+ var icon = _ref4.icon,
39319
+ label = _ref4.label,
39320
+ onClick = _ref4.onClick;
39321
+ return /*#__PURE__*/jsxs("button", {
39322
+ type: "button",
39323
+ onClick: onClick,
39324
+ 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",
39325
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
39326
+ icon: icon,
39327
+ className: "h-3.5 w-3.5 flex-shrink-0"
39328
+ }), /*#__PURE__*/jsx("span", {
39329
+ children: label
39161
39330
  })]
39162
39331
  });
39163
39332
  };
@@ -39912,6 +40081,23 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
39912
40081
  widgetSidebarCollapsed = _useState0[0],
39913
40082
  setWidgetSidebarCollapsed = _useState0[1];
39914
40083
 
40084
+ // ─── Recents + Session ──────────────────────────────────────────
40085
+ var _useState1 = useState([]),
40086
+ _useState10 = _slicedToArray(_useState1, 2),
40087
+ recentDashboards = _useState10[0],
40088
+ setRecentDashboards = _useState10[1];
40089
+ var sessionRestored = useRef(false);
40090
+
40091
+ // ─── Registry Auth (for sidebar) ────────────────────────────────
40092
+ var _useState11 = useState("loading"),
40093
+ _useState12 = _slicedToArray(_useState11, 2),
40094
+ authStatus = _useState12[0],
40095
+ setAuthStatus = _useState12[1];
40096
+ var _useState13 = useState(null),
40097
+ _useState14 = _slicedToArray(_useState13, 2),
40098
+ authProfile = _useState14[0],
40099
+ setAuthProfile = _useState14[1];
40100
+
39915
40101
  // Derive workspaceSelected from active tab
39916
40102
  var workspaceSelected = activeTabId ? (_openTabs$find$worksp = (_openTabs$find = openTabs.find(function (tab) {
39917
40103
  return tab.id === activeTabId;
@@ -39920,66 +40106,92 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
39920
40106
  /**
39921
40107
  * @param {Boolean} previewMode this is a toggle telling the dash we are editing
39922
40108
  */
39923
- var _useState1 = useState(preview),
39924
- _useState10 = _slicedToArray(_useState1, 2),
39925
- previewMode = _useState10[0],
39926
- setPreviewMode = _useState10[1];
40109
+ var _useState15 = useState(preview),
40110
+ _useState16 = _slicedToArray(_useState15, 2),
40111
+ previewMode = _useState16[0],
40112
+ setPreviewMode = _useState16[1];
39927
40113
 
39928
40114
  /**
39929
40115
  * @param {String["layout", "workspace", "widget"]} editMode this is the actual mode we are in
39930
40116
  */
39931
- var _useState11 = useState("all"),
39932
- _useState12 = _slicedToArray(_useState11, 1),
39933
- editMode = _useState12[0]; // for the time being use "all" as our "old" way
40117
+ var _useState17 = useState("all"),
40118
+ _useState18 = _slicedToArray(_useState17, 1),
40119
+ editMode = _useState18[0]; // for the time being use "all" as our "old" way
39934
40120
 
39935
40121
  // Workspace Management (loading)
39936
- var _useState13 = useState(false),
39937
- _useState14 = _slicedToArray(_useState13, 2),
39938
- isLoadingWorkspaces = _useState14[0],
39939
- setIsLoadingWorkspaces = _useState14[1];
39940
- var _useState15 = useState(false),
39941
- _useState16 = _slicedToArray(_useState15, 2),
39942
- isLoadingMenuItems = _useState16[0],
39943
- setIsLoadingMenuItems = _useState16[1];
39944
- var _useState17 = useState([]),
39945
- _useState18 = _slicedToArray(_useState17, 2),
39946
- menuItems = _useState18[0],
39947
- setMenuItems = _useState18[1];
39948
- var _useState19 = useState([]),
40122
+ var _useState19 = useState(false),
39949
40123
  _useState20 = _slicedToArray(_useState19, 2),
39950
- workspaceConfig = _useState20[0],
39951
- setWorkspaceConfig = _useState20[1];
39952
-
39953
- // Modal state
40124
+ isLoadingWorkspaces = _useState20[0],
40125
+ setIsLoadingWorkspaces = _useState20[1];
39954
40126
  var _useState21 = useState(false),
39955
40127
  _useState22 = _slicedToArray(_useState21, 2),
39956
- isThemeManagerOpen = _useState22[0],
39957
- setIsThemeManagerOpen = _useState22[1];
39958
- var _useState23 = useState(false),
40128
+ isLoadingMenuItems = _useState22[0],
40129
+ setIsLoadingMenuItems = _useState22[1];
40130
+ var _useState23 = useState([]),
39959
40131
  _useState24 = _slicedToArray(_useState23, 2),
39960
- isDashboardLoaderOpen = _useState24[0],
39961
- setIsDashboardLoaderOpen = _useState24[1];
39962
- var _useState25 = useState(false),
40132
+ menuItems = _useState24[0],
40133
+ setMenuItems = _useState24[1];
40134
+ var _useState25 = useState([]),
39963
40135
  _useState26 = _slicedToArray(_useState25, 2),
39964
- isLayoutPickerOpen = _useState26[0],
39965
- setIsLayoutPickerOpen = _useState26[1];
40136
+ workspaceConfig = _useState26[0],
40137
+ setWorkspaceConfig = _useState26[1];
39966
40138
 
39967
- // Unified App Settings Modal
40139
+ // Modal state
39968
40140
  var _useState27 = useState(false),
39969
40141
  _useState28 = _slicedToArray(_useState27, 2),
39970
- isAppSettingsOpen = _useState28[0],
39971
- setIsAppSettingsOpen = _useState28[1];
39972
- var _useState29 = useState("dashboards"),
40142
+ isThemeManagerOpen = _useState28[0],
40143
+ setIsThemeManagerOpen = _useState28[1];
40144
+ var _useState29 = useState(false),
39973
40145
  _useState30 = _slicedToArray(_useState29, 2),
39974
- appSettingsInitialSection = _useState30[0],
39975
- setAppSettingsInitialSection = _useState30[1];
40146
+ isDashboardLoaderOpen = _useState30[0],
40147
+ setIsDashboardLoaderOpen = _useState30[1];
40148
+ var _useState31 = useState(false),
40149
+ _useState32 = _slicedToArray(_useState31, 2),
40150
+ isLayoutPickerOpen = _useState32[0],
40151
+ setIsLayoutPickerOpen = _useState32[1];
40152
+
40153
+ // Unified App Settings Modal
40154
+ var _useState33 = useState(false),
40155
+ _useState34 = _slicedToArray(_useState33, 2),
40156
+ isAppSettingsOpen = _useState34[0],
40157
+ setIsAppSettingsOpen = _useState34[1];
40158
+ var _useState35 = useState("dashboards"),
40159
+ _useState36 = _slicedToArray(_useState35, 2),
40160
+ appSettingsInitialSection = _useState36[0],
40161
+ setAppSettingsInitialSection = _useState36[1];
39976
40162
  function openAppSettings() {
39977
- var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "dashboards";
40163
+ var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "general";
39978
40164
  setAppSettingsInitialSection(section);
39979
40165
  setIsAppSettingsOpen(true);
39980
40166
  }
39981
-
39982
- // Ref to access LayoutBuilder's current workspace without re-render cascades
40167
+ function handleProfileUpdated() {
40168
+ return _handleProfileUpdated.apply(this, arguments);
40169
+ } // Ref to access LayoutBuilder's current workspace without re-render cascades
40170
+ function _handleProfileUpdated() {
40171
+ _handleProfileUpdated = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
40172
+ var _window$mainApi11, profile;
40173
+ return _regeneratorRuntime.wrap(function (_context2) {
40174
+ while (1) switch (_context2.prev = _context2.next) {
40175
+ case 0:
40176
+ _context2.prev = 0;
40177
+ _context2.next = 1;
40178
+ 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();
40179
+ case 1:
40180
+ profile = _context2.sent;
40181
+ if (profile) setAuthProfile(profile);
40182
+ _context2.next = 3;
40183
+ break;
40184
+ case 2:
40185
+ _context2.prev = 2;
40186
+ _context2["catch"](0);
40187
+ case 3:
40188
+ case "end":
40189
+ return _context2.stop();
40190
+ }
40191
+ }, _callee2, null, [[0, 2]]);
40192
+ }));
40193
+ return _handleProfileUpdated.apply(this, arguments);
40194
+ }
39983
40195
  var currentWorkspaceRef = useRef(null);
39984
40196
 
39985
40197
  // Snapshot of the workspace before editing — used to restore on Cancel
@@ -40025,6 +40237,114 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40025
40237
  // eslint-disable-next-line react-hooks/exhaustive-deps
40026
40238
  }, [popout]);
40027
40239
 
40240
+ // ─── Load recents on mount ───────────────────────────────────────
40241
+ useEffect(function () {
40242
+ var _window$mainApi4;
40243
+ if (popout) return;
40244
+ (_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) {
40245
+ if (recents) setRecentDashboards(recents);
40246
+ });
40247
+ }, [popout]);
40248
+
40249
+ // ─── Session save (continuous) ──────────────────────────────────
40250
+ useEffect(function () {
40251
+ var _window$mainApi5;
40252
+ if (popout) return;
40253
+ var tabIds = openTabs.map(function (t) {
40254
+ return t.id;
40255
+ });
40256
+ (_window$mainApi5 = window.mainApi) === null || _window$mainApi5 === void 0 || (_window$mainApi5 = _window$mainApi5.session) === null || _window$mainApi5 === void 0 || _window$mainApi5.saveState(tabIds, activeTabId);
40257
+ }, [openTabs, activeTabId, popout]);
40258
+
40259
+ // ─── Session restore on launch ─────────────────────────────────
40260
+ useEffect(function () {
40261
+ var _window$mainApi6;
40262
+ if (popout || workspaceConfig.length === 0 || sessionRestored.current) return;
40263
+ sessionRestored.current = true;
40264
+ (_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) {
40265
+ var _state$openTabIds, _window$mainApi7;
40266
+ if (!(state !== null && state !== void 0 && (_state$openTabIds = state.openTabIds) !== null && _state$openTabIds !== void 0 && _state$openTabIds.length)) return;
40267
+ state.openTabIds.forEach(function (wsId) {
40268
+ var ws = workspaceConfig.find(function (w) {
40269
+ return w.id === wsId;
40270
+ });
40271
+ if (ws) handleOpenTab(ws);
40272
+ });
40273
+ if (state.activeTabId) setActiveTabId(state.activeTabId);
40274
+ (_window$mainApi7 = window.mainApi) === null || _window$mainApi7 === void 0 || (_window$mainApi7 = _window$mainApi7.session) === null || _window$mainApi7 === void 0 || _window$mainApi7.clearState();
40275
+ });
40276
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40277
+ }, [workspaceConfig, popout]);
40278
+
40279
+ // ─── Auth status check (for sidebar) ────────────────────────────
40280
+ useEffect(function () {
40281
+ if (popout) return;
40282
+ var cancelled = false;
40283
+ function checkAuth() {
40284
+ return _checkAuth.apply(this, arguments);
40285
+ }
40286
+ function _checkAuth() {
40287
+ _checkAuth = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
40288
+ var _window$mainApi8, status, _window$mainApi9, profile;
40289
+ return _regeneratorRuntime.wrap(function (_context) {
40290
+ while (1) switch (_context.prev = _context.next) {
40291
+ case 0:
40292
+ _context.prev = 0;
40293
+ _context.next = 1;
40294
+ 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();
40295
+ case 1:
40296
+ status = _context.sent;
40297
+ if (!cancelled) {
40298
+ _context.next = 2;
40299
+ break;
40300
+ }
40301
+ return _context.abrupt("return");
40302
+ case 2:
40303
+ if (!(status !== null && status !== void 0 && status.authenticated)) {
40304
+ _context.next = 5;
40305
+ break;
40306
+ }
40307
+ _context.next = 3;
40308
+ 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();
40309
+ case 3:
40310
+ profile = _context.sent;
40311
+ if (!cancelled) {
40312
+ _context.next = 4;
40313
+ break;
40314
+ }
40315
+ return _context.abrupt("return");
40316
+ case 4:
40317
+ if (profile) {
40318
+ setAuthProfile(profile);
40319
+ setAuthStatus("authenticated");
40320
+ } else {
40321
+ setAuthStatus("unauthenticated");
40322
+ }
40323
+ _context.next = 6;
40324
+ break;
40325
+ case 5:
40326
+ setAuthStatus("unauthenticated");
40327
+ case 6:
40328
+ _context.next = 8;
40329
+ break;
40330
+ case 7:
40331
+ _context.prev = 7;
40332
+ _context["catch"](0);
40333
+ if (!cancelled) setAuthStatus("unauthenticated");
40334
+ case 8:
40335
+ case "end":
40336
+ return _context.stop();
40337
+ }
40338
+ }, _callee, null, [[0, 7]]);
40339
+ }));
40340
+ return _checkAuth.apply(this, arguments);
40341
+ }
40342
+ checkAuth();
40343
+ return function () {
40344
+ cancelled = true;
40345
+ };
40346
+ }, [popout]);
40347
+
40028
40348
  // ─── Tab Handlers ─────────────────────────────────────────────────
40029
40349
 
40030
40350
  function handleOpenTab(workspaceItem) {
@@ -40057,6 +40377,14 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40057
40377
  }
40058
40378
  setPreviewMode(true);
40059
40379
  setSidebarCollapsed(true);
40380
+
40381
+ // Track in recents
40382
+ if (!popout) {
40383
+ var _window$mainApi0;
40384
+ (_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) {
40385
+ if (updated) setRecentDashboards(updated);
40386
+ });
40387
+ }
40060
40388
  }
40061
40389
  function handleCloseTab(tabId) {
40062
40390
  setOpenTabs(function (prev) {
@@ -40409,15 +40737,113 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40409
40737
  function handleToggleThemeVariant() {
40410
40738
  changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
40411
40739
  }
40740
+ function handleSidebarSignIn() {
40741
+ return _handleSidebarSignIn.apply(this, arguments);
40742
+ }
40743
+ function _handleSidebarSignIn() {
40744
+ _handleSidebarSignIn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
40745
+ var flow, interval, poll;
40746
+ return _regeneratorRuntime.wrap(function (_context4) {
40747
+ while (1) switch (_context4.prev = _context4.next) {
40748
+ case 0:
40749
+ _context4.prev = 0;
40750
+ _context4.next = 1;
40751
+ return window.mainApi.registryAuth.initiateLogin();
40752
+ case 1:
40753
+ flow = _context4.sent;
40754
+ if (flow.verificationUrlComplete) {
40755
+ window.mainApi.shell.openExternal(flow.verificationUrlComplete);
40756
+ }
40757
+ interval = (flow.interval || 5) * 1000;
40758
+ poll = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
40759
+ var result, profile;
40760
+ return _regeneratorRuntime.wrap(function (_context3) {
40761
+ while (1) switch (_context3.prev = _context3.next) {
40762
+ case 0:
40763
+ _context3.prev = 0;
40764
+ _context3.next = 1;
40765
+ return window.mainApi.registryAuth.pollToken(flow.deviceCode);
40766
+ case 1:
40767
+ result = _context3.sent;
40768
+ if (!(result.status === "authorized")) {
40769
+ _context3.next = 3;
40770
+ break;
40771
+ }
40772
+ clearInterval(poll);
40773
+ _context3.next = 2;
40774
+ return window.mainApi.registryAuth.getProfile();
40775
+ case 2:
40776
+ profile = _context3.sent;
40777
+ setAuthProfile(profile);
40778
+ setAuthStatus("authenticated");
40779
+ _context3.next = 4;
40780
+ break;
40781
+ case 3:
40782
+ if (result.status === "expired") {
40783
+ clearInterval(poll);
40784
+ }
40785
+ case 4:
40786
+ _context3.next = 6;
40787
+ break;
40788
+ case 5:
40789
+ _context3.prev = 5;
40790
+ _context3["catch"](0);
40791
+ clearInterval(poll);
40792
+ case 6:
40793
+ case "end":
40794
+ return _context3.stop();
40795
+ }
40796
+ }, _callee3, null, [[0, 5]]);
40797
+ })), interval);
40798
+ _context4.next = 3;
40799
+ break;
40800
+ case 2:
40801
+ _context4.prev = 2;
40802
+ _context4["catch"](0);
40803
+ case 3:
40804
+ case "end":
40805
+ return _context4.stop();
40806
+ }
40807
+ }, _callee4, null, [[0, 2]]);
40808
+ }));
40809
+ return _handleSidebarSignIn.apply(this, arguments);
40810
+ }
40811
+ function handleSidebarSignOut() {
40812
+ return _handleSidebarSignOut.apply(this, arguments);
40813
+ }
40814
+ function _handleSidebarSignOut() {
40815
+ _handleSidebarSignOut = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
40816
+ return _regeneratorRuntime.wrap(function (_context5) {
40817
+ while (1) switch (_context5.prev = _context5.next) {
40818
+ case 0:
40819
+ _context5.prev = 0;
40820
+ _context5.next = 1;
40821
+ return window.mainApi.registryAuth.logout();
40822
+ case 1:
40823
+ setAuthStatus("unauthenticated");
40824
+ setAuthProfile(null);
40825
+ _context5.next = 3;
40826
+ break;
40827
+ case 2:
40828
+ _context5.prev = 2;
40829
+ _context5["catch"](0);
40830
+ case 3:
40831
+ case "end":
40832
+ return _context5.stop();
40833
+ }
40834
+ }, _callee5, null, [[0, 2]]);
40835
+ }));
40836
+ return _handleSidebarSignOut.apply(this, arguments);
40837
+ }
40412
40838
  function handlePopout() {
40413
- var _window$mainApi4;
40414
- if (workspaceSelected && (_window$mainApi4 = window.mainApi) !== null && _window$mainApi4 !== void 0 && (_window$mainApi4 = _window$mainApi4.popout) !== null && _window$mainApi4 !== void 0 && _window$mainApi4.open) {
40839
+ var _window$mainApi1;
40840
+ if (workspaceSelected && (_window$mainApi1 = window.mainApi) !== null && _window$mainApi1 !== void 0 && (_window$mainApi1 = _window$mainApi1.popout) !== null && _window$mainApi1 !== void 0 && _window$mainApi1.open) {
40415
40841
  window.mainApi.popout.open(workspaceSelected.id);
40416
40842
  }
40417
40843
  }
40418
40844
  function handleWidgetPopout(widgetId) {
40419
- var _window$mainApi5;
40420
- if (workspaceSelected && (_window$mainApi5 = window.mainApi) !== null && _window$mainApi5 !== void 0 && (_window$mainApi5 = _window$mainApi5.widgetPopout) !== null && _window$mainApi5 !== void 0 && _window$mainApi5.open) {
40845
+ var _window$mainApi10;
40846
+ if (workspaceSelected && (_window$mainApi10 = window.mainApi) !== null && _window$mainApi10 !== void 0 && (_window$mainApi10 = _window$mainApi10.widgetPopout) !== null && _window$mainApi10 !== void 0 && _window$mainApi10.open) {
40421
40847
  window.mainApi.widgetPopout.open(workspaceSelected.id, widgetId);
40422
40848
  }
40423
40849
  }
@@ -40439,26 +40865,21 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40439
40865
  workspaces: workspaceConfig,
40440
40866
  menuItems: menuItems,
40441
40867
  activeTabId: activeTabId,
40868
+ recentDashboards: recentDashboards,
40869
+ authStatus: authStatus,
40870
+ authProfile: authProfile,
40442
40871
  onOpenWorkspace: handleOpenTab,
40443
40872
  onNewDashboard: function onNewDashboard() {
40444
40873
  return setIsLayoutPickerOpen(true);
40445
40874
  },
40446
- onGoHome: function onGoHome() {
40447
- return activeTabId && handleCloseTab(activeTabId);
40448
- },
40449
- onOpenProviders: function onOpenProviders() {
40450
- return openAppSettings("providers");
40451
- },
40452
- onOpenThemeManager: handleOpenThemeManager,
40453
- onOpenFolders: function onOpenFolders() {
40454
- return openAppSettings("folders");
40455
- },
40456
40875
  onOpenSettings: function onOpenSettings() {
40457
40876
  return openAppSettings("general");
40458
40877
  },
40459
40878
  onOpenCommandPalette: function onOpenCommandPalette() {
40460
40879
  return setIsCommandPaletteOpen(true);
40461
- }
40880
+ },
40881
+ onSignIn: handleSidebarSignIn,
40882
+ onSignOut: handleSidebarSignOut
40462
40883
  }), /*#__PURE__*/jsx("div", {
40463
40884
  className: "flex flex-col flex-1 min-w-0 overflow-hidden",
40464
40885
  children: workspaceSelected !== null ? /*#__PURE__*/jsxs(Fragment, {
@@ -40532,7 +40953,12 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
40532
40953
  onOpenThemeEditor: function onOpenThemeEditor() {
40533
40954
  setIsAppSettingsOpen(false);
40534
40955
  setIsThemeManagerOpen(true);
40535
- }
40956
+ },
40957
+ authStatus: authStatus,
40958
+ authProfile: authProfile,
40959
+ onSignIn: handleSidebarSignIn,
40960
+ onSignOut: handleSidebarSignOut,
40961
+ onProfileUpdated: handleProfileUpdated
40536
40962
  }), /*#__PURE__*/jsx(ThemeManagerModal, {
40537
40963
  open: isThemeManagerOpen,
40538
40964
  setIsOpen: function setIsOpen() {