2 lines
9.6 KiB
JavaScript
2 lines
9.6 KiB
JavaScript
import{r as o,b as N,j as e,T as u,d6 as j,cZ as O,v,C as I,d7 as w,d5 as L,e as K}from"./vendor-BKmmeuxg.js";import{L as G}from"./loading-button-BnTVAMJ7.js";import{B as i}from"./button-BpNwv2aE.js";import{C as H}from"./card-D9_SJYq6.js";import{D as y,b as D,c as C,d as k,g as R,e as S}from"./dialog-B2gN9MvT.js";import U from"./backgup-downloader-Dcd8Ehi_.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const Y=({recentBackups:m})=>{const[r,l]=o.useState(!1),[_,c]=o.useState(!1),[B,d]=o.useState(!1),[a,t]=o.useState(null),x=N({}),F=()=>{x.post(route("system.refresh"))},z=s=>{t(s),c(!0)},P=s=>{t(s),d(!0)},{delete:E,processing:p}=N({}),T=s=>{a&&(l(!0),E(route("system.backup.delete",a.id),{onSuccess:()=>{c(!1),t(null),l(!1)},onError:()=>{l(!1)}}))},M=()=>{a&&(l(!0),K.post(route("system.backup.restore",a.id),{},{onSuccess:()=>{d(!1),t(null),l(!1)},onError:()=>{l(!1)}}))},g=()=>{r||(c(!1),d(!1),t(null))},n=s=>{if(s===0)return"0 Bytes";const b=1024,A=["Bytes","KB","MB","GB"],f=Math.floor(Math.log(s)/Math.log(b));return parseFloat((s/Math.pow(b,f)).toFixed(2))+" "+A[f]},h=s=>new Date(s).toLocaleString();return e.jsxs(e.Fragment,{children:[e.jsx(y,{open:_,onOpenChange:s=>{r||(c(s),s||t(null))},children:e.jsxs(D,{className:"sm:max-w-[500px]",onInteractOutside:s=>{r&&s.preventDefault()},onEscapeKeyDown:s=>{r&&s.preventDefault()},children:[r&&e.jsx("div",{className:"bg-background/80 absolute inset-0 z-10 flex items-center justify-center rounded-lg backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"border-primary mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-4 border-t-transparent"}),e.jsx("p",{className:"text-sm font-medium",children:"Deleting backup..."}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Please wait"})]})}),e.jsxs(C,{children:[e.jsxs(k,{className:"flex items-center gap-2",children:[e.jsx(u,{className:"h-5 w-5 text-red-600"}),"Delete Backup"]}),e.jsxs(R,{className:"space-y-4 text-left",children:[e.jsxs("p",{children:["Are you sure you want to delete the backup ",e.jsxs("strong",{children:['"',a==null?void 0:a.backup_name,'"']}),"?"]}),e.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4",children:[e.jsx("p",{className:"mb-2 font-medium text-red-800",children:"⚠️ This action will:"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm text-red-700",children:[e.jsx("li",{children:"Permanently delete the backup files from storage"}),e.jsx("li",{children:"Remove the backup record from the database"}),e.jsx("li",{children:"Cannot be undone or recovered"})]})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4",children:e.jsxs("p",{className:"text-sm text-amber-700",children:[e.jsx("strong",{children:"Backup Details:"}),e.jsx("br",{}),"Source Code: ",a?n(a.source_code_size):"",e.jsx("br",{}),"Database: ",a?n(a.database_size):"",e.jsx("br",{}),"Created: ",a?h(a.created_at):""]})})]})]}),e.jsxs(S,{className:"flex-col gap-2 sm:flex-row",children:[e.jsx(i,{variant:"outline",onClick:g,disabled:r,className:"w-full sm:w-auto",children:"Cancel"}),e.jsx("form",{onSubmit:T,children:e.jsx(i,{type:"submit",variant:"destructive",disabled:p,className:"w-full sm:w-auto",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 animate-spin",children:"⏳"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"mr-2 h-4 w-4"}),"Delete Backup"]})})})]})]})}),e.jsx(y,{open:B,onOpenChange:s=>{r||(d(s),s||t(null))},children:e.jsxs(D,{className:"sm:max-w-[500px]",onInteractOutside:s=>{r&&s.preventDefault()},onEscapeKeyDown:s=>{r&&s.preventDefault()},children:[r&&e.jsx("div",{className:"bg-background/80 absolute inset-0 z-10 flex items-center justify-center rounded-lg backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"border-primary mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-4 border-t-transparent"}),e.jsx("p",{className:"text-sm font-medium",children:"Restoring backup..."}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Please do not close this window"})]})}),e.jsxs(C,{children:[e.jsxs(k,{className:"flex items-center gap-2",children:[e.jsx(j,{className:"h-5 w-5 text-blue-600"}),"Restore Backup"]}),e.jsxs(R,{className:"space-y-4 text-left",children:[e.jsxs("p",{children:["Are you sure you want to restore the backup ",e.jsxs("strong",{children:['"',a==null?void 0:a.backup_name,'"']}),"?"]}),e.jsxs("div",{className:"rounded-lg border border-orange-200 bg-orange-50 p-4",children:[e.jsx("p",{className:"mb-2 font-medium text-orange-800",children:"This restore will:"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm text-orange-700",children:[e.jsx("li",{children:"Put the site in maintenance mode"}),e.jsx("li",{children:"Overwrite all current application files"}),e.jsx("li",{children:"Replace the entire database with backup data"}),e.jsx("li",{children:"Process may take several minutes"})]})]}),e.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-red-800",children:"⚠️ Critical Warning:"}),e.jsx("p",{className:"text-sm text-red-700",children:"All current data and files will be lost! Make sure you have a recent backup of your current state if needed. This action cannot be undone."})]}),e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4",children:e.jsxs("p",{className:"text-sm text-blue-700",children:[e.jsx("strong",{children:"Backup Details:"}),e.jsx("br",{}),"Created: ",a?h(a.created_at):"",e.jsx("br",{}),"Source Code: ",a?n(a.source_code_size):"",e.jsx("br",{}),"Database: ",a?n(a.database_size):"",e.jsx("br",{}),"Status: ",(a==null?void 0:a.status)||""]})})]})]}),e.jsxs(S,{className:"flex-col gap-2 sm:flex-row",children:[e.jsx(i,{variant:"outline",onClick:g,disabled:r,className:"w-full sm:w-auto",children:"Cancel"}),e.jsx(i,{variant:"destructive",onClick:M,disabled:r,className:"w-full sm:w-auto",children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 animate-spin",children:"⏳"}),"Restoring..."]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{className:"mr-2 h-4 w-4"}),"Confirm Restore"]})})]})]})}),e.jsxs(H,{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Recent Backups"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"View and manage your recent application backups"})]}),e.jsx("div",{className:"dark:bg-secondary dark:border-border mb-6 rounded-lg border border-amber-200 bg-amber-50 p-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(O,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{className:"ml-3",children:[e.jsx("h3",{className:"text-sm font-medium text-amber-800",children:"Important Update Guidelines"}),e.jsx("div",{className:"mt-2 text-sm text-amber-700",children:e.jsx("ul",{className:"list-inside list-disc space-y-1",children:e.jsxs("li",{children:[e.jsx("strong",{children:"Refresh Server:"})," Every time refresh server before updating"]})})})]})]})}),m&&m.length>0?e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsx("div",{className:"rounded-lg border p-4 transition-colors hover:bg-gray-50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(v,{className:"h-4 w-4 text-blue-600"}),e.jsx("span",{className:"font-medium",children:s.backup_name})]}),e.jsx("span",{className:`rounded-full px-2 py-1 text-xs ${s.status==="completed"?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:s.status})]}),e.jsxs("div",{className:"text-muted-foreground grid grid-cols-1 gap-4 text-sm md:grid-cols-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-4 w-4"}),e.jsx("span",{children:h(s.created_at)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{className:"h-4 w-4"}),e.jsxs("span",{children:["Source: ",n(s.source_code_size)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{className:"h-4 w-4"}),e.jsxs("span",{children:["Database: ",n(s.database_size)]})]})]}),s.notes&&e.jsxs("div",{className:"mt-2 text-sm text-gray-500",children:[e.jsx("strong",{children:"Notes:"})," ",s.notes]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{type:"button",variant:"ghost",onClick:F,loading:x.processing,disabled:x.processing,children:e.jsxs("div",{className:"text-secondary-foreground flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4"}),e.jsx("span",{children:"Refresh"})]})}),e.jsxs(i,{variant:"ghost",onClick:()=>P(s),className:"flex items-center gap-1 rounded-md px-3 py-2 text-blue-600 transition-colors hover:bg-blue-50 hover:text-blue-800",title:"Restore backup",children:[e.jsx(j,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:"Restore"})]}),e.jsx(U,{backup:s}),e.jsxs(i,{variant:"ghost",onClick:()=>z(s),className:"flex items-center gap-1 rounded-md px-3 py-2 text-red-600 transition-colors hover:bg-red-50 hover:text-red-800",title:"Delete backup",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:"Delete"})]})]})]})},s.id))}):e.jsxs("div",{className:"py-8 text-center text-gray-500",children:[e.jsx(v,{className:"mx-auto mb-3 h-12 w-12 opacity-50"}),e.jsx("p",{children:"No recent backups found."}),e.jsx("p",{className:"text-sm",children:"Create your first backup using the form above."})]})]})]})};export{Y as default};
|