dsql-admin/dsql-app/.local_dist/static/chunks/278-d6cc8f11cc80675a.js

1 line
41 KiB
JavaScript
Raw Normal View History

2025-02-12 16:56:44 +00:00
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[278],{278:(e,l,t)=>{t.d(l,{A:()=>T});var a=t(4848),n=t(6540),i=t(6517),s=t(2543),r=t.n(s);function d(e){let{tableFields:l,setTableFields:t,setRefresh:a,setPageRefresh:n,refreshFieldsListRef:i}=e;if(l.find(e=>e.newTempField))return;let s=r().cloneDeep(l),d=s.findIndex(e=>"date_created"===e.fieldName);s.splice(d,0,{newTempField:!0}),t(s),(null==i?void 0:i.current)&&i.current(e=>e+1)}var o=t(1342),c=t(1710),u=t(2675),m=t(2086),p=t(9020),x=t(9632);function f(e){var l,t,i,s,r,d,o,c,f,h,v;let{field:g,database:b,currentTable:N,isDelegated:y,setLoading:j}=e,w=n.useContext(x.AppContext),[T,C]=n.useState(g),[A,F]=n.useState(!1);return(0,a.jsxs)("div",{className:"flex-col w-full table-field-wrapper"+(A?" shadow-2xl shadow-slate-700/40 relative z-50":""),children:[(0,a.jsxs)("div",{className:"card no-hover items-center w-full py-4"+(A?" rounded-t":" rounded")+((null===(l=T.fieldName)||void 0===l?void 0:l.match(u.A))?" text-slate-400 pointer-events-none border-slate-200 border":" light-gray"),children:[(0,a.jsx)("span",{className:"font-bold"+((null===(t=T.fieldName)||void 0===t?void 0:t.match(u.A))?" dark:text-slate-500":" dark:text-white"),children:T.fieldName}),(0,a.jsx)("span",{className:"text-xs py-1 px-2 bg-slate-100 dark:bg-slate-700 dark:text-slate-200 rounded ",children:T.dataType}),(null==T?void 0:T.foreignKey)&&(0,a.jsxs)("div",{className:"text-xs bg-primary text-white px-2 py-0.5 rounded-full",children:[(0,a.jsx)("span",{children:"Foreign Key: "}),(0,a.jsxs)("span",{children:[T.foreignKey.destinationTableName," ("," ",(0,a.jsx)("b",{children:T.foreignKey.destinationTableColumnName})," ",")"]})]}),(null===(i=T.fieldName)||void 0===i?void 0:i.match(u.A))&&(0,a.jsx)("span",{className:"text-slate-300 text-sm font-semibold ml-0 md:ml-auto",children:"Default Field"}),!(!y&&!(null===(s=T.fieldName)||void 0===s?void 0:s.match(u.A))&&(null===(r=T.dataType)||void 0===r?void 0:r.match(/INT/)))||T.foreignKey||(null==b?void 0:null===(o=b.active_clone)||void 0===o?void 0:null===(d=o.toString())||void 0===d?void 0:d.match(/1/))?!(!y&&!(null===(c=T.fieldName)||void 0===c?void 0:c.match(u.A))&&(null===(f=T.dataType)||void 0===f?void 0:f.match(/INT/)))||(null==b?void 0:null===(v=b.active_clone)||void 0===v?void 0:null===(h=v.toString())||void 0===h?void 0:h.match(/1/))?(0,a.jsx)(n.Fragment,{}):(0,a.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,a.jsx)("div",{className:"button py-1 text-xs light-gray",onClick:e=>{if(window.confirm("Delete this foreign Key?")){var l,t;delete g.foreignKey,j(!0),(0,p.A)("/api/updateClonedTableForeignKeys",{method:"post",body:{tableData:N,database:b.db_full_name,dbSlug:b.db_slug,delegated:null!==(t=window.location)&&void 0!==t&&null!==(l=t.search)&&void 0!==l&&!!l.match(/delegated=true/i)}},!0).then(e=>{e.success?window.location.reload():window.alert("Update Failed, Please Try again.")})}},style:{color:"var(--slate-500)"},children:"Delete Foreign Key"})}):(0,a.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,a.jsx)("div",{className:"button outlined py-1 text-xs gray",onClick:e=>{A?F(!1):F(!0)},style:{color:"var(--slate-500)"},children:"Add Foreign Key"})})]}),A&&!y&&(0,a.jsx)("div",{className:"card col w-full -mt-5 pt-0 no-hover",children:(0,a.jsx)(m.A,{fieldObject:g,setFieldObject:C,setActiveEdit:F,activeClonedTable:!0,appContextObject:w})})]})}var h=t(2958);function v(e){let{fieldIndex:l,tableFields:t,setTableFields:i,refreshFieldsListRef:s,database:r,currentTable:d,user:o}=e,[c,u]=n.useState("VARCHAR"),[m,p]=n.useState("200"),[x,f]=n.useState("10"),[v,g]=n.useState("2"),[b,N]=n.useState("Varchar is simply letters and numbers within the range 0 - 255"),[y,j]=n.useState({}),w=n.useRef(),[T,C]=n.useState("");return n.useEffect(()=>{var e;w.current&&(w.current.scrollIntoView({block:"center",behavior:"smooth"}),null===(e=w.current.querySelector("input"))||void 0===e||e.focus())},[]),c.match(/uuid/i),(0,a.jsx)(h.A,{setFields:i,fieldIndex:l,fields:t})}function g(e){let{tableFields:l,setTableFields:t,refreshFieldsListRe