@objectstack/console 17.0.0-rc.3 → 17.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -1
- package/dist/.objectui-sha +1 -1
- package/dist/assets/AdapterProvider-D5_dIBsl.js +2 -0
- package/dist/assets/{AiPendingActionsPage-CJwQWg1W.js → AiPendingActionsPage-CVC7LIfi.js} +1 -1
- package/dist/assets/{ApiConsolePage-D0rZy0lx.js → ApiConsolePage-CpDU7ooT.js} +1 -1
- package/dist/assets/{AppDocsIndex-CQo6tZPY.js → AppDocsIndex-DFMKKZm6.js} +1 -1
- package/dist/assets/{AppManagementPage-jLhhl_WS.js → AppManagementPage-Cot1HC5W.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-ruj1cfw8.js +1 -0
- package/dist/assets/AuditLogPage-QwYEUDC7.js +1 -0
- package/dist/assets/{ComponentNavView-4vcZh2oX.js → ComponentNavView-BzOXbmFy.js} +1 -1
- package/dist/assets/CreateViewDialog-DZQW3zK4.js +1 -0
- package/dist/assets/{DashboardView-S5Fshq0v.js → DashboardView-CWd5f0LK.js} +1 -1
- package/dist/assets/{DeveloperHubPage-yTPx0th5.js → DeveloperHubPage-CdgOf6lM.js} +1 -1
- package/dist/assets/{DocShell-BhkelvR8.js → DocShell-BAMZcj4T.js} +1 -1
- package/dist/assets/{ExpressionProvider-BQFSoabd.js → ExpressionProvider-BKktrnvG.js} +1 -1
- package/dist/assets/FlowRunsPage-Cr-PKPag.js +1 -0
- package/dist/assets/{IntegrationsPage-BWBfrCWI.js → IntegrationsPage-CmkmHyHB.js} +2 -2
- package/dist/assets/{InterfaceListPage-DcFmVgXg.js → InterfaceListPage-Bf9_sd45.js} +1 -1
- package/dist/assets/{ManagedByBadge-pdWk_Jcc.js → ManagedByBadge-BPiPq6-K.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-DDTfnIA8.js → MarketplaceAccessDenied-DQYD2Yla.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-Byn6Undk.js → MarketplaceInstalledPage-BvHt07_e.js} +1 -1
- package/dist/assets/MarketplacePackagePage-Duz9UzE3.js +4 -0
- package/dist/assets/{MarketplacePage-Dt4ldkBx.js → MarketplacePage-BfYSidiA.js} +1 -1
- package/dist/assets/{MetadataInspector-B7LigfJm.js → MetadataInspector-DZP7_4Ng.js} +1 -1
- package/dist/assets/{MetadataProvider-D9fSVVZp.js → MetadataProvider-C5EAtW6M.js} +1 -1
- package/dist/assets/ObjectDataPage-EBvhhSu8.js +1 -0
- package/dist/assets/PageView-DHw-8JWT.js +1 -0
- package/dist/assets/ProfilePage-BFO0o43s.js +1 -0
- package/dist/assets/{PublicFormsPage-C3z0TH0k.js → PublicFormsPage-3RTLTTOX.js} +1 -1
- package/dist/assets/RecordDetailView-D6YP24Fu.js +9 -0
- package/dist/assets/RecordFormPage-CEuXajud.js +1 -0
- package/dist/assets/ReportDefaultInspector-CoVDiePd.js +3 -0
- package/dist/assets/ReportView-DU1WEs9f.js +2 -0
- package/dist/assets/{SearchResultsPage-Ct2q9Lrf.js → SearchResultsPage-BaK92Vl2.js} +1 -1
- package/dist/assets/SettingsHub-BkazZzY4.js +1 -0
- package/dist/assets/SettingsView-BxS4_zm8.js +1 -0
- package/dist/assets/{SystemHubPage-BSunYA-X.js → SystemHubPage-CwaVpP2G.js} +1 -1
- package/dist/assets/{createDerive-CGF05Hgy.js → createDerive-CeHn9TlT.js} +1 -1
- package/dist/assets/data-adapter-BbwX3ocs.js +32 -0
- package/dist/assets/{drillUrlFilters-BL8PeMrH.js → drillUrlFilters-DHAQHZbx.js} +1 -1
- package/dist/assets/framework-Dk4iu8ZK.js +8 -0
- package/dist/assets/{getIcon-D3yCrAri.js → getIcon-0xu011em.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-DrPiUj_V.js → highlighted-body-OFNGDK62-DaX2t0Np.js} +1 -1
- package/dist/assets/{i18n-DBmEJ9U1.js → i18n-BqOg8Sj-.js} +1 -1
- package/dist/assets/index-DwcytixP.css +2 -0
- package/dist/assets/index-QGTHTleH.js +2 -0
- package/dist/assets/{infrastructure-PXm1h5tB.js → infrastructure-V4ehxh8R.js} +2 -2
- package/dist/assets/maplibre-gl-shared.mjs +6 -0
- package/dist/assets/maplibre-gl-worker.mjs +6 -0
- package/dist/assets/mermaid-GHXKKRXX-DhkyRE-b.js +1 -0
- package/dist/assets/metadata-admin-CngSCs9l.js +25 -0
- package/dist/assets/plugin-calendar-BhbFZ1Dz.js +1 -0
- package/dist/assets/plugin-charts-DCnTkboW.js +7 -0
- package/dist/assets/plugin-chatbot-Cxk2I5E2.js +120 -0
- package/dist/assets/plugin-dashboard-Cc5zXaJZ.js +6 -0
- package/dist/assets/plugin-form-BPgojUr9.js +1 -0
- package/dist/assets/plugin-gantt-D5_Cski-.js +63 -0
- package/dist/assets/plugin-grid-DOeo-xLc.js +8 -0
- package/dist/assets/plugin-kanban-DO8gBhwP.js +1 -0
- package/dist/assets/{plugin-map-D0SLy13S.js → plugin-map-Ob_kDGyN.js} +1 -1
- package/dist/assets/{plugin-markdown-D7iZb8hK.js → plugin-markdown-mn_FYkeV.js} +1 -1
- package/dist/assets/plugin-report-DVVwWMiU.js +59 -0
- package/dist/assets/{plugin-timeline-C_svagQ1.js → plugin-timeline-rzVARN_g.js} +1 -1
- package/dist/assets/plugin-tree-BjFac627.js +1 -0
- package/dist/assets/plugin-view-DA6WPNHK.js +1 -0
- package/dist/assets/plugins-views-wOHCrjrA.js +4 -0
- package/dist/assets/{runtime-metadata-persistence-BjYxldgR.js → runtime-metadata-persistence-DrONSJyN.js} +1 -1
- package/dist/assets/{skeletons-C8REUFE6.js → skeletons-D41oCKnf.js} +1 -1
- package/dist/assets/src-DGFWwOg3.js +1 -0
- package/dist/assets/{src-E-Ibo9NH.js → src-aYMNjfWn.js} +1 -1
- package/dist/assets/src-rZhRmjZV.js +19 -0
- package/dist/assets/ui-components-BioReIdK.js +72 -0
- package/dist/assets/ui-layout-CSKVB0dn.js +1 -0
- package/dist/assets/{use-book-data-D8LHn21q.js → use-book-data-DoM93RB0.js} +1 -1
- package/dist/assets/useOpenRecordList-CptPt5Mv.js +1 -0
- package/dist/assets/useSettingsLabel-JZ_zJ7Ow.js +1 -0
- package/dist/assets/vendor-objectstack-Dm5CaPeY.js +184 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/AdapterProvider-Bur-uZKZ.js +0 -2
- package/dist/assets/ApprovalsInboxPage-COyyj1KQ.js +0 -1
- package/dist/assets/AuditLogPage-CxGLPqlB.js +0 -1
- package/dist/assets/CreateViewDialog-C6sZGaIB.js +0 -1
- package/dist/assets/FlowRunsPage-DGyj2PBP.js +0 -1
- package/dist/assets/MarketplacePackagePage-DZkqNaao.js +0 -4
- package/dist/assets/ObjectDataPage-BZ4pf0ji.js +0 -1
- package/dist/assets/PageView-B8qkF17f.js +0 -1
- package/dist/assets/ProfilePage-Do9aTArT.js +0 -1
- package/dist/assets/RecordDetailView-CP1b5rdr.js +0 -9
- package/dist/assets/RecordFormPage-CyAjEE1O.js +0 -1
- package/dist/assets/ReportDefaultInspector-BqgFtk2E.js +0 -3
- package/dist/assets/ReportView-CfQ-Z9TJ.js +0 -2
- package/dist/assets/SettingsHub-C-7kyHtx.js +0 -1
- package/dist/assets/SettingsView-HmY6cAH1.js +0 -1
- package/dist/assets/data-adapter-rnhaIuyx.js +0 -32
- package/dist/assets/framework-UESyszCj.js +0 -8
- package/dist/assets/index-AHnJRZYu.css +0 -2
- package/dist/assets/index-U6sSlA28.js +0 -2
- package/dist/assets/mermaid-GHXKKRXX-DicGABpj.js +0 -1
- package/dist/assets/metadata-admin-Ci8bBNxq.js +0 -25
- package/dist/assets/plugin-calendar-WGoi_n7i.js +0 -1
- package/dist/assets/plugin-charts-CK8c0x6J.js +0 -7
- package/dist/assets/plugin-chatbot-DmEp7ZGx.js +0 -120
- package/dist/assets/plugin-dashboard-Cz2sTF7I.js +0 -6
- package/dist/assets/plugin-form-D_JAwPGr.js +0 -1
- package/dist/assets/plugin-gantt-BQGs0Vpj.js +0 -63
- package/dist/assets/plugin-grid-CKEYn10A.js +0 -8
- package/dist/assets/plugin-kanban-TdXxukPA.js +0 -1
- package/dist/assets/plugin-report-CPE7yyd4.js +0 -59
- package/dist/assets/plugin-tree-ieUxQVUL.js +0 -1
- package/dist/assets/plugin-view-Dy9ZzWYn.js +0 -1
- package/dist/assets/plugins-views-CJKuyDvq.js +0 -4
- package/dist/assets/src-CSrGzA_t.js +0 -19
- package/dist/assets/src-DzTCerTm.js +0 -1
- package/dist/assets/ui-components-BbC0qTrK.js +0 -72
- package/dist/assets/ui-layout-C3eKqnNJ.js +0 -1
- package/dist/assets/useOpenRecordList-aRVznRXU.js +0 -1
- package/dist/assets/useSettingsLabel-By0A6m6P.js +0 -1
- package/dist/assets/vendor-objectstack-CWf5hLam.js +0 -180
package/dist/index.html
CHANGED
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
<script>
|
|
47
47
|
window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
|
|
48
48
|
</script>
|
|
49
|
-
<script type="module" crossorigin src="./assets/index-
|
|
49
|
+
<script type="module" crossorigin src="./assets/index-QGTHTleH.js"></script>
|
|
50
50
|
<link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
|
|
51
51
|
<link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
|
|
52
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
53
|
-
<link rel="modulepreload" href="./assets/framework-
|
|
54
|
-
<link rel="modulepreload" href="./assets/ui-components-
|
|
52
|
+
<link rel="stylesheet" crossorigin href="./assets/index-DwcytixP.css">
|
|
53
|
+
<link rel="modulepreload" href="./assets/framework-Dk4iu8ZK.js" />
|
|
54
|
+
<link rel="modulepreload" href="./assets/ui-components-BioReIdK.js" />
|
|
55
55
|
<link rel="modulepreload" href="./assets/vendor-radix-BGBSy4-W.js" />
|
|
56
56
|
<link rel="modulepreload" href="./assets/vendor-react-DpRf6e0g.js" />
|
|
57
57
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/console",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.5",
|
|
4
4
|
"description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/objectstack-ai/objectstack/tree/main/packages/console",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{y as r}from"./infrastructure-PXm1h5tB.js";import{j as i}from"./framework-UESyszCj.js";import{nl as a}from"./ui-components-BbC0qTrK.js";import{r as o}from"./vendor-ui-utils-CnzHPXVC.js";import{t as s}from"./data-adapter-rnhaIuyx.js";var c=e(n(),1),l=0,u=new Set,d=[];function f(){for(let e of u)try{e(l)}catch{}if(l===0&&d.length>0){let e=d;d=[];for(let t of e)try{t()}catch{}}}function p(){l+=1,f()}function m(){l=Math.max(0,l-1),f()}function h(){return l}function g(){return l===0}function _(e){return u.add(e),()=>{u.delete(e)}}function v(e=1e4){return l===0?Promise.resolve():new Promise(t=>{let n=!1,r=()=>{n||(n=!0,t())};d.push(r),e>0&&typeof setTimeout<`u`&&setTimeout(r,e)})}function y(e){return(async(...t)=>{p();try{return await e(...t)}finally{m()}})}function b(){if(typeof window>`u`)return;let e=window,t=e.__objectui??={};Object.defineProperty(t,"pendingRequests",{get:h,configurable:!0}),Object.defineProperty(t,"idle",{get:g,configurable:!0}),t.whenIdle=v,t.subscribe=_}var x=t();function S(e,t){let n=new Map;for(let t of e.droppedFields){let e=n.get(t.reason)??[];for(let n of t.fields)e.includes(n)||e.push(n);n.set(t.reason,e)}let r=[];for(let[e,i]of n){if(i.length===0)continue;let n=i.join(`, `);r.push(e===`readonly_when`?t(`detail.writeStrippedByState`,{fields:n,defaultValue:`Not editable in this record's current state, so it was not saved: {{fields}}`}):t(`detail.writeStrippedReadonly`,{fields:n,defaultValue:`Read-only, so it was not saved: {{fields}}`}))}r.length!==0&&o.warning(t(`detail.writeStrippedTitle`,{defaultValue:`Some fields were not saved`}),{description:r.join(`
|
|
2
|
-
`)})}function C({children:e,adapter:t}){let[n,o]=(0,c.useState)(t??null),{t:l}=a(),u=(0,c.useRef)(l);return u.current=l,(0,c.useEffect)(()=>{if(t){o(t);return}let e=!1,n;b();async function i(){try{let t=new s({baseUrl:``,fetch:y(r()),autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});n=t.onWriteWarning(e=>S(e,u.current)),await t.connect(),e||o(t)}catch(t){e||console.error(`[Console] Failed to initialize:`,t)}}return i(),()=>{e=!0,n?.()}},[t]),(0,x.jsx)(i.Provider,{value:n,children:e})}export{y as n,C as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,h as n,m as r,r as i,y as a}from"./vendor-react-DpRf6e0g.js";import{_ as o,b as s,y as ee}from"./infrastructure-PXm1h5tB.js";import{Ar as te,At as ne,Cr as c,Dr as re,Fr as ie,Ft as l,Gc as u,Ic as ae,Ir as oe,It as d,Ji as se,Jr as ce,Kr as le,Lr as ue,Ls as de,Lt as fe,Mi as pe,Mr as me,Ms as he,Mt as ge,Nr as _e,Nt as ve,Or as ye,Pr as be,Pt as xe,Rr as Se,Rs as Ce,Rt as we,Tn as Te,Xs as Ee,_n as De,_r as Oe,ac as ke,an as f,cn as Ae,ct as je,dn as Me,dt as Ne,fn as Pe,gn as Fe,gr as Ie,hn as p,jr as Le,jt as Re,kt as ze,ln as Be,mn as Ve,nc as He,nl as Ue,oa as We,pn as Ge,ps as Ke,qi as qe,qs as Je,rc as Ye,sn as Xe,st as Ze,ti as Qe,un as $e,vr as et,wa as tt,ws as nt,zr as m}from"./ui-components-BbC0qTrK.js";import{r as h}from"./vendor-ui-utils-CnzHPXVC.js";import{p as rt}from"./src-CSrGzA_t.js";var g=e(a(),1),it=`${``.replace(/\/$/,``)}/api/v1`;async function _(e,t){let n=s.get(),r=await fetch(`${it}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{},...t?.headers||{}},...t}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.code??`HTTP_${r.status}`,t=i?.message??i?.error??r.statusText,n=Error(`${e}: ${t}`);throw n.code=e,n.status=r.status,n.details=i,n}return i}var v={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return _(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return _(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await _(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return _(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return _(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function at(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var y=i(),ot=50,b={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function st({status:e,label:t}){return(0,y.jsx)(c,{variant:`outline`,className:u(`font-medium`,b[e]??``),children:t})}function ct(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function x(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function S(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function C(e){return e.process_label||S(e.process_name)}function lt(e){return e.step_label?e.step_label:e.current_step?S(e.current_step):null}function ut(e){return e.submitter_name||x(e.submitter_id)}function dt(e,t){return t.pending_approver_names?.[e]||x(e)}function w(e,t){let n=t.pending_approver_groups?.[e];return n&&n.length?n.join(` / `):void 0}function ft(e){let t=[],n=new Map;for(let r of e.pending_approvers||[]){let i=dt(r,e),a=w(r,e),o=a?`${i} ${a}`:i,s=n.get(o);s?(s.count+=1,r&&!s.title.split(`, `).includes(r)&&(s.title+=`, ${r}`)):(n.set(o,{label:i,group:a,count:1,title:r||i}),t.push(o))}return t.map(e=>n.get(e))}function pt(e){if(e.submitter_name)return!1;let t=(e.submitter_id||``).trim();return!t||t.startsWith(`flow:`)||t.startsWith(`system:`)}function mt(e){return e.object_label||e.object_name}function T(e){return e.submitted_at||e.created_at||void 0}function ht(e,t){let n=T(e);if(!n)return null;let r=Date.parse(n);return Number.isNaN(r)?null:(t-r)/36e5}function gt(e,t){if(e.status!==`pending`)return`text-muted-foreground`;let n=ht(e,t);return n==null?`text-muted-foreground`:n>72?`text-red-600 dark:text-red-400 font-medium`:n>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function _t(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}function vt(e,t){if(!e)return null;let n=Date.parse(e);return Number.isNaN(n)?null:{overdue:n<t,ms:Math.abs(t-n)}}var E=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function D(e){let t=e.split(`_`).filter(Boolean);return t.length>1&&t[t.length-1].toLowerCase()===`id`&&t.pop(),t.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function O(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var yt=/^[A-Za-z0-9_-]{15,}$/;function bt(e,t,n,r=6,i){if(!e||typeof e!=`object`||Array.isArray(e))return[];let a=[];for(let[o,s]of Object.entries(e)){if(E.has(o)||i&&o===i||s==null||typeof s==`object`||String(s).trim()===``)continue;let e=t?.[o];if(!(!e&&typeof s==`string`&&yt.test(s.trim())&&!/^\d+$/.test(s.trim()))&&(a.push([n?.[o]??D(o),e??O(o,s)]),a.length>=r))break}return a}var xt=/(amount|total|price|value|cost|sum|budget|salary|fee|revenue|balance|金额|总额|价格|费用|预算|金额)/i;function k(e){let t=e.payload;if(!t||typeof t!=`object`||Array.isArray(t))return null;for(let[n,r]of Object.entries(t)){if(E.has(n)||!xt.test(n))continue;let t=typeof r==`number`?r:typeof r==`string`&&r.trim()!==``&&Number.isFinite(Number(r))?Number(r):null;if(!(t==null||!Number.isFinite(t)))return{key:n,label:e.payload_labels?.[n]??D(n),value:t,display:e.payload_display?.[n]??t.toLocaleString()}}return null}function A(){let{t:e,language:i}=Ue(),{user:a}=o(),{appName:s}=r(),[it,_]=n(),b=(0,g.useMemo)(()=>at(a),[a]),S=(0,g.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),[w,ht]=(0,g.useState)(()=>Date.now());(0,g.useEffect)(()=>{let e=setInterval(()=>ht(Date.now()),6e4);return()=>clearInterval(e)},[]);let E=(0,g.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Math.round((w-t)/1e3);if(n<45)return S(`justNow`,`just now`);let r=Math.round(n/60);if(r<60)return S(`minutesAgo`,`{{count}}m ago`,{count:r});let a=Math.round(r/60);if(a<24)return S(`hoursAgo`,`{{count}}h ago`,{count:a});let o=Math.round(a/24);if(o<30)return S(`daysAgo`,`{{count}}d ago`,{count:o});try{return new Date(e).toLocaleDateString(i)}catch{return e}},[S,i,w]),D=(0,g.useCallback)(e=>{switch(e){case`pending`:return S(`statusPending`,`Pending`);case`approved`:return S(`statusApproved`,`Approved`);case`rejected`:return S(`statusRejected`,`Rejected`);case`recalled`:return S(`statusRecalled`,`Recalled`);case`returned`:return S(`statusReturned`,`Returned for revision`);default:return e}},[S]),O=(0,g.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?S(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?S(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?S(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?S(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?S(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[S]),yt=(0,g.useCallback)(e=>e.overdue?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:_t(e.ms)}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:_t(e.ms)}),[S]),xt=(0,g.useCallback)(e=>`/apps/${s||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[s]),[A,St]=(0,g.useState)(`pending`),[j,Ct]=(0,g.useState)([]),[wt,Tt]=(0,g.useState)(!1),[Et,Dt]=(0,g.useState)(!1),[Ot,M]=(0,g.useState)(null),[kt,At]=(0,g.useState)(null),[jt,Mt]=(0,g.useState)(0),[N,Nt]=(0,g.useState)(null),[P,F]=(0,g.useState)(null),[Pt,I]=(0,g.useState)([]),[Ft,It]=(0,g.useState)(!1),Lt=(0,g.useMemo)(()=>ee(),[]),Rt=(0,g.useCallback)(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await Lt(`${n}/api/v1/storage/files/${encodeURIComponent(e.id)}/url`);if(!r.ok)throw Error(`HTTP_${r.status}`);let i=await r.json().catch(()=>null),a=i?.data?.url??i?.url;if(!a)throw Error(`NO_URL`);let o=/^https?:\/\//i.test(a)?a:`${n}${a}`;t?t.location.href=o:window.open(o,`_blank`,`noopener`)}catch{t?.close(),h.error(S(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[Lt,S]),[L,zt]=(0,g.useState)(``),[R,Bt]=(0,g.useState)(``),[z,Vt]=(0,g.useState)(`all`),[B,Ht]=(0,g.useState)(`all`),[V,Ut]=(0,g.useState)(`all`),[Wt,Gt]=(0,g.useState)(`recent`),[H,Kt]=(0,g.useState)(new Set),[qt,Jt]=(0,g.useState)(!1),[U,Yt]=(0,g.useState)(null),[W,Xt]=(0,g.useState)(null),[Zt,Qt]=(0,g.useState)(null),[G,$t]=(0,g.useState)(``),[en,tn]=(0,g.useState)(!1),[nn,rn]=(0,g.useState)(-1);(0,g.useEffect)(()=>{if(A===`pending`)return;let e=window.setTimeout(()=>Bt(L),350);return()=>window.clearTimeout(e)},[L,A]);let K=(0,g.useCallback)(async()=>{Tt(!0),At(null);try{let e=[];if(A===`pending`)e=b.length?(await v.listRequests({status:`pending`,approverId:b})).data:[],Mt(e.length),M(null);else{let t={q:R||void 0,status:V===`all`?void 0:V,limit:ot,offset:0};if(A===`submitted`){let n=a?.id;if(n){let r=await v.listRequests({submitterId:n,...t});e=r.data,M(r.total??r.data.length)}else e=[],M(0)}else{let n=await v.listRequests(t);e=n.data,M(n.total??n.data.length)}b.length&&v.listRequests({status:`pending`,approverId:b}).then(e=>Mt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(T(t)||``).localeCompare(T(e)||``)),Ct(e)}catch(e){At(e?.message||String(e)),Ct([])}finally{Tt(!1)}},[A,b,a?.id,R,V]);(0,g.useEffect)(()=>{K()},[K]);let an=(0,g.useCallback)(async()=>{if(!(A===`pending`||Et)){Dt(!0);try{let e=await v.listRequests({submitterId:A===`submitted`?a?.id??void 0:void 0,q:R||void 0,status:V===`all`?void 0:V,limit:ot,offset:j.length});Ct(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&M(e.total)}catch(e){h.error(O(e,S(`loadFailed`,`Failed to load request`)))}finally{Dt(!1)}}},[A,Et,a?.id,R,V,j.length,O,S]),q=(0,g.useCallback)(async e=>{Nt(e),It(!0);try{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data)}catch(e){h.error(O(e,S(`loadFailed`,`Failed to load request`))),F(null),I([])}finally{It(!1)}},[O,S]),on=()=>{Nt(null),F(null),I([])};(0,g.useEffect)(()=>{let e=it.get(`request`);e&&(_(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[it]);let J=(0,g.useCallback)(()=>{b.length&&v.listRequests({status:`pending`,approverId:b}).then(e=>Mt(e.data.length)).catch(()=>{})},[b]),sn=(0,g.useCallback)(async e=>{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data),K()},[K]),cn=(0,g.useCallback)(async()=>{if(!P)return;let e=P.id;try{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data),K();let r=new Set(t.data.pending_approvers||[]),i=t.data.status===`pending`&&b.some(e=>r.has(e));if(A===`pending`&&!i){let t=Cn.current,n=t.findIndex(t=>t.id===e),r=t[n+1]??t[n-1];if(r&&r.id!==e){q(r.id);return}on()}}catch{sn(e)}},[P,b,A,K,q,on,sn]),ln=(0,g.useCallback)(async()=>{if(!(!P||!G.trim())){tn(!0);try{await v.comment(P.id,{actor_id:a?.id,comment:G.trim()}),$t(``),await sn(P.id)}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{tn(!1)}}},[P,G,a?.id,sn,O,S]),un=(0,g.useMemo)(()=>{if(!P||P.status!==`pending`)return!1;if(P.viewer)return P.viewer.can_act||!!P.viewer.can_override;let e=new Set(P.pending_approvers||[]);return b.some(t=>e.has(t))},[P,b]),dn=(0,g.useMemo)(()=>!P||P.status!==`pending`?!1:P.viewer?P.viewer.is_submitter:P.submitter_id===a?.id,[P,a?.id]),fn=(0,g.useMemo)(()=>!P||P.status!==`returned`?!1:P.viewer?P.viewer.is_submitter:P.submitter_id===a?.id,[P,a?.id]),pn=(0,g.useMemo)(()=>{let e=new Set;for(let t of j)e.add(C(t));return Array.from(e).sort()},[j]),mn=(0,g.useMemo)(()=>{let e=new Set;for(let t of j)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[j]),Y=(0,g.useMemo)(()=>{let e=L.trim().toLowerCase(),t=j.filter(t=>z!==`all`&&C(t)!==z||B!==`all`&&t.object_name!==B||V!==`all`&&t.status!==V?!1:A!==`pending`||!e||[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e));if(Wt===`recent`)return t;let n=[...t];return Wt===`amount`?n.sort((e,t)=>{let n=k(e)?.value,r=k(t)?.value;return n==null&&r==null?0:n==null?1:r==null?-1:r-n}):n.sort((e,t)=>(T(e)||``).localeCompare(T(t)||``)),n},[j,L,z,B,V,A,Wt]),X=(0,g.useMemo)(()=>N?Y.findIndex(e=>e.id===N):-1,[Y,N]);(0,g.useEffect)(()=>{if(H.size===0)return;let e=new Set(Y.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Kt(n)},[Y,H]),(0,g.useEffect)(()=>{nn>=Y.length&&rn(Y.length-1)},[Y.length,nn]);let hn=(0,g.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(b);return(e.pending_approvers||[]).some(e=>t.has(e))},[b]),Z=(0,g.useCallback)(e=>Array.isArray(e.decision_outputs)&&e.decision_outputs.length>0,[]),gn=(0,g.useCallback)(e=>hn(e)&&!Z(e),[hn,Z]),Q=(0,g.useMemo)(()=>Y.filter(e=>H.has(e.id)&&gn(e)),[Y,H,gn]),$=Y.filter(e=>e.status===`pending`),_n=$.length>0&&$.every(e=>H.has(e.id)),vn=(0,g.useCallback)(()=>{Kt(e=>{if(_n)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[_n,$]),yn=(0,g.useCallback)(e=>{Kt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),bn=(0,g.useCallback)(async e=>{let t=Q;if(t.length===0)return;Jt(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),o=b.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?v.approve:v.reject)(i.id,{actor_id:o}),n++}catch{r.push(i.record_title||x(i.record_id))}}if(Jt(!1),Kt(new Set),r.length===0)h.success(e===`approve`?S(`bulkApproved`,`Approved {{count}} requests`,{count:n}):S(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);h.error(S(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,b,a?.id,K,J,S]),xn=(0,g.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=b.find(e=>t.has(e))||a?.id||``;Qt(e.id),Yt(null);try{let t=await v.approve(e.id,{actor_id:n});h.success(t.finalized?S(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||x(e.record_id)}):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{Qt(null)}},[U,b,a?.id,K,J,O,S]),Sn=(0,g.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=b.find(e=>t.has(e))||a?.id||``;Qt(e.id),Xt(null);try{await v.reject(e.id,{actor_id:n}),h.success(S(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||x(e.record_id)})),K(),J()}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{Qt(null)}},[W,b,a?.id,K,J,O,S]),Cn=(0,g.useRef)(Y);Cn.current=Y;let wn=(0,g.useRef)(nn);wn.current=nn,(0,g.useEffect)(()=>{let e=e=>{if(N||U||W)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Cn.current;if(!r.length)return;let i=wn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),rn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),rn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&A===`pending`?(e.preventDefault(),yn(r[i].id)):e.key===`a`&&i>=0&&r[i]&&gn(r[i])?(e.preventDefault(),Yt(r[i])):e.key===`r`&&i>=0&&r[i]&&gn(r[i])&&(e.preventDefault(),Xt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,U,W,A,q,yn,gn]),(0,g.useEffect)(()=>{if(!N)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Cn.current,i=r.findIndex(e=>e.id===N);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,q]);let Tn=!!L||z!==`all`||B!==`all`||V!==`all`,En=e=>{St(e),Ut(`all`),Vt(`all`),Ht(`all`),zt(``),Gt(`recent`),rn(-1)};function Dn({r:e}){return(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`font-medium truncate`,children:C(e)}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[lt(e)||`—`,(e.round??1)>1&&(0,y.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function On({r:e}){let n=k(e);return(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(t,{to:xt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,y.jsx)(`span`,{className:`truncate`,children:e.record_title||x(e.record_id)}),(0,y.jsx)(Ke,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[mt(e),n&&(0,y.jsxs)(`span`,{className:`ml-1.5 font-medium text-foreground`,title:`${n.label}: ${n.display}`,children:[`· `,n.display]})]})]})}function kn({r:e}){if(!hn(e))return null;let t=Zt===e.id,n=Z(e),r=S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`);return(0,y.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),title:n?r:void 0,children:[(0,y.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t||n,onClick:()=>Yt(e),"aria-label":n?r:S(`approve`,`Approve`),children:(0,y.jsx)(Je,{className:`h-4 w-4`})}),(0,y.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t||n,onClick:()=>Xt(e),"aria-label":n?r:S(`reject`,`Reject`),children:(0,y.jsx)(Ce,{className:`h-4 w-4`})})]})}return(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,y.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,y.jsx)(pe,{className:`h-6 w-6`}),S(`title`,`Approvals Inbox`)]}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(`subtitle`,`Review and act on approval requests.`)})]}),(0,y.jsxs)(m,{variant:`outline`,size:`sm`,onClick:K,disabled:wt,className:`self-start sm:self-auto`,children:[(0,y.jsx)(We,{className:`h-4 w-4 mr-2 ${wt?`animate-spin`:``}`}),S(`refresh`,`Refresh`)]})]}),kt&&(0,y.jsxs)(re,{variant:`destructive`,children:[(0,y.jsx)(Ee,{className:`h-4 w-4`}),(0,y.jsx)(ye,{children:kt})]}),(0,y.jsxs)(ze,{value:A,onValueChange:En,children:[(0,y.jsxs)(Re,{children:[(0,y.jsxs)(ge,{value:`pending`,children:[S(`tabMyPending`,`My Pending`),jt>0&&(0,y.jsx)(c,{variant:`secondary`,className:`ml-2`,children:jt})]}),(0,y.jsx)(ge,{value:`submitted`,children:S(`tabSubmitted`,`Submitted by me`)}),(0,y.jsx)(ge,{value:`all`,children:S(`tabAll`,`All`)})]}),(0,y.jsxs)(ne,{value:A,className:`mt-4 space-y-3`,children:[!wt&&(j.length>0||A!==`pending`&&(R||V!==`all`))&&(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,y.jsx)(se,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,y.jsx)(Te,{value:L,onChange:e=>zt(e.target.value),placeholder:S(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),L&&(0,y.jsx)(`button`,{type:`button`,onClick:()=>zt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":S(`clearSearch`,`Clear search`),children:(0,y.jsx)(le,{className:`h-3.5 w-3.5`})})]}),A!==`pending`&&(0,y.jsxs)(Ge,{value:V,onValueChange:Ut,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`statusFilter`,`Status`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allStatuses`,`All statuses`)}),(0,y.jsx)(p,{value:`pending`,children:D(`pending`)}),(0,y.jsx)(p,{value:`approved`,children:D(`approved`)}),(0,y.jsx)(p,{value:`rejected`,children:D(`rejected`)}),(0,y.jsx)(p,{value:`recalled`,children:D(`recalled`)}),(0,y.jsx)(p,{value:`returned`,children:D(`returned`)})]})]}),pn.length>1&&(0,y.jsxs)(Ge,{value:z,onValueChange:Vt,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`processFilter`,`Process`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allProcesses`,`All processes`)}),pn.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]})]}),mn.length>1&&(0,y.jsxs)(Ge,{value:B,onValueChange:Ht,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`objectFilter`,`Object`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allObjects`,`All objects`)}),mn.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]})]}),(0,y.jsxs)(Ge,{value:Wt,onValueChange:e=>Gt(e),children:[(0,y.jsxs)(Fe,{className:`h-8 w-auto min-w-[120px] text-sm`,children:[(0,y.jsx)(ae,{className:`h-3.5 w-3.5 mr-1 text-muted-foreground`}),(0,y.jsx)(De,{placeholder:S(`sortBy`,`Sort`)})]}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`recent`,children:S(`sortRecent`,`Newest first`)}),(0,y.jsx)(p,{value:`oldest`,children:S(`sortOldest`,`Oldest first`)}),(0,y.jsx)(p,{value:`amount`,children:S(`sortAmount`,`Amount (high→low)`)})]})]}),Tn&&(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:j.length})})]}),A===`pending`&&H.size>0&&(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`strong`,{children:H.size}),` `,S(`selected`,`selected`),Q.length!==H.size&&(0,y.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:S(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(te,{children:[(0,y.jsx)(Se,{asChild:!0,children:(0,y.jsxs)(m,{size:`sm`,disabled:qt||Q.length===0,children:[(0,y.jsx)(Je,{className:`h-3.5 w-3.5 mr-1`}),S(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,y.jsx)(be,{children:S(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>bn(`approve`),children:S(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,y.jsxs)(te,{children:[(0,y.jsx)(Se,{asChild:!0,children:(0,y.jsxs)(m,{size:`sm`,variant:`outline`,disabled:qt||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,y.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),S(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,y.jsx)(be,{children:S(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>bn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,y.jsx)(m,{size:`sm`,variant:`ghost`,onClick:()=>Kt(new Set),disabled:qt,children:S(`clear`,`Clear`)})]})]}),wt?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(f,{className:`h-10 w-full`}),(0,y.jsx)(f,{className:`h-10 w-full`}),(0,y.jsx)(f,{className:`h-10 w-full`})]}):j.length===0?(0,y.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,y.jsxs)(Ze,{children:[(0,y.jsx)(Ne,{children:S(`emptyTitle`,`No requests`)}),(0,y.jsx)(je,{children:A===`pending`?S(`emptyPending`,`You're all caught up — nothing is waiting on you.`):S(`emptyOther`,`Nothing here yet.`)}),A===`pending`&&(0,y.jsx)(m,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>En(`all`),children:S(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,y.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:S(`noMatches`,`No matches for current filters.`)}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Oe,{className:`hidden md:block`,children:(0,y.jsx)(et,{className:`p-0`,children:(0,y.jsxs)(ve,{children:[(0,y.jsx)(fe,{children:(0,y.jsxs)(we,{children:[A===`pending`&&(0,y.jsx)(d,{className:`w-10`,children:(0,y.jsx)(Ie,{checked:_n,onCheckedChange:vn,"aria-label":S(`selectAll`,`Select all`),disabled:$.length===0})}),(0,y.jsx)(d,{className:`w-[22%]`,children:S(`colRequest`,`Request`)}),(0,y.jsx)(d,{className:`w-[30%]`,children:S(`colRecord`,`Record`)}),(0,y.jsx)(d,{className:`w-[16%]`,children:S(`colRequester`,`Requester`)}),(0,y.jsx)(d,{className:`w-[110px] min-w-[96px] whitespace-nowrap`,children:S(`colStatus`,`Status`)}),(0,y.jsx)(d,{className:`w-[132px]`,children:S(`colWaiting`,`Submitted`)}),(0,y.jsx)(d,{className:`w-20`,"aria-label":S(`colActions`,`Actions`)})]})}),(0,y.jsx)(xe,{children:Y.map((e,t)=>(0,y.jsxs)(we,{className:u(`group cursor-pointer hover:bg-accent/50`,nn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{rn(t),q(e.id)},children:[A===`pending`&&(0,y.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,y.jsx)(Ie,{checked:H.has(e.id),onCheckedChange:()=>yn(e.id),disabled:e.status!==`pending`,"aria-label":S(`selectRow`,`Select request`)})}),(0,y.jsx)(l,{children:(0,y.jsx)(Dn,{r:e})}),(0,y.jsx)(l,{children:(0,y.jsx)(On,{r:e})}),(0,y.jsx)(l,{children:pt(e)?(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,y.jsx)(ce,{className:`h-3.5 w-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,y.jsx)(Qe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ut(e)})]})}),(0,y.jsx)(l,{children:(0,y.jsx)(st,{status:e.status,label:D(e.status)})}),(0,y.jsxs)(l,{className:u(`text-xs whitespace-nowrap`,gt(e,w)),title:ct(T(e)),children:[(0,y.jsx)(he,{className:`h-3 w-3 inline mr-1`}),E(T(e)),e.status===`pending`&&(()=>{let t=vt(e.sla_due_at,w);return t?(0,y.jsx)(`div`,{className:u(`mt-0.5 text-[10px] font-medium`,t.overdue?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:yt(t)}):null})()]}),(0,y.jsx)(l,{className:`w-20`,children:(0,y.jsx)(kn,{r:e})})]},e.id))})]})})}),(0,y.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,y.jsx)(Oe,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,y.jsxs)(et,{className:`p-3 space-y-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsx)(`div`,{className:`font-medium text-sm truncate`,children:C(e)}),(0,y.jsx)(st,{status:e.status,label:D(e.status)})]}),(0,y.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||x(e.record_id),(0,y.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:mt(e)}),(()=>{let t=k(e);return t?(0,y.jsxs)(`span`,{className:`text-xs ml-1.5 font-medium`,title:t.label,children:[`· `,t.display]}):null})()]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[pt(e)?(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate italic`,children:[(0,y.jsx)(ce,{className:`h-3 w-3`}),S(`flowOrigin`,`Flow-initiated`)]}):(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,y.jsx)(Qe,{className:`h-3 w-3`}),ut(e)]}),(0,y.jsxs)(`span`,{className:u(`inline-flex items-center gap-1 whitespace-nowrap`,gt(e,w)),children:[(0,y.jsx)(he,{className:`h-3 w-3`}),E(T(e))]})]}),hn(e)&&(0,y.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),title:Z(e)?S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`):void 0,children:[(0,y.jsxs)(m,{size:`sm`,className:`h-7 flex-1`,disabled:Zt===e.id||Z(e),onClick:()=>Yt(e),children:[(0,y.jsx)(Je,{className:`h-3.5 w-3.5 mr-1`}),S(`approve`,`Approve`)]}),(0,y.jsxs)(m,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Zt===e.id||Z(e),onClick:()=>Xt(e),children:[(0,y.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),S(`reject`,`Reject`)]})]})]})},e.id))}),A!==`pending`&&Ot!=null&&(0,y.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:j.length,total:Ot})}),j.length<Ot&&(0,y.jsx)(m,{size:`sm`,variant:`outline`,disabled:Et,onClick:()=>void an(),children:Et?S(`loadingMore`,`Loading…`):S(`loadMore`,`Load more`)})]}),(0,y.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:S(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,y.jsx)(te,{open:!!U,onOpenChange:e=>!e&&Yt(null),children:(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`approveOneTitle`,`Approve "{{title}}"?`,{title:U?U.record_title||x(U.record_id):``})}),(0,y.jsx)(be,{children:S(`approveOneBody`,`This approves the request with your identity. To add a comment or attachment, open the request instead.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>void xn(),children:S(`approve`,`Approve`)})]})]})}),(0,y.jsx)(te,{open:!!W,onOpenChange:e=>!e&&Xt(null),children:(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||x(W.record_id):``})}),(0,y.jsx)(be,{children:S(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>void Sn(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})}),(0,y.jsx)(Xe,{open:!!N,onOpenChange:e=>!e&&on(),children:(0,y.jsxs)(Ae,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,y.jsxs)($e,{children:[(0,y.jsx)(Me,{children:P?C(P):S(`drawerTitle`,`Approval Request`)}),(0,y.jsx)(Be,{children:P?lt(P)||mt(P):``})]}),P&&X>=0&&Y.length>1&&(0,y.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,y.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,y.jsx)(Ye,{className:`h-4 w-4 mr-0.5`}),S(`prevRequest`,`Previous`)]}),(0,y.jsx)(`span`,{children:S(`positionOf`,`Request {{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,y.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X>=Y.length-1,onClick:()=>{let e=Y[X+1];e&&q(e.id)},children:[S(`nextRequest`,`Next`),(0,y.jsx)(He,{className:`h-4 w-4 ml-0.5`})]})]}),Ft?(0,y.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,y.jsx)(f,{className:`h-6 w-3/4`}),(0,y.jsx)(f,{className:`h-6 w-1/2`}),(0,y.jsx)(f,{className:`h-20 w-full`})]}):P?(0,y.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,y.jsx)(st,{status:P.status,label:D(P.status)}),(P.round??1)>1&&(0,y.jsx)(c,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:P.round})}),(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:ct(T(P)),children:[(0,y.jsx)(he,{className:`h-3 w-3`}),S(`submittedAgo`,`Submitted {{when}}`,{when:E(T(P))})]}),P.completed_at&&(0,y.jsxs)(`span`,{children:[`· `,S(`completedAt`,`Completed {{when}}`,{when:E(P.completed_at)})]}),P.status===`pending`&&(()=>{let e=vt(P.sla_due_at,w);return e?(0,y.jsx)(c,{variant:`outline`,className:u(`text-[10px]`,e.overdue?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:yt(e)}):null})()]}),(()=>{let e=k(P),n=bt(P.payload,P.payload_display,P.payload_labels,6,e?.key);return(0,y.jsx)(Oe,{children:(0,y.jsxs)(et,{className:`p-4 space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(t,{to:xt(P),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,y.jsx)(`span`,{className:`truncate`,children:P.record_title||x(P.record_id)}),(0,y.jsx)(Ke,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:mt(P)})]}),(0,y.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,y.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:pt(P)?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ce,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{className:`italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Qe,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{title:P.submitter_id||``,children:ut(P)})]})})})]}),e&&(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.label}),(0,y.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,title:e.display,children:e.display})]}),n.length>0&&(0,y.jsx)(`div`,{className:u(`grid grid-cols-2 gap-x-4 gap-y-2 text-sm`,!e&&`border-t pt-3`),children:n.map(([e,t])=>(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,y.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),P.decision_progress&&(()=>{let e=P.decision_progress,t=(P.pending_approvers||[]).length;return(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.behavior===`per_group`?S(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:e.got,need:e.need}):S(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:e.got,need:e.need})}),e.behavior!==`per_group`&&P.status===`pending`&&t>0&&(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:S(`progressEligible`,`{{count}} eligible approver(s)`,{count:t})})]}),(0,y.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":e.need,"aria-valuenow":Math.min(e.got,e.need),"aria-label":S(`progressBar`,`Decision progress`),className:`flex gap-1`,children:e.need>0&&e.need<=12?Array.from({length:e.need}).map((t,n)=>(0,y.jsx)(`div`,{className:u(`h-1.5 flex-1 rounded-full`,n<e.got?`bg-emerald-500`:`bg-muted`)},n)):(0,y.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${e.need>0?Math.min(100,e.got/e.need*100):0}%`}})})}),e.groups&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.groups.map(e=>(0,y.jsxs)(c,{variant:`outline`,className:u(`text-[11px] gap-1`,e.satisfied?`border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),title:`${e.got}/${e.need}`,children:[e.satisfied?(0,y.jsx)(ke,{className:`h-3 w-3`}):(0,y.jsx)(de,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]})})(),P.status===`pending`&&(P.pending_approvers||[]).length>0&&(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:S(`waitingOn`,`Waiting on`)}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ft(P).map((e,t)=>(0,y.jsxs)(c,{variant:`outline`,className:`text-[11px]`,title:e.title,children:[e.label,e.group&&(0,y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`))})]})]})})})(),(P.flow_steps?.length??0)>1&&(0,y.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":S(`stepProgress`,`Approval steps`),children:P.flow_steps.map((e,t)=>(0,y.jsxs)(g.Fragment,{children:[t>0&&(0,y.jsx)(`div`,{className:u(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:u(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,y.jsx)(ke,{className:`h-3 w-3`}):t+1}),(0,y.jsx)(`span`,{className:u(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:S(`history`,`Activity`)}),Pt.length===0?(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`noActions`,`No actions yet.`)}):(0,y.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Pt.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?S(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===P.submitter_id?ut(P):x(e.actor_id)),r=e.action===`submit`?S(`actSubmit`,`Submitted`):e.action===`approve`?S(`actApprove`,`Approved`):e.action===`reject`?S(`actReject`,`Rejected`):e.action===`recall`?S(`actRecall`,`Recalled`):e.action===`reassign`?S(`actReassign`,`Reassigned`):e.action===`remind`?S(`actRemind`,`Reminder sent`):e.action===`request_info`?S(`actRequestInfo`,`Requested more info`):e.action===`comment`?S(`actComment`,`Commented`):e.action===`escalate`?S(`actEscalate`,`SLA escalated`):e.action===`revise`?S(`actRevise`,`Sent back for revision`):e.action===`resubmit`?S(`actResubmit`,`Resubmitted`):e.action;return(0,y.jsxs)(`li`,{className:`relative text-xs`,children:[(0,y.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,y.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,y.jsx)(`span`,{className:`font-medium`,children:r}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,y.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,y.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:ct(e.created_at),children:E(e.created_at)})]}),(()=>{let t=e;return e.action!==`reassign`||!t.reassign_from&&!t.reassign_to?null:(0,y.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:S(`reassignFromTo`,`from {{from}} to {{to}}`,{from:t.reassign_from_name??x(t.reassign_from),to:t.reassign_to_name??x(t.reassign_to)})})})(),e.comment&&(0,y.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void Rt(t),className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t.name||t.id,children:[(0,y.jsx)(tt,{className:`h-3 w-3`}),t.name||`${S(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id)})}),P.status===`pending`&&(un||dn)&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,y.jsx)(Te,{value:G,onChange:e=>$t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),ln())},placeholder:S(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,y.jsx)(m,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||en,onClick:()=>void ln(),children:(0,y.jsx)(qe,{className:`h-3.5 w-3.5`})})]})]}),P.payload!=null&&(0,y.jsxs)(`details`,{className:`group`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`rawData`,`Raw data (JSON)`)}),(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsx)(`div`,{className:`flex justify-end`,children:(0,y.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(P.payload,null,2)),h.success(S(`copied`,`Copied`))}catch{h.error(S(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,y.jsx)(nt,{className:`h-3 w-3`}),S(`copy`,`Copy`)]})}),(0,y.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(P.payload,null,2)})]})]}),P.status===`pending`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pe,{}),(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(rt,{objectName:`sys_approval_request`,record:P,location:`record_section`,label:S(`declaredActions`,`Actions`),onDone:()=>{cn()}}),!un&&(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:dn?S(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):S(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(P.pending_approvers||[]).map(e=>dt(e,P)).join(`, `)||`—`})})]})]}),fn&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pe,{}),(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,y.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,y.jsx)(m,{asChild:!0,size:`sm`,variant:`outline`,children:(0,y.jsxs)(t,{to:xt(P),children:[(0,y.jsx)(Ke,{className:`h-4 w-4 mr-1`}),S(`editRecordBtn`,`Edit record`)]})}),(0,y.jsx)(rt,{objectName:`sys_approval_request`,record:P,location:`record_section`,onDone:()=>{sn(P.id),K()}})]})]})]})]}):null]})})]})}export{A as ApprovalsInboxPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{Cr as r,Dr as i,Ft as a,It as o,Ji as ee,Kr as te,Lt as ne,Nt as re,Or as s,Pt as ie,Rt as c,Tn as l,Xs as u,Yi as ae,_n as d,_r as f,an as oe,cn as se,ct as ce,dn as le,dt as ue,fn as p,gn as m,hn as h,kn as g,ln as _,mn as v,oa as y,pn as b,sn as x,st as S,un as de,vr as C,zr as w}from"./ui-components-BbC0qTrK.js";var T=e(n(),1),E=t(),fe=`${``.replace(/\/$/,``)}/api/v1`,D=[`create`,`update`,`delete`,`restore`,`login`,`logout`,`permission_change`,`config_change`,`export`,`import`],O={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`},k=50;function A(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function j(e,t=24){return e?e.length>t?`${e.slice(0,t-1)}…`:e:`—`}function M(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function N(){let[e,t]=(0,T.useState)([]),[n,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`all`),[R,z]=(0,T.useState)(``),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(``),[W,G]=(0,T.useState)(``),[K,q]=(0,T.useState)(0),[J,Y]=(0,T.useState)(!1),[X,Z]=(0,T.useState)(null),Q=(0,T.useCallback)(async()=>{N(!0),F(null);try{let e={};I&&I!==`all`&&(e.action=I),R.trim()&&(e.object_name=R.trim()),B.trim()&&(e.user_id=B.trim()),H&&(e.created_at={...e.created_at||{},$gte:H}),W&&(e.created_at={...e.created_at||{},$lte:`${W}T23:59:59`});let n=new URLSearchParams;Object.keys(e).length>0&&n.set(`$filter`,JSON.stringify(e)),n.set(`$orderby`,`created_at desc`),n.set(`$top`,`51`),n.set(`$skip`,String(K*k));let r=await fetch(`${fe}/data/sys_audit_log?${n.toString()}`,{credentials:`include`});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`HTTP ${r.status}: ${e.slice(0,200)||r.statusText}`)}let i=await r.json(),a=Array.isArray(i)?i:Array.isArray(i?.records)?i.records:Array.isArray(i?.data)?i.data:[];Y(a.length>k),t(a.slice(0,k))}catch(e){console.warn(`[AuditLogPage] load failed:`,e),F(e?.message||`Failed to load audit log`),t([]),Y(!1)}finally{N(!1)}},[I,R,B,H,W,K]);(0,T.useEffect)(()=>{Q()},[Q]);let pe=(0,T.useCallback)(()=>{L(`all`),z(``),V(``),U(``),G(``),q(0)},[]),$=(0,T.useMemo)(()=>{let e=0;return I!==`all`&&(e+=1),R.trim()&&(e+=1),B.trim()&&(e+=1),H&&(e+=1),W&&(e+=1),e},[I,R,B,H,W]);return(0,E.jsxs)(`div`,{className:`p-6 space-y-4 max-w-screen-2xl mx-auto`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(ae,{className:`h-6 w-6 text-muted-foreground`}),(0,E.jsxs)(`div`,{className:`flex-1`,children:[(0,E.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Audit Log`}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only system activity and record changes. Newest first.`})]}),(0,E.jsxs)(w,{variant:`outline`,size:`sm`,onClick:Q,disabled:n,children:[(0,E.jsx)(y,{className:`h-4 w-4 mr-1 ${n?`animate-spin`:``}`}),`Refresh`]})]}),(0,E.jsx)(f,{children:(0,E.jsxs)(C,{className:`p-4 grid grid-cols-1 md:grid-cols-5 gap-3`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(g,{className:`text-xs`,children:`Action`}),(0,E.jsxs)(b,{value:I,onValueChange:e=>{L(e),q(0)},children:[(0,E.jsx)(m,{className:`h-9`,children:(0,E.jsx)(d,{})}),(0,E.jsxs)(v,{children:[(0,E.jsx)(h,{value:`all`,children:`All actions`}),D.map(e=>(0,E.jsx)(h,{value:e,children:e},e))]})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(g,{className:`text-xs`,children:`Object`}),(0,E.jsx)(l,{placeholder:`e.g. account`,value:R,onChange:e=>{z(e.target.value),q(0)},className:`h-9`})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(g,{className:`text-xs`,children:`Actor (user id)`}),(0,E.jsx)(l,{placeholder:`user id`,value:B,onChange:e=>{V(e.target.value),q(0)},className:`h-9`})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(g,{className:`text-xs`,children:`From`}),(0,E.jsx)(l,{type:`date`,value:H,onChange:e=>{U(e.target.value),q(0)},className:`h-9`})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(g,{className:`text-xs`,children:`To`}),(0,E.jsx)(l,{type:`date`,value:W,onChange:e=>{G(e.target.value),q(0)},className:`h-9`})]}),$>0&&(0,E.jsx)(`div`,{className:`md:col-span-5 flex justify-end`,children:(0,E.jsxs)(w,{variant:`ghost`,size:`sm`,onClick:pe,children:[(0,E.jsx)(te,{className:`h-4 w-4 mr-1`}),`Clear filters (`,$,`)`]})})]})}),P&&(0,E.jsxs)(i,{variant:`destructive`,children:[(0,E.jsx)(u,{className:`h-4 w-4`}),(0,E.jsx)(s,{children:P})]}),(0,E.jsx)(f,{children:(0,E.jsx)(C,{className:`p-0`,children:n&&e.length===0?(0,E.jsx)(`div`,{className:`p-6 space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,E.jsx)(oe,{className:`h-9 w-full`},t))}):e.length===0?(0,E.jsx)(`div`,{className:`p-12`,children:(0,E.jsxs)(S,{children:[(0,E.jsx)(ee,{className:`h-8 w-8 text-muted-foreground mb-3`}),(0,E.jsx)(ue,{children:`No audit entries`}),(0,E.jsx)(ce,{children:$>0?`Try clearing filters or widening the date range.`:`Events will appear here once tracked objects are modified.`})]})}):(0,E.jsxs)(re,{children:[(0,E.jsx)(ne,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{className:`w-[180px]`,children:`Timestamp`}),(0,E.jsx)(o,{className:`w-[130px]`,children:`Action`}),(0,E.jsx)(o,{children:`Object`}),(0,E.jsx)(o,{children:`Record`}),(0,E.jsx)(o,{children:`Actor`}),(0,E.jsx)(o,{className:`w-[130px]`,children:`IP`})]})}),(0,E.jsx)(ie,{children:e.map(e=>{let t=O[e.action||``]||`outline`;return(0,E.jsxs)(c,{className:`cursor-pointer`,onClick:()=>Z(e),children:[(0,E.jsx)(a,{className:`font-mono text-xs`,children:A(e.created_at)}),(0,E.jsx)(a,{children:(0,E.jsx)(r,{variant:t,children:e.action||`—`})}),(0,E.jsx)(a,{children:e.object_name||`—`}),(0,E.jsx)(a,{className:`font-mono text-xs`,children:j(e.record_id,18)}),(0,E.jsx)(a,{className:`font-mono text-xs`,children:j(e.user_id,18)}),(0,E.jsx)(a,{className:`font-mono text-xs`,children:e.ip_address||`—`})]},e.id)})})]})})}),(e.length>0||K>0)&&(0,E.jsxs)(`div`,{className:`flex items-center justify-between text-sm text-muted-foreground`,children:[(0,E.jsxs)(`span`,{children:[`Page `,K+1,J?``:` · end`]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(w,{variant:`outline`,size:`sm`,disabled:K===0||n,onClick:()=>q(e=>Math.max(0,e-1)),children:`Previous`}),(0,E.jsx)(w,{variant:`outline`,size:`sm`,disabled:!J||n,onClick:()=>q(e=>e+1),children:`Next`})]})]}),(0,E.jsx)(x,{open:!!X,onOpenChange:e=>!e&&Z(null),children:(0,E.jsxs)(se,{side:`right`,className:`sm:max-w-2xl w-full overflow-y-auto`,children:[(0,E.jsxs)(de,{children:[(0,E.jsxs)(le,{className:`flex items-center gap-2`,children:[(0,E.jsx)(r,{variant:X&&O[X.action||``]||`outline`,children:X?.action||`—`}),X?.object_name||`Audit Event`]}),(0,E.jsx)(_,{children:X?.id?(0,E.jsx)(`span`,{className:`font-mono text-xs`,children:X.id}):null})]}),X&&(0,E.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timestamp`}),(0,E.jsx)(`div`,{className:`font-mono`,children:A(X.created_at)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`IP Address`}),(0,E.jsx)(`div`,{className:`font-mono`,children:X.ip_address||`—`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Actor (user_id)`}),(0,E.jsx)(`div`,{className:`font-mono break-all`,children:X.user_id||`—`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Tenant`}),(0,E.jsx)(`div`,{className:`font-mono break-all`,children:X.tenant_id||`—`})]}),(0,E.jsxs)(`div`,{className:`col-span-2`,children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Target record`}),(0,E.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[X.object_name||`—`,` / `,X.record_id||`—`]})]}),X.user_agent&&(0,E.jsxs)(`div`,{className:`col-span-2`,children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`User Agent`}),(0,E.jsx)(`div`,{className:`font-mono text-xs break-all`,children:X.user_agent})]})]}),(X.old_value||X.new_value)&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(p,{}),(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsx)(`div`,{className:`text-sm font-medium`,children:`Change payload`}),X.old_value&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Before`}),(0,E.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.old_value)})]}),X.new_value&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`After`}),(0,E.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-64 overflow-auto`,children:M(X.new_value)})]})]})]}),X.metadata&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(p,{}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Metadata`}),(0,E.jsx)(`pre`,{className:`rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap max-h-48 overflow-auto`,children:M(X.metadata)})]})]})]})]})})]})}export{N as AuditLogPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{Gc as r,Ms as i,Ni as a,Oo as o,Tn as s,Xs as c,co as l,cr as u,dr as d,eo as f,fr as ee,go as p,hc as m,ji as h,lr as g,nl as _,pc as v,sr as y,ur as te,zr as b}from"./ui-components-BbC0qTrK.js";import{n as x}from"./createDerive-CGF05Hgy.js";import{a as S,i as C,n as w,o as T,r as E,s as ne,t as D}from"./plugin-view-Dy9ZzWYn.js";var O=e(n(),1),k=t();function A({title:e,description:t,icon:n,actions:i,accentColor:a,sticky:o=!1,className:s,"data-testid":c}){return(0,k.jsxs)(`div`,{style:{"--page-header-accent":a||`hsl(var(--primary))`},className:r(`relative shrink-0 border-b bg-background z-10`,o&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,s),"data-testid":c??`page-header`,children:[(0,k.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,k.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,k.jsx)(`div`,{className:r(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,k.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),i&&(0,k.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:i})]})]})}function j(e){return[{type:`grid`,icon:p,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:h,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:m,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:o,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:i,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:a,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:f,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:v,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:l,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function M(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var N={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:w}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>T(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:w},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function P({open:e,onOpenChange:t,onCreate:n,existingLabels:i,availableTypes:a,objectDef:o}){let{t:l}=_(),f=(0,O.useMemo)(()=>j(l),[l]),p=(0,O.useMemo)(()=>a&&a.length>0?f.filter(e=>a.includes(e.type)):f,[f,a]),m=(i??[]).join(`\0`),h=(0,O.useMemo)(()=>new Set(i??[]),[m]),v=(0,O.useMemo)(()=>o?C(o):[],[o]),[S,w]=(0,O.useState)(p[0]?.type??`grid`),[T,E]=(0,O.useState)(``),[D,A]=(0,O.useState)(!1),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)({});(0,O.useEffect)(()=>{e&&(w(p[0]?.type??`grid`),A(!1),L(!1),z({}))},[e,p]),(0,O.useEffect)(()=>{if(!D){let e=p.find(e=>e.type===S);E(M(e?.label??`View`,h))}},[S,D,p,h]),(0,O.useEffect)(()=>{I||F(x(T))},[T,I]);let B=N[S]??[],V=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!o||(e.filter?v.filter(e.filter):v).length>0,H=(0,O.useMemo)(()=>{let e={};return p.forEach(t=>{let n=(N[t.type]??[]).find(e=>!V(e));e[t.type]=n??null}),e},[p,v,o]),U=e=>R[`${S}.${e}`]??``,W=(e,t)=>z(n=>({...n,[`${S}.${e}`]:t})),G=T.trim(),K=G.length>0&&h.has(G),q=B.every(e=>U(e.key).length>0),J=/^[a-z_][a-z0-9_]*$/,Y=P.trim(),X=Y.length===0,Z=Y.length>0&&!J.test(Y),Q=G.length>0&&!K&&q&&!X&&!Z;(0,O.useEffect)(()=>{B.length!==0&&B.forEach(e=>{if(U(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&W(e.key,e.defaultValue);return}let t=e.filter?v.filter(e.filter):v;if(t.length===0)return;if(t.length===1){W(e.key,t[0].value);return}let n=ne(t,e.preferred??[]);n&&W(e.key,n)})},[S,v]);let $=()=>{if(!Q)return;let e={};B.forEach(t=>{let n=U(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:G,name:Y};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,k.jsx)(y,{open:e,onOpenChange:t,children:(0,k.jsxs)(u,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,k.jsxs)(d,{children:[(0,k.jsx)(ee,{children:l(`console.objectView.createView`)}),(0,k.jsx)(g,{children:l(`console.objectView.createViewDesc`)})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:p.map(({type:e,label:t,description:n,icon:i})=>{let a=e===S,o=H[e],s=!!o,c=s?l(`console.objectView.viewTypeUnavailable`,{field:l(o.i18nKey)}):void 0;return(0,k.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":a,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||w(e)},className:r(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,a&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,k.jsx)(i,{className:r(`h-5 w-5`,a&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,k.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,k.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?l(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),B.length>0&&(0,k.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:B.map(e=>{let t=U(e.key),n=e.kind===`enum`,i=n?[]:e.filter?v.filter(e.filter):v,a=!n&&v.length>0&&i.length===0;return(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[l(e.i18nKey),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>W(e.key,t.target.value),disabled:a,className:r(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,k.jsx)(`option`,{value:``,children:l(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.i18nKey)},e.value)):i.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!a&&(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:l(e.helpI18nKey)}),a&&(0,k.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,k.jsx)(c,{className:`h-3 w-3`}),l(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.title`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsx)(s,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),A(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:l(`console.objectView.newView`),className:`h-9`}),K&&(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:l(`console.objectView.duplicateViewName`)})]}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-machine-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.viewName`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsx)(s,{id:`create-view-machine-name-input`,"data-testid":`create-view-machine-name-input`,value:P,onChange:e=>{F(e.target.value),L(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:`grid_1`,className:`h-9 font-mono`}),X?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameRequired`)}):Z?(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-machine-name`,children:l(`console.objectView.viewNameInvalid`)}):(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameHelp`)})]}),(0,k.jsxs)(te,{className:`mt-2`,children:[(0,k.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:l(`console.objectView.cancel`)}),(0,k.jsx)(b,{type:`button`,disabled:!Q,onClick:$,"data-testid":`create-view-submit`,children:l(`console.objectView.create`)})]})]})})}export{A as n,P as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{y as r}from"./infrastructure-PXm1h5tB.js";import{N as i,P as a}from"./framework-UESyszCj.js";import{Cr as o,Ft as s,It as c,Jr as l,Lt as u,Ms as d,Nt as f,Ot as p,Pt as m,Rs as h,Rt as g,Tn as _,Xs as v,_a as y,_r as b,an as x,br as S,cn as C,dn as w,kn as T,ln as E,oa as D,oo as O,qs as k,sn as A,un as j,vn as M,vr as N,xr as P,yr as F,zr as I,zt as L}from"./ui-components-BbC0qTrK.js";import"./src-CSrGzA_t.js";import{E as R}from"./RecordDetailView-CP1b5rdr.js";var z=e(n(),1),B=t();function V({status:e}){let t={success:{icon:k,cls:`text-emerald-600 border-emerald-300`},completed:{icon:k,cls:`text-emerald-600 border-emerald-300`},failed:{icon:h,cls:`text-red-600 border-red-300`},error:{icon:h,cls:`text-red-600 border-red-300`},running:{icon:O,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:d,cls:`text-amber-600 border-amber-300`},paused:{icon:d,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,B.jsxs)(o,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),e]})}function H(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function U(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function W({data:e}){return(0,B.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function G(){let e=i()?.getClient?.(),[t,n]=(0,z.useState)([]),[r,a]=(0,z.useState)(!0),[o,s]=(0,z.useState)(null),[c,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(0),p=(0,z.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!c&&r.length>0&&u(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,c]);(0,z.useEffect)(()=>{p()},[p]);let m=(0,z.useMemo)(()=>t.find(e=>e.name===c)??null,[t,c]);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,B.jsx)(l,{className:`h-5 w-5`}),`Flow Runs`]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,B.jsxs)(b,{children:[(0,B.jsx)(S,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(P,{className:`text-base`,children:`Flow`}),(0,B.jsx)(F,{children:`Select a flow definition to test`})]}),(0,B.jsxs)(I,{variant:`outline`,size:`sm`,onClick:p,disabled:r,children:[(0,B.jsx)(D,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`Refresh`]})]})}),(0,B.jsxs)(N,{children:[r&&(0,B.jsx)(x,{className:`h-9 w-72`}),o&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!r&&!o&&t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!r&&!o&&t.length>0&&(0,B.jsx)(`select`,{value:c,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),m&&(0,B.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,B.jsx)(K,{client:e,flow:m.spec,onExecuted:()=>f(e=>e+1)}),(0,B.jsx)(q,{client:e,flowName:m.name,refreshKey:d})]})]})}function K({client:e,flow:t,onExecuted:n}){let s=(0,z.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),c=i(),{objects:l}=a(),u=(0,z.useMemo)(()=>r(),[]),[f,m]=(0,z.useState)({}),[g,v]=(0,z.useState)(!1),[x,C]=(0,z.useState)(null),[w,E]=(0,z.useState)(null),[D,A]=(0,z.useState)(null);(0,z.useEffect)(()=>{m({}),C(null),E(null),A(null)},[t?.name]);let j=(e,t)=>m(n=>({...n,[e]:t}));return(0,B.jsxs)(b,{children:[(0,B.jsxs)(S,{className:`pb-3`,children:[(0,B.jsx)(P,{className:`text-base`,children:`Test Run`}),(0,B.jsx)(F,{children:`Provide input values and invoke the flow`})]}),(0,B.jsxs)(N,{className:`space-y-3`,children:[s.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),s.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(T,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,B.jsx)(o,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{id:`var-${e.name}`,checked:f[e.name]===`true`,onCheckedChange:t=>j(e.name,t?`true`:`false`)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,B.jsx)(p,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:f[e.name]??``,onChange:t=>j(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,B.jsx)(_,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:f[e.name]??``,onChange:t=>j(e.name,t.target.value)})]},e.name)),(0,B.jsx)(`div`,{className:`pt-1`,children:(0,B.jsxs)(I,{onClick:async()=>{if(!e?.automation?.execute){E(`automation.execute is not available on this client`);return}v(!0),E(null),C(null),A(null);try{let r={};for(let e of s){let t=f[e.name];t!==void 0&&(r[e.name]=U(t,e.type))}let i=await e.automation.execute(t.name,{params:r});C(i),i?.status===`paused`&&i?.screen&&i?.runId&&A({flowName:t.name,runId:i.runId,screen:i.screen}),n?.()}catch(e){E(e?.message??String(e))}finally{v(!1)}},disabled:g,size:`sm`,children:[g?(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(y,{className:`h-3.5 w-3.5 mr-2`}),g?`Running…`:`Run Flow`]})}),(x||w)&&(0,B.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[w||x?.success===!1?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(h,{className:`h-4 w-4 text-red-500`}),` Failed`]}):x?.status===`paused`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(d,{className:`h-4 w-4 text-amber-500`}),` Waiting for input`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(k,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof x?.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono`,children:[x.durationMs,` ms`]})]}),w&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),x?.status===`paused`&&x?.screen&&x?.runId&&!D&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This run is paused at screen `,(0,B.jsx)(`span`,{className:`font-mono`,children:x.screen.nodeId}),`.`]}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>A({flowName:t.name,runId:x.runId,screen:x.screen}),children:`Continue run`})]}),x&&(0,B.jsx)(W,{data:x})]})]}),(0,B.jsx)(R,{state:D,authFetch:u,baseUrl:``,dataSource:c,objects:l,onClose:()=>{A(null),n?.()},onComplete:()=>{A(null),n?.()}})]})}function q({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,z.useState)([]),[a,l]=(0,z.useState)(!0),[d,p]=(0,z.useState)(null),[h,_]=(0,z.useState)(null),[v,y]=(0,z.useState)(null),[T,k]=(0,z.useState)(!1),[L,R]=(0,z.useState)(null),U=(0,z.useCallback)(async()=>{if(!e?.automation?.listRuns){p(`automation.listRuns is not available on this client`),l(!1);return}l(!0),p(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];i(r)}catch(e){p(e?.message??String(e))}finally{l(!1)}},[e,t]);(0,z.useEffect)(()=>{U()},[U,n]);let G=async n=>{_(n),y(null),R(null),k(!0);try{let r=await e.automation.getRun(t,n);y(r?.run??r)}catch(e){R(e?.message??String(e))}finally{k(!1)}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(b,{children:[(0,B.jsx)(S,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(P,{className:`text-base`,children:`Recent Runs`}),(0,B.jsx)(F,{className:`font-mono text-xs`,children:t})]}),(0,B.jsxs)(I,{variant:`outline`,size:`sm`,onClick:U,disabled:a,children:[a?(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(D,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,B.jsxs)(N,{children:[a&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(x,{className:`h-8 w-full`}),(0,B.jsx)(x,{className:`h-8 w-full`}),(0,B.jsx)(x,{className:`h-8 w-full`})]}),!a&&d&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!a&&!d&&r.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!a&&!d&&r.length>0&&(0,B.jsxs)(f,{children:[(0,B.jsx)(u,{children:(0,B.jsxs)(g,{children:[(0,B.jsx)(c,{children:`Run`}),(0,B.jsx)(c,{children:`Status`}),(0,B.jsx)(c,{children:`Started`}),(0,B.jsx)(c,{className:`text-right`,children:`Duration`})]})}),(0,B.jsx)(m,{children:r.map(e=>(0,B.jsxs)(g,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,B.jsxs)(s,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,B.jsx)(s,{children:(0,B.jsx)(V,{status:e.status})}),(0,B.jsx)(s,{className:`text-xs text-muted-foreground`,children:H(e.startedAt)}),(0,B.jsx)(s,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,B.jsx)(A,{open:!!h,onOpenChange:e=>{e||(_(null),y(null))},children:(0,B.jsxs)(C,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,B.jsxs)(j,{className:`p-4 border-b`,children:[(0,B.jsxs)(w,{className:`font-mono text-sm break-all`,children:[`Run `,h]}),(0,B.jsx)(E,{children:v&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,B.jsx)(V,{status:v.status}),typeof v.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono`,children:[v.durationMs,` ms`]}),(0,B.jsx)(`span`,{className:`text-xs`,children:H(v.startedAt)})]})})]}),(0,B.jsxs)(M,{className:`flex-1 p-4`,children:[T&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(x,{className:`h-16 w-full`}),(0,B.jsx)(x,{className:`h-16 w-full`}),(0,B.jsx)(x,{className:`h-16 w-full`})]}),L&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:L}),!T&&v&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(v.steps)&&v.steps.length>0?v.steps.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,B.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,B.jsx)(o,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,B.jsx)(V,{status:e.status}),typeof e.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,B.jsx)(W,{data:e.input})]}),e.output!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,B.jsx)(W,{data:e.output})]}),e.error&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,B.jsx)(W,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,B.jsx)(W,{data:v})]})})]})]})})]})}export{G as FlowRunsPage};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-DpRf6e0g.js";import{b as o,g as ee}from"./infrastructure-PXm1h5tB.js";import{P as s,rn as c}from"./framework-UESyszCj.js";import{An as te,Cr as l,Gc as u,Hi as d,Ia as ne,Ko as re,Nn as f,Os as p,Sc as m,Ui as ie,Vi as ae,Xr as h,Xs as g,Ys as oe,_n as se,_r as ce,_s as le,an as _,br as ue,cr as de,di as fe,dr as pe,fr as me,gn as he,gr as ge,hn as _e,jn as ve,kn as v,lr as ye,mn as be,ms as xe,nl as Se,oo as y,pn as Ce,ps as we,qs as b,sr as Te,ur as Ee,vr as De,xr as Oe,xs as ke,za as x,zc as Ae,zn as je,zr as S}from"./ui-components-BbC0qTrK.js";import{r as C}from"./vendor-ui-utils-CnzHPXVC.js";import"./MetadataProvider-D9fSVVZp.js";import{t as Me}from"./assistantBus-CpACs9I7.js";import{D as w,_ as Ne,a as Pe,c as Fe,d as Ie,g as Le,h as Re,i as T,l as ze,m as Be,n as Ve,o as He,s as Ue,t as We,v as Ge}from"./MarketplaceAccessDenied-DDTfnIA8.js";import{n as Ke,t as qe}from"./usePackageL10n-BgDMgWzW.js";var E=e(a(),1),D=i();function Je(e){let t=e.replace(/\r\n/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
|
|
4
|
-
`),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function O(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,D.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,D.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,D.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,D.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,D.jsx)(D.Fragment,{children:t.map((e,t)=>(0,D.jsx)(E.Fragment,{children:e},t))})}function Ye({source:e,className:t}){let n=Je(e);return(0,D.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,D.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:O(e.text??``)},t);case`h2`:return(0,D.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:O(e.text??``)},t);case`h3`:return(0,D.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:O(e.text??``)},t);case`p`:return(0,D.jsx)(`p`,{children:O(e.text??``)},t);case`ul`:return(0,D.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,D.jsxs)(`li`,{className:`flex gap-2`,children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,D.jsx)(`span`,{children:O(e)})]},t))},t);case`ol`:return(0,D.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,D.jsx)(`li`,{className:`pl-1`,children:O(e)},t))},t);case`code`:return(0,D.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var Xe={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function k({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,D.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Ze({version:e}){let{t}=Se();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,D.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,D.jsx)(p,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,D.jsx)(l,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:Xe[e.runtime]??e.runtime})}),e.platform_verified?(0,D.jsxs)(l,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,D.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,D.jsxs)(l,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,D.jsx)(ie,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,D.jsxs)(l,{variant:`outline`,className:`gap-1`,children:[(0,D.jsx)(b,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,D.jsx)(k,{icon:m,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,D.jsx)(k,{icon:h,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,D.jsx)(k,{icon:x,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,D.jsx)(k,{icon:re,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var A=`${``.replace(/\/$/,``)}/api/v1/security/suggested-bindings`;function j(e={}){let t={Accept:`application/json`,...e},n=o.get();return n?{...t,Authorization:`Bearer ${n}`}:t}async function M(e){let t=null;try{t=await e.json()}catch{}if(!e.ok){let n=t?.error?.code??`HTTP_${e.status}`,r=t?.error?.message??t?.error??e.statusText,i=Error(typeof r==`string`?r:String(n));throw i.code=n,i.status=e.status,i}return t?.data??t}async function N(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.packageId&&t.set(`packageId`,e.packageId);let n=t.toString(),r=await M(await fetch(`${A}${n?`?${n}`:``}`,{credentials:`include`,headers:j()}));return Array.isArray(r?.suggestions)?r.suggestions:[]}async function P(e){return(await M(await fetch(`${A}/${encodeURIComponent(e)}/confirm`,{method:`POST`,credentials:`include`,headers:j({"Content-Type":`application/json`})})))?.suggestion}async function F(e){return(await M(await fetch(`${A}/${encodeURIComponent(e)}/dismiss`,{method:`POST`,credentials:`include`,headers:j({"Content-Type":`application/json`})})))?.suggestion}function Qe({packageId:e,strings:t,className:n,onResolved:r}){let[i,a]=(0,E.useState)([]),[o,ee]=(0,E.useState)(null),s=(0,E.useCallback)(()=>{let t=!1;return N({status:`pending`,...e?{packageId:e}:{}}).then(e=>{t||a(e)}).catch(()=>{}),()=>{t=!0}},[e]);(0,E.useEffect)(()=>s(),[s]);let c=async(e,n)=>{ee(e.id);try{let i=n===`confirm`?await P(e.id):await F(e.id);a(t=>t.filter(t=>t.id!==e.id)),C.success(n===`confirm`?t.confirmedToast(e):t.dismissedToast(e)),r?.(i??e)}catch(e){C.error(e?.message??String(e))}finally{ee(null)}};return i.length===0?null:(0,D.jsx)(`div`,{"data-testid":`suggested-bindings-panel`,className:u(`rounded-lg border border-amber-300/60 dark:border-amber-700/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2 space-y-2`,n),children:i.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(ae,{className:`h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,D.jsx)(`p`,{className:`flex-1 min-w-0 text-sm text-amber-900 dark:text-amber-200`,children:t.describe(e)}),(0,D.jsx)(S,{size:`sm`,disabled:o===e.id,onClick:()=>c(e,`confirm`),"data-testid":`suggested-binding-confirm-${e.permission_set_name}`,children:o===e.id?t.confirming:t.confirm}),(0,D.jsx)(S,{size:`sm`,variant:`ghost`,disabled:o===e.id,onClick:()=>c(e,`dismiss`),"data-testid":`suggested-binding-dismiss-${e.permission_set_name}`,children:t.dismiss})]},e.id))})}var $e=t({MarketplacePackagePage:()=>et});function et(){let e=n(),{packageId:t,appName:i}=r(),a=ee(),{t:o,language:u}=Se(),d={describe:e=>o(e.anchor===`guest`?`marketplace.suggestedBindings.promptGuest`:`marketplace.suggestedBindings.promptEveryone`,{set:e.permission_set_name}),confirm:o(`marketplace.suggestedBindings.confirm`),confirming:o(`marketplace.suggestedBindings.confirming`),dismiss:o(`marketplace.suggestedBindings.dismiss`),confirmedToast:e=>o(`marketplace.suggestedBindings.confirmedToast`,{set:e.permission_set_name,anchor:e.anchor}),dismissedToast:e=>o(`marketplace.suggestedBindings.dismissedToast`,{set:e.permission_set_name})},re=i?`/apps/${i}`:``,{refresh:p}=s(),[m,ie]=(0,E.useState)(null),[ae,h]=(0,E.useState)(!0),[x,C]=(0,E.useState)(null),[Je,O]=(0,E.useState)(!1),[Xe,k]=(0,E.useState)([]),[A,j]=(0,E.useState)(!1),[M,N]=(0,E.useState)(null),[P,F]=(0,E.useState)(``),[$e,et]=(0,E.useState)({}),[tt,nt]=(0,E.useState)(!1),[rt,it]=(0,E.useState)(!1),[I,at]=(0,E.useState)(!1),[L,R]=(0,E.useState)(null),[z,ot]=(0,E.useState)(null),[B,V]=(0,E.useState)(null),[H,U]=(0,E.useState)(null),[W,G]=(0,E.useState)(null),[st,ct]=(0,E.useState)([]),[lt,K]=(0,E.useState)(!1),[q,J]=(0,E.useState)(null);(0,E.useEffect)(()=>{if(!w().features.installLocal)return;let e=!1;return(async()=>{let t=await Ie();e||ct(t)})(),()=>{e=!0}},[t,q]),(0,E.useEffect)(()=>{if(!t)return;let e=w().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await T(t,e);n||!r||(V(r),ot(r.version))})(),()=>{n=!0}},[t]),(0,E.useEffect)(()=>{let e=!1;return(async()=>{if(t){h(!0),C(null);try{let n=await Pe(t);e||ie(n)}catch(t){e||C(t?.message??String(t))}finally{e||h(!1)}}})(),()=>{e=!0}},[t]);let ut=async()=>{O(!0),R(null),N(null);let e=w().defaultEnvironmentId;if(e){j(!1),F(e),k([]);return}j(!0);try{let[e,n]=await Promise.all([Fe(),ze()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});k(r),et({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await T(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);et(t)}),e.length>0&&r.length===0?N(o(`marketplace.install.noPermission`)):r.length===1&&F(r[0].id)}catch(e){let t=e?.status;N(t===401||t===403?o(`marketplace.install.signInFirst`):e?.message??String(e))}finally{j(!1)}},dt=async()=>{if(!(!t||!P)){at(!0),R(null);try{let e=(await Ue({packageId:t,environmentId:P,seedSampleData:tt}))?.installation?.version??m?.package?.latest_version?.version??m?.versions?.[0]?.version??``;ot(e||`installed`);try{let e=w().defaultEnvironmentId||P;if(e){let n=await T(t,e);n&&V(n)}}catch{}let n=w().defaultEnvironmentId;if(!n||n===P)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await p()}catch{}R({ok:!0,message:o(`marketplace.install.success`)}),Me()}catch(e){R({ok:!1,message:e?.message??String(e)})}finally{at(!1)}}},ft=async()=>{if(t){K(!0),J(null);try{let e=await He({packageId:t});try{await p(`app`)}catch{}J({ok:!0,message:o(`marketplace.install.localSuccess`,{version:e.version,name:m?.package?qe(m.package,u).displayName:e.manifestId})}),Me()}catch(e){e?.code;let t=e?.message??String(e);c(e,`MANIFEST_CONFLICT`)?t=o(`marketplace.install.localManifestConflict`,{message:t}):c(e,`UNAUTHENTICATED`)?t=o(`marketplace.install.localUnauthorized`):c(e,`MARKETPLACE_UNAVAILABLE`)&&(t=o(`marketplace.install.localMarketplaceUnavailable`)),J({ok:!1,message:t})}finally{K(!1)}}},pt=async()=>{if(Q&&confirm(o(`marketplace.uninstall.confirm`,{manifestId:Q.manifestId,version:Q.version}))){K(!0),J(null);try{await Ge(Q.manifestId);try{await p(`app`)}catch{}J({ok:!0,message:o(`marketplace.uninstall.successInDetail`,{manifestId:Q.manifestId})})}catch(e){J({ok:!1,message:e?.message??String(e)})}finally{K(!1)}}},mt=async()=>{if(B){U(`reseed`),G(null);try{let e=await Ne(B.installationId);e.ok?(V({...B,withSampleData:!0}),G({ok:!0,text:o(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):G({ok:!1,text:e.error||`Re-seed failed`})}finally{U(null)}}},ht=async()=>{if(B&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){U(`purge`),G(null);try{let e=await Re(B.installationId);if(e.ok){V({...B,withSampleData:!1});let t=e.deleted??0;G({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else G({ok:!1,text:e.error||`Purge failed`})}finally{U(null)}}},gt=async()=>{if(Q){U(`reseed`),G(null);try{let e=await Le(Q.manifestId);ct(e=>e.map(e=>e.manifestId===Q.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0,r=e.errors??0,i=o(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;G(r>0?{ok:!1,text:`${i} ${o(`marketplace.detail.reseedPartialErrors`,{count:r})||`(${r} record(s) failed to write)`}`}:{ok:!0,text:i})}catch(e){G({ok:!1,text:e?.message||`Re-seed failed`})}finally{U(null)}}},_t=async()=>{if(Q&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){U(`purge`),G(null);try{let e=await Be(Q.manifestId);ct(e=>e.map(e=>e.manifestId===Q.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;G({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){G({ok:!1,text:e?.message||`Purge failed`})}finally{U(null)}}};if(ae)return(0,D.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsx)(_,{className:`h-8 w-32`}),(0,D.jsx)(_,{className:`h-16 w-full`}),(0,D.jsx)(_,{className:`h-64 w-full`})]});if(x||!m)return(0,D.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>e(`${re}/system/marketplace`),children:[(0,D.jsx)(Ae,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,D.jsx)(g,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`font-medium text-destructive`,children:o(`marketplace.load.packageFailed`)}),(0,D.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:x??o(`marketplace.load.notFound`)})]})]})]});let Y=m.package,X=qe(Y,u),Z=Y.latest_version?.version??m.versions[0]?.version??null,Q=st.find(e=>e.manifestId===Y.manifest_id)??null,vt=!!Y.latest_version?.contains_code,$=!!z&&z!==`installed`&&!!Z&&z!==Z,yt=w().features.installLocal,bt=!Z||lt||I||!yt&&!!z&&!$,xt=yt?{label:o(lt?`marketplace.action.working`:Q?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ft}:{label:I?o(`marketplace.action.installing`):z?$?o(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Z}):o(`marketplace.action.installed`,{defaultValue:`Installed`}):o(`marketplace.action.installToCloud`),onClick:ut},St=Y.category?o(`marketplace.category.${Y.category}`,{defaultValue:Y.category}):null;return a?(0,D.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(S,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${re}/system/marketplace`),children:[(0,D.jsx)(Ae,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,D.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,D.jsx)(Ke,{iconUrl:Y.icon_url,displayName:X.displayName,manifestId:Y.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,D.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:X.displayName||Y.manifest_id}),Y.homepage_url&&(0,D.jsxs)(`a`,{href:Y.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:o(`marketplace.detail.homepage`),children:[(0,D.jsx)(we,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`hidden sm:inline`,children:o(`marketplace.detail.homepage`)})]})]}),(0,D.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,D.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:Y.manifest_id}),Z&&(0,D.jsx)(l,{variant:`outline`,children:o(`marketplace.versionBadge`,{version:Z})}),Y.publisher&&Y.publisher!==`private`&&(0,D.jsx)(l,{variant:Y.publisher===`objectstack`?`default`:`secondary`,children:Y.publisher}),St&&(0,D.jsx)(l,{variant:`outline`,children:St}),Y.license&&(0,D.jsx)(l,{variant:`outline`,className:`font-normal`,children:Y.license}),Q&&(0,D.jsxs)(l,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,D.jsx)(b,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:Q.version})]}),!Q&&z&&(0,D.jsxs)(l,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,D.jsx)(b,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:z})]}),$&&(0,D.jsxs)(l,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,D.jsx)(oe,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Z]})]}),X.description&&(0,D.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:X.description})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,D.jsxs)(S,{onClick:xt.onClick,disabled:bt,size:`lg`,className:`min-w-[8rem]`,children:[(0,D.jsx)(le,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),xt.label]}),Q&&(0,D.jsxs)(te,{children:[(0,D.jsx)(je,{asChild:!0,children:(0,D.jsx)(S,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`),children:(0,D.jsx)(xe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,D.jsxs)(ve,{align:`end`,className:`w-56`,children:[(0,D.jsxs)(f,{onSelect:gt,disabled:H!==null,children:[H===`reseed`?(0,D.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,D.jsx)(ke,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),Q.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,D.jsxs)(f,{onSelect:_t,disabled:H!==null||!Q.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,D.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,D.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,D.jsxs)(f,{onSelect:pt,disabled:lt,className:`text-destructive focus:text-destructive`,children:[(0,D.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!Q&&B&&!w().cloudUrl&&(0,D.jsxs)(te,{children:[(0,D.jsx)(je,{asChild:!0,children:(0,D.jsx)(S,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`)||`More options`,children:(0,D.jsx)(xe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,D.jsxs)(ve,{align:`end`,className:`w-56`,children:[(0,D.jsxs)(f,{onSelect:mt,disabled:H!==null,children:[H===`reseed`?(0,D.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,D.jsx)(ke,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),B.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,D.jsxs)(f,{onSelect:ht,disabled:H!==null||!B.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,D.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,D.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),W&&(0,D.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${W.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[W.ok?(0,D.jsx)(b,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(g,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`flex-1`,children:W.text}),(0,D.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>G(null),children:o(`marketplace.action.dismiss`)})]}),q&&(0,D.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[q.ok?(0,D.jsx)(b,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(g,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsxs)(`div`,{className:`flex-1`,children:[q.message,q.ok&&(0,D.jsx)(Qe,{packageId:Y.manifest_id,strings:d,className:`mt-2`})]}),(0,D.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>J(null),children:o(`marketplace.action.dismiss`)})]}),(0,D.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,D.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,D.jsxs)(ce,{children:[(0,D.jsx)(ue,{children:(0,D.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.about`)})}),(0,D.jsx)(De,{children:X.readme?(0,D.jsx)(Ye,{source:X.readme}):(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noReadme`)})})]})}),(0,D.jsx)(`div`,{className:`space-y-4`,children:(0,D.jsxs)(ce,{children:[(0,D.jsx)(ue,{children:(0,D.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.versions`)})}),(0,D.jsx)(De,{children:m.versions.length===0?(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noApprovedVersions`)}):(0,D.jsx)(`ul`,{className:`space-y-3`,children:m.versions.map(e=>(0,D.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(ne,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,D.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,D.jsx)(l,{variant:`outline`,className:`text-xs`,children:o(`marketplace.detail.prerelease`)})]}),(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]}),e.release_notes&&e.release_notes.trim()&&(0,D.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,D.jsx)(Te,{open:Je,onOpenChange:e=>{O(e),e||(R(null),it(!1))},children:(0,D.jsxs)(de,{children:[(0,D.jsxs)(pe,{children:[(0,D.jsx)(me,{children:o(`marketplace.install.dialogTitle`,{name:X.displayName||Y.manifest_id})}),(0,D.jsx)(ye,{children:w().defaultEnvironmentId?o(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):o(`marketplace.install.dialogDescPicker`)})]}),A?(0,D.jsx)(_,{className:`h-10 w-full`}):M?(0,D.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(g,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`flex-1`,children:M})]}),(0,D.jsx)(`a`,{href:Ve(Y.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,D.jsxs)(S,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,D.jsx)(we,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.action.openOnCloud`)]})})]}):w().defaultEnvironmentId?(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(ge,{id:`seed`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,D.jsx)(v,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]}):Xe.length===0?(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.install.noEnvs`)}):(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,D.jsx)(v,{htmlFor:`env-select`,children:o(`marketplace.install.environment`)}),(0,D.jsxs)(Ce,{value:P,onValueChange:F,children:[(0,D.jsx)(he,{id:`env-select`,children:(0,D.jsx)(se,{placeholder:o(`marketplace.install.environmentPlaceholder`)})}),(0,D.jsx)(be,{children:Xe.map(e=>{let t=$e[e.id],n=!!t&&!!Z&&t!==`installed`&&t!==Z;return(0,D.jsxs)(_e,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,D.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,D.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,o(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Z})]}):(0,D.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,o(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(ge,{id:`seed`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,D.jsx)(v,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]})]}),vt&&!M&&(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(Ze,{version:Y.latest_version}),(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(ge,{id:`ack-perms`,checked:rt,onCheckedChange:e=>it(e===!0)}),(0,D.jsx)(v,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:o(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),L&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${L.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:L.message}),L?.ok===!0&&w().defaultEnvironmentId&&w().defaultEnvironmentId===P&&(0,D.jsx)(Qe,{packageId:Y.manifest_id,strings:d}),(0,D.jsxs)(Ee,{children:[(0,D.jsx)(S,{variant:`outline`,onClick:()=>O(!1),children:o(`marketplace.action.close`)}),!M&&(0,D.jsx)(S,{onClick:dt,disabled:!P||I||L?.ok===!0||vt&&!rt,children:o(I?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,D.jsx)(We,{})}export{Qe as n,$e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-DpRf6e0g.js";import{_ as o,g as s,n as ee,t as c}from"./infrastructure-PXm1h5tB.js";import{Bt as te,X as ne}from"./framework-UESyszCj.js";import{Kr as re,Xi as ie,Zc as ae,ao as oe,ct as l,dt as u,ha as d,it as f,nl as p,st as m,xs as h,zr as g}from"./ui-components-BbC0qTrK.js";import{i as _,r as se,s as ce}from"./MetadataProvider-D9fSVVZp.js";import{t as le}from"./RecordDetailView-CP1b5rdr.js";import{a as ue,c as de,i as fe,n as pe,o as me,r as he,s as ge}from"./InterfaceListPage-DcFmVgXg.js";import{t as _e}from"./getIcon-D3yCrAri.js";import{o as ve}from"./createDerive-CGF05Hgy.js";import{n as ye,t as be}from"./CreateViewDialog-C6sZGaIB.js";import{d as xe}from"./plugins-views-CJKuyDvq.js";import{o as Se,t as Ce}from"./runtime-metadata-persistence-BjYxldgR.js";import{n as v,r as y,t as b}from"./drillUrlFilters-BL8PeMrH.js";var x=e(a(),1),S=i(),C=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),w=4;function T({dataSource:e,objects:i}){let{appName:a,objectName:T}=r(),{t:E}=p(),{objectLabel:D,fieldLabel:O}=ae(),k=t(),[A,j]=n(),{can:M}=ee(),{canRead:N}=c(T??``),{user:P,activeOrganization:F}=o(),I=s(),L=ve(),R=de()===`group`,z=ce(),[we,B]=x.useState(!1),V=x.useMemo(()=>(i||[]).find(e=>e.name===T),[i,T]),[Te]=x.useState(()=>ge(new URLSearchParams(window.location.search))),Ee=x.useCallback(e=>{j(t=>me(t,e),{replace:!0})},[j]),H=Array.from(A.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),U=x.useMemo(()=>{let e=y(new URLSearchParams(H)),t=e.filter(([e])=>N(e));if(t.length<e.length){let t=e.filter(([e])=>!N(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return te(t,{currentUserId:P?.id??null,currentOrgId:F?.id??null})},[H,N,P?.id,F?.id]),De=x.useMemo(()=>v(U),[U]),Oe=x.useCallback(e=>{j(t=>b(new URLSearchParams(t),e))},[j]),W=x.useMemo(()=>he(V,{orgAttribution:R}).filter(e=>N(e)),[V,N,R]),G=x.useMemo(()=>{let e=V?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&C.has(t.type)&&N(e)).slice(0,w).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[V,N]),K=x.useCallback(e=>`/apps/${a}/${T}/record/${encodeURIComponent(String(e))}`,[a,T]),q=ne({navigation:{mode:`drawer`},objectName:T??``,onNavigate:e=>k(K(e))}),J=A.get(`recordId`),ke=x.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,j]),Ae=x.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);x.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=x.useMemo(()=>ue(V),[V]),X=x.useMemo(()=>pe(V),[V]),Z=x.useMemo(()=>fe(V),[V]),Q=x.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=x.useMemo(()=>{if(V)return{type:`list-view`,objectName:V.name,viewType:`grid`,columns:W,...U.length?{filter:U}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,userActions:{search:!0,sort:!0,filter:!0,rowHeight:!0,group:!0,hideFields:!0},showRecordCount:!0}},[V,W,U,Y,X,Z,G,Q]),je=x.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...U.length?{filter:U}:{}},n=Se(T??``,t,{name:e.name,label:e.label}),r=await Ce(`view`,n.name,n,{metadataClient:L});if(r){let e=z?``:`?${se}=${_}`;k(`../view/${r}${e}`,{relative:`path`})}}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,U,L,k,T,z]);return V?M(V.name,`read`)?(0,S.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,S.jsx)(`div`,{className:`hidden sm:block`,children:(0,S.jsx)(ye,{title:(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`truncate`,children:D(V)}),(0,S.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:E(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:E(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:x.createElement(_e(V?.icon),{className:`h-4 w-4`}),actions:(0,S.jsxs)(S.Fragment,{children:[M(V.name,`create`)&&(0,S.jsxs)(g,{size:`sm`,onClick:()=>k(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,S.jsx)(d,{className:`h-4 w-4`}),(0,S.jsx)(`span`,{className:`hidden sm:inline`,children:E(`console.objectView.new`)})]}),I&&(0,S.jsxs)(g,{size:`sm`,variant:`outline`,onClick:()=>B(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,S.jsx)(ie,{className:`h-4 w-4`}),(0,S.jsx)(`span`,{className:`hidden sm:inline`,children:E(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),U.length>0&&(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:E(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),De.map(({field:e,text:t})=>(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,S.jsx)(`span`,{className:`font-medium`,children:O(V.name,e,e)}),(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:t}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>Oe(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":E(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,S.jsx)(re,{className:`h-3 w-3`})})]},e))]}),(0,S.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,S.jsx)(xe,{schema:$,dataSource:e,userFilterSelections:Te,onUserFilterSelectionsChange:Ee,onRowClick:ke})}),q.isOverlay&&(0,S.jsx)(f,{...q,setIsOpen:e=>{e||Ae()},title:D(V),children:t=>(0,S.jsx)(le,{objectNameOverride:V.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),I&&(0,S.jsx)(be,{open:we,onOpenChange:B,onCreate:je,objectDef:V})]}):(0,S.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,S.jsxs)(m,{children:[(0,S.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,S.jsx)(oe,{className:`h-6 w-6 text-muted-foreground`})}),(0,S.jsx)(u,{children:E(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,S.jsx)(l,{children:E(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,S.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,S.jsxs)(m,{children:[(0,S.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,S.jsx)(h,{className:`h-6 w-6 text-muted-foreground`})}),(0,S.jsx)(u,{children:E(`console.objectView.objectNotFound`)}),(0,S.jsx)(l,{children:E(`console.objectView.objectNotFoundDescription`,{objectName:T})})]})})}export{T as ObjectDataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-DpRf6e0g.js";import{_ as c,g as l,n as u,y as d}from"./infrastructure-PXm1h5tB.js";import{G as f,N as p,P as m,et as h,p as g}from"./framework-UESyszCj.js";import{Ar as _,Fr as v,Ir as y,Lr as b,Mr as x,Nr as S,Pr as C,Sa as w,Zc as T,ct as ee,dt as E,es as D,nl as O,rt as k,st as A,zr as j}from"./ui-components-BbC0qTrK.js";import{r as M}from"./vendor-ui-utils-CnzHPXVC.js";import"./MetadataProvider-D9fSVVZp.js";import{r as te}from"./ExpressionProvider-BQFSoabd.js";import{D as ne,E as re,F as ie,I as ae,L as oe,N as se,O as N,T as ce,w as le}from"./RecordDetailView-CP1b5rdr.js";import{t as ue}from"./preferLocal-CKqyhTP9.js";import{t as P}from"./InterfaceListPage-DcFmVgXg.js";import{n as F,t as I}from"./MetadataInspector-B7LigfJm.js";var L=e(s(),1),R=o();function z(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function B({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=z(e.url,t);return(0,R.jsx)(j,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,R.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function de({state:e,apiBase:t,onOpenChange:n}){let r=e.spec,{t:i}=O();return(0,R.jsx)(_,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,R.jsxs)(S,{"data-testid":`environment-entitlement-dialog`,children:[(0,R.jsxs)(y,{children:[(0,R.jsx)(b,{children:r?.title}),(0,R.jsx)(C,{children:r?.message})]}),(0,R.jsxs)(v,{children:[(0,R.jsx)(x,{children:i(`common.close`,{defaultValue:`Close`})}),r?.secondaryCta&&(0,R.jsx)(B,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,R.jsx)(B,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var V=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function H(e){return typeof e==`string`&&V.has(e)}var U=`/settings/billing`;function W(e,t){return(typeof t?.defaultValue==`string`?t.defaultValue:e).replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t?.[n]??``))}function G(e,t){return typeof t==`string`&&t&&t!==`free`?e(`environment.entitlement.namedPlan`,{plan:t,defaultValue:`{{plan}} plan`}):e(`environment.entitlement.freePlan`,{defaultValue:`free plan`})}function K(e){let t=e?.error;return t&&typeof t==`object`?t:e}function fe(e,t=W){let n=K(e),r=n?.code;if(!H(r))return null;let i=typeof n?.upgrade_url==`string`&&n.upgrade_url?n.upgrade_url:U,a=typeof n?.contact_url==`string`&&n.contact_url?n.contact_url:``;if(r===`PRODUCTION_ENV_LIMIT`)return{code:r,title:t(`environment.entitlement.productionLimitTitle`,{defaultValue:`You already have your production environment`}),message:t(`environment.entitlement.productionLimitBody`,{defaultValue:`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`}),cta:a?{label:t(`environment.entitlement.contactSalesCta`,{defaultValue:`Contact sales`}),url:a}:void 0};let o={label:t(`environment.entitlement.upgradeCta`,{defaultValue:`Upgrade plan`}),url:i};if(r===`DEV_ENV_PLAN_LOCKED`)return{code:r,title:t(`environment.entitlement.planLockedTitle`,{defaultValue:`Development environments are a paid feature`}),message:t(`environment.entitlement.planLockedBody`,{plan:G(t,n?.plan),defaultValue:`Your {{plan}} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`}),cta:o};let s=Number(n?.current),c=Number(n?.limit),l=Number.isFinite(s)&&Number.isFinite(c);return{code:r,title:t(`environment.entitlement.limitTitle`,{defaultValue:`Development environment limit reached`}),message:l?t(`environment.entitlement.limitBodyWithCount`,{used:s,limit:c,defaultValue:`You are using {{used}} of {{limit}} development environments. Capacity scales with AI seats — add an AI seat, or archive an unused development environment to free one up.`}):t(`environment.entitlement.limitBody`,{defaultValue:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`}),cta:o}}function q(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function J(e,t=W){return{code:`DEV_ENV_PLAN_LOCKED`,title:t(`environment.entitlement.planLockedTitle`,{defaultValue:`Development environments are a paid feature`}),message:t(`environment.entitlement.planLockedBody`,{plan:G(t,e.plan),defaultValue:`Your {{plan}} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`}),cta:{label:t(`environment.entitlement.upgradeCta`,{defaultValue:`Upgrade plan`}),url:e.upgradeUrl||`/settings/billing`}}}var Y=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function X(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function Z(e,t){if(!e.includes(`{{`))return e;let n=e.match(Y);if(n){let e=X(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=X(n,t);return r==null?``:String(r)})}function Q(e,t){if(typeof e==`string`)return Z(e,t);if(Array.isArray(e))return e.map(e=>Q(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=Q(i,t);return n}return e}function pe(e,t){return t?Q(e,t):e}var me={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function he(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}var ge=N;function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:l}=c(),{systemPermissions:f}=u(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v,actionResultDialog:y}=T(),{t:b}=O(),x=(0,L.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),S=i||x?.name,C=(0,L.useCallback)(()=>{a?.()},[a]),w=g({dataSource:t,onUndo:()=>{C(),M.success(`Change undone`)}}),[ee,E]=(0,L.useState)({open:!1,message:``}),[D,k]=(0,L.useState)({open:!1,params:[]}),[A,j]=(0,L.useState)({open:!1}),[te,N]=(0,L.useState)(null),[ue,P]=(0,L.useState)({open:!1}),F=(0,L.useRef)(new Set),I=(0,L.useCallback)((e,t,n)=>new Promise(r=>{let a=typeof n?.objectName==`string`&&n.objectName?n.objectName:i||x?.name,o=y(a,n?.name,e)??e;j({open:!0,spec:o,data:t,resolve:r})}),[i,x,y]),z=(0,L.useCallback)((e,t)=>new Promise(n=>{E({open:!0,message:e,options:t,resolve:n})}),[]),B=(0,L.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,s=ce(e,{objectName:o||i||x?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),c=o||i||x?.name,l=s.map(e=>({...e,label:h(c,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(c,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(c,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(c,t?.name,e.name,n.value,n.label)})):e.options}));k({open:!0,params:l,title:t?.label||t?.title,description:v(c,t?.name,t?.description),resolve:r})}),[i,x,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...me,systemPermissions:f??[]},H=(0,L.useCallback)((e,t)=>{if(t?.type===`error`){M.error(e);return}if(t?.undo){M.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{w.undo()}}});return}M.success(e,{duration:t?.duration})},[w]),U=(0,L.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,L.useMemo)(()=>d(),[]),G=(0,L.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,L.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=pe(t,o),c=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(c)&&(c=c.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=c.startsWith(`http`)?c:`${c}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};for(let e of Object.keys(f))if(e.startsWith(`outputs.`)&&e.length>8){let t=f[e];if(delete f[e],t===void 0||t===``)continue;(f.outputs??={})[e.slice(8)]=t}if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(c)&&!f.organizationId&&l?.id&&(f.organizationId=l.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,pe(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=fe(e,b);return t?(G(t),{success:!1}):{success:!1,error:ge(e,`HTTP ${h.status}`)}}let g=await h.json().catch(()=>({}));return g&&typeof g==`object`&&g.success===!1?{success:!1,error:ge(g,`Action "${e.name||a}" failed`)}:(e.refreshAfter!==!1&&C(),{success:!0,data:g&&typeof g==`object`&&!Array.isArray(g)&&`data`in g?g.data:g,reload:e.refreshAfter!==!1})}let o=e.objectName||S,s=i._rowRecord,c={...i};delete c._rowRecord;let u=c.recordId??s?.[e.recordIdField||`id`];delete c.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(c,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,c):o&&u&&Object.keys(c).length>0&&typeof t?.update==`function`&&await t.update(o,u,c);let d;if(e.undoable&&o&&u&&s&&Object.keys(c).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(c))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...c}}}let f=e.refreshAfter!==!1;return f&&C(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,S,W,l,C,G,b]),q=(0,L.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(he(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||S,params:r})}),s=await o.json().catch(()=>null),c=ne(o,s,`Flow "${n}"`);if(c.kind===`failed`)return{success:!1,error:c.error};if(c.kind===`paused`)return N({flowName:n,runId:c.runId??``,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&C(),{success:!0,data:c.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,S,C]),J=(0,L.useCallback)(async(e,t)=>{let n=e.name;if(!n)return{success:!1,error:`Action has no name — a server action must declare one`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a],s=Array.isArray(r._selectedIds);if(o==null&&!s){let n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(he(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let c=`${n}:${o??``}`;if(F.current.has(c))return{success:!1,error:`Action already in progress`};F.current.add(c);let l=null;if(e.opensInNewTab)try{l=window.open(`about:blank`,`_blank`),l&&(l.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),l.document.close())}catch{l=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(l)try{l.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(l)try{l.location.href=n}catch{try{l.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||M(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&C(),{success:!0}}let i=e.objectName||S||`global`,a=await W(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null),c=le(a,s,`Action "${n}"`);if(!c.ok){if(l)try{l.close()}catch{}return{success:!1,error:c.error}}let u=e.refreshAfter!==!1;u&&C();let d=c.envelope,f=c.payload,p=f&&typeof f==`object`&&typeof f.redirectUrl==`string`?f.redirectUrl:null;if(p)if(l)try{l.location.href=p}catch{try{l.close()}catch{}window.location.href=p}else{let e=null;try{e=window.open(p,`_blank`)}catch{e=null}e||M(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(p,`_blank`)}catch{window.location.href=p}}},duration:1e4})}else if(l)try{l.close()}catch{}return{success:!0,data:d,reload:u}}catch(e){if(l)try{l.close()}catch{}return{success:!1,error:e.message}}finally{F.current.delete(c)}},[W,S,C]),{modalHandler:Y,modalElement:X,resolveModalTarget:Z}=oe(t),Q=(0,L.useCallback)(async(e,t)=>{let n=e.modal??e.target??e.params?.schema,r=n==null?null:await Z(n);return r?Y(r):{success:!1,error:`Action "${e.name}" is type:'modal' but its target ${n==null?``:`"${String(n)}" `}names no page or object to open. Point it at a page, or use type:'script' with params to collect input and run a handler.`}},[Z,Y]);return{confirmHandler:z,toastHandler:H,navigateHandler:U,paramCollectionHandler:B,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,modalActionHandler:Q,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,L.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:l?{id:l.id,slug:l.slug,name:l.name}:null},onConfirm:z,onToast:H,onNavigate:U,onParamCollection:B,onResultDialog:I,onModal:Y,handlers:{api:K,flow:q,script:J,modal:Q}}),[i,V,l,z,H,U,B,I,K,q,J,Y,Q]),dialogs:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ae,{state:ee,onOpenChange:e=>{e||E({open:!1,message:``})}}),(0,R.jsx)(ie,{state:D,onOpenChange:e=>{e||k({open:!1,params:[]})}}),(0,R.jsx)(se,{state:A,onAcknowledge:()=>{A.resolve?.(),j({open:!1})}}),(0,R.jsx)(re,{state:te,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>N(null),onComplete:()=>{N(null),C()}}),(0,R.jsx)(de,{state:ue,apiBase:``,onOpenChange:e=>{e||P({open:!1})}}),X]})}}function _e({children:e,...t}){let n=$(t);return(0,R.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ve=t({PageView:()=>ye});function ye(){let{t:e}=O(),{pageName:t}=a(),[o]=i(),{showDebug:s}=F(),c=r(),u=n(),d=l(),{pages:f,objects:g,getTypeStatus:_}=m(),{app:v}=te(),y=p(),[b,x]=(0,L.useState)(0),S=ue(f,t,v?._packageId);if(!S){let n=_?.(`page`);return n===`idle`||n===`loading`?(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,R.jsx)(k,{className:`h-5 w-5 text-muted-foreground`})}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(A,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(D,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(E,{children:e(`empty.pageNotFound`)}),(0,R.jsx)(ee,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let C=Object.fromEntries(o.entries()),T=u.pathname.match(/\/apps\/([^/]+)/)?.[1],j=d&&!!T&&!!t;return(0,R.jsx)(_e,{dataSource:y,objects:g,onRefresh:()=>x(e=>e+1),children:(0,R.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,R.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[j&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{j&&c(`/apps/${T}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,R.jsx)(w,{className:`h-3.5 w-3.5`})}),S.interfaceConfig?.source?(0,R.jsx)(P,{page:S,reserveEditAffordance:j},b):(0,R.jsx)(h,{schema:{...S,type:S.type||`page`,pageType:S.type,context:{...S.context,params:C,refreshKey:b}}},b)]}),(0,R.jsx)(I,{open:s,sections:[{title:`Page Configuration`,data:S}]})]})})}export{J as a,q as i,$ as n,U as r,ve as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{_ as r,u as i}from"./infrastructure-PXm1h5tB.js";import{Cr as a,Dr as o,Er as s,Kr as c,M as l,Or as u,Tn as d,Tr as f,Xs as p,_r as m,ai as h,ao as g,br as _,kn as v,nl as y,oo as b,qs as x,ti as S,vr as C,wr as w,xr as T,yr as E,zr as D}from"./ui-components-BbC0qTrK.js";var O=e(n(),1),k=t();function A(){let{t:e}=y(),{user:t,updateUser:n,isLoading:g,changePassword:A,setInitialPassword:M,hasLocalPassword:N}=r(),{upload:P}=l(),[F,I]=(0,O.useState)(t?.name??``),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),V=(0,O.useRef)(null),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(null);return(0,O.useEffect)(()=>{I(t?.name??``)},[t?.name]),t?(0,k.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:e(`profile.title`,{defaultValue:`Profile`})}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`profile.subtitle`,{defaultValue:`Manage your account settings`})})]}),(0,k.jsx)(m,{children:(0,k.jsxs)(C,{className:`pt-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,k.jsxs)(w,{className:`h-16 w-16`,children:[(0,k.jsx)(s,{src:t.image??void 0,alt:t.name??`User`}),(0,k.jsx)(f,{className:`text-lg bg-primary text-primary-foreground`,children:i(t)})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:t.name??`User`}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:t.email}),(0,k.jsx)(a,{variant:`secondary`,className:`mt-1`,children:t.role??`member`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,k.jsx)(`input`,{ref:V,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let t=e.target.files?.[0];if(V.current&&(V.current.value=``),t){U(!0),G(null);try{let e=await P(t);await n({image:e.url})}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},"data-testid":`profile-avatar-file`}),(0,k.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,disabled:H,onClick:()=>V.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[H?(0,k.jsx)(b,{className:`mr-2 h-4 w-4 animate-spin`}):(0,k.jsx)(h,{className:`mr-2 h-4 w-4`}),t.image?e(`profile.avatar.replace`,{defaultValue:`Replace`}):e(`profile.avatar.upload`,{defaultValue:`Upload`})]}),t.image&&(0,k.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,disabled:H,onClick:async()=>{U(!0),G(null);try{await n({image:null})}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,k.jsx)(c,{className:`mr-2 h-4 w-4`}),e(`profile.avatar.remove`,{defaultValue:`Remove`})]})]})]}),W&&(0,k.jsxs)(o,{variant:`destructive`,className:`mt-4`,children:[(0,k.jsx)(p,{className:`h-4 w-4`}),(0,k.jsx)(u,{children:W})]})]})}),(0,k.jsxs)(m,{children:[(0,k.jsxs)(_,{children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(S,{className:`h-4 w-4 text-muted-foreground`}),(0,k.jsx)(T,{className:`text-base sm:text-lg`,children:e(`profile.info.title`,{defaultValue:`Personal Information`})})]}),(0,k.jsx)(E,{children:e(`profile.info.description`,{defaultValue:`Update your name and view account details`})})]}),(0,k.jsx)(C,{children:(0,k.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),B(null),R(!1);try{await n({name:F}),R(!0)}catch(e){B(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[z&&(0,k.jsxs)(o,{variant:`destructive`,children:[(0,k.jsx)(p,{className:`h-4 w-4`}),(0,k.jsx)(u,{children:z})]}),L&&(0,k.jsxs)(o,{children:[(0,k.jsx)(x,{className:`h-4 w-4 text-green-600`}),(0,k.jsx)(u,{className:`text-green-800 dark:text-green-400`,children:e(`profile.info.saved`,{defaultValue:`Profile updated successfully.`})})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(v,{htmlFor:`profile-name`,children:e(`profile.info.name`,{defaultValue:`Name`})}),(0,k.jsx)(d,{id:`profile-name`,type:`text`,value:F,onChange:e=>I(e.target.value),required:!0,"aria-required":`true`,disabled:g})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(v,{htmlFor:`profile-email`,children:e(`profile.info.email`,{defaultValue:`Email`})}),(0,k.jsx)(d,{id:`profile-email`,type:`email`,value:t.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`profile.info.emailImmutable`,{defaultValue:`Email cannot be changed.`})})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(v,{children:e(`profile.info.role`,{defaultValue:`Role`})}),(0,k.jsx)(d,{type:`text`,value:t.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,k.jsx)(D,{type:`submit`,disabled:g,className:`w-full sm:w-auto`,children:g?e(`profile.saving`,{defaultValue:`Saving…`}):e(`profile.info.save`,{defaultValue:`Save Changes`})})]})})]}),(0,k.jsx)(j,{changePassword:A,setInitialPassword:M,hasLocalPassword:N})]}):null}function j({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let{t:a}=y(),[s,c]=(0,O.useState)(null),[l,f]=(0,O.useState)(``),[h,b]=(0,O.useState)(``),[S,w]=(0,O.useState)(``),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(null),[P,F]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=!1;return n().then(t=>{e||c(t)}).catch(()=>{e||c(!1)}),()=>{e=!0}},[n]);let I=()=>{f(``),b(``),w(``)},L=async n=>{if(n.preventDefault(),N(null),F(null),h.length<8){N(a(`profile.password.tooShort`,{defaultValue:`Password must be at least 8 characters`}));return}if(h!==S){N(a(`profile.password.mismatch`,{defaultValue:`Passwords do not match`}));return}j(!0);try{if(s){if(!l){N(a(`profile.password.enterCurrent`,{defaultValue:`Enter your current password`})),j(!1);return}await e(l,h),F(a(`profile.password.changed`,{defaultValue:`Password changed.`}))}else await t(h),F(a(`profile.password.localSet`,{defaultValue:`Local password set. You can now sign in with email and password on this environment.`})),c(!0),i?.();I()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},R=s===null;return(0,k.jsxs)(m,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,k.jsxs)(_,{children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(g,{className:`h-4 w-4 text-muted-foreground`}),(0,k.jsx)(T,{className:`text-base sm:text-lg`,children:s?a(`profile.password.changeTitle`,{defaultValue:`Change Password`}):a(`profile.password.setTitle`,{defaultValue:`Set Local Password`})})]}),(0,k.jsx)(E,{children:s?a(`profile.password.changeDescription`,{defaultValue:`Update the password you use to sign in to this environment.`}):a(`profile.password.setDescription`,{defaultValue:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})})]}),(0,k.jsx)(C,{children:(0,k.jsxs)(`form`,{onSubmit:L,className:`space-y-4 max-w-md`,children:[s&&(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(v,{htmlFor:`current-password`,children:a(`profile.password.current`,{defaultValue:`Current password`})}),(0,k.jsx)(d,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:l,onChange:e=>f(e.target.value),disabled:A||R,required:!0})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(v,{htmlFor:`new-password`,children:s?a(`profile.password.new`,{defaultValue:`New password`}):a(`profile.password.password`,{defaultValue:`Password`})}),(0,k.jsx)(d,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:h,onChange:e=>b(e.target.value),disabled:A||R,minLength:8,required:!0})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(v,{htmlFor:`confirm-password`,children:a(`profile.password.confirm`,{defaultValue:`Confirm password`})}),(0,k.jsx)(d,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:S,onChange:e=>w(e.target.value),disabled:A||R,minLength:8,required:!0})]}),M&&(0,k.jsxs)(o,{variant:`destructive`,children:[(0,k.jsx)(p,{className:`h-4 w-4`}),(0,k.jsx)(u,{children:M})]}),P&&(0,k.jsxs)(o,{children:[(0,k.jsx)(x,{className:`h-4 w-4`}),(0,k.jsx)(u,{children:P})]}),(0,k.jsx)(D,{type:`submit`,disabled:A||R,className:`w-full sm:w-auto`,children:A?a(`profile.saving`,{defaultValue:`Saving…`}):s?a(`profile.password.changeAction`,{defaultValue:`Change password`}):a(`profile.password.setAction`,{defaultValue:`Set password`})})]})})]})}export{A as ProfilePage};
|