mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
chore: lock the plugin boundary and remove 2.9.0 leftovers
This commit is contained in:
1 parent
6489b62ece
commit
2961297989
399 files changed
+3964
-5627
No files matched your search
@@ -204,6 +204,7 @@ export function createC2SRelay(ctx: PluginContext) {
|
||||
function connectSource(hostId: number): Promise<PluginSshConnection<Client>> {
|
||||
return ctx.ssh.connect<Client>(hostId, {
|
||||
purpose: "tunnel",
|
||||
profile: "forward",
|
||||
timeoutMs: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ export function createTunnelManager(ctx: PluginContext) {
|
||||
return ctx.asUser(userId, () =>
|
||||
ctx.ssh.connect<Client>(hostId, {
|
||||
purpose: "tunnel",
|
||||
profile: "forward",
|
||||
timeoutMs: CONNECT_TIMEOUT_MS,
|
||||
sock,
|
||||
}),
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Network } from "lucide-react";
|
||||
import { useTranslation } from "@termix/plugin-sdk/frontend";
|
||||
import { getTunnelStatuses } from "./api";
|
||||
|
||||
/** The dashboard's "active tunnels" counter; a click opens the tunnels tab. */
|
||||
export function ActiveTunnelsCounter({ onOpen }: { onOpen: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
const [count, setCount] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
getTunnelStatuses()
|
||||
.then((statuses) => {
|
||||
if (cancelled) return;
|
||||
setCount(
|
||||
Object.values(statuses ?? {}).filter(
|
||||
(status) =>
|
||||
(status as { status?: string })?.status?.toUpperCase() ===
|
||||
"CONNECTED",
|
||||
).length,
|
||||
);
|
||||
})
|
||||
.catch(() => {});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={onOpen}
|
||||
className="flex items-center gap-2.5 px-4 py-2.5 hover:bg-muted transition-colors cursor-pointer text-left"
|
||||
>
|
||||
<Network className="size-3.5 text-muted-foreground shrink-0" />
|
||||
<span className="text-base font-bold">{count}</span>
|
||||
<span className="text-[10px] text-muted-foreground uppercase tracking-widest font-semibold">
|
||||
{t("tunnels.activeTunnels")}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -13,7 +13,8 @@ import {
|
||||
TunnelWidget,
|
||||
TunnelWidgetEditForm,
|
||||
} from "./views";
|
||||
import { getTunnelStatuses, setTunnelsApi } from "./api";
|
||||
import { setTunnelsApi } from "./api";
|
||||
import { ActiveTunnelsCounter } from "./ActiveTunnelsCounter";
|
||||
import { hostTunnelSettings } from "./host-tunnels";
|
||||
|
||||
// Matches the homepage canvas grid.
|
||||
@@ -96,14 +97,20 @@ export function activate(app: TermixApp): void {
|
||||
editFormComponent: TunnelWidgetEditForm,
|
||||
} as HomepageWidgetContribution);
|
||||
|
||||
// The dashboard's active tunnel counter reads and opens these, and gets
|
||||
// undefined back while the plugin is off.
|
||||
app.registerAction("tunnels.statuses", (() => getTunnelStatuses()) as never, {
|
||||
permission: "use",
|
||||
});
|
||||
// The dashboard's active tunnel counter.
|
||||
app.registerAction(
|
||||
"tunnels.open",
|
||||
(() => app.tabs.openSingletonTab("tunnel")) as never,
|
||||
{ permission: "use" },
|
||||
);
|
||||
app.registerSlotContribution("dashboard.counters", {
|
||||
actionId: "tunnels.open",
|
||||
titleKey: "tunnels.activeTunnels",
|
||||
kind: "component",
|
||||
component: (() => (
|
||||
<ActiveTunnelsCounter
|
||||
onOpen={() => void app.tabs.openSingletonTab("tunnel")}
|
||||
/>
|
||||
)) as never,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user