@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.esm.js
CHANGED
|
@@ -45260,7 +45260,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45260
45260
|
var uninstallWidget = useCallback(/*#__PURE__*/function () {
|
|
45261
45261
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(widgetName) {
|
|
45262
45262
|
var _window$mainApi2;
|
|
45263
|
-
var cMap, keysToRemove, _t2;
|
|
45263
|
+
var widget, packageId, cMap, keysToRemove, _t2;
|
|
45264
45264
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
45265
45265
|
while (1) switch (_context2.prev = _context2.next) {
|
|
45266
45266
|
case 0:
|
|
@@ -45271,17 +45271,22 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45271
45271
|
return _context2.abrupt("return");
|
|
45272
45272
|
case 1:
|
|
45273
45273
|
_context2.prev = 1;
|
|
45274
|
-
//
|
|
45274
|
+
// Resolve packageId — widgetName may be a CM key (e.g. "AnalogClockWidget")
|
|
45275
|
+
// but the registry is keyed by scoped package ID (e.g. "@trops/clock").
|
|
45276
|
+
widget = widgets.find(function (w) {
|
|
45277
|
+
return w.name === widgetName;
|
|
45278
|
+
});
|
|
45279
|
+
packageId = (widget === null || widget === void 0 ? void 0 : widget.packageId) || widgetName; // Remove matching ComponentManager entries so the widget
|
|
45275
45280
|
// doesn't reappear as a "builtin" ghost after uninstall.
|
|
45276
45281
|
cMap = ComponentManager.componentMap() || {};
|
|
45277
45282
|
keysToRemove = Object.keys(cMap).filter(function (key) {
|
|
45278
|
-
return cMap[key]._sourcePackage ===
|
|
45283
|
+
return cMap[key]._sourcePackage === packageId;
|
|
45279
45284
|
});
|
|
45280
45285
|
keysToRemove.forEach(function (key) {
|
|
45281
45286
|
return delete cMap[key];
|
|
45282
45287
|
});
|
|
45283
45288
|
_context2.next = 2;
|
|
45284
|
-
return window.mainApi.widgets.uninstall(
|
|
45289
|
+
return window.mainApi.widgets.uninstall(packageId);
|
|
45285
45290
|
case 2:
|
|
45286
45291
|
_context2.next = 3;
|
|
45287
45292
|
return refresh();
|
|
@@ -45301,7 +45306,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
45301
45306
|
return function (_x) {
|
|
45302
45307
|
return _ref2.apply(this, arguments);
|
|
45303
45308
|
};
|
|
45304
|
-
}(), [refresh]);
|
|
45309
|
+
}(), [refresh, widgets]);
|
|
45305
45310
|
useEffect(function () {
|
|
45306
45311
|
refresh();
|
|
45307
45312
|
var handleWidgetsUpdated = function handleWidgetsUpdated() {
|
|
@@ -45617,15 +45622,25 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
45617
45622
|
// ── Uninstall with usage check ──────────────────────────────────────
|
|
45618
45623
|
|
|
45619
45624
|
function handleDeleteRequest(widget) {
|
|
45620
|
-
|
|
45625
|
+
// Find all sibling widgets in the same package (uninstall is package-level)
|
|
45626
|
+
var siblings = widget.packageId && widget.source === "installed" ? widgets.filter(function (w) {
|
|
45627
|
+
return w.packageId === widget.packageId && w.name !== widget.name;
|
|
45628
|
+
}) : [];
|
|
45629
|
+
var allComponentNames = [].concat(_toConsumableArray(widget.componentNames), _toConsumableArray(siblings.flatMap(function (s) {
|
|
45630
|
+
return s.componentNames;
|
|
45631
|
+
})));
|
|
45632
|
+
var usage = findWidgetUsage(allComponentNames, workspaces);
|
|
45621
45633
|
setDeleteUsage(usage);
|
|
45622
|
-
setDeleteTarget(widget)
|
|
45634
|
+
setDeleteTarget(_objectSpread$6(_objectSpread$6({}, widget), {}, {
|
|
45635
|
+
_siblings: siblings
|
|
45636
|
+
}));
|
|
45623
45637
|
}
|
|
45624
45638
|
function handleConfirmDelete() {
|
|
45625
45639
|
return _handleConfirmDelete.apply(this, arguments);
|
|
45626
45640
|
}
|
|
45627
45641
|
function _handleConfirmDelete() {
|
|
45628
45642
|
_handleConfirmDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
45643
|
+
var allNames;
|
|
45629
45644
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
45630
45645
|
while (1) switch (_context.prev = _context.next) {
|
|
45631
45646
|
case 0:
|
|
@@ -45639,7 +45654,11 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
45639
45654
|
_context.next = 2;
|
|
45640
45655
|
return uninstallWidget(deleteTarget.name);
|
|
45641
45656
|
case 2:
|
|
45642
|
-
if
|
|
45657
|
+
// Clear selection if it was the target or any sibling
|
|
45658
|
+
allNames = [deleteTarget.name].concat(_toConsumableArray((deleteTarget._siblings || []).map(function (s) {
|
|
45659
|
+
return s.name;
|
|
45660
|
+
})));
|
|
45661
|
+
if (allNames.includes(selectedWidgetName)) {
|
|
45643
45662
|
setSelectedWidgetName(null);
|
|
45644
45663
|
}
|
|
45645
45664
|
_context.next = 4;
|
|
@@ -46108,6 +46127,9 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46108
46127
|
|
|
46109
46128
|
var paragraphStyles = getStylesForItem(themeObjects.PARAGRAPH, currentTheme);
|
|
46110
46129
|
var deleteWidgetLabel = (deleteTarget === null || deleteTarget === void 0 ? void 0 : deleteTarget.displayName) || (deleteTarget === null || deleteTarget === void 0 ? void 0 : deleteTarget.name) || "";
|
|
46130
|
+
var deleteSiblings = (deleteTarget === null || deleteTarget === void 0 ? void 0 : deleteTarget._siblings) || [];
|
|
46131
|
+
var deletePackageLabel = deleteTarget !== null && deleteTarget !== void 0 && deleteTarget.packageId ? deleteTarget.packageId.replace(/^@[^/]+\//, "") : "";
|
|
46132
|
+
var hasPackageSiblings = deleteSiblings.length > 0;
|
|
46111
46133
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
46112
46134
|
children: [/*#__PURE__*/jsx(SectionLayout, {
|
|
46113
46135
|
listContent: listContent,
|
|
@@ -46125,8 +46147,8 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46125
46147
|
setDeleteTarget(null);
|
|
46126
46148
|
setDeleteUsage([]);
|
|
46127
46149
|
},
|
|
46128
|
-
title: "Uninstall Widget"
|
|
46129
|
-
}, deleteUsage.length === 0 ? {
|
|
46150
|
+
title: hasPackageSiblings ? "Uninstall Package" : "Uninstall Widget"
|
|
46151
|
+
}, !hasPackageSiblings && deleteUsage.length === 0 ? {
|
|
46130
46152
|
message: "Are you sure you want to uninstall \"".concat(deleteWidgetLabel, "\"?")
|
|
46131
46153
|
} : {}), {}, {
|
|
46132
46154
|
confirmLabel: "Uninstall",
|
|
@@ -46136,27 +46158,48 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
46136
46158
|
setDeleteTarget(null);
|
|
46137
46159
|
setDeleteUsage([]);
|
|
46138
46160
|
},
|
|
46139
|
-
children: deleteUsage.length > 0 && /*#__PURE__*/jsxs("div", {
|
|
46161
|
+
children: (hasPackageSiblings || deleteUsage.length > 0) && /*#__PURE__*/jsxs("div", {
|
|
46140
46162
|
className: paragraphStyles.textColor || "",
|
|
46141
|
-
children: [/*#__PURE__*/jsxs(
|
|
46142
|
-
|
|
46143
|
-
|
|
46144
|
-
|
|
46145
|
-
|
|
46146
|
-
|
|
46147
|
-
|
|
46148
|
-
|
|
46149
|
-
|
|
46150
|
-
|
|
46151
|
-
|
|
46152
|
-
|
|
46153
|
-
|
|
46154
|
-
|
|
46155
|
-
|
|
46156
|
-
|
|
46157
|
-
|
|
46158
|
-
|
|
46159
|
-
|
|
46163
|
+
children: [hasPackageSiblings && /*#__PURE__*/jsxs(Fragment, {
|
|
46164
|
+
children: [/*#__PURE__*/jsxs("p", {
|
|
46165
|
+
className: "text-sm leading-relaxed",
|
|
46166
|
+
children: ["\"", deleteWidgetLabel, "\" is part of the", " ", /*#__PURE__*/jsx("span", {
|
|
46167
|
+
className: "font-semibold",
|
|
46168
|
+
children: deletePackageLabel
|
|
46169
|
+
}), " ", "package. Uninstalling will remove all", " ", deleteSiblings.length + 1, " widgets in this package:"]
|
|
46170
|
+
}), /*#__PURE__*/jsx("div", {
|
|
46171
|
+
className: "mt-2 mb-2 space-y-1",
|
|
46172
|
+
children: [deleteTarget].concat(_toConsumableArray(deleteSiblings)).map(function (w) {
|
|
46173
|
+
return /*#__PURE__*/jsxs("div", {
|
|
46174
|
+
className: "text-xs opacity-60 flex items-center gap-1.5 pl-2",
|
|
46175
|
+
children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
|
|
46176
|
+
icon: "puzzle-piece",
|
|
46177
|
+
className: "h-3 w-3"
|
|
46178
|
+
}), w.displayName || w.name]
|
|
46179
|
+
}, w.name);
|
|
46180
|
+
})
|
|
46181
|
+
})]
|
|
46182
|
+
}), deleteUsage.length > 0 && /*#__PURE__*/jsxs(Fragment, {
|
|
46183
|
+
children: [/*#__PURE__*/jsxs("p", {
|
|
46184
|
+
className: "text-sm leading-relaxed",
|
|
46185
|
+
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."]
|
|
46186
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
46187
|
+
className: "mt-2 space-y-1",
|
|
46188
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
46189
|
+
className: "text-xs font-semibold opacity-70",
|
|
46190
|
+
children: "Affected dashboards:"
|
|
46191
|
+
}), deleteUsage.map(function (u) {
|
|
46192
|
+
return /*#__PURE__*/jsxs("div", {
|
|
46193
|
+
className: "text-xs opacity-60 flex items-center gap-1.5 pl-2",
|
|
46194
|
+
children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
|
|
46195
|
+
icon: "triangle-exclamation",
|
|
46196
|
+
className: "h-3 w-3 text-yellow-500"
|
|
46197
|
+
}), u.workspaceName, " ", /*#__PURE__*/jsxs("span", {
|
|
46198
|
+
className: "opacity-50",
|
|
46199
|
+
children: ["(", u.count, " instance", u.count !== 1 ? "s" : "", ")"]
|
|
46200
|
+
})]
|
|
46201
|
+
}, u.workspaceId);
|
|
46202
|
+
})]
|
|
46160
46203
|
})]
|
|
46161
46204
|
})]
|
|
46162
46205
|
})
|