import{e as R,S as G,N as U,b as C,r as o,P as H,f as i,g as a,v as _,q as n,x as y,T as d,U as c,s as t,K as q,a0 as K,as as M,X as m,j as D,k as B,B as O,Y as X,au as Y,bb as J,ar as Q}from"./jwt-decode.esm-CX61wVx3.js";import{C as N,d as W}from"./router-C3xfRTQ9.js";import{i as T}from"./featureFlags-BIpZLr-p.js";import{u as Z}from"./projectStore-VaavZXIZ.js";import{C as ee}from"./index-GnIaed8S.js";import{A}from"./index-BOb0Rqlm.js";import"./ts.worker-DBbJtN2A.js";import"./member-Mqwx3LJ6.js";import"./project-BBDdDK81.js";import"./tables-uXC0iev6.js";import"./string-BfaOmKtt.js";import"./organizationSwitcher-BGkTY3e2.js";import"./organization-CGHGUCUV.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[l]="a7565a2b-e44d-4c76-a5d8-3e1bef590656",u._sentryDebugIdIdentifier="sentry-dbid-a7565a2b-e44d-4c76-a5d8-3e1bef590656")}catch{}})();class ae{async get(l){return N.get(`projects/${l}/app-releases`)}async promote(l,v){return N.post(`projects/${l}/app-releases`,v)}}const te={key:2,class:"publish-form"},se={class:"build-line"},le={class:"gate-error-list"},re=R({__name:"AppReleases",setup(u){const l=G.TextArea,v=U(),g=Z(),S=new ae,E=C(()=>T(g.organization?.featureFlags,"APP_PUBLISHING")),I=o(!0),j=o(!1),f=o(null),P=o([]),r=o(null),b=o(""),h=o([]),k=o(null),$=C(()=>f.value?`Publish an update to "${f.value.name}" (${f.value.slug})`:"Publish this project as an App"),z=C(()=>r.value?new Date(r.value.createdAt).toLocaleString():""),F=[{title:"Version",dataIndex:"version",key:"version"},{title:"Published",key:"publishedAt"},{title:"Migrations",key:"migrations"},{title:"Changelog",dataIndex:"changelog",key:"changelog",ellipsis:!0}];async function x(){I.value=!0;try{const s=await S.get(g.projectId);f.value=s.app,P.value=s.releases,r.value=s.latestBuild}finally{I.value=!1}}async function L(){const s=r.value;if(!(!s||s.releasedVersion)){j.value=!0,h.value=[],k.value=null;try{const e=await S.promote(g.projectId,{buildId:s.id,changelog:b.value||void 0});e.ok?(k.value=e.release.version,b.value=""):h.value=e.errors}catch(e){if(e instanceof W)h.value=e.validationErrors?.length?e.validationErrors:[e.message];else throw e}finally{j.value=!1,await x()}}}let V=!1;return H(()=>g.organization,s=>{if(s){if(!T(s.featureFlags,"APP_PUBLISHING")){v.replace({name:"workflow",params:{projectId:g.projectId}});return}V||(V=!0,x())}},{immediate:!0}),(s,e)=>(a(),i(m,null,[_(t(K),null,{default:y(()=>[d(c(t(q).translate("i18n_projectview_app_releases")),1)]),_:1}),!E.value||I.value?(a(),n(t(M),{key:0,style:{width:"100%","margin-top":"3rem"}})):(a(),i(m,{key:1},[_(t(ee),{title:$.value,size:"small",class:"publish-card"},{default:y(()=>[r.value?r.value.releasedVersion?(a(),n(t(A),{key:1,type:"info","show-icon":"",message:`The current deploy is already published as version ${r.value.releasedVersion}`,description:"Deploy the project again to publish a new release."},null,8,["message"])):(a(),i("div",te,[B("p",se,[e[1]||(e[1]=d(" Publishing the deploy from ",-1)),B("strong",null,c(z.value),1),d(" ("+c(r.value.id.slice(0,8))+") ",1)]),_(t(l),{value:b.value,"onUpdate:value":e[0]||(e[0]=p=>b.value=p),rows:3,placeholder:"Changelog — what changed in this release?"},null,8,["value"]),_(t(O),{type:"primary",class:"publish-button",loading:j.value,onClick:L},{default:y(()=>[...e[2]||(e[2]=[d(" Publish Release ",-1)])]),_:1},8,["loading"])])):(a(),n(t(A),{key:0,type:"info","show-icon":"",message:"Nothing to publish yet",description:"A release ships this project's current deploy. Deploy the project, then come back here."})),h.value.length?(a(),n(t(A),{key:3,type:"error","show-icon":"",class:"gate-errors",message:"The publish gate rejected this release"},{description:y(()=>[B("ul",le,[(a(!0),i(m,null,X(h.value,(p,w)=>(a(),i("li",{key:w},c(p),1))),128))])]),_:1})):k.value?(a(),n(t(A),{key:4,type:"success","show-icon":"",class:"gate-errors",message:`Version ${k.value} published`},null,8,["message"])):D("",!0)]),_:1},8,["title"]),P.value.length===0?(a(),n(t(Y),{key:0,description:"No releases yet — the first publish creates this project's App.",style:{"margin-top":"3rem"}})):(a(),n(t(J),{key:1,"data-source":P.value,columns:F,pagination:{pageSize:20,hideOnSinglePage:!0},"row-key":"id",size:"small",class:"releases-table"},{bodyCell:y(({column:p,record:w})=>[p.key==="migrations"?(a(),i(m,{key:0},[d(c(w.migrationsCount),1)],64)):p.key==="publishedAt"?(a(),i(m,{key:1},[d(c(new Date(w.publishedAt).toLocaleString()),1)],64)):D("",!0)]),_:1},8,["data-source"]))],64))],64))}}),be=Q(re,[["__scopeId","data-v-26d1e671"]]);export{be as default};
//# sourceMappingURL=AppReleases-CALwLH68.js.map
