@64mb/freelens-power 2.21.0 → 2.21.2

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/renderer.js CHANGED
@@ -16057,7 +16057,7 @@ function startCatalogDisconnect() {
16057
16057
  let host;
16058
16058
  let renderedDisabled;
16059
16059
  const style = document.createElement("style");
16060
- style.textContent = ".power-catalog-disconnect{position:absolute;right:86px;bottom:30px;z-index:1}.power-catalog-disconnect button:disabled{opacity:.45;cursor:default}";
16060
+ style.textContent = ".power-catalog-disconnect{position:absolute;right:94px;bottom:30px;z-index:1}.power-catalog-disconnect button:disabled{opacity:.45;cursor:default}";
16061
16061
  document.head.append(style);
16062
16062
  const remove = () => {
16063
16063
  if (!host) return;
@@ -16166,6 +16166,8 @@ function startCatalogDisconnect() {
16166
16166
  var icons$3 = {
16167
16167
  "View Details": { material: "info_outline" },
16168
16168
  Settings: { material: "settings" },
16169
+ "Upload Icon": { material: "file_upload" },
16170
+ Clear: { material: "clear" },
16169
16171
  "Open kubeconfig": { material: "edit" },
16170
16172
  Connect: { material: "link" },
16171
16173
  Disconnect: { material: "link_off" },
@@ -16193,7 +16195,11 @@ function startCatalogMenuIcons() {
16193
16195
  const first = menu.querySelector(":scope > .MenuItem");
16194
16196
  return first && titleOf(first) === "Remove from Hotbar";
16195
16197
  });
16196
- const items = /* @__PURE__ */ new Set([...document.querySelectorAll("[data-testid^=\"menu-actions-for-catalog-for-\"] .MenuItem"), ...hotbarMenus.flatMap((menu) => [...menu.querySelectorAll(":scope > .MenuItem")])]);
16198
+ const items = /* @__PURE__ */ new Set([
16199
+ ...document.querySelectorAll("[data-testid^=\"menu-actions-for-catalog-for-\"] .MenuItem"),
16200
+ ...document.querySelectorAll("[data-testid^=\"menu-actions-for-cluster-icon-settings-for-\"] .MenuItem"),
16201
+ ...hotbarMenus.flatMap((menu) => [...menu.querySelectorAll(":scope > .MenuItem")])
16202
+ ]);
16197
16203
  for (const item of items) {
16198
16204
  const title = titleOf(item);
16199
16205
  const icon = icons$3[title];
@@ -16937,6 +16943,96 @@ function ClusterIconsPage() {
16937
16943
  })]
16938
16944
  });
16939
16945
  }
16946
+ // src/renderer/cluster-icon-settings-menu.tsx
16947
+ function startClusterIconSettingsMenu() {
16948
+ const prefix = "menu-actions-for-cluster-icon-settings-for-";
16949
+ const owned = /* @__PURE__ */ new Map();
16950
+ const modal = document.createElement("div");
16951
+ document.body.append(modal);
16952
+ let stopped = false;
16953
+ let request = 0;
16954
+ const open = async (id) => {
16955
+ const current = ++request;
16956
+ try {
16957
+ const entries = await ipcRenderer.invoke(CLUSTER_ICONS_CHANNEL, { operation: "list" });
16958
+ if (stopped || current !== request) return;
16959
+ const entry = entries.find((item) => item.id === id);
16960
+ if (!entry) return;
16961
+ renderIntoContainer(/* @__PURE__ */ jsx$1(IconEditor, {
16962
+ entry,
16963
+ onClose: () => unmountContainer(modal),
16964
+ onSaved: () => unmountContainer(modal)
16965
+ }, id), modal);
16966
+ } catch {
16967
+ if (!stopped && current === request) Renderer$1.Component.Notifications.error("Unable to open the cluster icon editor. Try again.");
16968
+ }
16969
+ };
16970
+ const remove = (menu, button) => {
16971
+ unmountContainer(button);
16972
+ button.remove();
16973
+ owned.delete(menu);
16974
+ };
16975
+ const update = () => {
16976
+ for (const [menu, button] of owned) if (!menu.isConnected) remove(menu, button);
16977
+ for (const menu of document.querySelectorAll(`[data-testid^="${prefix}"]`)) {
16978
+ if (owned.has(menu)) continue;
16979
+ const id = menu.dataset.testid?.slice(43);
16980
+ if (!id || !Renderer$1.Catalog.getClusterById(id)) continue;
16981
+ const button = document.createElement("li");
16982
+ button.tabIndex = 0;
16983
+ button.setAttribute("role", "menuitem");
16984
+ button.className = "MenuItem";
16985
+ button.setAttribute("aria-label", "Edit icon");
16986
+ button.onclick = () => {
16987
+ if (stopped) return;
16988
+ document.querySelector(`[data-testid="icon-for-${prefix}${CSS.escape(id)}"]`)?.click();
16989
+ open(id);
16990
+ };
16991
+ menu.append(button);
16992
+ owned.set(menu, button);
16993
+ renderIntoContainer(/* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx$1(Renderer$1.Component.Icon, {
16994
+ material: "palette",
16995
+ size: 18
16996
+ }), " Edit icon"] }), button);
16997
+ }
16998
+ };
16999
+ const onKeyDown = (event) => {
17000
+ if (event.defaultPrevented || event.isComposing || event.altKey || event.ctrlKey || event.metaKey) return;
17001
+ const target = event.target;
17002
+ if (!(target instanceof Element)) return;
17003
+ const menu = Array.from(owned.keys()).find((item) => item.contains(target));
17004
+ if (!menu) return;
17005
+ const items = Array.from(menu.querySelectorAll(":scope > .MenuItem:not(.disabled)"));
17006
+ const index = items.findIndex((item) => item === target || item.contains(target));
17007
+ if (index < 0) return;
17008
+ let next;
17009
+ if (event.key === "ArrowDown") next = items[(index + 1) % items.length];
17010
+ else if (event.key === "ArrowUp") next = items[(index - 1 + items.length) % items.length];
17011
+ else if (event.key === "Home") next = items[0];
17012
+ else if (event.key === "End") next = items.at(-1);
17013
+ else if (event.key !== "Enter" && event.key !== " " || items[index] !== owned.get(menu)) return;
17014
+ event.preventDefault();
17015
+ event.stopImmediatePropagation();
17016
+ if (next) next.focus();
17017
+ else items[index].click();
17018
+ };
17019
+ window.addEventListener("keydown", onKeyDown, true);
17020
+ const observer = new MutationObserver(update);
17021
+ observer.observe(document.body, {
17022
+ childList: true,
17023
+ subtree: true
17024
+ });
17025
+ update();
17026
+ return () => {
17027
+ stopped = true;
17028
+ request++;
17029
+ observer.disconnect();
17030
+ window.removeEventListener("keydown", onKeyDown, true);
17031
+ for (const [menu, button] of owned) remove(menu, button);
17032
+ unmountContainer(modal);
17033
+ modal.remove();
17034
+ };
17035
+ }
16940
17036
  // src/common/dashboard-views.ts
16941
17037
  var DASHBOARD_VIEWS_SYNC = "freelens-power:dashboard-views:sync";
16942
17038
  var DASHBOARD_VIEWS_RELOAD = "freelens-power:dashboard-views:reload";
@@ -21103,7 +21199,7 @@ function startExtensionUpdateNotifications() {
21103
21199
  };
21104
21200
  const started = () => {
21105
21201
  attempt = {
21106
- version: current?.installedVersion ?? "2.21.0",
21202
+ version: current?.installedVersion ?? "2.21.2",
21107
21203
  startedAt: Date.now()
21108
21204
  };
21109
21205
  try {
@@ -44258,6 +44354,7 @@ var FreelensPowerRenderer = class extends Renderer$1.LensExtension {
44258
44354
  startExtensionUpdateNotifications,
44259
44355
  startAppearanceOverride,
44260
44356
  startClusterIconOverlay,
44357
+ startClusterIconSettingsMenu,
44261
44358
  startCatalogMenuIcons,
44262
44359
  startCatalogDisconnect,
44263
44360
  startWelcomeOverride,