lms/public/build/assets/application-update-CJkViDLi.js
2025-12-15 12:26:23 +01:00

2 lines
7.6 KiB
JavaScript

import{r as a,b,j as e,U as N,cZ as v,d5 as H,ca as L,e as M}from"./vendor-BKmmeuxg.js";import{C as P}from"./chunked-uploader-input-D0XPVOTS.js";import{I as z}from"./input-error-LaPr_4wd.js";import{L as m}from"./loading-button-BnTVAMJ7.js";import{B as c}from"./button-BpNwv2aE.js";import{C as O,a as V,b as Z}from"./card-D9_SJYq6.js";import{D as y,a as G,b as w,d as S,g as C,e as U,f as k,c as q}from"./dialog-B2gN9MvT.js";import{L as J}from"./label-HmIcv5Yx.js";import{S as K}from"./scroll-area-C8HGru-R.js";import"./input-DM0goJrn.js";import"./utils-DxSsnXxD.js";import"./index-D9-QKOod.js";import"./index-WW_1X1qx.js";const de=({version:i})=>{const[D,n]=a.useState(!1),[p,x]=a.useState(!1),[t,h]=a.useState(!1),[d,u]=a.useState(!1),[o,j]=a.useState(""),{data:g,setData:F,post:R,errors:_,processing:r,reset:A}=b({update_file_url:""}),f=b({}),I=()=>{f.post(route("system.refresh"))},E=async s=>{if(s.preventDefault(),d){h(!0);return}},l=()=>{h(!1),u(!1),j(""),A("update_file_url")};a.useEffect(()=>{g.update_file_url&&t&&R(route("system.update"),{onSuccess:()=>{n(!1),l()},onError:()=>{l()}})},[g.update_file_url]);const B=s=>{t?n(!0):(n(s),s||l())},T=()=>{x(!0),M.get(route("system.update.seeder"),{},{onFinish:()=>x(!1)})};return e.jsxs(e.Fragment,{children:[e.jsxs(O,{className:"border-2",children:[e.jsxs(V,{className:"p-4 sm:p-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-xl font-semibold",children:[e.jsx(N,{className:"text-warning h-5 w-5"}),"Application Update"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload and install the latest version of your application"})]}),e.jsxs(Z,{className:"space-y-6 p-4 pt-0 sm:p-6 sm:pt-0",children:[e.jsx("div",{className:"dark:bg-secondary dark:border-border 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(v,{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.jsxs("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"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Backup First:"})," Always create a backup before updating"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"File Format:"})," Upload must be a valid ZIP file"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Maintenance Mode:"})," Site will be temporarily unavailable during update"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Migrations:"})," Database migrations will be automatically applied"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Downtime:"})," Update process may take several minutes"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Browser:"})," Do not refresh or close browser during update"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Seeder:"})," Run seeder only after updating the application version"]})]})})]})]})}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsx(m,{type:"button",variant:"secondary",onClick:I,loading:f.processing,disabled:r||t,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4"}),e.jsx("span",{children:"Refresh Server"})]})}),e.jsxs(c,{type:"button",onClick:()=>n(!0),children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx("span",{children:t?"Uploading...":r?"Updating Application...":"Update Application"})]}),e.jsxs(y,{children:[e.jsx(G,{asChild:!0,children:e.jsxs(c,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 text-destructive hover:text-destructive",children:["Run ",i," Version Seeder"]})}),e.jsxs(w,{children:[e.jsxs(S,{children:["Run Version ",i," Seeder"]}),e.jsxs(C,{className:"space-y-2",children:[e.jsxs("p",{children:["This will run the database seeder for version ",i,"."]}),e.jsxs("div",{className:"rounded-md bg-yellow-50 p-3 text-sm text-yellow-700",children:[e.jsx("p",{className:"font-medium",children:"Important Notes:"}),e.jsxs("ul",{className:"mt-1 list-inside list-disc space-y-1",children:[e.jsxs("li",{children:["Run this seeder only once after updating to version ",i]}),e.jsx("li",{children:"Running this multiple times will overwrite existing data"}),e.jsx("li",{children:"Do not run this seeder after you have added your own content to the website"})]})]})]}),e.jsxs(U,{className:"gap-2",children:[e.jsx(k,{asChild:!0,children:e.jsx(c,{type:"button",variant:"secondary",children:"Cancel"})}),e.jsx(m,{variant:"destructive",loading:p,disabled:p,className:"text-primary-foreground",onClick:T,children:"Run Seeder"})]})]})]})]})]})]}),e.jsx(y,{open:D,onOpenChange:B,children:e.jsxs(w,{className:"sm:max-w-[500px]",children:[r&&e.jsx("div",{className:"bg-background/80 absolute inset-0 z-50 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:"Updating application..."}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Please do not close this window"})]})}),e.jsxs(K,{className:"max-h-[90vh]",children:[e.jsxs(q,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-5 w-5 text-orange-600"}),"Confirm Application Update"]}),e.jsxs(C,{className:"space-y-4 text-left",children:[e.jsxs("p",{children:["Are you sure you want to update the application with ",e.jsxs("strong",{children:['"',o,'"']}),"?"]}),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 update 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:"Replace all application files"}),e.jsx("li",{children:"Run database migrations"}),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:"⚠️ Important:"}),e.jsx("p",{className:"text-sm text-red-700",children:"Make sure you have created a backup first! This action cannot be undone."})]})]})]}),e.jsxs("form",{onSubmit:E,className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx(J,{children:"Select File (.zip only)"}),e.jsx(P,{isSubmit:t,storage:"local",filetype:"zip",delayUpload:!1,onFileSelected:s=>{u(!0),j(s.name)},onFileUploaded:s=>{F("update_file_url",s.file_url)},onError:s=>{l()},onCancelUpload:()=>{l()}}),e.jsx(z,{message:String(_.update_file_url||"")})]}),d&&o&&e.jsx("div",{className:"rounded-lg border border-green-200 bg-green-50 p-3",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(L,{className:"mt-0.5 h-4 w-4 text-green-600"}),e.jsxs("div",{className:"ml-2",children:[e.jsxs("p",{className:"text-sm text-green-800",children:[e.jsx("strong",{children:"Selected file:"})," ",o]}),e.jsx("p",{className:"mt-1 text-xs text-blue-600",children:'File selected successfully. Click "Update Application" to proceed.'})]})]})}),e.jsxs(U,{className:"w-full justify-between space-x-2 pt-8",children:[e.jsx(k,{asChild:!0,children:e.jsx(c,{type:"button",variant:"outline",children:"Close"})}),e.jsx(m,{type:d?"submit":"button",disabled:r||t||!d,loading:r||t,children:t?"Uploading...":"Update Application"})]})]})]})]})})]})};export{de as default};