@acarmisc/backstage-plugin-litellm 0.29.0 → 0.30.0

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.cjs.js CHANGED
@@ -1524,6 +1524,18 @@ function pruneCopy(n) {
1524
1524
  }
1525
1525
  return `Remove ${n} expired keys from the list. They already don't work.`;
1526
1526
  }
1527
+ function blockButtonState(blocked, manage, unblock) {
1528
+ if (blocked) {
1529
+ return {
1530
+ label: unblock.denied ? "No permission to unblock keys" : "Unblock key",
1531
+ disabled: !unblock.allowed
1532
+ };
1533
+ }
1534
+ return {
1535
+ label: manage.denied ? "No permission to block keys" : "Block key \u2014 suspends without revoking",
1536
+ disabled: !manage.allowed
1537
+ };
1538
+ }
1527
1539
  var init_keyLabels = __esm({
1528
1540
  "src/keyLabels.ts"() {
1529
1541
  "use strict";
@@ -1738,10 +1750,13 @@ var init_KeysTable = __esm({
1738
1750
  }) => {
1739
1751
  const managePermission = (0, import_plugin_permission_react.usePermission)({ permission: import_backstage_plugin_litellm_common.litellmKeyManagePermission });
1740
1752
  const revokePermission = (0, import_plugin_permission_react.usePermission)({ permission: import_backstage_plugin_litellm_common.litellmKeyRevokePermission });
1753
+ const unblockPermission = (0, import_plugin_permission_react.usePermission)({ permission: import_backstage_plugin_litellm_common.litellmKeyUnblockPermission });
1741
1754
  const canManageKeys = !managePermission.loading && managePermission.allowed;
1742
1755
  const canRevokeKeys = !revokePermission.loading && revokePermission.allowed;
1743
1756
  const manageDenied = !managePermission.loading && !managePermission.allowed;
1744
1757
  const revokeDenied = !revokePermission.loading && !revokePermission.allowed;
1758
+ const canUnblockKeys = !unblockPermission.loading && unblockPermission.allowed;
1759
+ const unblockDenied = !unblockPermission.loading && !unblockPermission.allowed;
1745
1760
  const [blockConfirmKey, setBlockConfirmKey] = (0, import_react4.useState)(null);
1746
1761
  const [blockSubmitting, setBlockSubmitting] = (0, import_react4.useState)(false);
1747
1762
  const [deleteConfirmKey, setDeleteConfirmKey] = (0, import_react4.useState)(null);
@@ -1860,6 +1875,11 @@ var init_KeysTable = __esm({
1860
1875
  return filteredKeys.map((key) => {
1861
1876
  const keyId = key.token ?? key.key;
1862
1877
  const keyModels = key.models ?? [];
1878
+ const blockState = blockButtonState(
1879
+ key.blocked,
1880
+ { allowed: canManageKeys, denied: manageDenied },
1881
+ { allowed: canUnblockKeys, denied: unblockDenied }
1882
+ );
1863
1883
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1864
1884
  import_TableRow.default,
1865
1885
  {
@@ -1931,19 +1951,13 @@ var init_KeysTable = __esm({
1931
1951
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_material2.Edit, { fontSize: "small" })
1932
1952
  }
1933
1953
  ) }) }),
1934
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Tooltip.default, { describeChild: true, title: (() => {
1935
- if (manageDenied) return "No permission to block keys";
1936
- return key.blocked ? "Unblock key" : "Block key \u2014 suspends without revoking";
1937
- })(), placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1954
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_Tooltip.default, { describeChild: true, title: blockState.label, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1938
1955
  import_IconButton.default,
1939
1956
  {
1940
1957
  size: "small",
1941
1958
  onClick: () => handleToggleBlock(key),
1942
- disabled: blockSubmitting || !canManageKeys,
1943
- "aria-label": (() => {
1944
- if (manageDenied) return "No permission to block keys";
1945
- return key.blocked ? "Unblock key" : "Block key \u2014 suspends without revoking";
1946
- })(),
1959
+ disabled: blockSubmitting || blockState.disabled,
1960
+ "aria-label": blockState.label,
1947
1961
  sx: quietIconButtonSx("warning"),
1948
1962
  children: keyBlockIcon(blockSubmitting, key.blocked)
1949
1963
  }