feat: add server upgrade action — force-pull latest images and re-provision
Restart only stops/starts existing containers with the same image. The new upgrade action removes server + UI containers, force-pulls the latest Docker images, then re-provisions (preserving app containers, volumes, and networks). Available to both vendor (tenant detail) and tenant admin (dashboard). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,14 @@ export function useRestartServer() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpgradeServer() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation<void, Error, void>({
|
||||
mutationFn: () => api.post('/tenant/server/upgrade'),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['tenant', 'dashboard'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useTenantLicense() {
|
||||
return useQuery<TenantLicenseData>({
|
||||
queryKey: ['tenant', 'license'],
|
||||
|
||||
@@ -62,6 +62,14 @@ export function useRestartServer() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpgradeServer() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation<void, Error, string>({
|
||||
mutationFn: (id) => api.post(`/vendor/tenants/${id}/upgrade`),
|
||||
onSuccess: (_, id) => qc.invalidateQueries({ queryKey: ['vendor', 'tenants', id] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useRenewLicense() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation<LicenseResponse, Error, string>({
|
||||
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
Spinner,
|
||||
useToast,
|
||||
} from '@cameleer/design-system';
|
||||
import { ExternalLink, Key, RefreshCw, Settings } from 'lucide-react';
|
||||
import { useTenantDashboard, useRestartServer } from '../../api/tenant-hooks';
|
||||
import { ArrowUpCircle, ExternalLink, Key, RefreshCw, Settings } from 'lucide-react';
|
||||
import { useTenantDashboard, useRestartServer, useUpgradeServer } from '../../api/tenant-hooks';
|
||||
import { ServerStatusBadge } from '../../components/ServerStatusBadge';
|
||||
import { UsageIndicator } from '../../components/UsageIndicator';
|
||||
import { tierColor } from '../../utils/tier';
|
||||
@@ -30,6 +30,7 @@ export function TenantDashboardPage() {
|
||||
const { toast } = useToast();
|
||||
const { data, isLoading, isError } = useTenantDashboard();
|
||||
const restartServer = useRestartServer();
|
||||
const upgradeServer = useUpgradeServer();
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -98,7 +99,7 @@ export function TenantDashboardPage() {
|
||||
<span className={styles.kvValueMono}>{data.serverEndpoint}</span>
|
||||
</div>
|
||||
)}
|
||||
<div style={{ paddingTop: 8 }}>
|
||||
<div style={{ paddingTop: 8, display: 'flex', gap: 8 }}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={async () => {
|
||||
@@ -112,7 +113,22 @@ export function TenantDashboardPage() {
|
||||
loading={restartServer.isPending}
|
||||
>
|
||||
<RefreshCw size={14} style={{ marginRight: 6 }} />
|
||||
Restart Server
|
||||
Restart
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await upgradeServer.mutateAsync();
|
||||
toast({ title: 'Server upgrade started — pulling latest images', variant: 'success' });
|
||||
} catch (err) {
|
||||
toast({ title: 'Upgrade failed', description: String(err), variant: 'error' });
|
||||
}
|
||||
}}
|
||||
loading={upgradeServer.isPending}
|
||||
>
|
||||
<ArrowUpCircle size={14} style={{ marginRight: 6 }} />
|
||||
Upgrade
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
22
ui/src/pages/vendor/TenantDetailPage.tsx
vendored
22
ui/src/pages/vendor/TenantDetailPage.tsx
vendored
@@ -9,7 +9,7 @@ import {
|
||||
Spinner,
|
||||
useToast,
|
||||
} from '@cameleer/design-system';
|
||||
import { ArrowLeft, RefreshCw, Trash2 } from 'lucide-react';
|
||||
import { ArrowLeft, ArrowUpCircle, RefreshCw, Trash2 } from 'lucide-react';
|
||||
import {
|
||||
useVendorTenant,
|
||||
useSuspendTenant,
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
useDeleteTenant,
|
||||
useRenewLicense,
|
||||
useRestartServer,
|
||||
useUpgradeServer,
|
||||
} from '../../api/vendor-hooks';
|
||||
import { ServerStatusBadge } from '../../components/ServerStatusBadge';
|
||||
import { tierColor } from '../../utils/tier';
|
||||
@@ -69,6 +70,7 @@ export function TenantDetailPage() {
|
||||
const deleteTenant = useDeleteTenant();
|
||||
const renewLicense = useRenewLicense();
|
||||
const restartServer = useRestartServer();
|
||||
const upgradeServer = useUpgradeServer();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
@@ -117,6 +119,16 @@ export function TenantDetailPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUpgrade() {
|
||||
if (!id) return;
|
||||
try {
|
||||
await upgradeServer.mutateAsync(id);
|
||||
toast({ title: 'Server upgrade started — pulling latest images', variant: 'success' });
|
||||
} catch (err) {
|
||||
toast({ title: 'Upgrade failed', description: String(err), variant: 'error' });
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
if (!id) return;
|
||||
try {
|
||||
@@ -267,6 +279,14 @@ export function TenantDetailPage() {
|
||||
<RefreshCw size={14} style={{ marginRight: 6 }} />
|
||||
Restart Server
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={handleUpgrade}
|
||||
loading={upgradeServer.isPending}
|
||||
>
|
||||
<ArrowUpCircle size={14} style={{ marginRight: 6 }} />
|
||||
Upgrade Server
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={handleSuspendToggle}
|
||||
|
||||
Reference in New Issue
Block a user