@trops/dash-core 0.1.274 → 0.1.276
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 +73 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +73 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45278,7 +45278,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45278
45278
|
var uninstallWidget = React.useCallback(/*#__PURE__*/function () {
|
|
45279
45279
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(widgetName) {
|
|
45280
45280
|
var _window$mainApi2;
|
|
45281
|
-
var cMap, keysToRemove, _t2;
|
|
45281
|
+
var widget, packageId, cMap, keysToRemove, _t2;
|
|
45282
45282
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
45283
45283
|
while (1) switch (_context2.prev = _context2.next) {
|
|
45284
45284
|
case 0:
|
|
@@ -45289,17 +45289,22 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45289
45289
|
return _context2.abrupt("return");
|
|
45290
45290
|
case 1:
|
|
45291
45291
|
_context2.prev = 1;
|
|
45292
|
-
//
|
|
45292
|
+
// Resolve packageId — widgetName may be a CM key (e.g. "AnalogClockWidget")
|
|
45293
|
+
// but the registry is keyed by scoped package ID (e.g. "@trops/clock").
|
|
45294
|
+
widget = widgets.find(function (w) {
|
|
45295
|
+
return w.name === widgetName;
|
|
45296
|
+
});
|
|
45297
|
+
packageId = (widget === null || widget === void 0 ? void 0 : widget.packageId) || widgetName; // Remove matching ComponentManager entries so the widget
|
|
45293
45298
|
// doesn't reappear as a "builtin" ghost after uninstall.
|
|
45294
45299
|
cMap = ComponentManager.componentMap() || {};
|
|
45295
45300
|
keysToRemove = Object.keys(cMap).filter(function (key) {
|
|
45296
|
-
return cMap[key]._sourcePackage ===
|
|
45301
|
+
return cMap[key]._sourcePackage === packageId;
|
|
45297
45302
|
});
|
|
45298
45303
|
keysToRemove.forEach(function (key) {
|
|
45299
45304
|
return delete cMap[key];
|
|
45300
45305
|
});
|
|
45301
45306
|
_context2.next = 2;
|
|
45302
|
-
return window.mainApi.widgets.uninstall(
|
|
45307
|
+
return window.mainApi.widgets.uninstall(packageId);
|
|
45303
45308
|
case 2:
|
|
45304
45309
|
_context2.next = 3;
|
|
45305
45310
|
return refresh();
|
|
@@ -45319,7 +45324,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45319
45324
|
return function (_x) {
|
|
45320
45325
|
return _ref2.apply(this, arguments);
|
|
45321
45326
|
};
|
|
45322
|
-
}(), [refresh]);
|
|
45327
|
+
}(), [refresh, widgets]);
|
|
45323
45328
|
React.useEffect(function () {
|
|
45324
45329
|
refresh();
|
|
45325
45330
|
var handleWidgetsUpdated = function handleWidgetsUpdated() {
|
|
@@ -45635,15 +45640,25 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
45635
45640
|
// ── Uninstall with usage check ──────────────────────────────────────
|
|
45636
45641
|
|
|
45637
45642
|
function handleDeleteRequest(widget) {
|
|
45638
|
-
|
|
45643
|
+
// Find all sibling widgets in the same package (uninstall is package-level)
|
|
45644
|
+
var siblings = widget.packageId && widget.source === "installed" ? widgets.filter(function (w) {
|
|
45645
|
+
return w.packageId === widget.packageId && w.name !== widget.name;
|
|
45646
|
+
}) : [];
|
|
45647
|
+
var allComponentNames = [].concat(_toConsumableArray(widget.componentNames), _toConsumableArray(siblings.flatMap(function (s) {
|
|
45648
|
+
return s.componentNames;
|
|
45649
|
+
})));
|
|
45650
|
+
var usage = findWidgetUsage(allComponentNames, workspaces);
|
|
45639
45651
|
setDeleteUsage(usage);
|
|
45640
|
-
setDeleteTarget(widget)
|
|
45652
|
+
setDeleteTarget(_objectSpread$6(_objectSpread$6({}, widget), {}, {
|
|
45653
|
+
_siblings: siblings
|
|
45654
|
+
}));
|
|
45641
45655
|
}
|
|
45642
45656
|
function handleConfirmDelete() {
|
|
45643
45657
|
return _handleConfirmDelete.apply(this, arguments);
|
|
45644
45658
|
}
|
|
45645
45659
|
function _handleConfirmDelete() {
|
|
45646
45660
|
_handleConfirmDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
45661
|
+
var allNames;
|
|
45647
45662
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
45648
45663
|
while (1) switch (_context.prev = _context.next) {
|
|
45649
45664
|
case 0:
|
|
@@ -45657,7 +45672,11 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
45657
45672
|
_context.next = 2;
|
|
45658
45673
|
return uninstallWidget(deleteTarget.name);
|
|
45659
45674
|
case 2:
|
|
45660
|
-
if
|
|
45675
|
+
// Clear selection if it was the target or any sibling
|
|
45676
|
+
allNames = [deleteTarget.name].concat(_toConsumableArray((deleteTarget._siblings || []).map(function (s) {
|
|
45677
|
+
return s.name;
|
|
45678
|
+
})));
|
|
45679
|
+
if (allNames.includes(selectedWidgetName)) {
|
|
45661
45680
|
setSelectedWidgetName(null);
|
|
45662
45681
|
}
|
|
45663
45682
|
_context.next = 4;
|
|
@@ -46126,6 +46145,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46126
46145
|
|
|
46127
46146
|
var paragraphStyles = DashReact.getStylesForItem(DashReact.themeObjects.PARAGRAPH, currentTheme);
|
|
46128
46147
|
var deleteWidgetLabel = (deleteTarget === null || deleteTarget === void 0 ? void 0 : deleteTarget.displayName) || (deleteTarget === null || deleteTarget === void 0 ? void 0 : deleteTarget.name) || "";
|
|
46148
|
+
var deleteSiblings = (deleteTarget === null || deleteTarget === void 0 ? void 0 : deleteTarget._siblings) || [];
|
|
46149
|
+
var deletePackageLabel = deleteTarget !== null && deleteTarget !== void 0 && deleteTarget.packageId ? deleteTarget.packageId.replace(/^@[^/]+\//, "") : "";
|
|
46150
|
+
var hasPackageSiblings = deleteSiblings.length > 0;
|
|
46129
46151
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
46130
46152
|
children: [/*#__PURE__*/jsxRuntime.jsx(SectionLayout, {
|
|
46131
46153
|
listContent: listContent,
|
|
@@ -46143,8 +46165,8 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46143
46165
|
setDeleteTarget(null);
|
|
46144
46166
|
setDeleteUsage([]);
|
|
46145
46167
|
},
|
|
46146
|
-
title: "Uninstall Widget"
|
|
46147
|
-
}, deleteUsage.length === 0 ? {
|
|
46168
|
+
title: hasPackageSiblings ? "Uninstall Package" : "Uninstall Widget"
|
|
46169
|
+
}, !hasPackageSiblings && deleteUsage.length === 0 ? {
|
|
46148
46170
|
message: "Are you sure you want to uninstall \"".concat(deleteWidgetLabel, "\"?")
|
|
46149
46171
|
} : {}), {}, {
|
|
46150
46172
|
confirmLabel: "Uninstall",
|
|
@@ -46154,27 +46176,48 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46154
46176
|
setDeleteTarget(null);
|
|
46155
46177
|
setDeleteUsage([]);
|
|
46156
46178
|
},
|
|
46157
|
-
children: deleteUsage.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46179
|
+
children: (hasPackageSiblings || deleteUsage.length > 0) && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46158
46180
|
className: paragraphStyles.textColor || "",
|
|
46159
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs(
|
|
46160
|
-
|
|
46161
|
-
|
|
46162
|
-
|
|
46163
|
-
|
|
46164
|
-
|
|
46165
|
-
|
|
46166
|
-
|
|
46167
|
-
|
|
46168
|
-
|
|
46169
|
-
|
|
46170
|
-
|
|
46171
|
-
|
|
46172
|
-
|
|
46173
|
-
|
|
46174
|
-
|
|
46175
|
-
|
|
46176
|
-
|
|
46177
|
-
|
|
46181
|
+
children: [hasPackageSiblings && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
46182
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("p", {
|
|
46183
|
+
className: "text-sm leading-relaxed",
|
|
46184
|
+
children: ["\"", deleteWidgetLabel, "\" is part of the", " ", /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
46185
|
+
className: "font-semibold",
|
|
46186
|
+
children: deletePackageLabel
|
|
46187
|
+
}), " ", "package. Uninstalling will remove all", " ", deleteSiblings.length + 1, " widgets in this package:"]
|
|
46188
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
46189
|
+
className: "mt-2 mb-2 space-y-1",
|
|
46190
|
+
children: [deleteTarget].concat(_toConsumableArray(deleteSiblings)).map(function (w) {
|
|
46191
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46192
|
+
className: "text-xs opacity-60 flex items-center gap-1.5 pl-2",
|
|
46193
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
|
|
46194
|
+
icon: "puzzle-piece",
|
|
46195
|
+
className: "h-3 w-3"
|
|
46196
|
+
}), w.displayName || w.name]
|
|
46197
|
+
}, w.name);
|
|
46198
|
+
})
|
|
46199
|
+
})]
|
|
46200
|
+
}), deleteUsage.length > 0 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
46201
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("p", {
|
|
46202
|
+
className: "text-sm leading-relaxed",
|
|
46203
|
+
children: [hasPackageSiblings ? "These widgets are" : "\"".concat(deleteWidgetLabel, "\" is"), " ", "currently used in ", deleteUsage.length, " dashboard", deleteUsage.length !== 1 ? "s" : "", ". Uninstalling will leave orphaned layout items on these dashboards."]
|
|
46204
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46205
|
+
className: "mt-2 space-y-1",
|
|
46206
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
46207
|
+
className: "text-xs font-semibold opacity-70",
|
|
46208
|
+
children: "Affected dashboards:"
|
|
46209
|
+
}), deleteUsage.map(function (u) {
|
|
46210
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46211
|
+
className: "text-xs opacity-60 flex items-center gap-1.5 pl-2",
|
|
46212
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
|
|
46213
|
+
icon: "triangle-exclamation",
|
|
46214
|
+
className: "h-3 w-3 text-yellow-500"
|
|
46215
|
+
}), u.workspaceName, " ", /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
46216
|
+
className: "opacity-50",
|
|
46217
|
+
children: ["(", u.count, " instance", u.count !== 1 ? "s" : "", ")"]
|
|
46218
|
+
})]
|
|
46219
|
+
}, u.workspaceId);
|
|
46220
|
+
})]
|
|
46178
46221
|
})]
|
|
46179
46222
|
})]
|
|
46180
46223
|
})
|