Add an "Open admin" button to the integration pages
Each integration page now has a button next to its title that opens the product's own admin panel in a new tab, using the address entered on the integration. Tailscale links to its admin console. Only http(s) addresses become links. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
51ad309e35
commit
75f0a3d881
9 files changed
+64
-8
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import type { IntegrationSummary } from "../api/client";
|
||||
|
||||
/** Only http(s) addresses become links, so a stored value can never turn into a javascript: link. */
|
||||
function webAddress(value: string | undefined): string | null {
|
||||
if (!value) return null;
|
||||
try {
|
||||
const url = new URL(value);
|
||||
return url.protocol === "http:" || url.protocol === "https:" ? url.href : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page heading for an integration page, with a button that opens the product's own admin panel
|
||||
* in a new tab. The address is the one entered on the integration (its URL field); `url` overrides
|
||||
* it for products with no address of their own (Tailscale).
|
||||
*/
|
||||
export default function IntegrationPageTitle({
|
||||
title,
|
||||
adminName,
|
||||
integration,
|
||||
url,
|
||||
}: {
|
||||
title: string;
|
||||
/** Product name for the button when the page title is not it (the Docker page is Dockhand). */
|
||||
adminName?: string;
|
||||
integration: IntegrationSummary | null;
|
||||
url?: string;
|
||||
}) {
|
||||
const href = webAddress(url ?? integration?.baseUrl);
|
||||
return (
|
||||
<div className="d-flex flex-wrap align-items-center gap-3 mb-3">
|
||||
<h2 className="page-title mb-0">{title}</h2>
|
||||
{href && (
|
||||
<a
|
||||
className="btn btn-sm btn-outline-secondary"
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={href}
|
||||
>
|
||||
Open {adminName ?? title} admin ↗
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
function updateBadge(c: DockhandContainer) {
|
||||
if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
|
||||
@@ -140,7 +141,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Docker</h2>
|
||||
<IntegrationPageTitle title="Docker" adminName="Dockhand" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type CurrentUser, type GiteaRepo, type IntegrationSummary } from "../api/client";
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
@@ -113,7 +114,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Gitea</h2>
|
||||
<IntegrationPageTitle title="Gitea" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
function formatBytes(bytes: number | null): string {
|
||||
if (bytes === null) return "—";
|
||||
@@ -126,7 +127,7 @@ export default function PbsBackup({ user: _user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Proxmox Backup Server</h2>
|
||||
<IntegrationPageTitle title="Proxmox Backup Server" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -16,6 +16,7 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
function proxmoxStatusBadge(status: string) {
|
||||
return status === "running" ? (
|
||||
@@ -203,7 +204,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Proxmox</h2>
|
||||
<IntegrationPageTitle title="Proxmox" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -14,6 +14,7 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
function semaphoreStatusBadge(template: SemaphoreTemplate) {
|
||||
const status = template.lastTask?.status;
|
||||
@@ -118,7 +119,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Semaphore</h2>
|
||||
<IntegrationPageTitle title="Semaphore" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import { useSortable } from "../hooks/useSortable";
|
||||
import SortableTh from "../components/SortableTh";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
function healthBadge(status: string) {
|
||||
return status === "normal" ? (
|
||||
@@ -133,7 +134,7 @@ export default function Synology({ user: _user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Synology</h2>
|
||||
<IntegrationPageTitle title="Synology" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -15,6 +15,7 @@ import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { useSelection } from "../hooks/useSelection";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
const KEY_EXPIRY_WARN_DAYS = 30;
|
||||
|
||||
@@ -156,7 +157,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Tailscale</h2>
|
||||
<IntegrationPageTitle title="Tailscale" url="https://login.tailscale.com/admin/machines" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
@@ -7,6 +7,7 @@ import { usePagination } from "../hooks/usePagination";
|
||||
import Pagination from "../components/Pagination";
|
||||
import { downloadCsv } from "../utils/csv";
|
||||
import { readableError } from "../utils/errors";
|
||||
import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
||||
|
||||
function statusBadge(monitor: UptimeKumaMonitor) {
|
||||
switch (monitor.status) {
|
||||
@@ -97,7 +98,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-3">Uptime Kuma</h2>
|
||||
<IntegrationPageTitle title="Uptime Kuma" integration={selected} />
|
||||
{error && <div className="alert alert-danger">{error}</div>}
|
||||
|
||||
{integrations?.length === 0 ? (
|
||||
|
||||
Reference in new issue
Block a user