feat(deployments): deployment restart özelliği ekle

Deployment projeleri için yeniden başlatma (restart) yeteneği eklendi.
Backend servisi, API endpoint'i ve kullanıcı arayüzü butonları güncellendi.
This commit is contained in:
2026-02-03 08:53:03 +00:00
parent a117275efe
commit b04ac03739
5 changed files with 154 additions and 2 deletions

View File

@@ -96,6 +96,10 @@ export async function runDeployment(id: string, message?: string): Promise<void>
await apiClient.post(`/deployments/${id}/run`, message ? { message } : {});
}
export async function restartDeployment(id: string, message?: string): Promise<void> {
await apiClient.post(`/deployments/${id}/restart`, message ? { message } : {});
}
export async function fetchDeployment(id: string): Promise<DeploymentDetailResponse> {
const { data } = await apiClient.get(`/deployments/${id}`);
return data as DeploymentDetailResponse;

View File

@@ -7,7 +7,8 @@ import {
faCopy,
faEye,
faEyeSlash,
faHistory
faHistory,
faRotate
} from "@fortawesome/free-solid-svg-icons";
import { toast } from "sonner";
import { Button } from "../components/ui/button";
@@ -25,6 +26,7 @@ import {
fetchDeploymentBranches,
fetchDeploymentComposeFiles,
fetchDeploymentEnvExamples,
restartDeployment,
runDeployment,
updateDeployment
} from "../api/deployments";
@@ -49,6 +51,7 @@ export function DeploymentDetailPage() {
const [runs, setRuns] = useState<DeploymentRun[]>([]);
const [loading, setLoading] = useState(true);
const [triggering, setTriggering] = useState(false);
const [restarting, setRestarting] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const [saving, setSaving] = useState(false);
const [form, setForm] = useState<FormState>({
@@ -169,6 +172,19 @@ export function DeploymentDetailPage() {
}
};
const handleRestart = async () => {
if (!id) return;
setRestarting(true);
try {
await restartDeployment(id, "restart");
toast.success("Restart tetiklendi");
} catch {
toast.error("Restart tetiklenemedi");
} finally {
setRestarting(false);
}
};
useEffect(() => {
const repoUrl = form.repoUrl.trim();
if (!repoUrl) {
@@ -341,6 +357,10 @@ export function DeploymentDetailPage() {
>
Düzenle
</Button>
<Button onClick={handleRestart} disabled={restarting} className="gap-2">
<FontAwesomeIcon icon={faRotate} className="h-4 w-4" />
{restarting ? "Restarting..." : "Restart"}
</Button>
<Button onClick={handleRun} disabled={triggering} className="gap-2">
<FontAwesomeIcon icon={faCloudArrowUp} className="h-4 w-4" />
{triggering ? "Deploying..." : "Deploy"}

View File

@@ -6,6 +6,7 @@ import {
faCloudArrowUp,
faEye,
faEyeSlash,
faPenToSquare,
faPlus,
faRotate,
faRocket
@@ -25,6 +26,7 @@ import {
fetchDeploymentBranches,
fetchDeploymentEnvExamples,
fetchDeployments,
restartDeployment,
runDeployment,
updateDeployment
} from "../api/deployments";
@@ -293,6 +295,15 @@ export function DeploymentsPage() {
}
};
const handleRestart = async (id: string) => {
try {
await restartDeployment(id, "restart");
toast.success("Restart tetiklendi");
} catch {
toast.error("Restart tetiklenemedi");
}
};
const handleDelete = async (deployment: DeploymentProject) => {
const ok = window.confirm("Bu deployment'ı silmek istediğinize emin misiniz?");
if (!ok) return;
@@ -393,6 +404,18 @@ export function DeploymentsPage() {
>
<FontAwesomeIcon icon={faCloudArrowUp} className="h-4 w-4" />
</Button>
<Button
variant="outline"
size="icon"
onClick={(e) => {
e.stopPropagation();
handleRestart(deployment._id);
}}
title="Restart"
aria-label="Restart"
>
<FontAwesomeIcon icon={faRotate} className="h-4 w-4" />
</Button>
<Button
variant="outline"
size="icon"
@@ -402,7 +425,7 @@ export function DeploymentsPage() {
}}
title="Düzenle"
>
<FontAwesomeIcon icon={faRotate} className="h-4 w-4" />
<FontAwesomeIcon icon={faPenToSquare} className="h-4 w-4" />
</Button>
<Button
variant="outline"