planche 0.7.20 → 0.8.0
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/app/assets/{AboutDialog-dKk703-Z.js → AboutDialog-CC7jb8_P.js} +1 -1
- package/app/assets/AiSettingsDialog-1t0_9610.js +1 -0
- package/app/assets/ConnectDialog-C8novVo3.js +1 -0
- package/app/assets/{CopyDatabaseDialog-B7w3Ek74.js → CopyDatabaseDialog-BZaC4BRf.js} +1 -1
- package/app/assets/CopyTableDialog-mjYPJxx8.js +1 -0
- package/app/assets/{CreateDatabaseDialog-Dnulabm5.js → CreateDatabaseDialog-K9LU6SFa.js} +1 -1
- package/app/assets/{CreateSchemaDialog-Lvff6Tdj.js → CreateSchemaDialog-IMU6kUwh.js} +1 -1
- package/app/assets/{DataDiffDialog-DNTu-7-T.js → DataDiffDialog-DcPx4VLE.js} +1 -1
- package/app/assets/{DownloadToCSVDialog-jxCkzB3J.js → DownloadToCSVDialog-cWxA73M8.js} +2 -2
- package/app/assets/EditSchemaDialog-UuUlGY4B.js +2 -0
- package/app/assets/{FindReplaceDialog-CyNlKq00.js → FindReplaceDialog-BphY4fYD.js} +1 -1
- package/app/assets/{FlushDialog-Cp7W6Ck1.js → FlushDialog-C1ahiGEa.js} +1 -1
- package/app/assets/GeneralSettingsDialog-CSoV6bfv.js +1 -0
- package/app/assets/{GroupByDialog-CHwsURs9.js → GroupByDialog-CO8in38J.js} +1 -1
- package/app/assets/{LicenseDialog-RY0SOUb1.js → LicenseDialog-d17TldUe.js} +1 -1
- package/app/assets/LinkColumnDialog-Dtz38QJy.js +1 -0
- package/app/assets/{LocalHistoryDialog-LnF86KJl.js → LocalHistoryDialog-B8WdxxF7.js} +1 -1
- package/app/assets/{ProcessListDialog-Jt-1b88E.js → ProcessListDialog-D0hVqOEu.js} +1 -1
- package/app/assets/QuerySettingsDialog-C-chLD8U.js +1 -0
- package/app/assets/QuickCommandPalette-BhTxG9s-.js +1 -0
- package/app/assets/RowFormDialog-MZivb9nJ.js +2 -0
- package/app/assets/SafetySettingsDialog-D4p0vAK7.js +1 -0
- package/app/assets/SchemaDiffDialog-BIxIvBGm.js +7 -0
- package/app/assets/{SchemaToHTMLDialog-Da8c-rAe.js → SchemaToHTMLDialog-CalQNcBO.js} +1 -1
- package/app/assets/{StatusDialog-mibIDpmA.js → StatusDialog-C49Nlkmj.js} +1 -1
- package/app/assets/{SyncDialog-BIDs_FZr.js → SyncDialog-DgjppEJu.js} +1 -1
- package/app/assets/{TermsDialog-CWw3XSw0.js → TermsDialog-CMGa972R.js} +1 -1
- package/app/assets/{UserAddDialog-D-TQNCsa.js → UserAddDialog-D_Ntb9Oc.js} +1 -1
- package/app/assets/{UserManagerDialog-DTxhu0T8.js → UserManagerDialog-BTOhBvd9.js} +1 -1
- package/app/assets/{VariablesDialog-CCzXtQQV.js → VariablesDialog-BTVi_JEh.js} +1 -1
- package/app/assets/connection-store-BnO3WqEO.js +1 -0
- package/app/assets/contract-W8-jEnEI.js +1 -0
- package/app/assets/database-BvWJHB7q.js +1 -0
- package/app/assets/de-DPmJYeTi.js +2 -0
- package/app/assets/{engine-DtZy_Zk0.js → engine-s5WfEr4n.js} +1 -1
- package/app/assets/error-hints-AQZemZKj.js +8 -0
- package/app/assets/fr-BLVbrMir.js +2 -0
- package/app/assets/i18n-D0mAAGED.js +2 -0
- package/app/assets/ja-BKUEaPbL.js +2 -0
- package/app/assets/ko-XOd5LtL3.js +2 -0
- package/app/assets/license-store-D_XwbbCs.js +1 -0
- package/app/assets/{main-BPskUSLM.js → main-C-Gt0g0g.js} +206 -189
- package/app/assets/main-C3ej0FPT.css +2 -0
- package/app/assets/{pro-gate-IRkx6bbE.js → pro-gate-DZATEYdR.js} +1 -1
- package/app/assets/{pro-upsell-lFmxmise.js → pro-upsell-akqEMS8_.js} +1 -1
- package/app/assets/pro-usage-C661VD02.js +1 -0
- package/app/assets/query-execution-CZvQYEUq.js +2 -0
- package/app/assets/{query-store-BR6Saeed.js → query-store-dYiA8oM5.js} +1 -1
- package/app/assets/{select-C3A-RS4G.js → select-DwgCtoqv.js} +1 -1
- package/app/assets/settings-controls-DrW8_eiX.js +1 -0
- package/app/assets/settings-store-BBVuUVjA.js +1 -0
- package/app/assets/table-copy-LtbDgIEc.js +1 -0
- package/app/assets/tunneling-BPoIRxJA.js +1 -0
- package/app/assets/zh-DNy8t_lA.js +2 -0
- package/app/index.html +17 -17
- package/dist/index.js +799 -45
- package/package.json +3 -1
- package/app/assets/ConnectDialog-DdXULzdj.js +0 -1
- package/app/assets/CopyTableDialog-B0kK-0Bl.js +0 -1
- package/app/assets/EditSchemaDialog-CFrD-8z9.js +0 -2
- package/app/assets/LinkColumnDialog-BD9rpsyg.js +0 -1
- package/app/assets/QuickCommandPalette-DEFuPaG7.js +0 -1
- package/app/assets/RowFormDialog-mM6FFZQr.js +0 -2
- package/app/assets/SafetySettingsDialog-B3MafT1S.js +0 -1
- package/app/assets/SchemaDiffDialog-BvNzQo5m.js +0 -7
- package/app/assets/connection-store-Ds9Gjt3K.js +0 -1
- package/app/assets/contract-D2InX341.js +0 -1
- package/app/assets/database-eJWHFM-2.js +0 -1
- package/app/assets/de-D9wNOTjH.js +0 -2
- package/app/assets/fr-CMT9T7_Z.js +0 -2
- package/app/assets/i18n-BAv7QdV3.js +0 -2
- package/app/assets/ja-C5Z0_8jZ.js +0 -2
- package/app/assets/ko-BF4ZzLce.js +0 -2
- package/app/assets/license-store-BfuSb6KZ.js +0 -1
- package/app/assets/main-DmICiyzI.css +0 -2
- package/app/assets/pro-usage-WSD_KOk4.js +0 -1
- package/app/assets/query-execution-C5QxvBZj.js +0 -7
- package/app/assets/settings-store-CSMhaLcw.js +0 -1
- package/app/assets/table-copy-BJBmJ9OO.js +0 -1
- package/app/assets/tunneling-rujGqkfQ.js +0 -1
- package/app/assets/use-engine-CxcEyIko.js +0 -1
- package/app/assets/zh-BpFgSEeR.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./main-
|
|
1
|
+
import{t as e}from"./main-C-Gt0g0g.js";import{n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-FBpgH0QJ.js";var d=n(),f=`https://planche.dev`,p=`/third-party-notices.txt`;function m(){let n=t(e=>e.activeDialog),m=t(e=>e.closeDialog),{t:h}=r();return(0,d.jsx)(u,{open:n===`about`,onOpenChange:e=>{e||m()},children:(0,d.jsxs)(s,{className:`sm:max-w-[440px]`,children:[(0,d.jsx)(a,{children:(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(e,{size:44,className:`shrink-0`}),(0,d.jsxs)(`div`,{className:`grid gap-1`,children:[(0,d.jsx)(c,{children:h(`about.title`)}),(0,d.jsx)(l,{children:h(`about.tagline`)})]})]})}),(0,d.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,d.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.version`)}),(0,d.jsx)(`dd`,{children:`0.1.1`}),(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.website`)}),(0,d.jsx)(`dd`,{children:(0,d.jsx)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:f})}),(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.licenses`)}),(0,d.jsx)(`dd`,{children:(0,d.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:h(`about.licensesLink`)})})]}),(0,d.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`© 2026 Juwon Jeong. `,h(`about.rights`)]}),(0,d.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:h(`about.disclaimer`)}),(0,d.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-muted-foreground`,children:[(0,d.jsx)(`p`,{className:`mb-1 font-medium text-amber-600 dark:text-amber-400`,children:h(`pro.noticeTitle`)}),(0,d.jsx)(`p`,{children:h(`pro.notice`)})]})]}),(0,d.jsx)(o,{children:(0,d.jsx)(i,{onClick:m,children:h(`settings.done`)})})]})})}export{m as AboutDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,w as r}from"./main-C-Gt0g0g.js";import{h as i,n as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-DwgCtoqv.js";import{_ as m,c as h,d as g}from"./tunneling-BPoIRxJA.js";import{i as _,n as v}from"./settings-store-BBVuUVjA.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(i(),1),E=o();function D(){let{t:e}=s(),[i,a]=(0,T.useState)(null),[o,y]=(0,T.useState)(!1),[b,x]=(0,T.useState)(`anthropic`),[S,C]=(0,T.useState)(``),[w,D]=(0,T.useState)(``),[O,k]=(0,T.useState)(``),[A,j]=(0,T.useState)(!1),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(null),I=v(e=>e.setAiPreferences),L=(0,T.useCallback)(()=>{g().then(e=>{a(e);let t=v.getState().aiPreferences,n=e.storage!==`none`;x(n?e.provider:t.provider),C(n?e.model:t.model),D((n?e.baseUrl:t.baseUrl)??``),j(n?e.storage===`file`:t.remember)}).catch(()=>y(!0))},[]);(0,T.useEffect)(L,[L]);let R=(0,T.useCallback)(e=>{x(e),C(t=>_(t,e))},[]),z=(0,T.useCallback)(()=>{N(!0),F(null),m({provider:b,model:S.trim()||void 0,baseUrl:w.trim()||void 0,key:O,remember:A}).then(t=>{a(t),k(``),I({provider:b,model:S.trim()||t.model,baseUrl:w.trim(),remember:A}),F(e(`settings.ai.saved`)),r()}).catch(e=>F(e instanceof Error?e.message:String(e))).finally(()=>N(!1))},[b,S,w,O,A,I,e]),B=(0,T.useCallback)(()=>{N(!0),F(null),h().then(e=>{a(e),k(``),r()}).catch(e=>F(e instanceof Error?e.message:String(e))).finally(()=>N(!1))},[]);if(o)return(0,E.jsx)(`p`,{className:`rounded-md border p-3 text-xs text-muted-foreground`,children:e(`settings.ai.unreachable`)});if(!i)return null;let V=i.fromEnvironment;return(0,E.jsxs)(`div`,{className:`grid gap-3 rounded-md border p-3`,children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.intro`)}),(0,E.jsx)(`p`,{className:`text-xs`,children:i.storage===`environment`?e(`settings.ai.configuredEnv`):i.storage===`file`?e(`settings.ai.configuredFile`,{path:i.path}):i.storage===`session`?e(`settings.ai.configuredSession`):e(`settings.ai.none`)}),!V&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-provider`,className:`text-sm font-medium`,children:e(`settings.ai.provider`)}),(0,E.jsxs)(p,{value:b,onValueChange:e=>R(e),children:[(0,E.jsx)(u,{id:`ai-provider`,children:(0,E.jsx)(l,{})}),(0,E.jsxs)(d,{children:[(0,E.jsx)(f,{value:`anthropic`,children:`Anthropic`}),(0,E.jsx)(f,{value:`openai`,children:e(`settings.ai.openaiCompatible`)}),(0,E.jsx)(f,{value:`gemini`,children:`Google Gemini`})]})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-model`,className:`text-sm font-medium`,children:e(`settings.ai.model`)}),(0,E.jsx)(n,{id:`ai-model`,value:S,onChange:e=>C(e.target.value),spellCheck:!1})]}),b===`openai`&&(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,E.jsx)(t,{htmlFor:`ai-base-url`,className:`text-sm font-medium`,children:e(`settings.ai.baseUrl`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.baseUrlHint`)})]}),(0,E.jsx)(n,{id:`ai-base-url`,value:w,onChange:e=>D(e.target.value),placeholder:`https://api.openai.com/v1`,spellCheck:!1})]}),(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(t,{htmlFor:`ai-key`,className:`text-sm font-medium`,children:e(`settings.ai.key`)}),(0,E.jsx)(n,{id:`ai-key`,type:`password`,value:O,onChange:e=>k(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:i.configured?`••••••••`:``}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.keyHint`)})]}),(0,E.jsxs)(`label`,{htmlFor:`ai-remember`,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,E.jsx)(`input`,{id:`ai-remember`,type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,E.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings.ai.remember`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.rememberHint`,{path:i.path})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(c,{size:`sm`,onClick:z,disabled:M||!O.trim(),children:e(`settings.ai.save`)}),i.configured&&(0,E.jsx)(c,{size:`sm`,variant:`ghost`,onClick:B,disabled:M,children:e(`settings.ai.forget`)}),P&&(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:P})]})]})]})}function O(){let e=a(e=>e.activeDialog),t=a(e=>e.closeDialog),{t:n}=s();return(0,E.jsx)(w,{open:e===`ai-settings`,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(x,{className:`sm:max-w-[560px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:n(`settings.ai.title`)}),(0,E.jsx)(C,{children:n(`settings.ai.description`)})]}),(0,E.jsx)(D,{}),(0,E.jsx)(b,{children:(0,E.jsx)(c,{onClick:t,children:n(`settings.done`)})})]})})}export{O as AiSettingsDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,C as r,F as i,I as a,S as o,a as s,b as c,c as l,i as u,k as d,l as f,n as p,o as m,r as h,s as g,u as _,ut as v,v as y,x as b,y as x}from"./main-C-Gt0g0g.js";import{h as S,n as C,t as w}from"./ui-store-5IssrgmG.js";import{l as T,m as E,t as D}from"./button-B2EsmMJs.js";import{a as O,i as k,n as A,r as j,t as M}from"./select-DwgCtoqv.js";import{C as N,a as P,b as F,f as I,p as ee,x as L}from"./tunneling-BPoIRxJA.js";import{t as R}from"./connection-store-BnO3WqEO.js";import{n as te}from"./query-store-dYiA8oM5.js";import{S as ne,d as z,g as re,i as ie,l as B,r as ae}from"./database-BvWJHB7q.js";import{n as V,t as H}from"./dbms-BwnatOMe.js";import{n as U}from"./pro-gate-DZATEYdR.js";import{a as oe,i as se,n as ce,o as le,t as ue}from"./dialog-FBpgH0QJ.js";var W=e(S(),1),G=new Set([`postgres:`,`postgresql:`]);function K(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!G.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var q=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function J(e,t){let n;try{let t=new URL(e);if(!q.has(t.hostname.toLowerCase()))return[];n=t.origin}catch{return[]}try{let e=await fetch(`${n}/cdn-cgi/local/explorer/api/d1/database`,{signal:t});if(!e.ok)return[];let r=await e.json(),i=new Map;for(let e of r.result??[])e.uuid&&i.set(e.uuid,{name:e.name??e.uuid,id:e.uuid});return[...i.values()]}catch{return[]}}var Y=T(),X=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],Z={enabled:!1,host:``,port:22,user:``,auth:`key`};function Q({label:e,htmlFor:t,children:n}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,Y.jsx)(l,{htmlFor:t,children:e}),n]})}function de({value:e,onChange:t}){let{t:r}=E();function i(n,r){t({...e,[n]:r})}let[o,s]=(0,W.useState)([]),c=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!c){s([]);return}let e=new AbortController,t=setTimeout(()=>{J(c,e.signal).then(s)},300);return()=>{clearTimeout(t),e.abort()}},[c]);let l=e.dbms===`sqlite`,u=e.transport??`browser`,p=l&&u===`browser`,h=L.has(e.dbms),v=e.dbms===`d1`,y=e.dbms===`do`,b=H.find(t=>t.id===e.dbms)?.capabilities,x=e.ssh??Z,[S,C]=(0,W.useState)(``),w=S.trim()===``?`empty`:K(S)?`applied`:`invalid`,T=e.dbms===`supabase`&&e.port===6543;function P(n){C(n);let r=K(n);r&&t({...e,host:r.host??e.host,port:r.port??H.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function F(n){t({...e,ssh:{...x,...n}})}async function I(e){e&&F({privateKey:await e.text(),privateKeyName:e.name})}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,Y.jsx)(Q,{label:r(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,Y.jsx)(f,{id:`conn-hostName`,placeholder:r(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>i(`hostName`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.dataSource`),children:(0,Y.jsxs)(M,{value:e.dbms,onValueChange:n=>{let r=H.find(e=>e.id===n);if(!r)return;let i=r.id,a=L.has(i)||i===`d1`||i===`do`;C(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||h||v||y?g(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!h&&!v&&!y?e.database:m(i)??e.database})},children:[(0,Y.jsx)(k,{id:`conn-dbms`,className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsx)(A,{children:H.map(e=>(0,Y.jsx)(j,{value:e.id,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(_,{dbms:e.id}),e.label]})},e.id))})]})}),h&&(0,Y.jsx)(Q,{label:r(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(f,{id:`conn-uri`,type:`password`,autoComplete:`new-password`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:S,onChange:e=>P(e.target.value)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${w===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:r(w===`invalid`?`connection.form.connectionStringInvalid`:w===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),l&&(0,Y.jsxs)(Q,{label:r(`connection.form.openVia`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>i(`transport`,`browser`),className:`accent-primary`}),r(`connection.form.viaBrowser`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>i(`transport`,`tunnel`),className:`accent-primary`}),r(`connection.form.viaAgent`)]})]}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(u===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),p?(0,Y.jsx)(Q,{label:r(`connection.form.databaseFile`),children:(0,Y.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,Y.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{B(e.id),i(`file`,``)},children:r(`connection.form.changeFile`)})]}):(0,Y.jsx)(`p`,{children:r(`connection.form.filePickerHint`)}),(0,Y.jsx)(`p`,{className:`mt-1`,children:r(`connection.form.fileRememberedHint`)})]})}):null,!p&&(0,Y.jsx)(Q,{label:r(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,Y.jsx)(f,{id:`conn-authToken`,type:`password`,autoComplete:`new-password`,placeholder:r(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>i(`authToken`,e.target.value.trim())})}),p?null:y?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,Y.jsx)(f,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>i(`devUrl`,e.target.value.trim())})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.doHint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.doLimitsHint`)})]}):v?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,Y.jsx)(f,{id:`conn-d1-dev`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>i(`devUrl`,e.target.value.trim())})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.d1DevUrlHint`)}),(0,Y.jsx)(Q,{label:r(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,Y.jsx)(f,{id:`conn-d1-account`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>i(`accountId`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:r(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:o.length>0?(0,Y.jsxs)(M,{value:e.databaseId??``,onValueChange:e=>i(`databaseId`,e),children:[(0,Y.jsx)(k,{id:`conn-d1-database`,children:(0,Y.jsx)(O,{placeholder:r(`connection.form.d1PickDatabase`)})}),(0,Y.jsx)(A,{children:o.map(e=>(0,Y.jsxs)(j,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,Y.jsx)(f,{id:`conn-d1-database`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>i(`databaseId`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:r(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(f,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>i(`pass`,e.target.value.trim())}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:r(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>i(`savePassword`,e.target.checked)}),r(`connection.form.savePassword`)]})]})}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.d1Hint`)}),(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.d1LimitsHint`)})]}):l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,Y.jsx)(f,{id:`conn-file`,placeholder:r(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>i(`file`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>i(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`connection.form.createIfMissingHint`)})]})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.host`),htmlFor:`conn-host`,children:(0,Y.jsx)(f,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>i(`host`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.port`),htmlFor:`conn-port`,children:(0,Y.jsx)(f,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>i(`port`,Number(t.target.value)||H.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),T&&(0,Y.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:r(`connection.form.supabasePoolerWarning`)}),(N(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,Y.jsx)(Q,{label:e.dbms===`oracle`?r(`connection.form.serviceName`):r(`connection.form.database`),htmlFor:`conn-database`,children:(0,Y.jsx)(f,{id:`conn-database`,placeholder:m(e.dbms),value:e.database??``,onChange:e=>i(`database`,e.target.value.trim())})}),(0,Y.jsx)(Q,{label:r(`connection.form.user`),htmlFor:`conn-user`,children:(0,Y.jsx)(f,{id:`conn-user`,autoComplete:`off`,placeholder:g(e.dbms),value:e.user,onChange:e=>i(`user`,e.target.value)})}),(0,Y.jsx)(Q,{label:r(`connection.form.password`),htmlFor:`conn-pass`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(f,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>i(`pass`,e.target.value)}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:r(`connection.form.savePasswordHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>i(`savePassword`,e.target.checked)}),r(`connection.form.savePassword`)]})]})}),h&&(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.managedTlsHint`)}),!h&&e.dbms!==`oracle`&&(0,Y.jsx)(Q,{label:r(`connection.form.tls`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>i(`ssl`,e.target.checked),className:`size-4 accent-primary`}),r(`connection.form.tlsEnable`)]}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:r(`connection.form.tlsVerifyHint`),children:[(0,Y.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>i(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),r(`connection.form.tlsVerify`)]})]})}),!h&&(0,Y.jsx)(Q,{label:r(`connection.form.charset`),children:(0,Y.jsxs)(M,{value:e.charset,onValueChange:e=>i(`charset`,e),children:[(0,Y.jsx)(k,{className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsx)(A,{children:X.map(e=>(0,Y.jsx)(j,{value:e,children:e},e))})]})})]}),!l&&!h&&!v&&!y&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[r(`connection.form.ssh`),(0,Y.jsx)(a,{className:`ml-2`})]}),(0,Y.jsx)(Q,{label:r(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:x.enabled,onChange:e=>{(!e.target.checked||U(`ssh_tunnel`))&&F({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`connection.form.sshTunnelHint`)})]})}),x.enabled&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(f,{id:`conn-ssh-host`,placeholder:r(`connection.form.sshHostPlaceholder`),value:x.host,onChange:e=>F({host:e.target.value.trim()})}),(0,Y.jsx)(f,{"aria-label":r(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:x.port,onChange:e=>F({port:Number(e.target.value)||22})})]})}),(0,Y.jsx)(Q,{label:r(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,Y.jsx)(f,{id:`conn-ssh-user`,placeholder:r(`connection.form.sshUserPlaceholder`),value:x.user,onChange:e=>F({user:e.target.value.trim()})})}),(0,Y.jsx)(Q,{label:r(`connection.form.sshAuth`),children:(0,Y.jsxs)(M,{value:x.auth,onValueChange:e=>F({auth:e}),children:[(0,Y.jsx)(k,{className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsxs)(A,{children:[(0,Y.jsx)(j,{value:`key`,children:r(`connection.form.sshAuthKey`)}),(0,Y.jsx)(j,{value:`password`,children:r(`connection.form.sshAuthPassword`)}),(0,Y.jsx)(j,{value:`agent`,children:r(`connection.form.sshAuthAgent`)})]})]})}),x.auth===`password`&&(0,Y.jsx)(Q,{label:r(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,Y.jsx)(f,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:x.password??``,onChange:e=>F({password:e.target.value})})}),x.auth===`key`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{label:r(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{I(e.target.files?.[0]),e.target.value=``}}),(0,Y.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:x.privateKey?r(`connection.form.changeFile`):r(`connection.form.sshKeyPick`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:x.privateKeyName,children:x.privateKey?x.privateKeyName||r(`connection.form.sshKeyLoaded`):r(`connection.form.sshKeyHint`)})]})}),(0,Y.jsx)(Q,{label:r(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,Y.jsx)(f,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:r(`connection.form.sshPassphrasePlaceholder`),value:x.passphrase??``,onChange:e=>F({passphrase:e.target.value})})})]}),x.auth===`agent`&&(0,Y.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.sshAuthAgentHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.sshTargetHint`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:r(`connection.form.sshSecretsHint`)})]})]}),(0,Y.jsx)(Q,{label:r(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,Y.jsx)(`div`,{className:`flex items-center`,children:(0,Y.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>i(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,Y.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:r(`connection.form.safety`)}),(0,Y.jsx)(Q,{label:r(`connection.form.environment`),children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[d.map(t=>{let r=(e.environmentColor??`none`)===t.id;return(0,Y.jsx)(`button`,{type:`button`,title:n(t.id),"aria-label":n(t.id),"aria-pressed":r,onClick:()=>i(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${r?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,Y.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:r(`connection.form.environmentHint`)})]})}),(0,Y.jsx)(Q,{label:r(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>i(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`connection.form.readOnlyHint`)})]})}),b?.transactions!==!1&&(0,Y.jsx)(Q,{label:r(`connection.form.transactions`),children:(0,Y.jsxs)(M,{value:e.transactionMode??`auto`,onValueChange:e=>i(`transactionMode`,e),children:[(0,Y.jsx)(k,{className:`w-full`,children:(0,Y.jsx)(O,{})}),(0,Y.jsxs)(A,{children:[(0,Y.jsx)(j,{value:`auto`,children:r(`connection.form.txAuto`)}),(0,Y.jsx)(j,{value:`manual`,children:r(`connection.form.txManual`)})]})]})})]})}function fe(){let{t:e}=E(),{activeDialog:n,closeDialog:a,showMessage:l}=C(),[d,f]=(0,W.useState)(!1),{savedConnections:m,addSavedConnection:g,updateSavedConnection:S,deleteSavedConnection:T,openConnection:O}=R(),k=w(`connect`)?.profileId,[A,j]=(0,W.useState)(()=>k??null),[M,N]=(0,W.useState)(()=>{let e=k?m.find(e=>e.id===k):void 0;return e?{...e}:null}),L=n===`connect`,[B,H]=(0,W.useState)(null),[U,G]=(0,W.useState)(null),K=i(e=>e.url),q=i(e=>e.token);(0,W.useEffect)(()=>{if(!L)return;let e=!1;return(async()=>{try{let t=await P();if(e||t.state!==`online`||!t.gateway){e||H(null);return}let n=await I();e||(H({name:n.gateway,profiles:n.profiles}),G(null))}catch(t){e||G(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[L,K,q]);function J(t){let n=m.find(e=>e.gatewayProfile===t.name);if(n){Z(n);return}let r=h(t);g(r),Z(r),C.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function X(e){e||(a(),j(null),N(null))}function Z(e){j(e.id),N({...e})}function Q(e){N(e),S(e.id,e)}function fe(){let e=s();g(e),j(e.id),N(e)}function pe(){A&&(T(A),j(null),N(null))}let[me,he]=(0,W.useState)(!1),ge=te(e=>e.addQueryTab);function $(t){let n=R.getState().activeConnections.some(e=>e.id===t.id);if(O(t),ne.getState().removeTree(t.id),n){a(),j(null),N(null);return}ge(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),a(),j(null),N(null)}async function _e(t){let n=await ae(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};S(t.id,{file:n.fileName}),$(r),R.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?C.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?C.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&C.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function ve(t,n){try{return await n(t)}catch(r){let i=ee(r);if(!i||!(`ssh`in t)||!t.ssh||!await C.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function ye(){if(M){he(!0);try{if(z(M)===`browser`){await _e(M);return}let t=await ve(F(M),e=>ie(e,M.authToken||void 0));t.success?$({...M,serverConnectionId:t.connectionId}):l({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){l({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{he(!1)}}}async function be(){if(M){if(z(M)===`browser`){l({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}f(!0);try{let t=await ve(F(M),e=>re(e,M.authToken||void 0));t.success?l({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):l({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){l({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{f(!1)}}}return(0,Y.jsx)(ue,{open:L,onOpenChange:X,children:(0,Y.jsxs)(ce,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,Y.jsx)(oe,{children:(0,Y.jsx)(le,{children:e(`connection.dialog.title`)})}),(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,Y.jsx)(v,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,Y.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,Y.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(B||U)&&(0,Y.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,Y.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),B?` — ${B.name}`:``]}),U&&(0,Y.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:U})}),B?.profiles.map(t=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,Y.jsx)(_,{dbms:p[t.driver],className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t.name}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,Y.jsx)(D,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>J(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,Y.jsx)(t,{className:`h-full`,children:(0,Y.jsxs)(y,{className:`table-fixed`,children:[(0,Y.jsx)(o,{children:(0,Y.jsxs)(r,{children:[(0,Y.jsx)(b,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,Y.jsx)(b,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,Y.jsx)(b,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,Y.jsx)(x,{children:m.length===0?(0,Y.jsx)(r,{children:(0,Y.jsx)(c,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):m.map(t=>(0,Y.jsxs)(r,{"data-state":A===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>Z(t),onDoubleClick:()=>{Z(t),ye()},children:[(0,Y.jsx)(c,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,Y.jsx)(c,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(z(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user}@${t.host}:${t.port}`}),(0,Y.jsx)(c,{className:`truncate`,title:V(t.dbms).label,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(_,{dbms:t.dbms,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:V(t.dbms).label})]})})]},t.id))})]})})]}),(0,Y.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,Y.jsxs)(Y.Fragment,{children:[z(M)!==`browser`&&(0,Y.jsx)(`div`,{className:`p-4 pb-0`,children:(0,Y.jsx)(u,{})}),M.gatewayProfile?(0,Y.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,Y.jsx)(_,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,Y.jsx)(de,{value:M,onChange:Q})]}):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,Y.jsxs)(se,{className:`sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(D,{variant:`outline`,onClick:fe,children:e(`connection.dialog.addNew`)}),(0,Y.jsx)(D,{variant:`destructive`,onClick:pe,disabled:!A,children:e(`connection.dialog.delete`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(D,{variant:`outline`,onClick:be,disabled:!M||d,children:e(`connection.dialog.testConnection`)}),(0,Y.jsx)(D,{onClick:ye,disabled:!M||me,children:e(`connection.dialog.connect`)}),(0,Y.jsx)(D,{variant:`outline`,onClick:()=>X(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{fe as ConnectDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-C-Gt0g0g.js";import{h as r,n as i,t as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{t as l}from"./connection-store-BnO3WqEO.js";import{a as u}from"./database-BvWJHB7q.js";import{n as d}from"./engine-s5WfEr4n.js";import{c as f,p}from"./query-execution-CZvQYEUq.js";import{n as m,t as h}from"./table-copy-LtbDgIEc.js";import{a as g,i as _,n as v,o as y,t as b}from"./dialog-FBpgH0QJ.js";var x=e(r(),1),S=o();function C(){let{t:e}=s(),{activeDialog:r,closeDialog:o}=i(),C=a(`copy-database`),w=r===`copy-database`,T=C?.database??``,[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(`structure_data`),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null);function P(e){e||(o(),N(null),j(null),D(``),k(`structure_data`))}async function F(){let t=l.getState().activeConnectionId,n=E.trim();if(!t||!n||!T)return;N(null);let r=d(t),i=l.getState().activeConnections.find(e=>e.id===t);if(i?.serverConnectionId)try{j(e(`database.copy.creating`,{database:n})),await f(t,r.getQuery(`CREATE_DATABASE`,n,`utf8mb4`,`utf8mb4_general_ci`));let a=u(i.serverConnectionId),o=await r.introspect.listTables(a,T);for(let[r,i]of o.entries()){j(e(`database.copy.copying`,{table:i.name,index:r+1,total:o.length}));let a={connectionId:t,database:T,table:i.name},s={connectionId:t,database:n,table:i.name},c=await h(a,s);await m({source:a,target:s,mode:O,onConflict:`abort`,createSql:d(t).ddl.createTable(c)})}await p(t),P(!1)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(null)}}return(0,S.jsx)(b,{open:w,onOpenChange:P,children:(0,S.jsxs)(v,{className:`sm:max-w-[450px]`,children:[(0,S.jsx)(g,{children:(0,S.jsx)(y,{children:e(`database.copy.title`)})}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{children:e(`database.copy.source`)}),(0,S.jsx)(n,{value:T,disabled:!0})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,S.jsx)(n,{id:`target-db-name`,value:E,onChange:e=>D(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{children:e(`database.copy.options`)}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:O===`structure_data`,onChange:()=>k(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:O===`structure_only`,onChange:()=>k(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),A&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:A}),M&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:M}),(0,S.jsxs)(_,{children:[(0,S.jsx)(c,{variant:`outline`,onClick:()=>P(!1),children:e(`database.copy.cancel`)}),(0,S.jsx)(c,{onClick:()=>void F(),disabled:!E.trim()||A!==null,children:e(`database.copy.copy`)})]})]})})}export{C as CopyDatabaseDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,j as n,l as r}from"./main-C-Gt0g0g.js";import{h as i,n as a,t as ee}from"./ui-store-5IssrgmG.js";import{l as o,m as te,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DwgCtoqv.js";import{t as ne}from"./connection-store-BnO3WqEO.js";import{a as re}from"./database-BvWJHB7q.js";import{n as p}from"./engine-s5WfEr4n.js";import{t as ie}from"./query-execution-CZvQYEUq.js";import{n as ae,t as oe}from"./table-copy-LtbDgIEc.js";import{a as m,i as se,n as ce,o as le,t as h}from"./dialog-FBpgH0QJ.js";var g=e(i(),1),_=o(),v=e=>e instanceof Error?e.message:String(e),y=e=>e.hostName||e.host||e.file||e.id,ue=`w-full rounded border bg-background px-2 py-1 text-xs font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 min-h-[160px] resize-y`;function b(){let{t:e}=te(),i=a(e=>e.activeDialog),o=a(e=>e.closeDialog),b=a(e=>e.showMessage),x=ee(`copy-table`),S=ne(e=>e.activeConnections),C=i===`copy-table`,w=x?.connectionId??``,T=String(x?.metadata?.database??``),E=x?.nodeText??``,D=S.find(e=>e.id===w),de=S.filter(e=>e.serverConnectionId),[O,k]=(0,g.useState)(w),[A,j]=(0,g.useState)([]),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(E),[I,L]=(0,g.useState)(`structure_data`),[R,z]=(0,g.useState)(`abort`),[B,V]=(0,g.useState)(``),[H,U]=(0,g.useState)(null),[W,G]=(0,g.useState)(null),[K,q]=(0,g.useState)(null),[J,Y]=(0,g.useState)(!1),X=(0,g.useRef)(null),Z=S.find(e=>e.id===O),Q=Z?p(O):null,fe=!!D&&!!Z&&p(w).id===Q?.id;(0,g.useEffect)(()=>{if(!C||!Z?.serverConnectionId)return;let e=!1,t=p(O),n=re(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=O===w,a=i||r.includes(T)?T:r[0]??``;N(a),F(e=>i&&a===T&&e===E?`${E}_copy`:e)}catch(t){e||q(v(t))}})(),()=>{e=!0}},[C,O]),(0,g.useEffect)(()=>{if(!C||!Z||!M||!P.trim()||!D)return;let e=!1;return(async()=>{U(null);try{let t=await oe({connectionId:w,database:T,table:E},{connectionId:O,database:M,table:P.trim()});e||V(p(O).ddl.createTable(t))}catch(t){e||U(v(t))}})(),()=>{e=!0}},[C,O,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}o()}}async function pe(){if(!M||!P.trim()||!B.trim())return;Y(!0),q(null),G({phase:`create`,copied:0,total:null});let t=new AbortController;X.current=t;try{let n=await ae({source:{connectionId:w,database:T,table:E},target:{connectionId:O,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);o(),await b({title:e(`table.copy.doneTitle`),description:I===`structure_data`?e(`table.copy.doneRows`,{count:n.rows,table:P.trim()}):e(`table.copy.doneStructure`,{table:P.trim()}),tone:`success`})}catch(e){e instanceof ie||q(v(e)),G(null)}finally{Y(!1),X.current=null}}let me=W?.phase===`copy`&&W.total?Math.min(100,Math.round(W.copied/W.total*100)):null,he=W?W.phase===`create`?e(`table.copy.progressCreate`):W.phase===`count`?e(`table.copy.progressCount`):W.phase===`copy`?e(`table.copy.progressRows`,{copied:W.copied,total:W.total??`?`}):e(`table.copy.progressDone`):``;return(0,_.jsx)(h,{open:C,onOpenChange:$,children:(0,_.jsxs)(ce,{className:`sm:max-w-[640px]`,children:[(0,_.jsx)(m,{children:(0,_.jsx)(le,{children:e(`table.copy.title`)})}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.source`)}),(0,_.jsx)(r,{value:D?`${y(D)} / ${T} / ${E}`:``,disabled:!0})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,_.jsxs)(f,{value:O,onValueChange:k,disabled:J,children:[(0,_.jsx)(l,{id:`copy-target-conn`,className:`w-full`,children:(0,_.jsx)(c,{})}),(0,_.jsx)(u,{children:de.map(t=>(0,_.jsxs)(d,{value:t.id,children:[y(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,_.jsxs)(f,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,_.jsx)(l,{id:`copy-target-db`,className:`w-full`,children:(0,_.jsx)(c,{placeholder:e(`table.copy.loading`)})}),(0,_.jsx)(u,{children:A.map(e=>(0,_.jsx)(d,{value:e,children:e},e))})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,_.jsx)(r,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.what`)}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.ifExists`)}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,_.jsx)(`textarea`,{id:`copy-ddl`,className:ue,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,_.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(n,{value:me??(W.phase===`done`?100:0)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,_.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,_.jsxs)(se,{children:[(0,_.jsx)(s,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,_.jsx)(s,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{b as CopyTableDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-C-Gt0g0g.js";import{h as r,n as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DwgCtoqv.js";import{t as p}from"./connection-store-BnO3WqEO.js";import{n as m}from"./engine-s5WfEr4n.js";import{c as h,p as g}from"./query-execution-CZvQYEUq.js";import{a as _,i as v,n as y,o as b,t as x}from"./dialog-FBpgH0QJ.js";var S=e(r(),1),C=a(),w=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],T={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function E(){let{t:e}=o(),{activeDialog:r,closeDialog:a}=i(),E=r===`create-database`,[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(`utf8mb4`),[j,M]=(0,S.useState)(`utf8mb4_general_ci`),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null);function L(e){e||(a(),I(null),O(``),A(`utf8mb4`),M(`utf8mb4_general_ci`))}function R(e){A(e);let t=T[e];M(t?.[0]??``)}async function z(){let e=p.getState().activeConnectionId,t=D.trim();if(!(!e||!t)){I(null),P(!0);try{let n=m(e).getQuery(`CREATE_DATABASE`,t,k,j);await h(e,n),await g(e),L(!1)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}}let B=T[k]??[];return(0,C.jsx)(x,{open:E,onOpenChange:L,children:(0,C.jsxs)(y,{className:`sm:max-w-[450px]`,children:[(0,C.jsx)(_,{children:(0,C.jsx)(b,{children:e(`database.create.title`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,C.jsx)(n,{id:`db-name`,value:D,onChange:e=>O(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,C.jsxs)(f,{value:k,onValueChange:R,children:[(0,C.jsx)(l,{id:`db-charset`,className:`w-full`,children:(0,C.jsx)(c,{})}),(0,C.jsx)(u,{children:w.map(e=>(0,C.jsx)(d,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,C.jsxs)(f,{value:j,onValueChange:M,children:[(0,C.jsx)(l,{id:`db-collation`,className:`w-full`,children:(0,C.jsx)(c,{})}),(0,C.jsx)(u,{children:B.map(e=>(0,C.jsx)(d,{value:e,children:e},e))})]})]})]}),F&&(0,C.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:F}),(0,C.jsxs)(v,{children:[(0,C.jsx)(s,{variant:`outline`,onClick:()=>L(!1),children:e(`database.create.cancel`)}),(0,C.jsx)(s,{onClick:()=>void z(),disabled:!D.trim()||N,children:e(`database.create.create`)})]})]})})}export{E as CreateDatabaseDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-C-Gt0g0g.js";import{h as r,n as i,t as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{t as l}from"./connection-store-BnO3WqEO.js";import{n as u}from"./engine-s5WfEr4n.js";import{c as d,p as f}from"./query-execution-CZvQYEUq.js";import{a as p,i as m,n as h,o as g,t as _}from"./dialog-FBpgH0QJ.js";var v=e(r(),1),y=o();function b(){let{t:e}=s(),{activeDialog:r,closeDialog:o}=i(),b=a(`create-schema`),x=r===`create-schema`,[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(null);function O(e){e||(o(),C(``),D(null))}async function k(){let e=b?.connectionId??l.getState().activeConnectionId,t=S.trim();if(!(!e||!t)){D(null),T(!0);try{await d(e,u(e).getQuery(`CREATE_SCHEMA`,t)),await f(e),O(!1)}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}}}return(0,y.jsx)(_,{open:x,onOpenChange:O,children:(0,y.jsxs)(h,{className:`sm:max-w-[420px]`,children:[(0,y.jsx)(p,{children:(0,y.jsx)(g,{children:e(`database.schema.createTitle`)})}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(t,{htmlFor:`schema-name`,children:e(`database.schema.name`)}),(0,y.jsx)(n,{id:`schema-name`,value:S,autoFocus:!0,placeholder:e(`database.schema.namePlaceholder`),onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()}})]}),E&&(0,y.jsx)(`p`,{className:`text-xs text-destructive leading-relaxed`,children:E}),(0,y.jsxs)(m,{children:[(0,y.jsx)(c,{variant:`outline`,onClick:()=>O(!1),children:e(`database.schema.cancel`)}),(0,y.jsx)(c,{onClick:()=>void k(),disabled:!S.trim()||w,children:e(`database.schema.create`)})]})]})})}export{b as CreateSchemaDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{X as t,_ as n,c as r,g as i,h as a,z as o}from"./main-C-Gt0g0g.js";import{c as s,h as c,n as l,t as u}from"./ui-store-5IssrgmG.js";import{l as d,m as f,t as p}from"./button-B2EsmMJs.js";import{a as m,i as h,n as g,r as _,t as v}from"./select-DwgCtoqv.js";import{t as y}from"./connection-store-BnO3WqEO.js";import{a as b}from"./database-BvWJHB7q.js";import{n as x}from"./engine-s5WfEr4n.js";import{t as ee}from"./pro-usage-C661VD02.js";import{a as S,i as te,n as ne,o as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(c(),1),E=d(),D=e=>e instanceof Error?e.message:String(e),O=e=>e.hostName||e.host||e.file||e.id,k=5e4;function A({id:e,label:t,side:n,onChange:i,connections:a,disabled:o}){let{t:s}=f(),[c,l]=(0,T.useState)([]),[u,d]=(0,T.useState)([]),p=a.find(e=>e.id===n.connectionId);return(0,T.useEffect)(()=>{if(!p?.serverConnectionId)return;let e=!1;return(async()=>{try{let t=await x(p.id).introspect.listDatabases(b(p.serverConnectionId));if(e)return;l(t),t.includes(n.database)||i({connectionId:p.id,database:t[0]??``,table:``})}catch{e||l([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId]),(0,T.useEffect)(()=>{if(!p?.serverConnectionId||!n.database)return;let e=!1;return(async()=>{try{let t=await x(p.id).introspect.listTables(b(p.serverConnectionId),n.database);if(e)return;let r=t.map(e=>e.name);d(r),n.table&&!r.includes(n.table)&&i({...n,table:``})}catch{e||d([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId,n.database]),(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,E.jsx)(r,{className:`font-medium`,children:t}),(0,E.jsxs)(v,{value:n.connectionId,onValueChange:e=>i({connectionId:e,database:``,table:``}),disabled:o,children:[(0,E.jsx)(h,{id:`${e}-conn`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.diff.pickConnection`)})}),(0,E.jsx)(g,{children:a.map(e=>(0,E.jsx)(_,{value:e.id,children:O(e)},e.id))})]}),(0,E.jsxs)(v,{value:n.database,onValueChange:e=>i({...n,database:e,table:``}),disabled:o||c.length===0,children:[(0,E.jsx)(h,{id:`${e}-db`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.diff.pickDatabase`)})}),(0,E.jsx)(g,{children:c.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]}),(0,E.jsxs)(v,{value:n.table,onValueChange:e=>i({...n,table:e}),disabled:o||u.length===0,children:[(0,E.jsx)(h,{id:`${e}-table`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.dataDiff.pickTable`)})}),(0,E.jsx)(g,{children:u.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]})]})}async function j(e,t){let n=await o({connectionId:e.connectionId,database:e.database,table:e.table,limit:k,onProgress:t}),r=[];for await(let e of n.pages)r.push(...e);return{rows:r,columns:n.fields.map(e=>e.name),capped:r.length>=k}}function M({diff:e,row:t,other:n,changed:r}){let{t:a}=f(),o=[...e.keyColumns,...e.compareColumns];return(0,E.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,E.jsx)(`thead`,{className:`text-muted-foreground`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:a(`database.diff.column`)}),(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:a(`database.diff.source`)}),(0,E.jsx)(`th`,{className:`text-left font-normal`,children:a(`database.diff.target`)})]})}),(0,E.jsx)(`tbody`,{children:o.map(e=>(0,E.jsxs)(`tr`,{className:r?.includes(e)?`text-amber-600 dark:text-amber-400`:``,children:[(0,E.jsx)(`td`,{className:`pr-2 align-top whitespace-nowrap`,children:e}),(0,E.jsx)(`td`,{className:`pr-2 align-top break-all`,children:i(t[e])}),(0,E.jsx)(`td`,{className:`align-top break-all`,children:n?i(n[e]):`—`})]},e))})]})}function N(){let{t:e}=f(),r=l(e=>e.activeDialog),o=l(e=>e.closeDialog),c=u(`data-diff`),d=y(e=>e.activeConnections),m=(0,T.useMemo)(()=>d.filter(e=>e.serverConnectionId),[d]),h=y(e=>e.activeConnectionId),g=r===`data-diff`,[_,v]=(0,T.useState)(()=>c&&m.some(e=>e.id===c.connectionId)?{connectionId:c.connectionId,database:c.database,table:c.table}:{connectionId:h&&m.some(e=>e.id===h)?h:m[0]?.id??``,database:``,table:``}),[O,N]=(0,T.useState)(()=>({connectionId:m.find(e=>e.id!==_.connectionId)?.id??_.connectionId,database:``,table:``})),[P,re]=(0,T.useState)([]),[F,I]=(0,T.useState)(null),[ie,ae]=(0,T.useState)(!1),[L,R]=(0,T.useState)(`changed`),[z,B]=(0,T.useState)(0),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(!1),[G,K]=(0,T.useState)({source:null,target:null}),[q,J]=(0,T.useState)(null),oe=e=>N(e.database&&!e.table&&_.table?{...e,table:_.table}:e),Y=_.connectionId===O.connectionId&&_.database===O.database&&_.table===O.table,se=!!_.table&&!!O.table&&!Y,X=O.connectionId?x(O.connectionId):null;async function ce(){W(!0),J(null),I(null);try{let t=y.getState().activeConnections.find(e=>e.id===_.connectionId);if(!t?.serverConnectionId)throw Error(e(`services.query.notConnected`));let r=await x(_.connectionId).introspect.getPrimaryKeys(b(t.serverConnectionId),_.database,_.table);if(r.length===0)throw Error(e(`database.dataDiff.noPrimaryKey`,{table:_.table}));K({source:{loaded:0,total:null},target:{loaded:0,total:null}});let[i,a]=await Promise.all([j(_,e=>K(t=>({...t,source:e}))),j(O,e=>K(t=>({...t,target:e})))]);if(r.some(e=>!a.columns.includes(e)))throw Error(e(`database.dataDiff.keyMissingInTarget`,{columns:r.join(`, `)}));let o=n(i.rows,a.rows,r,i.columns,a.columns);re(r),ae(i.capped||a.capped),I(o),R(o.changed.length>0?`changed`:o.added.length>0?`added`:`removed`),B(0),ee(`compare_data`),s(`data_diff`,{source_dbms:x(_.connectionId).id,target_dbms:X?.id??`unknown`,added:o.added.length,changed:o.changed.length,removed:o.removed.length})}catch(e){J(D(e))}finally{W(!1),K({source:null,target:null})}}let Z=e=>e?e.total===null?e.loaded.toLocaleString():`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:``,Q=(0,T.useMemo)(()=>F&&X?a(F,X,{database:O.database,table:O.table},{includeDeletes:V}):``,[F,X,O.database,O.table,V]);function le(){Q&&(t(O.connectionId,Q,O.database,e(`database.dataDiff.tabTitle`,{table:O.table})),o())}let $=F?L===`added`?F.added:L===`removed`?F.removed:F.changed.map(e=>e.source):[],ue=!!F&&F.added.length+F.changed.length+F.removed.length>0,de=e=>P.map(t=>i(e[t])).join(`, `);return(0,E.jsx)(w,{open:g,onOpenChange:e=>{e||o()},children:(0,E.jsxs)(ne,{className:`sm:max-w-[900px]`,children:[(0,E.jsx)(S,{children:(0,E.jsx)(C,{children:e(`database.dataDiff.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,E.jsx)(A,{id:`ddiff-source`,label:e(`database.diff.source`),side:_,onChange:v,connections:m,disabled:U}),(0,E.jsx)(A,{id:`ddiff-target`,label:e(`database.diff.target`),side:O,onChange:oe,connections:m,disabled:U})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.hint`,{cap:k.toLocaleString()})}),Y&&_.table&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`database.dataDiff.sameSide`)}),q&&(0,E.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:q}),U&&(G.source||G.target)&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.loading`,{source:Z(G.source),target:Z(G.target)})}),F&&(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.summary`,{key:P.join(`, `),added:F.added.length,changed:F.changed.length,removed:F.removed.length,identical:F.identical})}),ie&&(0,E.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:e(`database.dataDiff.capped`,{cap:k.toLocaleString()})}),(F.sourceOnlyColumns.length>0||F.targetOnlyColumns.length>0)&&(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.ignoredColumns`,{columns:[...F.sourceOnlyColumns,...F.targetOnlyColumns].join(`, `)})})]}),(0,E.jsx)(`div`,{className:`flex gap-1 text-xs`,children:[`added`,`changed`,`removed`].map(t=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{R(t),B(0)},className:`rounded border px-2 py-0.5 ${L===t?`bg-accent`:``}`,children:e(`database.dataDiff.${t}`,{count:t===`added`?F.added.length:t===`removed`?F.removed.length:F.changed.length})},t))}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] gap-3 h-[280px]`,children:[(0,E.jsxs)(`ul`,{className:`overflow-auto rounded-md border text-sm font-mono`,children:[$.slice(0,2e3).map((e,t)=>(0,E.jsx)(`li`,{className:`px-2 py-1 cursor-pointer ${z===t?`bg-accent`:``}`,onClick:()=>B(t),children:de(e)},t)),$.length===0&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.dataDiff.none`)}),$.length>2e3&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`database.dataDiff.more`,{count:$.length-2e3})})]}),(0,E.jsx)(`div`,{className:`overflow-auto rounded-md border p-2`,children:$[z]?L===`changed`?(0,E.jsx)(M,{diff:F,row:F.changed[z].source,other:F.changed[z].target,changed:F.changed[z].columns}):L===`removed`?(0,E.jsx)(M,{diff:F,row:{},other:$[z]}):(0,E.jsx)(M,{diff:F,row:$[z]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.diff.selectTable`)})})]}),(0,E.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>H(e.target.checked)}),(0,E.jsx)(`span`,{className:V?`text-destructive`:``,children:e(`database.dataDiff.includeDeletes`)})]})]})]}),(0,E.jsxs)(te,{children:[(0,E.jsx)(p,{variant:`outline`,onClick:o,children:e(`database.diff.close`)}),(0,E.jsx)(p,{variant:`secondary`,onClick:()=>{ce()},disabled:!se||U,children:e(U?`database.diff.comparing`:`database.diff.compare`)}),(0,E.jsx)(p,{onClick:le,disabled:!ue,children:e(`database.diff.openScript`)})]})]})})}export{N as DataDiffDialog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,j as n,l as r,z as i}from"./main-C-Gt0g0g.js";import{c as a,h as o,n as s,t as c}from"./ui-store-5IssrgmG.js";import{l,m as u,t as d}from"./button-B2EsmMJs.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-DwgCtoqv.js";import{t as _}from"./connection-store-BnO3WqEO.js";import{n as v}from"./query-store-dYiA8oM5.js";import{a as ee}from"./database-BvWJHB7q.js";import{o as y}from"./dbms-BwnatOMe.js";import{n as b}from"./engine-s5WfEr4n.js";import{n as x}from"./query-execution-CZvQYEUq.js";import{a as S,i as te,n as ne,o as re,t as ie}from"./dialog-FBpgH0QJ.js";import{t as C}from"./file-name-CnYBZPf9.js";var w=e(o(),1);function T(e,t){let n=e==null?``:typeof e==`object`?JSON.stringify(e):String(e);return!(typeof e==`number`||typeof e==`bigint`||/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))&&/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),n.includes(t)||n.includes(`"`)||n.includes(`
|
|
2
2
|
`)||n.includes(`\r`)?`"${n.replace(/"/g,`""`)}"`:n}var E=(e,t)=>e.map(e=>T(e,t)).join(t)+`
|
|
3
|
-
`,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let t=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),
|
|
3
|
+
`,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let t=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),n=0;try{let r=await i({connectionId:e.connectionId,database:e.database,table:e.table,signal:e.signal,onProgress:e.onProgress}),o=r.fields.map(e=>e.name);e.includeHeaders&&await t.write(E(o,e.delimiter));for await(let i of r.pages)await t.write(i.map(t=>E(o.map(e=>t[e]),e.delimiter)).join(``)),n+=i.length;return await t.finish(),a(`export_csv`,{source:`table`,rows:n,format:O(e.delimiter)}),n}catch(e){throw await t.abort().catch(()=>void 0),e}}function P(e,t,n,r,i){let o=e.map(e=>e.name),s=[``];r&&s.push(E(o,n));for(let e of t)s.push(E(o.map(t=>e[t]),n));let c=new Blob(s,{type:`${A(n)};charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=C(i??`query_result${k(n)}`),u.click(),URL.revokeObjectURL(l),a(`export_csv`,{source:`result`,rows:t.length,format:O(n)})}var F=l(),I=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function L(){let{t:e}=u(),{activeDialog:i,closeDialog:a}=s(),o=c(`export-csv`),l=_(e=>e.activeConnectionId),C=v(),T=i===`export-csv`,[E,O]=(0,w.useState)(`query_result`),[k,A]=(0,w.useState)(``),[j,L]=(0,w.useState)([]),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(`,`),[H,U]=(0,w.useState)(!0),[W,G]=(0,w.useState)(!1),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(null),X=(0,w.useRef)(null),Z=D(B)?`TSV`:`CSV`,Q=()=>{if(o?.nodeText&&(o.nodeType===y.TABLE||o.nodeType===y.VIEW)){let e=o.metadata?.database;return{table:o.nodeText,database:typeof e==`string`?e:``}}if(!l)return null;let e=(C.tabs[l]??[]).find(e=>e.id===C.activeTabId[l]);return e?.sourceTable?{table:e.sourceTable.table,database:e.sourceTable.database}:null};(0,w.useEffect)(()=>{if(!T)return;let e=Q();V(o?.delimiter??`,`),e&&(A(e.table),O(`table_data`))},[T]),(0,w.useEffect)(()=>{if(!T||!l)return;let e=_.getState().activeConnections.find(e=>e.id===l);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await b(l).introspect.listDatabases(ee(e.serverConnectionId));if(t)return;L(n);let r=C.tabs[l]?.find(e=>e.id===C.activeTabId[l])?.database||``,i=Q()?.database||``;z(e=>n.includes(i)?i:n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||L([])}})(),()=>{t=!0}},[T,l]);function $(e){if(!e){if(W){X.current?.abort();return}a(),O(`query_result`),A(``),V(`,`),U(!0)}}async function ae(){if(!l)return;if(Y(null),E===`query_result`){let e=C.activeTabId[l],t=(C.tabs[l]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;P(t.fields,t.rows,B,H),a();return}if(!k.trim()||!R)return;let t=new AbortController;X.current=t,G(!0),q({loaded:0,total:null});try{let n=await N({connectionId:l,database:R,table:k.trim(),delimiter:B,includeHeaders:H,onProgress:q,signal:t.signal});s.getState().setFooterMessage(e(`database.csv.done`,{count:n,table:k.trim(),format:Z})),a()}catch(e){!(e instanceof M)&&!(e instanceof x&&t.signal.aborted)&&Y(e instanceof Error?e.message:String(e))}finally{G(!1),q(null),X.current=null}}let oe=K?.total?Math.min(100,Math.round(K.loaded/K.total*100)):null;return(0,F.jsx)(ie,{open:T,onOpenChange:$,children:(0,F.jsxs)(ne,{className:`sm:max-w-[450px]`,children:[(0,F.jsx)(S,{children:(0,F.jsx)(re,{children:e(`database.csv.title`,{format:Z})})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{children:e(`database.csv.target`)}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:E===`query_result`,onChange:()=>O(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:E===`table_data`,onChange:()=>O(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),E===`table_data`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,F.jsxs)(g,{value:R,onValueChange:z,disabled:j.length===0,children:[(0,F.jsx)(p,{id:`csv-database`,className:`w-full`,children:(0,F.jsx)(f,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,F.jsx)(m,{children:j.map(e=>(0,F.jsx)(h,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,F.jsx)(r,{id:`csv-table-name`,value:k,onChange:e=>A(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(t,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,F.jsxs)(g,{value:B,onValueChange:V,children:[(0,F.jsx)(p,{id:`csv-delimiter`,className:`w-full`,children:(0,F.jsx)(f,{})}),(0,F.jsx)(m,{children:I.map(t=>(0,F.jsx)(h,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),K&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(n,{value:oe??0}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.total===null?e(`database.csv.progressUnknown`,{loaded:K.loaded}):e(`database.csv.progress`,{loaded:K.loaded,total:K.total})})]}),J&&(0,F.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:J}),(0,F.jsxs)(te,{children:[(0,F.jsx)(d,{variant:`outline`,onClick:()=>$(!1),children:e(W?`database.csv.stop`:`database.csv.cancel`)}),(0,F.jsx)(d,{onClick:ae,disabled:W||E===`table_data`&&!k.trim(),children:e(W?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{L as DownloadToCSVDialog};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,C as n,D as r,E as i,Nt as a,O as o,Q as s,S as c,T as l,W as u,Z as d,b as f,c as p,l as m,v as h,x as g,y as _}from"./main-C-Gt0g0g.js";import{h as v,n as y,t as ee}from"./ui-store-5IssrgmG.js";import{l as b,m as x,t as S}from"./button-B2EsmMJs.js";import{a as C,i as w,n as T,r as E,t as D}from"./select-DwgCtoqv.js";import{t as O}from"./connection-store-BnO3WqEO.js";import{a as te}from"./database-BvWJHB7q.js";import{n as k}from"./engine-s5WfEr4n.js";import{c as ne,f as re}from"./query-execution-CZvQYEUq.js";import{i as ie}from"./table-copy-LtbDgIEc.js";import{a as A,i as j,n as M,o as N,t as P}from"./dialog-FBpgH0QJ.js";var F=e(v(),1);function I(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function L(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function R(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function z(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var B=b(),V=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,H=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,U=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,W=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function ae({columns:e,onChange:r}){let{t:i}=x(),a=d().getDataTypes(),o=(0,F.useCallback)((t,n,i)=>{r(e.map(e=>e.id===t?{...e,[n]:i}:e))},[e,r]);function s(){r([...e,I()])}function l(){e.length>0&&r(e.slice(0,-1))}return(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(t,{className:`flex-1`,children:(0,B.jsxs)(h,{className:V,children:[(0,B.jsx)(c,{className:H,children:(0,B.jsxs)(n,{children:[(0,B.jsx)(g,{className:`w-[120px]`,children:i(`table.schema.colField`)}),(0,B.jsx)(g,{className:`w-[120px]`,children:i(`table.schema.colType`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colLength`)}),(0,B.jsx)(g,{className:`w-[100px]`,children:i(`table.schema.colDefault`)}),(0,B.jsx)(g,{className:`w-[40px]`,children:i(`table.schema.colPk`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colNotNull`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colUnsigned`)}),(0,B.jsx)(g,{className:`w-[70px]`,children:i(`table.schema.colAutoIncrement`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:i(`table.schema.colZerofill`)}),(0,B.jsx)(g,{children:i(`table.schema.colComment`)})]})}),(0,B.jsx)(_,{children:e.length===0?(0,B.jsx)(n,{children:(0,B.jsx)(f,{colSpan:10,className:`text-center text-muted-foreground`,children:i(`table.schema.empty`)})}):e.map(e=>(0,B.jsxs)(n,{children:[(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.field,onChange:t=>o(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,B.jsx)(f,{children:(0,B.jsxs)(D,{value:e.type,onValueChange:t=>o(e.id,`type`,t),children:[(0,B.jsx)(w,{className:W,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:a.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})}),(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.length,onChange:t=>o(e.id,`length`,t.target.value)})}),(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.defaultValue,onChange:t=>o(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>o(e.id,`pk`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>o(e.id,`notNull`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>o(e.id,`unsigned`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>o(e.id,`autoIncrement`,t.target.checked)})}),(0,B.jsx)(f,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>o(e.id,`zerofill`,t.target.checked)})}),(0,B.jsx)(f,{children:(0,B.jsx)(m,{className:U,value:e.comment,onChange:t=>o(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,B.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:s,children:i(`table.schema.add`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:l,disabled:e.length===0,children:i(`table.schema.remove`)})]})]})}var G=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function K({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:a}=x(),[o,s]=(0,F.useState)(t.name),[c,l]=(0,F.useState)(t.type),[u,d]=(0,F.useState)(t.columns);function f(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function h(){r({id:t.id,name:c===`PRIMARY`?`PRIMARY`:o,type:c,columns:u})}return(0,B.jsx)(P,{open:e,onOpenChange:e=>{e||i()},children:(0,B.jsxs)(M,{className:`sm:max-w-[500px]`,children:[(0,B.jsx)(A,{children:(0,B.jsx)(N,{children:t.name?a(`table.index.editTitle`):a(`table.index.addTitle`)})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`idx-name`,children:a(`table.index.name`)}),(0,B.jsx)(m,{id:`idx-name`,value:c===`PRIMARY`?`PRIMARY`:o,onChange:e=>s(e.target.value),disabled:c===`PRIMARY`,placeholder:a(`table.index.namePlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`idx-type`,children:a(`table.index.type`)}),(0,B.jsxs)(D,{value:c,onValueChange:e=>l(e),children:[(0,B.jsx)(w,{id:`idx-type`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:G.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{children:a(`table.index.columns`)}),(0,B.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`table.index.noColumns`)}):n.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:u.includes(e.field),onChange:()=>f(e.field)}),(0,B.jsx)(`span`,{children:e.field||a(`table.index.unnamed`)}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,B.jsxs)(j,{children:[(0,B.jsx)(S,{variant:`outline`,onClick:i,children:a(`table.index.cancel`)}),(0,B.jsx)(S,{onClick:h,disabled:u.length===0,children:a(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:r,onChange:i}){let{t:a}=x(),[o,s]=(0,F.useState)(null),[l,u]=(0,F.useState)(!1);function d(){let e=L();s(e),u(!0)}function p(e){s({...e}),u(!0)}function m(){e.length>0&&i(e.slice(0,-1))}function v(t){e.find(e=>e.id===t.id)?i(e.map(e=>e.id===t.id?t:e)):i([...e,t]),u(!1),s(null)}function y(){u(!1),s(null)}return(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(t,{className:`flex-1`,children:(0,B.jsxs)(h,{className:V+` [&_td]:px-2`,children:[(0,B.jsx)(c,{className:H,children:(0,B.jsxs)(n,{children:[(0,B.jsx)(g,{className:`w-[150px]`,children:a(`table.indexes.colName`)}),(0,B.jsx)(g,{className:`w-[120px]`,children:a(`table.indexes.colType`)}),(0,B.jsx)(g,{children:a(`table.indexes.colColumns`)})]})}),(0,B.jsx)(_,{children:e.length===0?(0,B.jsx)(n,{children:(0,B.jsx)(f,{colSpan:3,className:`text-center text-muted-foreground`,children:a(`table.indexes.empty`)})}):e.map(e=>(0,B.jsxs)(n,{className:`cursor-pointer`,onDoubleClick:()=>p(e),children:[(0,B.jsx)(f,{children:e.name}),(0,B.jsx)(f,{children:e.type}),(0,B.jsx)(f,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,B.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:d,children:a(`table.indexes.add`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:m,disabled:e.length===0,children:a(`table.indexes.remove`)})]}),o&&(0,B.jsx)(K,{open:l,index:o,availableColumns:r,onSave:v,onClose:y})]})}var q=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],J=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],Y={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function se({properties:e,onChange:t}){let{t:n}=x();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=Y[r]?.[0]??``),t(i)}let i=Y[e.charset]??[];return(0,B.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,B.jsxs)(D,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,B.jsx)(w,{id:`prop-engine`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:q.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,B.jsxs)(D,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,B.jsx)(w,{id:`prop-charset`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:J.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,B.jsxs)(D,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,B.jsx)(w,{id:`prop-collation`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:i.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,B.jsx)(m,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(p,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,B.jsx)(m,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:o}){let c=u(e=>e.themeId),l=s(e),d=c===`light`||c===`light-blue`||c===`solarized-light`?`vs`:`vs-dark`,f=(0,F.useMemo)(()=>l.ddl.createTable(z(t,n,r,i,o)),[l,t,n,r,i,o]);return(0,B.jsx)(`div`,{className:`h-[320px]`,children:(0,B.jsx)(a,{height:`100%`,language:`sql`,theme:d,value:f,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function X(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Z(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function Q(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function $(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function le({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?$(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Z(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),X(i)!==X(r)){let e=a.alterColumn(t,n,Z(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,Q(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,Q(r)));return{statements:o,destructive:s,unsupported:c}}function ue(){let{t:e}=x(),{activeDialog:t,closeDialog:n}=y(),a=ee(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,u=t===`alter-table`,d=t===`duplicate-table-structure`,f=a?.nodeText??``,h=a?.metadata?.database??``,[g,_]=(0,F.useState)(``),[v,b]=(0,F.useState)([I()]),[C,w]=(0,F.useState)([]),[T,E]=(0,F.useState)(R()),[D,L]=(0,F.useState)(!1),[V,H]=(0,F.useState)(!1),[U,W]=(0,F.useState)(null),[G,K]=(0,F.useState)(null),q=a?.connectionId??O.getState().activeConnectionId,J=s(q);(0,F.useEffect)(()=>{c&&(W(null),K(null),u||d?(_(d?`${f}_copy`:f),Y()):(_(``),b([I()]),w([]),E(R())))},[c,t]);async function Y(){let e=O.getState(),t=a?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!h||!f)return;L(!0);let{introspect:r,capabilities:i}=k(t),o=te(n);try{let e=await r.listColumns(o,h,f),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});b(n),t=n}let n=await r.listIndexes(o,h,f),a=[];if(n.length>0&&(a=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),w(a)),K({columns:t,indexes:a}),i.tableProperties){let e=await r.getTableInfo(o,h,f);e&&E({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),W(e instanceof Error?e.message:String(e))}finally{L(!1)}}function X(e){e||n()}async function Z(){let t=a?.connectionId??O.getState().activeConnectionId;if(!t||!g.trim())return;let r=k(t);W(null);let i,o=[];if(u){if(!G)return;let t=le({engine:r,database:h,table:f,before:G,after:{columns:v,indexes:C}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:r.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){n();return}i=t.statements.join(`
|
|
2
|
+
`),o=t.destructive}else{let e=d?C.map(e=>({...e,name:ie(e.name,f,g.trim())})):C;i=r.ddl.createTable(z(h,g.trim(),v,e,T))}H(!0);try{await ne(t,i,{skipDestructiveConfirm:o.length===0}),await re(t,h),n()}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}}let Q=e(u?`table.dialog.alterTitle`:d?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),$=e(u?`table.dialog.alter`:`table.dialog.create`);return(0,B.jsx)(P,{open:c,onOpenChange:X,children:(0,B.jsxs)(M,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,B.jsx)(A,{children:(0,B.jsx)(N,{children:Q})}),(0,B.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,B.jsx)(p,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,B.jsx)(m,{id:`table-name`,value:g,onChange:e=>_(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:u})]}),D?(0,B.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,B.jsxs)(l,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,B.jsxs)(r,{children:[(0,B.jsx)(o,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,B.jsx)(o,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),J.capabilities.tableProperties&&(0,B.jsx)(o,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,B.jsx)(o,{value:`sql`,children:`SQL`})]}),(0,B.jsx)(i,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(ae,{columns:v,onChange:b})}),(0,B.jsx)(i,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(oe,{indexes:C,availableColumns:v,onChange:w})}),(0,B.jsx)(i,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(se,{properties:T,onChange:E})}),(0,B.jsx)(i,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,B.jsx)(ce,{connectionId:q,database:h,tableName:g,columns:v,indexes:C,properties:T})})]})]}),U&&(0,B.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:U}),(0,B.jsxs)(j,{children:[(0,B.jsx)(S,{variant:`outline`,onClick:()=>X(!1),children:e(`table.dialog.cancel`)}),(0,B.jsx)(S,{onClick:()=>void Z(),disabled:D||V||!g.trim(),children:V?e(`table.dialog.applying`):$})]})]})})}export{ue as EditSchemaDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dt as t,c as n,l as r}from"./main-C-Gt0g0g.js";import{h as i,n as a}from"./ui-store-5IssrgmG.js";import{i as o,l as s,m as c,t as l}from"./button-B2EsmMJs.js";import{t as u}from"./chevron-up-CBnVjNE1.js";import{t as d}from"./connection-store-BnO3WqEO.js";import{n as f}from"./query-store-dYiA8oM5.js";import{n as p,o as m,s as h,t as g}from"./editor-registry-ukUyoekH.js";var _=e(i(),1),v=s();function y(){let{t:e}=c(),{activeDialog:i,closeDialog:s}=a(),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(!1),[k,A]=(0,_.useState)(0),j=d(e=>e.activeConnectionId)??``,M=f(e=>j?e.activeTabId[j]:void 0)??``;if(i!==`find-replace`)return null;let N={query:y,caseSensitive:C,regex:T,wholeWord:D},P=j!==``&&M!==``&&y!==``;function F(){s()}function I(){A(P?p(j,M,N,`next`):0)}function L(){A(P?p(j,M,N,`prev`):0)}function R(){P&&A(h(j,M,N,x))}function z(){P&&(m(j,M,N,x),A(g(j,M,N)))}return(0,v.jsxs)(`div`,{className:`fixed top-12 right-4 z-50 bg-background border rounded-md shadow-lg p-3 w-[400px] space-y-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(r,{placeholder:e(`command.findReplace.findPlaceholder`),value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey?L():I()),e.key===`Escape`&&F()},className:`flex-1 h-7 text-sm`,autoFocus:!0}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap min-w-[60px] text-center`,children:k>0?e(`command.findReplace.found`,{count:k}):e(`command.findReplace.noResults`)}),(0,v.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:L,title:e(`command.findReplace.previous`),children:(0,v.jsx)(u,{className:`h-4 w-4`})}),(0,v.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:I,title:e(`command.findReplace.next`),children:(0,v.jsx)(t,{className:`h-4 w-4`})}),(0,v.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:F,title:e(`command.findReplace.close`),children:(0,v.jsx)(o,{className:`h-4 w-4`})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(r,{placeholder:e(`command.findReplace.replacePlaceholder`),value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Escape`&&F()},className:`flex-1 h-7 text-sm`}),(0,v.jsx)(l,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:R,children:e(`command.findReplace.replace`)}),(0,v.jsx)(l,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:z,children:e(`command.findReplace.all`)})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,v.jsxs)(n,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.caseSensitive`)]}),(0,v.jsxs)(n,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.regex`)]}),(0,v.jsxs)(n,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:D,onChange:e=>O(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.wholeWord`)]})]})]})}export{y as FindReplaceDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{t as i}from"./connection-store-
|
|
1
|
+
import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{t as i}from"./connection-store-BnO3WqEO.js";import{c as a}from"./database-BvWJHB7q.js";import{a as o,i as s,n as c,o as l,t as u}from"./dialog-FBpgH0QJ.js";var d=t(),f=[`FLUSH HOSTS`,`FLUSH LOGS`,`FLUSH PRIVILEGES`,`FLUSH STATUS`,`FLUSH TABLES`,`FLUSH THREADS`,`FLUSH QUERY CACHE`,`FLUSH DES_KEY_FILE`,`FLUSH RELAY LOGS`,`FLUSH SLOW LOGS`,`FLUSH BINARY LOGS`,`FLUSH ENGINE LOGS`,`FLUSH ERROR LOGS`,`FLUSH GENERAL LOGS`,`FLUSH USER_RESOURCES`,`FLUSH OPTIMIZER_COSTS`];function p(){let e=i.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}function m(){let{t}=n(),{activeDialog:i,closeDialog:m,setFooterMessage:h}=e(),g=i===`flush`;function _(e){e||m()}async function v(e){let n=p();if(!n){h(t(`command.noActiveConnection`));return}try{await a(n,e),h(t(`command.flush.executed`,{command:e}))}catch(n){h(t(`command.flush.executeError`,{command:e,message:n instanceof Error?n.message:String(n)}))}}return(0,d.jsx)(u,{open:g,onOpenChange:_,children:(0,d.jsxs)(c,{className:`sm:max-w-[500px]`,children:[(0,d.jsx)(o,{children:(0,d.jsx)(l,{children:t(`command.flush.title`)})}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2 py-2`,children:f.map(e=>(0,d.jsx)(r,{variant:`outline`,size:`sm`,className:`justify-start text-xs h-8`,onClick:()=>{v(e)},children:e},e))}),(0,d.jsx)(s,{children:(0,d.jsx)(r,{variant:`outline`,onClick:()=>_(!1),children:t(`command.close`)})})]})})}export{m as FlushDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{r as a,t as o}from"./i18n-D0mAAGED.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-DwgCtoqv.js";import{n as f}from"./settings-store-BBVuUVjA.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-FBpgH0QJ.js";import{t as y}from"./settings-controls-DrW8_eiX.js";var b=n();function x(){let n=t(e=>e.activeDialog),x=t(e=>e.closeDialog),S=f(),{t:C}=r();return(0,b.jsx)(v,{open:n===`general-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:C(`settings.general.title`)}),(0,b.jsx)(_,{children:C(`settings.general.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-history`,checked:S.persistQueryHistory,onChange:e=>S.setPersistQueryHistory(e),label:C(`settings.persistHistory`),hint:C(`settings.persistHistoryHint`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:C(`settings.language`)}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`settings.languageHint`)})]}),(0,b.jsxs)(d,{value:S.locale,onValueChange:e=>S.setLocale(e),children:[(0,b.jsx)(c,{children:(0,b.jsx)(s,{})}),(0,b.jsxs)(l,{children:[(0,b.jsx)(u,{value:`auto`,children:C(`language.auto`,{name:C(`language.${a()}`)})}),o.map(e=>(0,b.jsx)(u,{value:e,children:C(`language.${e}`)},e))]})]})]}),(0,b.jsx)(y,{id:`s-analytics`,checked:S.analyticsEnabled,onChange:S.setAnalyticsEnabled,label:C(`settings.analytics`),hint:e()?C(`settings.analyticsHint`):C(`settings.analyticsUnavailableHint`)})]}),(0,b.jsx)(m,{children:(0,b.jsx)(i,{onClick:x,children:C(`settings.done`)})})]})})}export{x as GeneralSettingsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,X as n,c as r,it as i,l as a,yt as ee}from"./main-C-Gt0g0g.js";import{c as te,h as o,n as s,t as ne}from"./ui-store-5IssrgmG.js";import{l as c,m as re,t as l}from"./button-B2EsmMJs.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-DwgCtoqv.js";import{t as h}from"./connection-store-BnO3WqEO.js";import{a as g}from"./database-BvWJHB7q.js";import{n as _}from"./engine-s5WfEr4n.js";import{i as ie,u as v}from"./query-execution-CZvQYEUq.js";import{a as ae,i as oe,n as y,o as b,r as se,t as ce}from"./dialog-FBpgH0QJ.js";var x=e(o(),1),le=[`SUM`,`AVG`,`MIN`,`MAX`],S=`row_count`;function ue(e,t){if(t.columns.length===0)return``;let n=t=>e.quoteIdentifier(t),r=t.columns.map(n),i=[...r,`COUNT(*) AS ${n(S)}`];if(t.aggregate){let{fn:e,column:r}=t.aggregate;i.push(`${e}(${n(r)}) AS ${n(`${e.toLowerCase()}_${r}`)}`)}let a=[];return t.where&&a.push(t.where),a.push(`GROUP BY ${r.join(`, `)}`),t.minCount&&t.minCount>1&&a.push(`HAVING COUNT(*) >= ${Math.floor(t.minCount)}`),a.push(`ORDER BY COUNT(*) DESC`),t.limit>0&&a.push(e.limitClause(t.limit)),e.getQuery(`SELECT_TABLE`,t.database,t.table,i.join(`, `),a.join(` `))}function C(e){let t=new Set;for(let n of e){let e=n.columns[0];e&&t.add(e.toLowerCase())}return t}function w(e,t){return t.has(e.toLowerCase())}function de(e,t){let n=C(t);return e.some(e=>w(e,n))}var T=c(),E=`none`,fe=/\b(int|dec|numeric|number|float|double|real|money|serial)/i;function D(){let{t:e}=re(),o=s(e=>e.activeDialog),c=s(e=>e.closeDialog),S=ne(`group-by`),D=o===`group-by`,O=h(e=>e.activeConnections),pe=h(e=>e.activeConnectionId),me=(0,x.useMemo)(()=>O.filter(e=>e.serverConnectionId),[O]),[k,he]=(0,x.useState)(()=>S?.connectionId??pe??``),[A,j]=(0,x.useState)(()=>S?.database??``),[M,N]=(0,x.useState)(()=>S?.table??``),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)([]),R=S&&k===S.connectionId&&A===S.database&&M===S.table?S.where??``:``,[z,ge]=(0,x.useState)([]),[B,_e]=(0,x.useState)([]),[V,H]=(0,x.useState)(()=>S?.column?[S.column]:[]),[U,ve]=(0,x.useState)(E),[W,ye]=(0,x.useState)(``),[G,be]=(0,x.useState)(`1`),[K,xe]=(0,x.useState)(!0),[q,J]=(0,x.useState)(``),[Se,Y]=(0,x.useState)(!1),X=e=>h.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId;(0,x.useEffect)(()=>{if(!D||!k)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{try{let n=await _(k).introspect.listDatabases(g(e));if(t)return;F(n),j(e=>e&&n.includes(e)?e:n[0]??``)}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k]),(0,x.useEffect)(()=>{if(!D||!k||!A)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{try{let n=await _(k).introspect.listTables(g(e),A);if(t)return;let r=n.map(e=>e.name);L(r),N(e=>e&&r.includes(e)?e:r[0]??``)}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k,A]),(0,x.useEffect)(()=>{if(!D||!k||!M)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{let n=g(e),r=_(k).introspect;try{let[e,i]=await Promise.all([r.listColumns(n,A,M),r.listIndexes(n,A,M).catch(()=>[])]);if(t)return;ge(e),_e(i),H(t=>t.filter(t=>e.some(e=>e.name===t)))}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k,A,M]);let Ce=(0,x.useMemo)(()=>C(B),[B]),we=(0,x.useMemo)(()=>z.filter(e=>fe.test(e.type)),[z]),Z=(0,x.useMemo)(()=>!k||V.length===0?``:ue(_(k),{database:A,table:M,columns:V,aggregate:U!==E&&W?{fn:U,column:W}:null,where:K?R:``,minCount:Number(G)||1,limit:v()}),[k,A,M,V,U,W,G,K,R]),Q=V.length>0&&B.length>0&&!de(V,B);function Te(e){H(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function $(e){te(`group_by`,{action:e,dbms:_(k).id,columns:V.length,aggregate:U,filtered:!!(K&&R),indexed:!Q})}function Ee(){Z&&($(`open`),n(k,Z,A,e(`database.groupBy.tabTitle`,{table:M})),c())}async function De(){if(!Z)return;$(`run`),Y(!0);let t=n(k,Z,A,e(`database.groupBy.tabTitle`,{table:M}));c();try{await ie(k,t)}finally{Y(!1)}}return(0,T.jsx)(ce,{open:D,onOpenChange:e=>{e||c()},children:(0,T.jsxs)(y,{className:`flex max-h-[85vh] flex-col sm:max-w-[720px]`,children:[(0,T.jsxs)(ae,{children:[(0,T.jsx)(b,{children:e(`database.groupBy.title`)}),(0,T.jsx)(se,{children:e(`database.groupBy.description`,{table:M})})]}),q&&(0,T.jsx)(`p`,{className:`rounded-md border border-destructive/40 px-3 py-2 text-xs text-destructive`,children:q}),(0,T.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(r,{className:`text-xs`,children:e(`database.groupBy.connection`)}),(0,T.jsxs)(m,{value:k,onValueChange:he,children:[(0,T.jsx)(d,{className:`h-8 text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsx)(f,{children:me.map(e=>(0,T.jsx)(p,{value:e.id,children:e.hostName||e.host||e.file||e.id},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(r,{className:`text-xs`,children:e(`database.groupBy.database`)}),(0,T.jsxs)(m,{value:A,onValueChange:j,children:[(0,T.jsx)(d,{className:`h-8 text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsx)(f,{children:P.map(e=>(0,T.jsx)(p,{value:e,children:e},e))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(r,{className:`text-xs`,children:e(`database.groupBy.table`)}),(0,T.jsxs)(m,{value:M,onValueChange:N,children:[(0,T.jsx)(d,{className:`h-8 text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsx)(f,{children:I.map(e=>(0,T.jsx)(p,{value:e,children:e},e))})]})]})]}),(0,T.jsxs)(`div`,{className:`grid min-h-0 grid-cols-[1fr_1fr] gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-1.5`,children:[(0,T.jsx)(r,{className:`text-xs`,children:e(`database.groupBy.columns`)}),(0,T.jsx)(t,{className:`h-[260px] rounded-md border`,children:(0,T.jsx)(`ul`,{className:`p-1`,children:z.map(t=>{let n=w(t.name,Ce);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs hover:bg-accent`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:V.includes(t.name),onChange:()=>Te(t.name)}),(0,T.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),(0,T.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t.type}),n&&(0,T.jsx)(ee,{className:`ml-auto h-3 w-3 shrink-0 text-muted-foreground`,"aria-label":e(`database.groupBy.indexed`)})]})},t.name)})})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(r,{className:`text-xs`,children:e(`database.groupBy.aggregate`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsxs)(m,{value:U,onValueChange:ve,children:[(0,T.jsx)(d,{className:`h-8 w-[110px] text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsxs)(f,{children:[(0,T.jsx)(p,{value:E,children:e(`database.groupBy.countOnly`)}),le.map(e=>(0,T.jsx)(p,{value:e,children:e},e))]})]}),(0,T.jsxs)(m,{value:W,onValueChange:ye,disabled:U===E,children:[(0,T.jsx)(d,{className:`h-8 flex-1 text-xs`,children:(0,T.jsx)(u,{placeholder:e(`database.groupBy.column`)})}),(0,T.jsx)(f,{children:we.map(e=>(0,T.jsx)(p,{value:e.name,children:e.name},e.name))})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(r,{htmlFor:`gb-min`,className:`text-xs`,children:e(`database.groupBy.minCount`)}),(0,T.jsx)(a,{id:`gb-min`,type:`number`,min:1,value:G,onChange:e=>be(e.target.value),className:`h-8 text-xs`})]}),R&&(0,T.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:K,onChange:e=>xe(e.target.checked)}),e(`database.groupBy.useFilter`)]}),Q&&(0,T.jsxs)(`p`,{className:`flex gap-1.5 rounded-md border border-dashed px-2 py-1.5 text-xs text-muted-foreground`,children:[(0,T.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,T.jsx)(`span`,{children:e(`database.groupBy.noIndexWarning`)})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(r,{className:`text-xs`,children:e(`database.groupBy.preview`)}),(0,T.jsx)(`pre`,{className:`max-h-[120px] overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap`,children:Z||e(`database.groupBy.pickColumn`)})]}),(0,T.jsxs)(oe,{children:[(0,T.jsx)(l,{variant:`outline`,onClick:c,children:e(`command.close`)}),(0,T.jsx)(l,{variant:`outline`,onClick:Ee,disabled:!Z,children:e(`database.groupBy.openInTab`)}),(0,T.jsx)(l,{onClick:De,disabled:!Z||Se,children:e(`database.groupBy.run`)})]})]})})}export{D as GroupByDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{I as t,c as n,t as r}from"./main-C-Gt0g0g.js";import{h as i,n as a,t as o}from"./ui-store-5IssrgmG.js";import{l as s,m as c,t as l}from"./button-B2EsmMJs.js";import{n as u,r as d}from"./license-store-D_XwbbCs.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-FBpgH0QJ.js";import{t as v}from"./pro-upsell-akqEMS8_.js";var y=e(i(),1),b=s();function x(e){return e.state===`invalid`?e.reason===`no-public-key`?`pro.notConfigured`:e.reason===`no-webcrypto`?`pro.noWebcrypto`:`pro.invalidKey`:null}function S(){let e=a(e=>e.activeDialog),i=a(e=>e.closeDialog),s=o(`license`),{key:S,status:C,activate:w,clear:T}=u(),{t:E}=c(),[D,O]=(0,y.useState)(S),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!s?.feature||!!S),N=(0,y.useRef)(null),[P,F]=(0,y.useState)(d()?null:E(`pro.notConfigured`)),I=async()=>{A(!0);let e=x(await w(D.trim()));F(e?E(e):null),A(!1)},L=C.state===`valid`||C.state===`expired`?C.claim:null,R=s?.feature?E(`pro.blocked`,{feature:E(`pro.features.${s.feature}`)}):null;return(0,b.jsx)(_,{open:e===`license`,onOpenChange:e=>{e||i()},children:(0,b.jsxs)(m,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>{N.current&&(e.preventDefault(),N.current.focus())},children:[(0,b.jsx)(f,{children:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,b.jsx)(r,{size:44}),(0,b.jsx)(t,{className:`absolute -right-2 -bottom-1 ml-0`})]}),(0,b.jsxs)(`div`,{className:`grid gap-1`,children:[(0,b.jsx)(h,{children:E(`pro.licenseTitle`)}),(0,b.jsx)(g,{children:R??E(`pro.licenseDescription`)})]})]})}),(0,b.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[C.state===`valid`&&(0,b.jsxs)(`div`,{className:`rounded-md border border-emerald-500/40 bg-emerald-500/5 p-3 text-xs`,children:[(0,b.jsx)(`p`,{className:`font-medium text-emerald-600 dark:text-emerald-400`,children:E(`pro.active`)}),(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:E(`pro.licensedTo`,{email:L?.sub})}),(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:E(`pro.validUntil`,{date:L?.exp})})]}),C.state===`expired`&&(0,b.jsx)(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-amber-600 dark:text-amber-400`,children:E(`pro.expiredOn`,{date:L?.exp})}),R&&(0,b.jsx)(v,{highlight:s?.feature,innerRef:N}),!j&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>M(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:E(`pro.haveKey`)}),(0,b.jsxs)(`div`,{className:j?`grid gap-1.5`:`hidden`,children:[(0,b.jsx)(n,{htmlFor:`license-key`,children:E(`pro.keyLabel`)}),(0,b.jsx)(`textarea`,{id:`license-key`,value:D,onChange:e=>{O(e.target.value),F(null)},spellCheck:!1,rows:3,className:`w-full resize-none rounded-md border bg-transparent p-2 font-mono text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`}),P&&(0,b.jsx)(`p`,{className:`text-xs text-destructive`,children:P})]})]}),(0,b.jsxs)(p,{children:[S&&(0,b.jsx)(l,{variant:`ghost`,onClick:()=>{T(),O(``)},children:E(`pro.remove`)}),j&&(0,b.jsx)(l,{disabled:k||!D.trim()||D.trim()===S,onClick:()=>{I()},children:E(`pro.activate`)}),(0,b.jsx)(l,{variant:`secondary`,onClick:i,children:E(`settings.done`)})]})]})})}export{S as LicenseDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{H as t,U as n,c as r,l as i}from"./main-C-Gt0g0g.js";import{c as ee,h as a,n as o,t as s}from"./ui-store-5IssrgmG.js";import{l as c,m as l,t as u}from"./button-B2EsmMJs.js";import{a as d,i as f,n as p,r as m,t as h}from"./select-DwgCtoqv.js";import{t as g}from"./connection-store-BnO3WqEO.js";import{a as _}from"./database-BvWJHB7q.js";import{n as v}from"./engine-s5WfEr4n.js";import{t as y}from"./pro-usage-C661VD02.js";import{a as b,i as x,n as S,o as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(a(),1),E=c(),D=e=>e instanceof Error?e.message:String(e);function O(){let{t:e}=l(),a=o(e=>e.activeDialog),c=o(e=>e.closeDialog),O=s(`link-column`),k=a===`link-column`&&!!O,A=O?.connectionId??``,j=g(e=>e.activeConnections),M=j.filter(e=>e.serverConnectionId),N=n(e=>e.links),P=n(e=>e.setLink),F=n(e=>e.removeLink),I=O?t(N,A,O.database,O.table).find(e=>e.column===O.column)??null:null,[L,R]=(0,T.useState)(I?.targetConnectionId??A),z=j.find(e=>e.id===L)?.serverConnectionId,[B,V]=(0,T.useState)([]),[H,U]=(0,T.useState)([]),[W,G]=(0,T.useState)([]),[K,q]=(0,T.useState)(I?.targetDatabase??O?.database??``),[J,Y]=(0,T.useState)(I?.targetTable??``),[X,Z]=(0,T.useState)(I?.targetColumn??``),[Q,$]=(0,T.useState)(null);if((0,T.useEffect)(()=>{if(!k||!z)return;let e=!1;return(async()=>{try{let t=await v(L).introspect.listDatabases(_(z));if(e)return;V(t),q(e=>t.includes(e)?e:t[0]??``)}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L]),(0,T.useEffect)(()=>{if(!k||!z||!K)return;let e=!1;return(async()=>{try{let t=await v(L).introspect.listTables(_(z),K);if(e)return;U(t.map(e=>e.name))}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L,K]),(0,T.useEffect)(()=>{if(!k||!z||!K||!J)return;let e=!1;return(async()=>{try{let t=await v(L).introspect.listColumns(_(z),K,J);if(e)return;G(t.map(e=>e.name)),Z(e=>t.some(t=>t.name===e)?e:t.find(e=>e.key===`PRI`)?.name??t[0]?.name??``)}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L,K,J]),!O)return null;function te(){if(!O||!K||!J||!X)return;let e=L!==A;P(A,{database:O.database,table:O.table,column:O.column,...e?{targetConnectionId:L}:{},targetDatabase:K,targetTable:J,targetColumn:X}),y(`column_link`),ee(`column_link_set`,{dbms:v(A).id,target_dbms:v(L).id,cross_database:K!==O.database,cross_connection:e}),c()}function ne(){O&&(F(A,O),c())}return(0,E.jsx)(w,{open:k,onOpenChange:e=>{e||c()},children:(0,E.jsxs)(S,{className:`sm:max-w-[460px]`,children:[(0,E.jsx)(b,{children:(0,E.jsx)(C,{children:e(`result.link.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(r,{children:e(`result.link.source`)}),(0,E.jsx)(i,{value:`${O.database}.${O.table}.${O.column}`,disabled:!0})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`result.link.hint`)}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(r,{htmlFor:`link-conn`,children:e(`result.link.targetConnection`)}),(0,E.jsxs)(h,{value:L,onValueChange:e=>{R(e),Y(``),U([]),G([])},children:[(0,E.jsx)(f,{id:`link-conn`,className:`w-full`,children:(0,E.jsx)(d,{})}),(0,E.jsx)(p,{children:M.map(e=>(0,E.jsx)(m,{value:e.id,children:e.hostName||e.host||e.file||e.id},e.id))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(r,{htmlFor:`link-db`,children:e(`result.link.targetDatabase`)}),(0,E.jsxs)(h,{value:K,onValueChange:e=>{q(e),Y(``),G([])},children:[(0,E.jsx)(f,{id:`link-db`,className:`w-full`,children:(0,E.jsx)(d,{})}),(0,E.jsx)(p,{children:B.map(e=>(0,E.jsx)(m,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(r,{htmlFor:`link-table`,children:e(`result.link.targetTable`)}),(0,E.jsxs)(h,{value:J,onValueChange:Y,disabled:H.length===0,children:[(0,E.jsx)(f,{id:`link-table`,className:`w-full`,children:(0,E.jsx)(d,{placeholder:e(`result.link.pickTable`)})}),(0,E.jsx)(p,{children:H.map(e=>(0,E.jsx)(m,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(r,{htmlFor:`link-column`,children:e(`result.link.targetColumn`)}),(0,E.jsxs)(h,{value:X,onValueChange:Z,disabled:W.length===0,children:[(0,E.jsx)(f,{id:`link-column`,className:`w-full`,children:(0,E.jsx)(d,{placeholder:e(`result.link.pickColumn`)})}),(0,E.jsx)(p,{children:W.map(e=>(0,E.jsx)(m,{value:e,children:e},e))})]})]}),Q&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:Q})]}),(0,E.jsxs)(x,{children:[I&&(0,E.jsx)(u,{variant:`destructive`,onClick:ne,className:`mr-auto`,children:e(`result.link.remove`)}),(0,E.jsx)(u,{variant:`outline`,onClick:c,children:e(`result.link.cancel`)}),(0,E.jsx)(u,{onClick:te,disabled:!K||!J||!X,children:e(`result.link.save`)})]})]})})}export{O as LinkColumnDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Pt as n,W as r,X as i,at as ee,dt as a,l as o}from"./main-C-Gt0g0g.js";import{c as s,h as c,i as l,n as u}from"./ui-store-5IssrgmG.js";import{l as d,m as f,t as p}from"./button-B2EsmMJs.js";import{i as m,t as h}from"./connection-store-BnO3WqEO.js";import{n as g}from"./settings-store-BBVuUVjA.js";import{n as _,t as v}from"./query-store-dYiA8oM5.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(c(),1),E=d(),D={execute:`command.localHistory.reason.execute`,edit:`command.localHistory.reason.edit`,replaced:`command.localHistory.reason.replaced`,restore:`command.localHistory.reason.restore`,close:`command.localHistory.reason.close`},O=Object.freeze([]);function k(e){let t=(Date.now()-e)/36e5;return t<1?`<1h`:t<24?`1-24h`:t<168?`1-7d`:`7d+`}function A(){let{t:e}=f(),c=u(e=>e.activeDialog),d=u(e=>e.closeDialog),A=u(e=>e.setFooterMessage),j=h(e=>e.activeConnectionId),M=_(e=>j?e.activeTabId[j]:null),N=_(e=>j?e.tabs[j]??v:v),P=m(e=>j?e.revisions[j]??O:O),F=g(e=>e.persistQueryHistory),I=r(e=>e.themeId),L=I===`light`||I===`light-blue`||I===`solarized-light`?`vs`:`vs-dark`,[R,z]=(0,T.useState)(!0),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(null),[W,G]=(0,T.useState)(`current`),K=N.find(e=>e.id===M),q=c===`local-history`;(0,T.useEffect)(()=>{if(!q)return;let e=M?P.filter(e=>e.docId===M).length:0;s(`local_history_open`,{revisions:l(P.length),tab_revisions:l(e)})},[q]);let J=(0,T.useMemo)(()=>{let e=B.trim().toLowerCase();return P.filter(t=>R&&M&&t.docId!==M?!1:!e||t.text.toLowerCase().includes(e)||t.title.toLowerCase().includes(e))},[P,B,R,M]),Y=K?.query??``,X=J.find(e=>e.id===H)??J.find(e=>e.text!==Y)??J[0],Z=(0,T.useMemo)(()=>{if(!X)return;let e=P.filter(e=>e.docId===X.docId);return e[e.findIndex(e=>e.id===X.id)+1]},[P,X]),Q=W===`current`?Y:Z?.text??``;function $(e,t){s(`local_history_recover`,{action:e,reason:t.reason,age:k(t.timestamp),same_tab:t.docId===M,compare:W})}function te(){if(!j||!M||!X)return;$(`restore`,X);let t=_.getState();t.captureRevision(j,M,`restore`),t.setEditorContent(j,M,X.text),A(e(`command.localHistory.restored`)),d()}function ne(){!j||!X||($(`new_tab`,X),i(j,X.text,X.database,X.title),A(e(`command.localHistory.openedInTab`)),d())}function re(e){j&&(m.getState().removeRevision(j,e.id),H===e.id&&U(null))}function ie(){j&&(m.getState().clearRevisions(j),U(null))}return(0,E.jsx)(w,{open:q,onOpenChange:e=>{e||d()},children:(0,E.jsxs)(x,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:e(`command.localHistory.title`)}),(0,E.jsx)(C,{children:e(`command.localHistory.description`)})]}),!F&&(0,E.jsx)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,children:e(`command.localHistory.notPersisted`)}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(`div`,{className:`relative min-w-[200px] flex-1`,children:[(0,E.jsx)(a,{className:`absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,E.jsx)(o,{value:B,onChange:e=>V(e.target.value),placeholder:e(`command.localHistory.searchPlaceholder`),className:`h-8 pl-7 text-xs`})]}),(0,E.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>z(!0),className:`px-2 py-1 text-xs ${R?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.scopeTab`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`border-l px-2 py-1 text-xs ${R?`hover:bg-accent/50`:`bg-accent`}`,children:e(`command.localHistory.scopeAll`)})]}),(0,E.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>G(`current`),className:`px-2 py-1 text-xs ${W===`current`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.compareCurrent`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>G(`previous`),className:`border-l px-2 py-1 text-xs ${W===`previous`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.comparePrevious`)})]})]}),J.length===0?(0,E.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:P.length===0?e(`command.localHistory.empty`):e(`command.localHistory.noMatch`)}):(0,E.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[260px_1fr] gap-3`,children:[(0,E.jsx)(t,{className:`h-[440px] rounded-md border`,children:(0,E.jsx)(`ul`,{className:`divide-y`,children:J.map(t=>(0,E.jsxs)(`li`,{className:`group relative`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t.id),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 pr-8 text-left text-xs hover:bg-accent ${t.id===X?.id?`bg-accent`:``}`,children:[(0,E.jsx)(`span`,{className:`font-medium`,children:new Date(t.timestamp).toLocaleString()}),(0,E.jsxs)(`span`,{className:`w-full truncate text-muted-foreground`,children:[t.title,` · `,e(D[t.reason]),` · `,e(`command.localHistory.chars`,{count:t.text.length})]})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>re(t),title:e(`command.localHistory.delete`),className:`absolute right-1.5 top-1.5 rounded p-1 text-muted-foreground opacity-0 hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,children:(0,E.jsx)(ee,{className:`h-3.5 w-3.5`})})]},t.id))})}),(0,E.jsxs)(`div`,{className:`flex h-[440px] flex-col overflow-hidden rounded-md border`,children:[(0,E.jsx)(`div`,{className:`border-b bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,children:W===`current`?e(`command.localHistory.diffAgainstCurrent`):Z?e(`command.localHistory.diffAgainstPrevious`,{time:new Date(Z.timestamp).toLocaleString()}):e(`command.localHistory.noPrevious`)}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(n,{language:`sql`,theme:L,original:X?.text??``,modified:Q,options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,renderOverviewRuler:!1}})})]})]}),(0,E.jsxs)(b,{className:`sm:justify-between`,children:[(0,E.jsx)(p,{variant:`ghost`,onClick:ie,disabled:P.length===0,children:e(`command.localHistory.clearAll`)}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(p,{variant:`outline`,onClick:d,children:e(`command.close`)}),(0,E.jsx)(p,{variant:`outline`,onClick:ne,disabled:!X,children:e(`command.localHistory.openInNewTab`)}),(0,E.jsx)(p,{onClick:te,disabled:!X||!K,children:e(`command.localHistory.restore`)})]})]})]})})}export{A as LocalHistoryDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Dt as n,Et as r,Ot as i,S as a,b as o,ct as s,st as c,v as ee,wt as l,x as u,y as te,yt as ne}from"./main-BPskUSLM.js";import{h as d,n as f}from"./ui-store-5IssrgmG.js";import{a as p,i as re,l as m,m as ie,t as h}from"./button-B2EsmMJs.js";import{a as g}from"./i18n-BAv7QdV3.js";import{t as _}from"./connection-store-Ds9Gjt3K.js";import{c as v}from"./database-eJWHFM-2.js";import{t as y}from"./engine-DtZy_Zk0.js";import{a as ae,i as oe,n as b,o as x,t as se}from"./dialog-FBpgH0QJ.js";var ce=p(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),le=p(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ue=p(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),S=p(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),C=e(d(),1),w=m(),T=10,de=[2,5,10,30];function E(){let e=_.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function fe(){let e=E();if(!e)throw Error(g.t(`command.noActiveConnection`));let t=await v(e,y().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function D(e){return/^(sleep|idle)/i.test(e.Command??``)}function pe(e){return/lock/i.test(e.State??``)}function me(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function O(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function k(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function A({icon:e,label:t,value:n,tone:r}){return(0,w.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,w.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,w.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function j(){let{t:e}=ie(),{activeDialog:d,closeDialog:p,setFooterMessage:m,requestDestructiveConfirm:g}=f(),[_,j]=(0,C.useState)([]),[M,N]=(0,C.useState)(!1),[P,he]=(0,C.useState)(5),[F,I]=(0,C.useState)(null),[L,R]=(0,C.useState)(``),[z,ge]=(0,C.useState)(!1),[B,_e]=(0,C.useState)(!0),[V,H]=(0,C.useState)(!1),[U,ve]=(0,C.useState)(null),[W,G]=(0,C.useState)(!1),K=(0,C.useRef)(null),q=d===`process-list`,J=(0,C.useCallback)(()=>Promise.resolve().then(()=>(H(!0),fe())).then(e=>{j(e),ve(new Date)}).catch(t=>m(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[m,e]);(0,C.useEffect)(()=>{q&&J()},[q,J]),(0,C.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),M&&q&&(K.current=setInterval(()=>{J()},P*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[M,P,q,J]);function Y(e){e||(N(!1),I(null),R(``),p())}let X=(0,C.useMemo)(()=>{let e=_.filter(D).length,t=_.filter(e=>!D(e)).reduce((e,t)=>Math.max(e,O(t)),0);return{total:_.length,active:_.length-e,idle:e,longest:t}},[_]),Z=(0,C.useMemo)(()=>{let e=L.trim().toLowerCase();return _.filter(t=>z&&D(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?O(t)-O(e):O(e)-O(t))},[_,L,z,B]),Q=_.find(e=>e.Id===F)??null,ye=(0,C.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){m(e(`command.processList.selectToKill`));return}let r=E();if(!r)return;let i=_.find(e=>e.Id===n),a=y().getQuery(`KILL_QUERY`,String(n));if(await g({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[a]}))try{await v(r,a),m(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){m(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,w.jsx)(se,{open:q,onOpenChange:Y,children:(0,w.jsxs)(b,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,w.jsx)(ae,{children:(0,w.jsxs)(x,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,w.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(A,{icon:(0,w.jsx)(ce,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,w.jsx)(A,{icon:(0,w.jsx)(i,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,w.jsx)(A,{icon:(0,w.jsx)(le,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,w.jsx)(A,{icon:(0,w.jsx)(S,{}),label:e(`command.processList.stats.longest`),value:k(X.longest),tone:X.longest>=T?`warn`:void 0})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,w.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,w.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,w.jsx)(re,{className:`size-3`})})]}),(0,w.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,w.jsx)(`div`,{className:`flex-1`}),(0,w.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:M,onChange:e=>N(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,w.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:P,onChange:e=>he(Number(e.target.value)),disabled:!M,children:de.map(e=>(0,w.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,w.jsxs)(h,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,w.jsx)(s,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,w.jsxs)(ee,{className:`text-xs`,children:[(0,w.jsx)(a,{className:`sticky top-0 z-10 bg-background`,children:(0,w.jsxs)(t,{children:[(0,w.jsx)(u,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,w.jsx)(u,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,w.jsx)(u,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,w.jsx)(u,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,w.jsx)(u,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,w.jsx)(u,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,w.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,w.jsx)(n,{className:`size-3 text-primary`}):(0,w.jsx)(r,{className:`size-3 text-primary`})]})}),(0,w.jsx)(u,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,w.jsx)(u,{children:e(`command.processList.columns.info`)}),(0,w.jsx)(u,{className:`w-[50px]`})]})}),(0,w.jsx)(te,{children:Z.length===0?(0,w.jsx)(t,{children:(0,w.jsx)(o,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:_.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(n=>{let r=D(n),i=O(n),a=!r&&i>=T,s=pe(n),c=me(n);return(0,w.jsxs)(t,{"data-state":F===n.Id?`selected`:void 0,className:`cursor-pointer ${r?`text-muted-foreground`:``} ${s?`bg-destructive/5`:a?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(n.Id),children:[(0,w.jsx)(o,{className:`font-mono tabular-nums`,children:(0,w.jsxs)(`span`,{className:`flex items-center gap-1`,children:[n.Id,c&&(0,w.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,w.jsx)(o,{children:n.User}),(0,w.jsx)(o,{className:`font-mono`,children:n.Host}),(0,w.jsx)(o,{className:`font-mono`,children:n.db??``}),(0,w.jsx)(o,{children:(0,w.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${r?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:n.Command})}),(0,w.jsx)(o,{className:`tabular-nums ${a?`font-semibold text-catppuccin-yellow`:``}`,children:k(i)}),(0,w.jsx)(o,{className:s?`font-medium text-destructive`:``,children:n.State}),(0,w.jsx)(o,{className:`max-w-[260px] truncate font-mono`,title:n.Info??``,children:n.Info??``}),(0,w.jsx)(o,{className:`text-right`,children:(0,w.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(n.Id)},children:(0,w.jsx)(ue,{className:`size-3.5`})})})]},n.Id)})})]})}),Q&&(0,w.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,w.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,w.jsx)(`div`,{className:`flex-1`}),(0,w.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,w.jsx)(l,{className:`size-3`}):(0,w.jsx)(ne,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,w.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,w.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,w.jsxs)(oe,{children:[(0,w.jsx)(h,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,w.jsx)(h,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{j as ProcessListDialog};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{At as t,C as n,Ct as r,Mt as i,Ot as a,S as o,b as s,dt as c,ft as ee,jt as l,v as te,x as u,y as ne}from"./main-C-Gt0g0g.js";import{h as d,n as f}from"./ui-store-5IssrgmG.js";import{a as p,i as re,l as m,m as ie,t as h}from"./button-B2EsmMJs.js";import{a as g}from"./i18n-D0mAAGED.js";import{t as _}from"./connection-store-BnO3WqEO.js";import{c as v}from"./database-BvWJHB7q.js";import{t as y}from"./engine-s5WfEr4n.js";import{a as ae,i as oe,n as b,o as x,t as se}from"./dialog-FBpgH0QJ.js";var ce=p(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),le=p(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ue=p(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),S=p(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),C=e(d(),1),w=m(),T=10,de=[2,5,10,30];function E(){let e=_.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function fe(){let e=E();if(!e)throw Error(g.t(`command.noActiveConnection`));let t=await v(e,y().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function D(e){return/^(sleep|idle)/i.test(e.Command??``)}function pe(e){return/lock/i.test(e.State??``)}function me(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function O(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function k(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function A({icon:e,label:t,value:n,tone:r}){return(0,w.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,w.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,w.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function j(){let{t:e}=ie(),{activeDialog:d,closeDialog:p,setFooterMessage:m,requestDestructiveConfirm:g}=f(),[_,j]=(0,C.useState)([]),[M,N]=(0,C.useState)(!1),[P,he]=(0,C.useState)(5),[F,I]=(0,C.useState)(null),[L,R]=(0,C.useState)(``),[z,ge]=(0,C.useState)(!1),[B,_e]=(0,C.useState)(!0),[V,H]=(0,C.useState)(!1),[U,ve]=(0,C.useState)(null),[W,G]=(0,C.useState)(!1),K=(0,C.useRef)(null),q=d===`process-list`,J=(0,C.useCallback)(()=>Promise.resolve().then(()=>(H(!0),fe())).then(e=>{j(e),ve(new Date)}).catch(t=>m(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[m,e]);(0,C.useEffect)(()=>{q&&J()},[q,J]),(0,C.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),M&&q&&(K.current=setInterval(()=>{J()},P*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[M,P,q,J]);function Y(e){e||(N(!1),I(null),R(``),p())}let X=(0,C.useMemo)(()=>{let e=_.filter(D).length,t=_.filter(e=>!D(e)).reduce((e,t)=>Math.max(e,O(t)),0);return{total:_.length,active:_.length-e,idle:e,longest:t}},[_]),Z=(0,C.useMemo)(()=>{let e=L.trim().toLowerCase();return _.filter(t=>z&&D(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?O(t)-O(e):O(e)-O(t))},[_,L,z,B]),Q=_.find(e=>e.Id===F)??null,ye=(0,C.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){m(e(`command.processList.selectToKill`));return}let r=E();if(!r)return;let i=_.find(e=>e.Id===n),a=y().getQuery(`KILL_QUERY`,String(n));if(await g({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[a]}))try{await v(r,a),m(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){m(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,w.jsx)(se,{open:q,onOpenChange:Y,children:(0,w.jsxs)(b,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,w.jsx)(ae,{children:(0,w.jsxs)(x,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,w.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(A,{icon:(0,w.jsx)(ce,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,w.jsx)(A,{icon:(0,w.jsx)(i,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,w.jsx)(A,{icon:(0,w.jsx)(le,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,w.jsx)(A,{icon:(0,w.jsx)(S,{}),label:e(`command.processList.stats.longest`),value:k(X.longest),tone:X.longest>=T?`warn`:void 0})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,w.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,w.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,w.jsx)(re,{className:`size-3`})})]}),(0,w.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,w.jsx)(`div`,{className:`flex-1`}),(0,w.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:M,onChange:e=>N(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,w.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:P,onChange:e=>he(Number(e.target.value)),disabled:!M,children:de.map(e=>(0,w.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,w.jsxs)(h,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,w.jsx)(ee,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,w.jsxs)(te,{className:`text-xs`,children:[(0,w.jsx)(o,{className:`sticky top-0 z-10 bg-background`,children:(0,w.jsxs)(n,{children:[(0,w.jsx)(u,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,w.jsx)(u,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,w.jsx)(u,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,w.jsx)(u,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,w.jsx)(u,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,w.jsx)(u,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,w.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,w.jsx)(l,{className:`size-3 text-primary`}):(0,w.jsx)(t,{className:`size-3 text-primary`})]})}),(0,w.jsx)(u,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,w.jsx)(u,{children:e(`command.processList.columns.info`)}),(0,w.jsx)(u,{className:`w-[50px]`})]})}),(0,w.jsx)(ne,{children:Z.length===0?(0,w.jsx)(n,{children:(0,w.jsx)(s,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:_.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(t=>{let r=D(t),i=O(t),a=!r&&i>=T,o=pe(t),c=me(t);return(0,w.jsxs)(n,{"data-state":F===t.Id?`selected`:void 0,className:`cursor-pointer ${r?`text-muted-foreground`:``} ${o?`bg-destructive/5`:a?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(t.Id),children:[(0,w.jsx)(s,{className:`font-mono tabular-nums`,children:(0,w.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.Id,c&&(0,w.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,w.jsx)(s,{children:t.User}),(0,w.jsx)(s,{className:`font-mono`,children:t.Host}),(0,w.jsx)(s,{className:`font-mono`,children:t.db??``}),(0,w.jsx)(s,{children:(0,w.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${r?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:t.Command})}),(0,w.jsx)(s,{className:`tabular-nums ${a?`font-semibold text-catppuccin-yellow`:``}`,children:k(i)}),(0,w.jsx)(s,{className:o?`font-medium text-destructive`:``,children:t.State}),(0,w.jsx)(s,{className:`max-w-[260px] truncate font-mono`,title:t.Info??``,children:t.Info??``}),(0,w.jsx)(s,{className:`text-right`,children:(0,w.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(t.Id)},children:(0,w.jsx)(ue,{className:`size-3.5`})})})]},t.Id)})})]})}),Q&&(0,w.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,w.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,w.jsx)(`div`,{className:`flex-1`}),(0,w.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,w.jsx)(a,{className:`size-3`}):(0,w.jsx)(r,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,w.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,w.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,w.jsxs)(oe,{children:[(0,w.jsx)(h,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,w.jsx)(h,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{j as ProcessListDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,l as t}from"./main-C-Gt0g0g.js";import{n}from"./ui-store-5IssrgmG.js";import{l as r,m as i,t as a}from"./button-B2EsmMJs.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DwgCtoqv.js";import{n as d}from"./settings-store-BBVuUVjA.js";import{n as f}from"./pro-gate-DZATEYdR.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-FBpgH0QJ.js";import{t as y}from"./settings-controls-DrW8_eiX.js";var b=r();function x(){let r=n(e=>e.activeDialog),x=n(e=>e.closeDialog),S=d(),C=S.update,{t:w}=i();return(0,b.jsx)(v,{open:r===`query-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:w(`settings.query.title`)}),(0,b.jsx)(_,{children:w(`settings.query.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-dryrun`,checked:S.previewAffectedRows,onChange:e=>{(!e||f(`dry_run`))&&C({previewAffectedRows:e})},pro:!0,label:`Dry run`,hint:`Before an UPDATE or DELETE runs, read its WHERE (joins included) as a SELECT and show how many rows it would change, with a sample of them, to confirm.`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_140px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(e,{htmlFor:`s-limit`,className:`text-sm font-medium`,children:`Result row limit`}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`LIMIT appended to SELECTs that have none. 0 disables.`})]}),(0,b.jsx)(t,{id:`s-limit`,type:`number`,min:0,step:100,value:S.resultRowLimit,onChange:e=>C({resultRowLimit:Math.max(0,Number(e.target.value)||0)})})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:`F9 / Run button executes`}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Ctrl+Enter always runs the statement at the cursor; Ctrl+Shift+Enter the whole script.`})]}),(0,b.jsxs)(u,{value:S.executeScope,onValueChange:e=>C({executeScope:e}),children:[(0,b.jsx)(s,{children:(0,b.jsx)(o,{})}),(0,b.jsxs)(c,{children:[(0,b.jsx)(l,{value:`script`,children:`Whole script`}),(0,b.jsx)(l,{value:`statement`,children:`Statement at cursor`})]})]})]})]}),(0,b.jsx)(m,{children:(0,b.jsx)(a,{onClick:x,children:w(`settings.done`)})})]})})}export{x as QuerySettingsDialog};
|