@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.esm.js CHANGED
@@ -1500,6 +1500,18 @@ function pruneCopy(n) {
1500
1500
  }
1501
1501
  return `Remove ${n} expired keys from the list. They already don't work.`;
1502
1502
  }
1503
+ function blockButtonState(blocked, manage, unblock) {
1504
+ if (blocked) {
1505
+ return {
1506
+ label: unblock.denied ? "No permission to unblock keys" : "Unblock key",
1507
+ disabled: !unblock.allowed
1508
+ };
1509
+ }
1510
+ return {
1511
+ label: manage.denied ? "No permission to block keys" : "Block key \u2014 suspends without revoking",
1512
+ disabled: !manage.allowed
1513
+ };
1514
+ }
1503
1515
  var init_keyLabels = __esm({
1504
1516
  "src/keyLabels.ts"() {
1505
1517
  "use strict";
@@ -1603,7 +1615,8 @@ import { ContentCopy, Delete, Edit, Autorenew, Search, Lock, LockOpen, Check, Cl
1603
1615
  import { usePermission } from "@backstage/plugin-permission-react";
1604
1616
  import {
1605
1617
  litellmKeyManagePermission,
1606
- litellmKeyRevokePermission
1618
+ litellmKeyRevokePermission,
1619
+ litellmKeyUnblockPermission
1607
1620
  } from "@acarmisc/backstage-plugin-litellm-common";
1608
1621
  import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1609
1622
  function expiryChipLabel(status, expiresAt) {
@@ -1717,10 +1730,13 @@ var init_KeysTable = __esm({
1717
1730
  }) => {
1718
1731
  const managePermission = usePermission({ permission: litellmKeyManagePermission });
1719
1732
  const revokePermission = usePermission({ permission: litellmKeyRevokePermission });
1733
+ const unblockPermission = usePermission({ permission: litellmKeyUnblockPermission });
1720
1734
  const canManageKeys = !managePermission.loading && managePermission.allowed;
1721
1735
  const canRevokeKeys = !revokePermission.loading && revokePermission.allowed;
1722
1736
  const manageDenied = !managePermission.loading && !managePermission.allowed;
1723
1737
  const revokeDenied = !revokePermission.loading && !revokePermission.allowed;
1738
+ const canUnblockKeys = !unblockPermission.loading && unblockPermission.allowed;
1739
+ const unblockDenied = !unblockPermission.loading && !unblockPermission.allowed;
1724
1740
  const [blockConfirmKey, setBlockConfirmKey] = useState3(null);
1725
1741
  const [blockSubmitting, setBlockSubmitting] = useState3(false);
1726
1742
  const [deleteConfirmKey, setDeleteConfirmKey] = useState3(null);
@@ -1839,6 +1855,11 @@ var init_KeysTable = __esm({
1839
1855
  return filteredKeys.map((key) => {
1840
1856
  const keyId = key.token ?? key.key;
1841
1857
  const keyModels = key.models ?? [];
1858
+ const blockState = blockButtonState(
1859
+ key.blocked,
1860
+ { allowed: canManageKeys, denied: manageDenied },
1861
+ { allowed: canUnblockKeys, denied: unblockDenied }
1862
+ );
1842
1863
  return /* @__PURE__ */ jsxs7(
1843
1864
  TableRow,
1844
1865
  {
@@ -1910,19 +1931,13 @@ var init_KeysTable = __esm({
1910
1931
  children: /* @__PURE__ */ jsx8(Edit, { fontSize: "small" })
1911
1932
  }
1912
1933
  ) }) }),
1913
- /* @__PURE__ */ jsx8(Tooltip, { describeChild: true, title: (() => {
1914
- if (manageDenied) return "No permission to block keys";
1915
- return key.blocked ? "Unblock key" : "Block key \u2014 suspends without revoking";
1916
- })(), placement: "top", children: /* @__PURE__ */ jsx8("span", { children: /* @__PURE__ */ jsx8(
1934
+ /* @__PURE__ */ jsx8(Tooltip, { describeChild: true, title: blockState.label, placement: "top", children: /* @__PURE__ */ jsx8("span", { children: /* @__PURE__ */ jsx8(
1917
1935
  IconButton,
1918
1936
  {
1919
1937
  size: "small",
1920
1938
  onClick: () => handleToggleBlock(key),
1921
- disabled: blockSubmitting || !canManageKeys,
1922
- "aria-label": (() => {
1923
- if (manageDenied) return "No permission to block keys";
1924
- return key.blocked ? "Unblock key" : "Block key \u2014 suspends without revoking";
1925
- })(),
1939
+ disabled: blockSubmitting || blockState.disabled,
1940
+ "aria-label": blockState.label,
1926
1941
  sx: quietIconButtonSx("warning"),
1927
1942
  children: keyBlockIcon(blockSubmitting, key.blocked)
1928
1943
  }
@@ -5750,7 +5765,7 @@ import {
5750
5765
  litellmKeyRevokePermission as litellmKeyRevokePermission2,
5751
5766
  litellmKeyManagePermission as litellmKeyManagePermission2,
5752
5767
  litellmKeyResetSpendPermission as litellmKeyResetSpendPermission2,
5753
- litellmKeyUnblockPermission,
5768
+ litellmKeyUnblockPermission as litellmKeyUnblockPermission2,
5754
5769
  litellmAuditReadPermission,
5755
5770
  litellmTeamCreatePermission,
5756
5771
  litellmTeamManagePermission,