@64mb/freelens-power 2.20.2 → 2.21.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/README.md +5 -1
- package/dist/main.js +301 -11
- package/dist/main.js.map +1 -1
- package/dist/renderer.js +705 -22
- package/dist/renderer.js.map +1 -1
- package/package.json +1 -1
package/dist/renderer.js
CHANGED
|
@@ -7318,31 +7318,36 @@ var PowerPreferencesStore = class extends Common.Store.ExtensionStore {
|
|
|
7318
7318
|
enabled = true;
|
|
7319
7319
|
checkUpdates = true;
|
|
7320
7320
|
nodeBulkActions = true;
|
|
7321
|
+
hotbarShortcuts = true;
|
|
7321
7322
|
constructor() {
|
|
7322
7323
|
super({
|
|
7323
7324
|
configName: "power-preferences",
|
|
7324
7325
|
defaults: {
|
|
7325
7326
|
enabled: true,
|
|
7326
7327
|
checkUpdates: true,
|
|
7327
|
-
nodeBulkActions: true
|
|
7328
|
+
nodeBulkActions: true,
|
|
7329
|
+
hotbarShortcuts: true
|
|
7328
7330
|
}
|
|
7329
7331
|
});
|
|
7330
7332
|
makeObservable(this, {
|
|
7331
7333
|
enabled: observable,
|
|
7332
7334
|
checkUpdates: observable,
|
|
7333
|
-
nodeBulkActions: observable
|
|
7335
|
+
nodeBulkActions: observable,
|
|
7336
|
+
hotbarShortcuts: observable
|
|
7334
7337
|
});
|
|
7335
7338
|
}
|
|
7336
7339
|
fromStore(data) {
|
|
7337
7340
|
this.enabled = data.enabled !== false;
|
|
7338
7341
|
this.checkUpdates = data.checkUpdates !== false;
|
|
7339
7342
|
this.nodeBulkActions = data.nodeBulkActions !== false;
|
|
7343
|
+
this.hotbarShortcuts = data.hotbarShortcuts !== false;
|
|
7340
7344
|
}
|
|
7341
7345
|
toJSON() {
|
|
7342
7346
|
return {
|
|
7343
7347
|
enabled: this.enabled,
|
|
7344
7348
|
checkUpdates: this.checkUpdates,
|
|
7345
|
-
nodeBulkActions: this.nodeBulkActions
|
|
7349
|
+
nodeBulkActions: this.nodeBulkActions,
|
|
7350
|
+
hotbarShortcuts: this.hotbarShortcuts
|
|
7346
7351
|
};
|
|
7347
7352
|
}
|
|
7348
7353
|
};
|
|
@@ -16012,8 +16017,7 @@ function startAppearanceOverride() {
|
|
|
16012
16017
|
:root [role="treeitem"][class*="catalog-tree-module__selected--"] { --blue: var(--primary); }
|
|
16013
16018
|
:root [class*="main-layout-module__sidebar--"] > .ResizingAnchor { --blue: var(--primary); }
|
|
16014
16019
|
:root .Dock > .ResizingAnchor { --blue: var(--primary); }
|
|
16015
|
-
:root
|
|
16016
|
-
:root .CatalogAddButton .MuiSpeedDial-fab:not(.Mui-disabled):hover { background-color: color-mix(in srgb, var(--primary) 88%, black) !important; }
|
|
16020
|
+
:root [class*="command-container-module__CommandContainer--"] { --blue: var(--primary); --menuSelectedOptionBgc: color-mix(in srgb, var(--primary) 24%, var(--contentColor)); }
|
|
16017
16021
|
:root .MenuItem { --bgc-active: var(--primary); --color-active: var(--freelens-power-accent-foreground); }
|
|
16018
16022
|
:root [data-testid="no-metrics-message"] { --blue: var(--primary); }
|
|
16019
16023
|
:root .Select__option--is-selected { background: var(--primary) !important; color: var(--freelens-power-accent-foreground) !important; }
|
|
@@ -16026,13 +16030,14 @@ function startAppearanceOverride() {
|
|
|
16026
16030
|
:root .Select__option:not(.Select__option--is-disabled):active { background: var(--primary) !important; color: var(--freelens-power-accent-foreground) !important; }
|
|
16027
16031
|
:root .NamespaceSelectMenu .Select__option--is-selected:active .Icon { color: inherit; }
|
|
16028
16032
|
:root a.link { color: var(--primary); }
|
|
16033
|
+
:root [data-testid="add-cluster-page"] a[href] { color: var(--primary); }
|
|
16029
16034
|
:root [data-testid="download-logs-dropdown"] { --accent-color: var(--primary); }
|
|
16030
16035
|
:root .Notifications .notification.info { background: var(--primary); color: var(--freelens-power-accent-foreground); }
|
|
16031
16036
|
${recolorAppIcon ? ".Welcome [data-testid=\"no-welcome-banners-icon\"] svg path[fill=\"#23a49c\"] { fill: var(--primary); }" : ""}
|
|
16032
16037
|
`;
|
|
16033
16038
|
style.textContent = `${accent}
|
|
16034
16039
|
input[role="switch"] { --track-color-active: var(--primary) !important; }
|
|
16035
|
-
:root .Input:not(.
|
|
16040
|
+
:root .Input:not(.validating) label:focus-within { border-color: var(--primary) !important; }
|
|
16036
16041
|
:root .Select:not(.Select--is-disabled) .Select__control--is-focused:not(.Select__control--is-disabled) { border-color: var(--primary) !important; box-shadow: 0 0 0 1px var(--primary) !important; }
|
|
16037
16042
|
`;
|
|
16038
16043
|
if (!style.isConnected) document.head.append(style);
|
|
@@ -16043,18 +16048,228 @@ function startAppearanceOverride() {
|
|
|
16043
16048
|
editorStyle.remove();
|
|
16044
16049
|
};
|
|
16045
16050
|
}
|
|
16051
|
+
// src/renderer/catalog-disconnect.tsx
|
|
16052
|
+
var clusters = () => Renderer$1.Catalog.catalogEntities.getItemsForApiKind(Common.Catalog.KubernetesCluster.apiVersion, Common.Catalog.KubernetesCluster.kind);
|
|
16053
|
+
var active = (entity) => entity.status.phase === "connected" || entity.status.phase === "connecting";
|
|
16054
|
+
function startCatalogDisconnect() {
|
|
16055
|
+
let stopped = false;
|
|
16056
|
+
let pending = false;
|
|
16057
|
+
let host;
|
|
16058
|
+
let renderedDisabled;
|
|
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}";
|
|
16061
|
+
document.head.append(style);
|
|
16062
|
+
const remove = () => {
|
|
16063
|
+
if (!host) return;
|
|
16064
|
+
unmountContainer(host);
|
|
16065
|
+
host.remove();
|
|
16066
|
+
host = void 0;
|
|
16067
|
+
renderedDisabled = void 0;
|
|
16068
|
+
};
|
|
16069
|
+
const request = () => {
|
|
16070
|
+
if (stopped || pending || !host?.isConnected) return;
|
|
16071
|
+
const snapshot = new Map(clusters().filter(active).map((entity) => [entity.getId(), entity]));
|
|
16072
|
+
if (!snapshot.size) return;
|
|
16073
|
+
const confirmationHost = host;
|
|
16074
|
+
pending = true;
|
|
16075
|
+
update();
|
|
16076
|
+
let submitted = false;
|
|
16077
|
+
Renderer$1.Component.ConfirmDialog.open({
|
|
16078
|
+
message: `Disconnect ${snapshot.size} active cluster${snapshot.size === 1 ? "" : "s"}?`,
|
|
16079
|
+
labelOk: "Disconnect all",
|
|
16080
|
+
cancel: () => {
|
|
16081
|
+
if (submitted) return;
|
|
16082
|
+
submitted = true;
|
|
16083
|
+
pending = false;
|
|
16084
|
+
update();
|
|
16085
|
+
},
|
|
16086
|
+
ok: async () => {
|
|
16087
|
+
if (submitted || stopped) return;
|
|
16088
|
+
submitted = true;
|
|
16089
|
+
if (host !== confirmationHost || !host?.isConnected) {
|
|
16090
|
+
pending = false;
|
|
16091
|
+
update();
|
|
16092
|
+
return;
|
|
16093
|
+
}
|
|
16094
|
+
try {
|
|
16095
|
+
const targets = clusters().filter((entity) => snapshot.get(entity.getId()) === entity && active(entity));
|
|
16096
|
+
const results = await Promise.allSettled(targets.map((entity) => Promise.resolve().then(() => {
|
|
16097
|
+
if (!stopped && active(entity) && clusters().includes(entity)) return entity.disconnect();
|
|
16098
|
+
})));
|
|
16099
|
+
if (!stopped && results.some((result) => result.status === "rejected")) Renderer$1.Component.Notifications.error("Unable to disconnect some clusters. Check their connection status.");
|
|
16100
|
+
} finally {
|
|
16101
|
+
pending = false;
|
|
16102
|
+
update();
|
|
16103
|
+
}
|
|
16104
|
+
}
|
|
16105
|
+
});
|
|
16106
|
+
};
|
|
16107
|
+
const update = () => {
|
|
16108
|
+
if (stopped) return;
|
|
16109
|
+
let container = document.querySelector("[data-testid=\"catalog-list-for-Clusters\"]")?.parentElement;
|
|
16110
|
+
let plus = null;
|
|
16111
|
+
while (container && container !== document.body) {
|
|
16112
|
+
plus = container.querySelector(".CatalogAddButton");
|
|
16113
|
+
if (plus) break;
|
|
16114
|
+
container = container.parentElement;
|
|
16115
|
+
}
|
|
16116
|
+
if (!plus?.parentElement || !pending && !clusters().some(active)) {
|
|
16117
|
+
remove();
|
|
16118
|
+
return;
|
|
16119
|
+
}
|
|
16120
|
+
if (!host || host.parentElement !== plus.parentElement) {
|
|
16121
|
+
remove();
|
|
16122
|
+
host = document.createElement("div");
|
|
16123
|
+
host.className = "power-catalog-disconnect";
|
|
16124
|
+
plus.parentElement.insertBefore(host, plus);
|
|
16125
|
+
}
|
|
16126
|
+
const disabled = pending || !clusters().some(active);
|
|
16127
|
+
if (renderedDisabled === disabled) return;
|
|
16128
|
+
renderedDisabled = disabled;
|
|
16129
|
+
renderIntoContainer(/* @__PURE__ */ jsx$1(NativeTooltip, {
|
|
16130
|
+
title: "Disconnect all",
|
|
16131
|
+
children: /* @__PURE__ */ jsx$1("button", {
|
|
16132
|
+
type: "button",
|
|
16133
|
+
className: "power-catalog-disconnect-button",
|
|
16134
|
+
"aria-label": "Disconnect all",
|
|
16135
|
+
disabled,
|
|
16136
|
+
onClick: request,
|
|
16137
|
+
children: /* @__PURE__ */ jsx$1(Renderer$1.Component.Icon, {
|
|
16138
|
+
material: "link_off",
|
|
16139
|
+
size: 18
|
|
16140
|
+
})
|
|
16141
|
+
})
|
|
16142
|
+
}), host);
|
|
16143
|
+
};
|
|
16144
|
+
const stop = reaction(() => clusters().map((entity) => [
|
|
16145
|
+
entity,
|
|
16146
|
+
entity.getId(),
|
|
16147
|
+
entity.status.phase
|
|
16148
|
+
]), update);
|
|
16149
|
+
const observer = new MutationObserver(update);
|
|
16150
|
+
observer.observe(document.body, {
|
|
16151
|
+
childList: true,
|
|
16152
|
+
subtree: true,
|
|
16153
|
+
attributes: true,
|
|
16154
|
+
attributeFilter: ["data-testid"]
|
|
16155
|
+
});
|
|
16156
|
+
update();
|
|
16157
|
+
return () => {
|
|
16158
|
+
stopped = true;
|
|
16159
|
+
stop();
|
|
16160
|
+
observer.disconnect();
|
|
16161
|
+
remove();
|
|
16162
|
+
style.remove();
|
|
16163
|
+
};
|
|
16164
|
+
}
|
|
16165
|
+
// src/renderer/catalog-menu-icons.tsx
|
|
16166
|
+
var icons$3 = {
|
|
16167
|
+
"View Details": { material: "info_outline" },
|
|
16168
|
+
Settings: { material: "settings" },
|
|
16169
|
+
"Open kubeconfig": { material: "edit" },
|
|
16170
|
+
Connect: { material: "link" },
|
|
16171
|
+
Disconnect: { material: "link_off" },
|
|
16172
|
+
Remove: { material: "delete" },
|
|
16173
|
+
Delete: { material: "delete" },
|
|
16174
|
+
"Add to Hotbar": { material: "push_pin" },
|
|
16175
|
+
"Remove from Hotbar": { svg: "push_off" }
|
|
16176
|
+
};
|
|
16177
|
+
function startCatalogMenuIcons() {
|
|
16178
|
+
const owned = /* @__PURE__ */ new Map();
|
|
16179
|
+
const style = document.createElement("style");
|
|
16180
|
+
style.textContent = "[data-power-catalog-menu-icon]{display:inline-flex;align-items:center;justify-content:center;flex:0 0 18px;width:18px;height:18px;margin-right:8px;pointer-events:none}[data-power-catalog-menu-icon] .Icon{color:inherit;margin:0!important}";
|
|
16181
|
+
document.head.append(style);
|
|
16182
|
+
const remove = (item) => {
|
|
16183
|
+
const entry = owned.get(item);
|
|
16184
|
+
if (!entry) return;
|
|
16185
|
+
unmountContainer(entry.host);
|
|
16186
|
+
entry.host.remove();
|
|
16187
|
+
owned.delete(item);
|
|
16188
|
+
};
|
|
16189
|
+
const update = () => {
|
|
16190
|
+
const targets = /* @__PURE__ */ new Set();
|
|
16191
|
+
const titleOf = (item) => Array.from(item.childNodes).filter((node) => !(node instanceof HTMLElement && node.hasAttribute("data-power-catalog-menu-icon"))).map((node) => node.textContent).join("").trim();
|
|
16192
|
+
const hotbarMenus = Array.from(document.querySelectorAll(".Menu.portal")).filter((menu) => {
|
|
16193
|
+
const first = menu.querySelector(":scope > .MenuItem");
|
|
16194
|
+
return first && titleOf(first) === "Remove from Hotbar";
|
|
16195
|
+
});
|
|
16196
|
+
const items = /* @__PURE__ */ new Set([...document.querySelectorAll("[data-testid^=\"menu-actions-for-catalog-for-\"] .MenuItem"), ...hotbarMenus.flatMap((menu) => [...menu.querySelectorAll(":scope > .MenuItem")])]);
|
|
16197
|
+
for (const item of items) {
|
|
16198
|
+
const title = titleOf(item);
|
|
16199
|
+
const icon = icons$3[title];
|
|
16200
|
+
const nativeIcon = Array.from(item.querySelectorAll(".Icon")).some((node) => !node.closest("[data-power-catalog-menu-icon]"));
|
|
16201
|
+
if (!icon || nativeIcon) continue;
|
|
16202
|
+
targets.add(item);
|
|
16203
|
+
let entry = owned.get(item);
|
|
16204
|
+
if (!entry) {
|
|
16205
|
+
const host = document.createElement("span");
|
|
16206
|
+
host.setAttribute("data-power-catalog-menu-icon", "");
|
|
16207
|
+
host.setAttribute("aria-hidden", "true");
|
|
16208
|
+
item.prepend(host);
|
|
16209
|
+
entry = {
|
|
16210
|
+
host,
|
|
16211
|
+
title: ""
|
|
16212
|
+
};
|
|
16213
|
+
owned.set(item, entry);
|
|
16214
|
+
}
|
|
16215
|
+
if (entry.host.parentElement !== item) item.prepend(entry.host);
|
|
16216
|
+
if (entry.title === title) continue;
|
|
16217
|
+
entry.title = title;
|
|
16218
|
+
renderIntoContainer(/* @__PURE__ */ jsx$1(Renderer$1.Component.Icon, {
|
|
16219
|
+
...icon,
|
|
16220
|
+
size: 18
|
|
16221
|
+
}), entry.host);
|
|
16222
|
+
}
|
|
16223
|
+
for (const item of owned.keys()) if (!targets.has(item)) remove(item);
|
|
16224
|
+
};
|
|
16225
|
+
const observer = new MutationObserver(update);
|
|
16226
|
+
observer.observe(document.body, {
|
|
16227
|
+
childList: true,
|
|
16228
|
+
subtree: true,
|
|
16229
|
+
characterData: true,
|
|
16230
|
+
attributes: true,
|
|
16231
|
+
attributeFilter: ["data-testid"]
|
|
16232
|
+
});
|
|
16233
|
+
update();
|
|
16234
|
+
return () => {
|
|
16235
|
+
observer.disconnect();
|
|
16236
|
+
for (const item of owned.keys()) remove(item);
|
|
16237
|
+
style.remove();
|
|
16238
|
+
};
|
|
16239
|
+
}
|
|
16046
16240
|
// src/renderer/cluster-icon-overlay.ts
|
|
16047
16241
|
function startClusterIconOverlay() {
|
|
16048
16242
|
const store = ClusterIconsStore.getInstanceOrCreate();
|
|
16243
|
+
const links = () => Renderer$1.Catalog.catalogEntities.getItemsForApiKind("entity.k8slens.dev/v1alpha1", "WebLink");
|
|
16049
16244
|
const owned = /* @__PURE__ */ new Map();
|
|
16245
|
+
const webLinkAvatars = /* @__PURE__ */ new Set();
|
|
16050
16246
|
const style = document.createElement("style");
|
|
16051
|
-
style.textContent = `[data-power-cluster-icon]{position:relative!important;color:transparent!important}[data-power-cluster-icon]>:not([data-power-icon-image]){visibility:hidden!important}[data-power-icon-image]{position:absolute;inset:0;width:100%;height:100%;border-radius:inherit;pointer-events:none;object-fit:cover}`;
|
|
16247
|
+
style.textContent = `[data-power-cluster-icon]{position:relative!important;color:transparent!important;background:transparent!important}[data-power-cluster-icon]>:not([data-power-icon-image]){visibility:hidden!important}[data-power-icon-image]{position:absolute;inset:0;width:100%;height:100%;border-radius:inherit;pointer-events:none;object-fit:cover}[data-power-web-link-avatar]>img{width:16px;height:16px;margin:auto;object-fit:contain}`;
|
|
16052
16248
|
document.head.append(style);
|
|
16053
16249
|
let stopped = false;
|
|
16054
16250
|
const update = () => {
|
|
16055
16251
|
if (stopped) return;
|
|
16056
16252
|
const urls = new Map(Object.entries(store.icons).map(([id, value]) => [id, clusterIconDataUrl(value.design)]));
|
|
16253
|
+
const remote = /* @__PURE__ */ new Set();
|
|
16254
|
+
const webLinkIds = /* @__PURE__ */ new Set();
|
|
16255
|
+
const nextWebLinkAvatars = /* @__PURE__ */ new Set();
|
|
16256
|
+
for (const link of links()) {
|
|
16257
|
+
webLinkIds.add(link.getId());
|
|
16258
|
+
if (link.spec.icon?.src || typeof link.spec.url !== "string") continue;
|
|
16259
|
+
try {
|
|
16260
|
+
const page = new URL(link.spec.url);
|
|
16261
|
+
if (!["http:", "https:"].includes(page.protocol) || page.username || page.password) continue;
|
|
16262
|
+
const url = new URL("/favicon.ico", page).href;
|
|
16263
|
+
urls.set(link.getId(), url);
|
|
16264
|
+
remote.add(url);
|
|
16265
|
+
} catch {}
|
|
16266
|
+
}
|
|
16057
16267
|
const targets = /* @__PURE__ */ new Map();
|
|
16268
|
+
try {
|
|
16269
|
+
const id = /^\/entity\/([^/]+)\/settings\/?$/.exec(location.pathname)?.[1];
|
|
16270
|
+
const url = id ? urls.get(decodeURIComponent(id)) : void 0;
|
|
16271
|
+
if (url) for (const avatar of document.querySelectorAll("[data-testid=\"entity-settings\"] [class*=\"Avatar\"]")) targets.set(avatar, url);
|
|
16272
|
+
} catch {}
|
|
16058
16273
|
for (const avatar of document.querySelectorAll("[id^=\"hotbarIcon-\"]")) {
|
|
16059
16274
|
const url = urls.get(avatar.id.slice(11));
|
|
16060
16275
|
if (url) targets.set(avatar, url);
|
|
@@ -16070,12 +16285,19 @@ function startClusterIconOverlay() {
|
|
|
16070
16285
|
const avatar = container.querySelector("[data-testid=\"detail-panel-hot-bar-icon\"]");
|
|
16071
16286
|
if (url && avatar) targets.set(avatar, url);
|
|
16072
16287
|
}
|
|
16073
|
-
for (const menu of document.querySelectorAll("[data-testid^=\"menu-actions-for-catalog-for-\"]")) {
|
|
16074
|
-
const id = menu.getAttribute("data-testid")?.slice(
|
|
16288
|
+
for (const menu of document.querySelectorAll("[data-testid^=\"icon-for-menu-actions-for-catalog-for-\"]")) {
|
|
16289
|
+
const id = menu.getAttribute("data-testid")?.slice(38);
|
|
16075
16290
|
const url = id ? urls.get(id) : void 0;
|
|
16076
16291
|
const avatar = menu.closest(".TableRow")?.querySelector("[class*=\"Avatar\"]");
|
|
16292
|
+
if (avatar && id && webLinkIds.has(id)) {
|
|
16293
|
+
nextWebLinkAvatars.add(avatar);
|
|
16294
|
+
avatar.setAttribute("data-power-web-link-avatar", "");
|
|
16295
|
+
}
|
|
16077
16296
|
if (url && avatar) targets.set(avatar, url);
|
|
16078
16297
|
}
|
|
16298
|
+
for (const avatar of webLinkAvatars) if (!nextWebLinkAvatars.has(avatar)) avatar.removeAttribute("data-power-web-link-avatar");
|
|
16299
|
+
webLinkAvatars.clear();
|
|
16300
|
+
for (const avatar of nextWebLinkAvatars) webLinkAvatars.add(avatar);
|
|
16079
16301
|
for (const [avatar, image] of owned) {
|
|
16080
16302
|
if (targets.has(avatar) && avatar.isConnected) continue;
|
|
16081
16303
|
image.remove();
|
|
@@ -16090,13 +16312,32 @@ function startClusterIconOverlay() {
|
|
|
16090
16312
|
image.alt = "";
|
|
16091
16313
|
image.setAttribute("aria-hidden", "true");
|
|
16092
16314
|
owned.set(avatar, image);
|
|
16093
|
-
avatar.setAttribute("data-power-cluster-icon", "");
|
|
16094
16315
|
}
|
|
16095
|
-
if (image.getAttribute("src") !== url)
|
|
16316
|
+
if (image.getAttribute("src") !== url) {
|
|
16317
|
+
const pending = remote.has(url);
|
|
16318
|
+
image.hidden = pending;
|
|
16319
|
+
image.referrerPolicy = "no-referrer";
|
|
16320
|
+
avatar.toggleAttribute("data-power-cluster-icon", !pending);
|
|
16321
|
+
image.onload = () => {
|
|
16322
|
+
if (stopped || owned.get(avatar) !== image || image.getAttribute("src") !== url) return;
|
|
16323
|
+
image.hidden = false;
|
|
16324
|
+
avatar.setAttribute("data-power-cluster-icon", "");
|
|
16325
|
+
};
|
|
16326
|
+
image.onerror = () => {
|
|
16327
|
+
if (stopped || owned.get(avatar) !== image || image.getAttribute("src") !== url) return;
|
|
16328
|
+
image.hidden = true;
|
|
16329
|
+
avatar.removeAttribute("data-power-cluster-icon");
|
|
16330
|
+
};
|
|
16331
|
+
image.src = url;
|
|
16332
|
+
}
|
|
16096
16333
|
if (image.parentElement !== avatar) avatar.append(image);
|
|
16097
16334
|
}
|
|
16098
16335
|
};
|
|
16099
|
-
const stop = reaction(() => JSON.stringify(store.icons
|
|
16336
|
+
const stop = reaction(() => JSON.stringify([store.icons, links().map((link) => [
|
|
16337
|
+
link.getId(),
|
|
16338
|
+
link.spec.url,
|
|
16339
|
+
link.spec.icon?.src
|
|
16340
|
+
])]), update);
|
|
16100
16341
|
const observer = new MutationObserver(update);
|
|
16101
16342
|
observer.observe(document.body, {
|
|
16102
16343
|
childList: true,
|
|
@@ -16114,6 +16355,8 @@ function startClusterIconOverlay() {
|
|
|
16114
16355
|
avatar.removeAttribute("data-power-cluster-icon");
|
|
16115
16356
|
}
|
|
16116
16357
|
owned.clear();
|
|
16358
|
+
for (const avatar of webLinkAvatars) avatar.removeAttribute("data-power-web-link-avatar");
|
|
16359
|
+
webLinkAvatars.clear();
|
|
16117
16360
|
style.remove();
|
|
16118
16361
|
};
|
|
16119
16362
|
}
|
|
@@ -16302,20 +16545,41 @@ function IconColorPicker({ label, value, onChange, disabled = false, onOpenChang
|
|
|
16302
16545
|
});
|
|
16303
16546
|
}
|
|
16304
16547
|
// src/renderer/preferences/settings-modal.tsx
|
|
16305
|
-
function SettingsModal({ id, title, onClose, children }) {
|
|
16548
|
+
function SettingsModal({ id, title, onClose, children, width = 560, guardClose = false }) {
|
|
16549
|
+
const [dialogGeneration, setDialogGeneration] = useState(0);
|
|
16306
16550
|
useEffect(() => {
|
|
16307
16551
|
const closeOnEscape = (event) => {
|
|
16308
16552
|
if (event.key !== "Escape") return;
|
|
16553
|
+
if (guardClose && event.target instanceof Element && event.target.closest(".monaco-editor")?.querySelector(".find-widget.visible, .suggest-widget.visible, .monaco-hover")) return;
|
|
16554
|
+
event.preventDefault();
|
|
16555
|
+
event.stopPropagation();
|
|
16556
|
+
onClose();
|
|
16557
|
+
};
|
|
16558
|
+
const closeOnBackdrop = (event) => {
|
|
16559
|
+
if (!guardClose || !(event.target instanceof HTMLElement) || event.target.dataset.testid !== `${id}-modal`) return;
|
|
16309
16560
|
event.preventDefault();
|
|
16310
16561
|
event.stopPropagation();
|
|
16311
16562
|
onClose();
|
|
16312
16563
|
};
|
|
16313
16564
|
document.addEventListener("keydown", closeOnEscape, true);
|
|
16314
|
-
|
|
16315
|
-
|
|
16565
|
+
document.addEventListener("click", closeOnBackdrop, true);
|
|
16566
|
+
return () => {
|
|
16567
|
+
document.removeEventListener("keydown", closeOnEscape, true);
|
|
16568
|
+
document.removeEventListener("click", closeOnBackdrop, true);
|
|
16569
|
+
};
|
|
16570
|
+
}, [
|
|
16571
|
+
onClose,
|
|
16572
|
+
guardClose,
|
|
16573
|
+
id
|
|
16574
|
+
]);
|
|
16316
16575
|
return /* @__PURE__ */ jsxs(Renderer$1.Component.Dialog, {
|
|
16317
16576
|
isOpen: true,
|
|
16318
|
-
|
|
16577
|
+
pinned: guardClose,
|
|
16578
|
+
"data-testid": `${id}-modal`,
|
|
16579
|
+
close: () => {
|
|
16580
|
+
if (guardClose) setDialogGeneration((value) => value + 1);
|
|
16581
|
+
onClose();
|
|
16582
|
+
},
|
|
16319
16583
|
modal: true,
|
|
16320
16584
|
className: "power-dashboard-dialog power-settings-dialog",
|
|
16321
16585
|
children: [/* @__PURE__ */ jsx$1("style", { children: `
|
|
@@ -16342,7 +16606,7 @@ function SettingsModal({ id, title, onClose, children }) {
|
|
|
16342
16606
|
display: "grid",
|
|
16343
16607
|
gap: 16,
|
|
16344
16608
|
padding: 24,
|
|
16345
|
-
width
|
|
16609
|
+
width,
|
|
16346
16610
|
maxWidth: "calc(100vw - 48px)"
|
|
16347
16611
|
},
|
|
16348
16612
|
children: [/* @__PURE__ */ jsx$1("h2", {
|
|
@@ -16351,7 +16615,7 @@ function SettingsModal({ id, title, onClose, children }) {
|
|
|
16351
16615
|
children: title
|
|
16352
16616
|
}), children]
|
|
16353
16617
|
})]
|
|
16354
|
-
});
|
|
16618
|
+
}, guardClose ? dialogGeneration : void 0);
|
|
16355
16619
|
}
|
|
16356
16620
|
function SettingsField({ id, label, children }) {
|
|
16357
16621
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -20839,7 +21103,7 @@ function startExtensionUpdateNotifications() {
|
|
|
20839
21103
|
};
|
|
20840
21104
|
const started = () => {
|
|
20841
21105
|
attempt = {
|
|
20842
|
-
version: current?.installedVersion ?? "2.
|
|
21106
|
+
version: current?.installedVersion ?? "2.21.0",
|
|
20843
21107
|
startedAt: Date.now()
|
|
20844
21108
|
};
|
|
20845
21109
|
try {
|
|
@@ -26038,6 +26302,45 @@ function startHostLayoutStyles() {
|
|
|
26038
26302
|
const style = document.createElement("style");
|
|
26039
26303
|
style.dataset.freelensPower = "host-layout";
|
|
26040
26304
|
style.textContent = `
|
|
26305
|
+
:root .SettingLayout [class*="close-button-module__closeButton--"] {
|
|
26306
|
+
box-sizing: border-box;
|
|
26307
|
+
border: 1px solid color-mix(in srgb, var(--borderColor) 75%, var(--textColorSecondary) 25%);
|
|
26308
|
+
border-radius: 6px;
|
|
26309
|
+
background: var(--contentColor);
|
|
26310
|
+
}
|
|
26311
|
+
:root .SettingLayout [class*="close-button-module__closeButton--"] > .Icon {
|
|
26312
|
+
--size: 18px;
|
|
26313
|
+
width: 18px;
|
|
26314
|
+
height: 18px;
|
|
26315
|
+
font-size: 18px;
|
|
26316
|
+
color: var(--textColorSecondary);
|
|
26317
|
+
opacity: 1;
|
|
26318
|
+
}
|
|
26319
|
+
:root .SettingLayout [class*="close-button-module__closeButton--"]:hover {
|
|
26320
|
+
border-color: var(--textColorAccent);
|
|
26321
|
+
background: color-mix(in srgb, var(--contentColor) 92%, var(--primary) 8%);
|
|
26322
|
+
}
|
|
26323
|
+
:root .SettingLayout [class*="close-button-module__closeButton--"]:hover > .Icon { color: var(--textColorAccent); }
|
|
26324
|
+
|
|
26325
|
+
:root [data-testid="add-cluster-page"] > .contentRegion > .content {
|
|
26326
|
+
width: min(1320px, calc(100vw - 96px));
|
|
26327
|
+
max-width: none;
|
|
26328
|
+
min-width: 0;
|
|
26329
|
+
padding: 40px 40px 0;
|
|
26330
|
+
box-sizing: border-box;
|
|
26331
|
+
}
|
|
26332
|
+
:root [data-testid="add-cluster-page"] [class*="add-cluster-module__editor--"] {
|
|
26333
|
+
--editor-height: clamp(240px, calc(100vh - 240px), 900px);
|
|
26334
|
+
}
|
|
26335
|
+
|
|
26336
|
+
:root .CatalogAddButton { right: 40px; bottom: 30px; }
|
|
26337
|
+
:root .catalogSpeedDialPopper .MuiTooltip-tooltip {
|
|
26338
|
+
background-color: var(--contentColor);
|
|
26339
|
+
color: var(--textColorPrimary);
|
|
26340
|
+
border: 1px solid var(--borderColor);
|
|
26341
|
+
}
|
|
26342
|
+
:root .catalogSpeedDialPopper .MuiTooltip-arrow { color: var(--contentColor); }
|
|
26343
|
+
|
|
26041
26344
|
:root .HotbarMenu .HotbarItems.flex.flex-col > .HotbarCell:not(:last-child) {
|
|
26042
26345
|
margin-bottom: 4px;
|
|
26043
26346
|
}
|
|
@@ -26106,10 +26409,23 @@ var nativeTabs = {
|
|
|
26106
26409
|
};
|
|
26107
26410
|
var page = `.Preferences.SettingLayout > .contentRegion > .content > :is(${Object.keys(nativeTabs).map((id) => `[data-preference-page-test="${id === "app" ? "application" : id}-page"]`).join(", ")})`;
|
|
26108
26411
|
var tab = `.Preferences.SettingLayout > .sidebarRegion [data-preference-tab-link-test]:is(${Object.keys(nativeTabs).map((id) => `[data-preference-tab-link-test="${id}"]`).join(", ")})`;
|
|
26412
|
+
var entityTabs = {
|
|
26413
|
+
general: "settings",
|
|
26414
|
+
proxy: "swap_horiz",
|
|
26415
|
+
terminal: "terminal",
|
|
26416
|
+
namespace: "folder",
|
|
26417
|
+
metrics: "show_chart",
|
|
26418
|
+
"node-shell": "vpn_key"
|
|
26419
|
+
};
|
|
26420
|
+
var entityTab = `[data-testid="entity-settings"] > .sidebarRegion .Tab:is(${Object.keys(entityTabs).map((id) => `[data-testid="${id}-tab"]`).join(",")})`;
|
|
26109
26421
|
function startHostPreferencesStyles() {
|
|
26110
26422
|
const style = document.createElement("style");
|
|
26111
26423
|
style.dataset.freelensPower = "host-preferences";
|
|
26112
26424
|
style.textContent = `
|
|
26425
|
+
${entityTab} { display: flex; align-items: center; gap: 10px; }
|
|
26426
|
+
${entityTab}::before { flex: 0 0 18px; width: 18px; font-family: "Material Icons"; font-size: 18px; font-weight: 400; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; direction: ltr; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; }
|
|
26427
|
+
${Object.entries(entityTabs).map(([id, icon]) => `[data-testid="entity-settings"] > .sidebarRegion .Tab[data-testid="${id}-tab"]::before { content: "${icon}" / ""; }`).join("\n")}
|
|
26428
|
+
|
|
26113
26429
|
.Preferences.SettingLayout > .sidebarRegion [data-preference-tab-group-test="extensions-tab-group"] > .header { gap: 8px; }
|
|
26114
26430
|
.Preferences.SettingLayout > .sidebarRegion [data-preference-tab-group-test="extensions-tab-group"] > .header > .Icon { margin: 0; flex: 0 0 18px; --size: 18px; }
|
|
26115
26431
|
.Preferences.SettingLayout > .sidebarRegion :is([data-preference-tab-group-test="general-tab-group"], [data-preference-tab-group-test="extensions-tab-group"]) > [data-preference-tab-link-test] { margin-left: 12px; width: calc(100% - 12px); box-sizing: border-box; }
|
|
@@ -26277,6 +26593,359 @@ function startHostPreferencesStyles() {
|
|
|
26277
26593
|
style.remove();
|
|
26278
26594
|
};
|
|
26279
26595
|
}
|
|
26596
|
+
// src/renderer/hotbar-name.tsx
|
|
26597
|
+
function startHotbarName() {
|
|
26598
|
+
const preferences = PowerPreferencesStore.getInstanceOrCreate();
|
|
26599
|
+
const prefix = "hotbar-menu-badge-for-";
|
|
26600
|
+
let count = 0;
|
|
26601
|
+
let stopped = false;
|
|
26602
|
+
let refreshing = false;
|
|
26603
|
+
const owned = /* @__PURE__ */ new Map();
|
|
26604
|
+
const style = document.createElement("style");
|
|
26605
|
+
style.textContent = `[data-power-hotbar-name]{position:relative;z-index:1;flex-shrink:0;width:100%;min-width:0;padding:6px;box-sizing:border-box;text-align:center;color:var(--settingsColor);font-size:10px;line-height:16px}[data-power-hotbar-name] span{display:block;padding:1px 4px;border:1px solid var(--borderColor);border-radius:4px;background:var(--secondaryBackground);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}`;
|
|
26606
|
+
document.head.append(style);
|
|
26607
|
+
const remove = (selector) => {
|
|
26608
|
+
const entry = owned.get(selector);
|
|
26609
|
+
if (!entry) return;
|
|
26610
|
+
unmountContainer(entry.host);
|
|
26611
|
+
entry.host.remove();
|
|
26612
|
+
owned.delete(selector);
|
|
26613
|
+
};
|
|
26614
|
+
const update = () => {
|
|
26615
|
+
const targets = /* @__PURE__ */ new Set();
|
|
26616
|
+
for (const badge of count > 1 ? document.querySelectorAll(`.HotbarMenu [data-testid^="${prefix}"]`) : []) {
|
|
26617
|
+
const selector = badge.closest("[class*=\"HotbarSelector\"]");
|
|
26618
|
+
const name = badge.dataset.testid?.slice(22);
|
|
26619
|
+
if (!selector || !name) continue;
|
|
26620
|
+
targets.add(selector);
|
|
26621
|
+
let entry = owned.get(selector);
|
|
26622
|
+
if (!entry) {
|
|
26623
|
+
const host = document.createElement("div");
|
|
26624
|
+
host.setAttribute("data-power-hotbar-name", "");
|
|
26625
|
+
selector.before(host);
|
|
26626
|
+
entry = {
|
|
26627
|
+
host,
|
|
26628
|
+
name: ""
|
|
26629
|
+
};
|
|
26630
|
+
owned.set(selector, entry);
|
|
26631
|
+
}
|
|
26632
|
+
if (entry.host.nextElementSibling !== selector) selector.before(entry.host);
|
|
26633
|
+
if (entry.name === name) continue;
|
|
26634
|
+
entry.name = name;
|
|
26635
|
+
renderIntoContainer(/* @__PURE__ */ jsx$1(NativeTooltip, {
|
|
26636
|
+
title: name,
|
|
26637
|
+
children: /* @__PURE__ */ jsx$1("span", { children: name })
|
|
26638
|
+
}), entry.host);
|
|
26639
|
+
}
|
|
26640
|
+
for (const selector of owned.keys()) if (!targets.has(selector)) remove(selector);
|
|
26641
|
+
};
|
|
26642
|
+
const refreshCount = async () => {
|
|
26643
|
+
if (refreshing || stopped) return;
|
|
26644
|
+
refreshing = true;
|
|
26645
|
+
try {
|
|
26646
|
+
const next = await ipcRenderer.invoke("freelens-power:hotbar-count");
|
|
26647
|
+
if (!stopped && typeof next === "number" && Number.isInteger(next) && next >= 0) {
|
|
26648
|
+
count = next;
|
|
26649
|
+
update();
|
|
26650
|
+
}
|
|
26651
|
+
} catch {} finally {
|
|
26652
|
+
refreshing = false;
|
|
26653
|
+
}
|
|
26654
|
+
};
|
|
26655
|
+
const observer = new MutationObserver((records) => {
|
|
26656
|
+
update();
|
|
26657
|
+
if (records.some((record) => record.type === "attributes" && record.target instanceof HTMLElement && record.target.dataset.testid?.startsWith(prefix))) refreshCount();
|
|
26658
|
+
});
|
|
26659
|
+
observer.observe(document.body, {
|
|
26660
|
+
childList: true,
|
|
26661
|
+
subtree: true,
|
|
26662
|
+
attributes: true,
|
|
26663
|
+
attributeFilter: ["data-testid"]
|
|
26664
|
+
});
|
|
26665
|
+
refreshCount();
|
|
26666
|
+
const keydown = (event) => {
|
|
26667
|
+
if (preferences.hotbarShortcuts === false) return;
|
|
26668
|
+
const mac = /Mac|iPhone|iPad/.test(navigator.platform);
|
|
26669
|
+
if (event.defaultPrevented || event.repeat || event.isComposing || event.altKey || event.shiftKey || (mac ? !event.metaKey || event.ctrlKey : !event.ctrlKey || event.metaKey)) return;
|
|
26670
|
+
const digit = /^Digit([1-9])$/.exec(event.code);
|
|
26671
|
+
if (!digit) return;
|
|
26672
|
+
const editable = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"textbox\"], [role=\"combobox\"], .monaco-editor, .xterm, .cm-editor, .CodeMirror";
|
|
26673
|
+
if (event.composedPath().some((node) => node instanceof Element && node.closest(editable))) return;
|
|
26674
|
+
if (document.querySelector(".Dialog.modal, [aria-modal=\"true\"], .SettingLayout, [class*=\"command-container-module__CommandContainer--\"]")) return;
|
|
26675
|
+
const target = Number(digit[1]);
|
|
26676
|
+
const badge = document.querySelector(".HotbarMenu [data-testid^=\"hotbar-menu-badge-for-\"]");
|
|
26677
|
+
const current = Number(badge?.textContent?.trim());
|
|
26678
|
+
const arrows = (badge?.closest("[class*=\"HotbarSelector\"]"))?.querySelectorAll(":scope > .Icon");
|
|
26679
|
+
if (!arrows || arrows.length !== 2 || !Number.isInteger(current) || current < 1 || current > count || target > count) return;
|
|
26680
|
+
event.preventDefault();
|
|
26681
|
+
event.stopPropagation();
|
|
26682
|
+
const arrow = arrows[target > current ? 1 : 0];
|
|
26683
|
+
for (let step = 0; step < Math.abs(target - current); step++) arrow.click();
|
|
26684
|
+
};
|
|
26685
|
+
document.addEventListener("keydown", keydown);
|
|
26686
|
+
const timer = setInterval(() => void refreshCount(), 2e3);
|
|
26687
|
+
return () => {
|
|
26688
|
+
stopped = true;
|
|
26689
|
+
document.removeEventListener("keydown", keydown);
|
|
26690
|
+
clearInterval(timer);
|
|
26691
|
+
observer.disconnect();
|
|
26692
|
+
for (const selector of owned.keys()) remove(selector);
|
|
26693
|
+
style.remove();
|
|
26694
|
+
};
|
|
26695
|
+
}
|
|
26696
|
+
// src/common/kubeconfig-editor.ts
|
|
26697
|
+
var KUBECONFIG_EDITOR_CHANNEL = "freelens-power:kubeconfig-editor";
|
|
26698
|
+
// src/renderer/kubeconfig-editor.tsx
|
|
26699
|
+
var KubeconfigEditor = observer(function KubeconfigEditor({ clusterId, onClose }) {
|
|
26700
|
+
const [snapshot, setSnapshot] = useState();
|
|
26701
|
+
const [text, setText] = useState("");
|
|
26702
|
+
const [busy, setBusy] = useState(false);
|
|
26703
|
+
const [error, setError] = useState("");
|
|
26704
|
+
const [saved, setSaved] = useState(false);
|
|
26705
|
+
const [discard, setDiscard] = useState(false);
|
|
26706
|
+
const [discardReload, setDiscardReload] = useState(false);
|
|
26707
|
+
const sequence = useRef(0);
|
|
26708
|
+
const dirty = snapshot !== void 0 && text !== snapshot.text;
|
|
26709
|
+
const readOnly = snapshot?.readOnly || ReadOnlyPreferencesStore.getInstanceOrCreate().enabled;
|
|
26710
|
+
const load = useCallback(async () => {
|
|
26711
|
+
const request = ++sequence.current;
|
|
26712
|
+
setBusy(true);
|
|
26713
|
+
setError("");
|
|
26714
|
+
setSaved(false);
|
|
26715
|
+
try {
|
|
26716
|
+
const result = await ipcRenderer.invoke(KUBECONFIG_EDITOR_CHANNEL, {
|
|
26717
|
+
operation: "read",
|
|
26718
|
+
clusterId
|
|
26719
|
+
});
|
|
26720
|
+
if (request !== sequence.current) return;
|
|
26721
|
+
setSnapshot(result);
|
|
26722
|
+
setText(result.text);
|
|
26723
|
+
setDiscard(false);
|
|
26724
|
+
} catch {
|
|
26725
|
+
if (request === sequence.current) setError("Unable to open the kubeconfig.");
|
|
26726
|
+
} finally {
|
|
26727
|
+
if (request === sequence.current) setBusy(false);
|
|
26728
|
+
}
|
|
26729
|
+
}, [clusterId]);
|
|
26730
|
+
useEffect(() => {
|
|
26731
|
+
load();
|
|
26732
|
+
return () => {
|
|
26733
|
+
sequence.current++;
|
|
26734
|
+
};
|
|
26735
|
+
}, [load]);
|
|
26736
|
+
const close = () => {
|
|
26737
|
+
if (busy) return;
|
|
26738
|
+
if (dirty && !discard) {
|
|
26739
|
+
setDiscardReload(false);
|
|
26740
|
+
setDiscard(true);
|
|
26741
|
+
} else if (dirty && discard) setDiscard(false);
|
|
26742
|
+
else onClose();
|
|
26743
|
+
};
|
|
26744
|
+
const save = async () => {
|
|
26745
|
+
if (!snapshot || busy || readOnly || !dirty) return;
|
|
26746
|
+
const request = ++sequence.current;
|
|
26747
|
+
setBusy(true);
|
|
26748
|
+
setError("");
|
|
26749
|
+
setSaved(false);
|
|
26750
|
+
try {
|
|
26751
|
+
const result = await ipcRenderer.invoke(KUBECONFIG_EDITOR_CHANNEL, {
|
|
26752
|
+
operation: "save",
|
|
26753
|
+
clusterId,
|
|
26754
|
+
text,
|
|
26755
|
+
revision: snapshot.revision
|
|
26756
|
+
});
|
|
26757
|
+
if (request !== sequence.current) return;
|
|
26758
|
+
setSnapshot(result);
|
|
26759
|
+
setText(result.text);
|
|
26760
|
+
setSaved(true);
|
|
26761
|
+
setDiscard(false);
|
|
26762
|
+
} catch {
|
|
26763
|
+
if (request === sequence.current) setError("Unable to save. Check the YAML and reload if the file changed outside this editor.");
|
|
26764
|
+
} finally {
|
|
26765
|
+
if (request === sequence.current) setBusy(false);
|
|
26766
|
+
}
|
|
26767
|
+
};
|
|
26768
|
+
return /* @__PURE__ */ jsx$1(SettingsModal, {
|
|
26769
|
+
id: "power-kubeconfig-editor",
|
|
26770
|
+
title: "Kubeconfig",
|
|
26771
|
+
onClose: close,
|
|
26772
|
+
width: 1320,
|
|
26773
|
+
guardClose: true,
|
|
26774
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
26775
|
+
"data-power-kubeconfig-editor": "",
|
|
26776
|
+
style: { minWidth: 0 },
|
|
26777
|
+
children: [
|
|
26778
|
+
error && /* @__PURE__ */ jsx$1("p", {
|
|
26779
|
+
role: "alert",
|
|
26780
|
+
style: { color: "var(--colorError)" },
|
|
26781
|
+
children: error
|
|
26782
|
+
}),
|
|
26783
|
+
readOnly && /* @__PURE__ */ jsx$1("p", { children: "Read-only mode is enabled." }),
|
|
26784
|
+
snapshot ? /* @__PURE__ */ jsx$1(HelmCodeView, {
|
|
26785
|
+
value: text,
|
|
26786
|
+
readOnly: !!readOnly || busy,
|
|
26787
|
+
onChange: (value) => {
|
|
26788
|
+
setText(value);
|
|
26789
|
+
setSaved(false);
|
|
26790
|
+
},
|
|
26791
|
+
ariaLabel: "Kubeconfig YAML",
|
|
26792
|
+
style: { height: "clamp(240px, calc(100vh - 240px), 900px)" }
|
|
26793
|
+
}) : /* @__PURE__ */ jsx$1("p", {
|
|
26794
|
+
role: "status",
|
|
26795
|
+
children: busy ? "Loading kubeconfig…" : "Kubeconfig is unavailable."
|
|
26796
|
+
}),
|
|
26797
|
+
saved && /* @__PURE__ */ jsx$1("p", {
|
|
26798
|
+
role: "status",
|
|
26799
|
+
children: "Saved"
|
|
26800
|
+
}),
|
|
26801
|
+
discard && /* @__PURE__ */ jsx$1("p", {
|
|
26802
|
+
role: "alert",
|
|
26803
|
+
children: "Discard unsaved changes?"
|
|
26804
|
+
}),
|
|
26805
|
+
/* @__PURE__ */ jsxs("div", {
|
|
26806
|
+
style: {
|
|
26807
|
+
display: "flex",
|
|
26808
|
+
alignItems: "center",
|
|
26809
|
+
justifyContent: "space-between",
|
|
26810
|
+
gap: 12,
|
|
26811
|
+
marginTop: 16
|
|
26812
|
+
},
|
|
26813
|
+
children: [/* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
|
|
26814
|
+
label: "Reload",
|
|
26815
|
+
disabled: busy,
|
|
26816
|
+
onClick: () => {
|
|
26817
|
+
if (dirty) {
|
|
26818
|
+
setDiscardReload(true);
|
|
26819
|
+
setDiscard(true);
|
|
26820
|
+
} else load();
|
|
26821
|
+
}
|
|
26822
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
26823
|
+
style: {
|
|
26824
|
+
display: "flex",
|
|
26825
|
+
gap: 8
|
|
26826
|
+
},
|
|
26827
|
+
children: [
|
|
26828
|
+
discard && /* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
|
|
26829
|
+
label: "Discard changes",
|
|
26830
|
+
disabled: busy,
|
|
26831
|
+
onClick: () => {
|
|
26832
|
+
if (discardReload) load();
|
|
26833
|
+
else onClose();
|
|
26834
|
+
}
|
|
26835
|
+
}),
|
|
26836
|
+
/* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
|
|
26837
|
+
label: discard ? "Keep editing" : "Close",
|
|
26838
|
+
disabled: busy,
|
|
26839
|
+
onClick: close
|
|
26840
|
+
}),
|
|
26841
|
+
/* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
|
|
26842
|
+
label: "Save",
|
|
26843
|
+
primary: true,
|
|
26844
|
+
disabled: busy || !!readOnly || !dirty,
|
|
26845
|
+
onClick: () => void save()
|
|
26846
|
+
})
|
|
26847
|
+
]
|
|
26848
|
+
})]
|
|
26849
|
+
})
|
|
26850
|
+
]
|
|
26851
|
+
})
|
|
26852
|
+
});
|
|
26853
|
+
});
|
|
26854
|
+
function startKubeconfigEditorEntrypoints() {
|
|
26855
|
+
const modal = document.createElement("div");
|
|
26856
|
+
modal.setAttribute("data-power-kubeconfig-modal", "");
|
|
26857
|
+
document.body.append(modal);
|
|
26858
|
+
let stopped = false;
|
|
26859
|
+
const open = (clusterId) => {
|
|
26860
|
+
if (stopped || !Renderer$1.Catalog.getClusterById(clusterId)) return;
|
|
26861
|
+
renderIntoContainer(/* @__PURE__ */ jsx$1(KubeconfigEditor, {
|
|
26862
|
+
clusterId,
|
|
26863
|
+
onClose: () => unmountContainer(modal)
|
|
26864
|
+
}, clusterId), modal);
|
|
26865
|
+
};
|
|
26866
|
+
const addMenu = (entity, context) => {
|
|
26867
|
+
if (!Renderer$1.Catalog.getClusterById(entity.getId())) return;
|
|
26868
|
+
context.menuItems.push({
|
|
26869
|
+
title: "Open kubeconfig",
|
|
26870
|
+
icon: "edit",
|
|
26871
|
+
onClick: () => open(entity.getId())
|
|
26872
|
+
});
|
|
26873
|
+
};
|
|
26874
|
+
let category;
|
|
26875
|
+
const stopCategory = reaction(() => Renderer$1.Catalog.catalogCategories.getForGroupKind("entity.k8slens.dev", "KubernetesCluster"), (next) => {
|
|
26876
|
+
category?.off("contextMenuOpen", addMenu);
|
|
26877
|
+
category = next;
|
|
26878
|
+
category?.on("contextMenuOpen", addMenu);
|
|
26879
|
+
}, { fireImmediately: true });
|
|
26880
|
+
const owned = /* @__PURE__ */ new Map();
|
|
26881
|
+
const remove = (heading) => {
|
|
26882
|
+
const entry = owned.get(heading);
|
|
26883
|
+
if (!entry) return;
|
|
26884
|
+
unmountContainer(entry.host);
|
|
26885
|
+
entry.host.remove();
|
|
26886
|
+
owned.delete(heading);
|
|
26887
|
+
};
|
|
26888
|
+
const update = () => {
|
|
26889
|
+
if (stopped) return;
|
|
26890
|
+
const found = /* @__PURE__ */ new Set();
|
|
26891
|
+
let clusterId;
|
|
26892
|
+
try {
|
|
26893
|
+
clusterId = decodeURIComponent(/^\/entity\/([^/]+)\/settings\/?$/.exec(location.pathname)?.[1] ?? "");
|
|
26894
|
+
} catch {}
|
|
26895
|
+
if (clusterId && Renderer$1.Catalog.getClusterById(clusterId)) for (const heading of document.querySelectorAll("[data-testid=\"entity-settings\"] .SubTitle")) {
|
|
26896
|
+
if (Array.from(heading.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.textContent).join("").trim() !== "Kubeconfig") continue;
|
|
26897
|
+
found.add(heading);
|
|
26898
|
+
let entry = owned.get(heading);
|
|
26899
|
+
if (!entry) {
|
|
26900
|
+
const host = document.createElement("span");
|
|
26901
|
+
host.setAttribute("data-power-kubeconfig-action", "");
|
|
26902
|
+
heading.append(host);
|
|
26903
|
+
entry = {
|
|
26904
|
+
host,
|
|
26905
|
+
clusterId: ""
|
|
26906
|
+
};
|
|
26907
|
+
owned.set(heading, entry);
|
|
26908
|
+
}
|
|
26909
|
+
if (entry.clusterId === clusterId) continue;
|
|
26910
|
+
entry.clusterId = clusterId;
|
|
26911
|
+
const id = clusterId;
|
|
26912
|
+
renderIntoContainer(/* @__PURE__ */ jsx$1(NativeTooltip, {
|
|
26913
|
+
title: "Open kubeconfig",
|
|
26914
|
+
children: /* @__PURE__ */ jsx$1("button", {
|
|
26915
|
+
type: "button",
|
|
26916
|
+
className: "power-kubeconfig-open",
|
|
26917
|
+
"aria-label": "Open kubeconfig",
|
|
26918
|
+
onClick: () => open(id),
|
|
26919
|
+
children: /* @__PURE__ */ jsx$1(Renderer$1.Component.Icon, {
|
|
26920
|
+
material: "edit",
|
|
26921
|
+
size: 18
|
|
26922
|
+
})
|
|
26923
|
+
})
|
|
26924
|
+
}), entry.host);
|
|
26925
|
+
}
|
|
26926
|
+
for (const heading of owned.keys()) if (!found.has(heading)) remove(heading);
|
|
26927
|
+
};
|
|
26928
|
+
const style = document.createElement("style");
|
|
26929
|
+
style.textContent = `[data-power-kubeconfig-action]{display:inline-flex;vertical-align:middle;margin-left:8px}.power-kubeconfig-open{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:0;border-radius:4px;background:transparent;color:var(--textColorSecondary);cursor:pointer}.power-kubeconfig-open:hover{color:var(--primary)}.power-kubeconfig-open:focus-visible{outline:2px solid var(--primary);outline-offset:2px}`;
|
|
26930
|
+
document.head.append(style);
|
|
26931
|
+
const observer = new MutationObserver(update);
|
|
26932
|
+
observer.observe(document.body, {
|
|
26933
|
+
childList: true,
|
|
26934
|
+
subtree: true,
|
|
26935
|
+
characterData: true
|
|
26936
|
+
});
|
|
26937
|
+
update();
|
|
26938
|
+
return () => {
|
|
26939
|
+
stopped = true;
|
|
26940
|
+
observer.disconnect();
|
|
26941
|
+
stopCategory();
|
|
26942
|
+
category?.off("contextMenuOpen", addMenu);
|
|
26943
|
+
for (const heading of owned.keys()) remove(heading);
|
|
26944
|
+
unmountContainer(modal);
|
|
26945
|
+
modal.remove();
|
|
26946
|
+
style.remove();
|
|
26947
|
+
};
|
|
26948
|
+
}
|
|
26280
26949
|
// src/common/ip-address.ts
|
|
26281
26950
|
function isIP(value) {
|
|
26282
26951
|
if (/^(?:0|[1-9]\d{0,2})(?:\.(?:0|[1-9]\d{0,2})){3}$/.test(value)) return value.split(".").every((part) => Number(part) <= 255) ? 4 : 0;
|
|
@@ -33559,7 +34228,7 @@ function startPowerButtonStyles(customizeResources = true) {
|
|
|
33559
34228
|
const scope = ":is(.freelens-power-preferences, .freelens-power-dashboard, .power-dashboard-dialog, .power-ai-panel, .power-ai-overview-actions)";
|
|
33560
34229
|
const controls = `:root ${scope} :is(button, .Button), :root .power-ai-launcher, :root .power-dashboard-card-header a, :root .freelens-power-settings-icon`;
|
|
33561
34230
|
const hover = `:root ${scope} :is(button, .Button):not(:disabled):not(.disabled):hover, :root .power-dashboard-card-header a:hover, :root .freelens-power-settings-icon:hover`;
|
|
33562
|
-
const floating = customizeResources ? ":root :is(.AddRemoveButtons .Button:is(.remove-button, .add-button), .power-node-bulk-floating .Button.power-node-bulk-fab)" : ":root .power-node-bulk-floating .Button.power-node-bulk-fab";
|
|
34231
|
+
const floating = customizeResources ? ":root :is(.AddRemoveButtons .Button:is(.remove-button, .add-button), .power-node-bulk-floating .Button.power-node-bulk-fab, .power-catalog-disconnect-button, .CatalogAddButton .MuiFab-root:not(.Mui-disabled))" : ":root :is(.power-node-bulk-floating .Button.power-node-bulk-fab, .power-catalog-disconnect-button, .CatalogAddButton .MuiFab-root:not(.Mui-disabled))";
|
|
33563
34232
|
style.textContent = `
|
|
33564
34233
|
${controls} { transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
|
|
33565
34234
|
${hover} { background-color: color-mix(in srgb, var(--contentColor) 88%, var(--textColorPrimary) 12%); color: var(--textColorAccent); border-color: var(--borderColor); }
|
|
@@ -33583,13 +34252,13 @@ function startPowerButtonStyles(customizeResources = true) {
|
|
|
33583
34252
|
box-shadow: none;
|
|
33584
34253
|
transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
|
|
33585
34254
|
}
|
|
33586
|
-
${floating} .Icon { --size: 18px; width: 18px; height: 18px; font-size: 18px; }
|
|
34255
|
+
${floating} :is(.Icon, .MuiSvgIcon-root) { --size: 18px; width: 18px; height: 18px; font-size: 18px; }
|
|
33587
34256
|
${floating}:not(.disabled):not(:disabled):hover {
|
|
33588
34257
|
border-color: var(--textColorAccent);
|
|
33589
34258
|
color: var(--textColorAccent) !important;
|
|
33590
34259
|
background: color-mix(in srgb, var(--contentColor) 92%, var(--primary) 8%);
|
|
33591
34260
|
}
|
|
33592
|
-
${floating}.power-node-bulk-fab[aria-expanded=true]:not(.disabled):not(:disabled) { border-color: var(--primary); }
|
|
34261
|
+
${floating}:is(.power-node-bulk-fab, .MuiSpeedDial-fab)[aria-expanded=true]:not(.disabled):not(:disabled) { border-color: var(--primary); }
|
|
33593
34262
|
${floating}:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
|
|
33594
34263
|
@media (prefers-reduced-motion: reduce) { ${floating} { transition: none; } }
|
|
33595
34264
|
@media (prefers-reduced-motion: reduce) { ${controls} { transition: none; } }
|
|
@@ -40483,6 +41152,16 @@ var OtherPreferences = observer(() => {
|
|
|
40483
41152
|
className: "power-settings-hint",
|
|
40484
41153
|
children: "Bulk actions and clearer resource dialogs."
|
|
40485
41154
|
})] }),
|
|
41155
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx$1(Renderer$1.Component.Switch, {
|
|
41156
|
+
checked: preferences.hotbarShortcuts,
|
|
41157
|
+
onChange: (value) => {
|
|
41158
|
+
preferences.hotbarShortcuts = value;
|
|
41159
|
+
},
|
|
41160
|
+
children: "Hotbar keyboard shortcuts"
|
|
41161
|
+
}), /* @__PURE__ */ jsx$1("div", {
|
|
41162
|
+
className: "power-settings-hint",
|
|
41163
|
+
children: "Switch panels with Cmd+1-9 on macOS or Ctrl+1-9 on Windows and Linux."
|
|
41164
|
+
})] }),
|
|
40486
41165
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx$1(Renderer$1.Component.Switch, {
|
|
40487
41166
|
checked: monitoring.resourceSearchEnabled,
|
|
40488
41167
|
onChange: (value) => {
|
|
@@ -43571,12 +44250,16 @@ var FreelensPowerRenderer = class extends Renderer$1.LensExtension {
|
|
|
43571
44250
|
startPodDetailsEnhancements,
|
|
43572
44251
|
startPodBulkCustomization,
|
|
43573
44252
|
startHostLayoutStyles,
|
|
44253
|
+
startHotbarName,
|
|
44254
|
+
startKubeconfigEditorEntrypoints,
|
|
43574
44255
|
startHostPreferencesStyles,
|
|
43575
44256
|
startHostExtensionsStyles,
|
|
43576
44257
|
startExtensionUpdate,
|
|
43577
44258
|
startExtensionUpdateNotifications,
|
|
43578
44259
|
startAppearanceOverride,
|
|
43579
44260
|
startClusterIconOverlay,
|
|
44261
|
+
startCatalogMenuIcons,
|
|
44262
|
+
startCatalogDisconnect,
|
|
43580
44263
|
startWelcomeOverride,
|
|
43581
44264
|
startAiChat,
|
|
43582
44265
|
startResourceSearch,
|