@acarmisc/backstage-plugin-litellm 0.36.0 → 0.37.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/connect.d.ts CHANGED
@@ -6,3 +6,5 @@
6
6
  export declare function isLoopbackCallback(uri: string | null): uri is string;
7
7
  /** Hands the keys to the local client as a form POST, so they never land in a URL or the browser history. */
8
8
  export declare function postToLoopback(redirectUri: string, fields: [string, string][]): void;
9
+ /** Teams ticked when the page opens: only the ones the client has no key for, when it says (`have`). */
10
+ export declare function initialTeams(all: string[], have: Set<string>): Set<string>;
package/dist/index.cjs.js CHANGED
@@ -6758,6 +6758,10 @@ function postToLoopback(redirectUri, fields) {
6758
6758
  document.body.appendChild(form);
6759
6759
  form.submit();
6760
6760
  }
6761
+ function initialTeams(all, have) {
6762
+ const missing = all.filter((id) => !have.has(id));
6763
+ return new Set(have.size ? missing : all);
6764
+ }
6761
6765
  var init_connect = __esm({
6762
6766
  "src/connect.ts"() {
6763
6767
  "use strict";
@@ -6795,6 +6799,7 @@ var init_ConnectPage = __esm({
6795
6799
  const redirectUri = params.get("redirect_uri");
6796
6800
  const state = params.get("state") ?? "";
6797
6801
  const client = params.get("client") || "a local application";
6802
+ const have = new Set((params.get("have") ?? "").split(",").filter(Boolean));
6798
6803
  const teams = (0, import_react_use3.useAsync)(() => api.getTeams(), [api]);
6799
6804
  const [selected, setSelected] = (0, import_react14.useState)();
6800
6805
  const [busy, setBusy] = (0, import_react14.useState)(false);
@@ -6804,7 +6809,7 @@ var init_ConnectPage = __esm({
6804
6809
  }
6805
6810
  if (teams.loading) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core_components4.Progress, {});
6806
6811
  const all = teams.value ?? [];
6807
- const chosen = selected ?? new Set(all.map((t) => t.team_id));
6812
+ const chosen = selected ?? initialTeams(all.map((t) => t.team_id), have);
6808
6813
  const toggle = (id) => {
6809
6814
  const next = new Set(chosen);
6810
6815
  if (!next.delete(id)) next.add(id);
@@ -6830,7 +6835,7 @@ var init_ConnectPage = __esm({
6830
6835
  ] }),
6831
6836
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_Typography16.default, { variant: "body2", color: "text.secondary", paragraph: true, children: [
6832
6837
  client,
6833
- " will receive an API key for each selected team. Connecting again replaces the keys created by a previous connection."
6838
+ " will receive an API key for each selected team. Selecting a team that is already connected replaces its key, also on your other devices."
6834
6839
  ] }),
6835
6840
  teams.error && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_Alert7.default, { severity: "error", children: [
6836
6841
  "Could not load your teams: ",
@@ -6840,7 +6845,7 @@ var init_ConnectPage = __esm({
6840
6845
  import_FormControlLabel3.default,
6841
6846
  {
6842
6847
  control: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_Checkbox3.default, { checked: chosen.has(t.team_id), onChange: () => toggle(t.team_id) }),
6843
- label: t.team_alias ?? t.team_id
6848
+ label: `${t.team_alias ?? t.team_id}${have.has(t.team_id) ? " (already connected)" : ""}`
6844
6849
  },
6845
6850
  t.team_id
6846
6851
  )) }),