erdbpro 3.4.7-rc.8 → 3.4.7-rc.9
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/dist/assets/{AdminRoute-DST_3IUP.js → AdminRoute-CkdlycJM.js} +2 -2
- package/dist/assets/{Combination-BREwCNuY.js → Combination-DK5VWY7a.js} +1 -1
- package/dist/assets/{DataViewerModeToolbar-CLMZaq1D.js → DataViewerModeToolbar-HUZyDhsW.js} +1 -1
- package/dist/assets/{DbClientEditorRoute-Ci38MHkA.js → DbClientEditorRoute-f6htcYtm.js} +1 -1
- package/dist/assets/{DiagramEditorRoute-BybThU4k.js → DiagramEditorRoute-CVm7eQqS.js} +1 -1
- package/dist/assets/{DrawingEditorRoute-ByGHmRNT.js → DrawingEditorRoute-3TKBr2z5.js} +2 -2
- package/dist/assets/{DrawingsView-D8glDkzo.js → DrawingsView-DoXo8otp.js} +1 -1
- package/dist/assets/{ExcalidrawEditor-Bpc4if6_.js → ExcalidrawEditor-IU24Tjg-.js} +8 -8
- package/dist/assets/{FlowchartEditorRoute-CwCbs8Ge.js → FlowchartEditorRoute-Cqg1bqva.js} +1 -1
- package/dist/assets/{FlowchartView-bCG777et.js → FlowchartView-D_gRO8Ea.js} +1 -1
- package/dist/assets/{JumpToNode-CsIEfKOc.js → JumpToNode-kHkRfX2R.js} +1 -1
- package/dist/assets/{NoteEditorRoute-_O40AM2L.js → NoteEditorRoute-BJvyf8R4.js} +2 -2
- package/dist/assets/{NotesCompanionPane-BgmhMr03.js → NotesCompanionPane-D7uoP_Zj.js} +2 -2
- package/dist/assets/{NotesView-Bc1M73hO.js → NotesView-BMDZZeVk.js} +3 -3
- package/dist/assets/{ProjectFileTabs-l0uAfLaH.js → ProjectFileTabs-CrIm_c1Q.js} +1 -1
- package/dist/assets/{TeamInventoryRoute-aDYYSWRp.js → TeamInventoryRoute-DcZoyQzL.js} +1 -1
- package/dist/assets/{TeamManagementRoute-N1HbNo94.js → TeamManagementRoute-DJn2ecfr.js} +1 -1
- package/dist/assets/{TrashView-DVF3jCHE.js → TrashView-DkfHoege.js} +1 -1
- package/dist/assets/{UserManagementRoute-BvqHtAAE.js → UserManagementRoute-D8qLDN-S.js} +1 -1
- package/dist/assets/{WorkspaceProvider-DRRcvif2.js → WorkspaceProvider-CCtybqSH.js} +3 -3
- package/dist/assets/{abnfDiagram-N423BO3Z-Bj1hwXhu.js → abnfDiagram-N423BO3Z-CFRcoLpg.js} +1 -1
- package/dist/assets/{ar-SA-G6X2FPQ2-C3Z-nQuo.js → ar-SA-G6X2FPQ2-sAfgkCRO.js} +1 -1
- package/dist/assets/{architectureDiagram-T3A2C74G-D1XF7so6.js → architectureDiagram-T3A2C74G-D-pypPDC.js} +1 -1
- package/dist/assets/{az-AZ-76LH7QW2-D1hq5LzZ.js → az-AZ-76LH7QW2-B7UUtA9V.js} +1 -1
- package/dist/assets/{bg-BG-XCXSNQG7-DDz26IRu.js → bg-BG-XCXSNQG7-pBr-EcOp.js} +1 -1
- package/dist/assets/{blockDiagram-VBNYF7ZC-BjrXf4Lx.js → blockDiagram-VBNYF7ZC-DvgqkKq8.js} +1 -1
- package/dist/assets/{bn-BD-2XOGV67Q-DntJZuNN.js → bn-BD-2XOGV67Q-ZmHKJeXT.js} +1 -1
- package/dist/assets/{c4Diagram-5PPSVZJV-SJjATZxH.js → c4Diagram-5PPSVZJV-BLNCYyJq.js} +1 -1
- package/dist/assets/{ca-ES-6MX7JW3Y-HyKozy7T.js → ca-ES-6MX7JW3Y-uiuqntE7.js} +1 -1
- package/dist/assets/{calendar-Buen4kc1.js → calendar-CK7ETGoj.js} +1 -1
- package/dist/assets/channel-BbcQ65Db.js +1 -0
- package/dist/assets/{chunk-2GRJ4B5K-DxmnKQWO.js → chunk-2GRJ4B5K-Bfem8Whi.js} +1 -1
- package/dist/assets/{chunk-4I5QYGJK-CjtQRcsg.js → chunk-4I5QYGJK-8fYYsl65.js} +1 -1
- package/dist/assets/{chunk-5RXB4S5H-DndcRZlm.js → chunk-5RXB4S5H-BtNgmASf.js} +1 -1
- package/dist/assets/{chunk-6Q2QTUOP-Dzgr_4Ox.js → chunk-6Q2QTUOP-D7pQ0XCV.js} +1 -1
- package/dist/assets/{chunk-7Z6QIM7H-DZHhMbeE.js → chunk-7Z6QIM7H-DIuSkVKY.js} +1 -1
- package/dist/assets/{chunk-EIO257PC-BXmQMfy6.js → chunk-EIO257PC-DSggl7CS.js} +1 -1
- package/dist/assets/{chunk-GF5L2VYU-C_pjsgY5.js → chunk-GF5L2VYU-DZyK-lyz.js} +1 -1
- package/dist/assets/{chunk-I66GZJ75-Du-egtlL.js → chunk-I66GZJ75-D8ZvZtt-.js} +1 -1
- package/dist/assets/{chunk-JQJVKLGR-D-es_GWU.js → chunk-JQJVKLGR-DeW2EiZ0.js} +1 -1
- package/dist/assets/{chunk-KBJHAD2P-BrVpNf_H.js → chunk-KBJHAD2P-DcBWrqJQ.js} +1 -1
- package/dist/assets/{chunk-NSK5VX7P-Cktj7w1S.js → chunk-NSK5VX7P-D7fsThyg.js} +1 -1
- package/dist/assets/{chunk-QR6OTTB3-CuTncP5h.js → chunk-QR6OTTB3-C2Xmq4bt.js} +1 -1
- package/dist/assets/{chunk-UBXNYLIW-3WmxOIwF.js → chunk-UBXNYLIW-DbauHShz.js} +1 -1
- package/dist/assets/{chunk-W5SLKNZC-DAcGTqwB.js → chunk-W5SLKNZC-B8o2CBYp.js} +1 -1
- package/dist/assets/{chunk-WRU74C26-lYPpjwnu.js → chunk-WRU74C26-tdNHfgp9.js} +1 -1
- package/dist/assets/classDiagram-JCYQIIEL-C3yn2hDE.js +1 -0
- package/dist/assets/classDiagram-v2-OCEON4UE-C3yn2hDE.js +1 -0
- package/dist/assets/{cs-CZ-2BRQDIVT-BaU2cgs_.js → cs-CZ-2BRQDIVT-DW5M6RIQ.js} +1 -1
- package/dist/assets/{cynefinDiagram-MW4NZA55-DgJ_7Npa.js → cynefinDiagram-MW4NZA55-DAV3eIe0.js} +1 -1
- package/dist/assets/{da-DK-5WZEPLOC-CZPXvkUA.js → da-DK-5WZEPLOC-odK_TOrt.js} +1 -1
- package/dist/assets/{dagre-VZM6K2ZE-DExKyNn2.js → dagre-VZM6K2ZE-DSmSLUQ_.js} +1 -1
- package/dist/assets/{de-DE-XR44H4JA-C42bAW9l.js → de-DE-XR44H4JA-COKTYBK3.js} +1 -1
- package/dist/assets/{diagram-7IWD3JNH-CYfYVInc.js → diagram-7IWD3JNH-X9IkQkfO.js} +1 -1
- package/dist/assets/{diagram-B4RE2ZJO-DAbTkPkl.js → diagram-B4RE2ZJO-BauLmT2J.js} +1 -1
- package/dist/assets/{diagram-LBJQPF4R-DPt9FtMx.js → diagram-LBJQPF4R-Bi7cqiVB.js} +1 -1
- package/dist/assets/{diagram-Q27KOJAE-C1xebg4P.js → diagram-Q27KOJAE-DkxkQUqQ.js} +1 -1
- package/dist/assets/{diagram-UB23O5K3-DWuhvwdK.js → diagram-UB23O5K3-BwAzC2lE.js} +1 -1
- package/dist/assets/{dist-DWm32btd.js → dist-DcpemCE_.js} +4 -4
- package/dist/assets/{ebnfDiagram-BXEA7PRR-BppQvfxv.js → ebnfDiagram-BXEA7PRR-BV3-5bWe.js} +1 -1
- package/dist/assets/{el-GR-BZB4AONW-DlMr1QNv.js → el-GR-BZB4AONW-BwoB9TTL.js} +1 -1
- package/dist/assets/{en-B4ZKOASM-CsR0DoS7.js → en-B4ZKOASM-q_5emM7g.js} +1 -1
- package/dist/assets/{erDiagram-JOGREHBK-DBAQqy4y.js → erDiagram-JOGREHBK-CXtA4SRa.js} +1 -1
- package/dist/assets/{erd-edge-style-NJXJJ5ej.js → erd-edge-style-BYti6SGl.js} +1 -1
- package/dist/assets/{es-ES-U4NZUMDT-WHSxMHnk.js → es-ES-U4NZUMDT-DGOHzCGU.js} +1 -1
- package/dist/assets/{eu-ES-A7QVB2H4-Bdeyw7dK.js → eu-ES-A7QVB2H4-Dqp-jzCx.js} +1 -1
- package/dist/assets/{fa-IR-HGAKTJCU-CDbJ-TYj.js → fa-IR-HGAKTJCU-C-M6zzgp.js} +1 -1
- package/dist/assets/{fi-FI-Z5N7JZ37-BWh-3CKN.js → fi-FI-Z5N7JZ37-C3QfOOO9.js} +1 -1
- package/dist/assets/flowDiagram-UKHOOZJN-CJPWvAcS.js +1 -0
- package/dist/assets/{fr-FR-RHASNOE6-GVGP0zmf.js → fr-FR-RHASNOE6-DdmrzSxm.js} +1 -1
- package/dist/assets/{ganttDiagram-PKOTCBZU-CrBWGVDD.js → ganttDiagram-PKOTCBZU-CfyVBbwV.js} +1 -1
- package/dist/assets/{gitGraphDiagram-DS77QQ5N-CQZHGqeL.js → gitGraphDiagram-DS77QQ5N-ne9WCL2d.js} +1 -1
- package/dist/assets/{gl-ES-HMX3MZ6V-Ck1Vmu8P.js → gl-ES-HMX3MZ6V-BDHyohie.js} +1 -1
- package/dist/assets/{he-IL-6SHJWFNN-5-9PhciM.js → he-IL-6SHJWFNN-CnPyy9Lv.js} +1 -1
- package/dist/assets/{hi-IN-IWLTKZ5I-DG0US0FK.js → hi-IN-IWLTKZ5I-zK_okxxQ.js} +1 -1
- package/dist/assets/{hu-HU-A5ZG7DT2-CbSegLDJ.js → hu-HU-A5ZG7DT2-BUaUfwjC.js} +1 -1
- package/dist/assets/{id-ID-SAP4L64H-VZzWpNg-.js → id-ID-SAP4L64H-Cr0eVTB8.js} +1 -1
- package/dist/assets/image-GAAHSSAO-B4J4J0uC.js +1 -0
- package/dist/assets/{index-eaTZrxyp.js → index-ClgzsBw5.js} +91 -91
- package/dist/assets/{infoDiagram-6WML65LV-CM4ntjpv.js → infoDiagram-6WML65LV-DTHrCYH0.js} +1 -1
- package/dist/assets/{ishikawaDiagram-WSZJBQD7-SfCNBhvc.js → ishikawaDiagram-WSZJBQD7-D72hybiD.js} +1 -1
- package/dist/assets/{it-IT-JPQ66NNP-B2ZchUfh.js → it-IT-JPQ66NNP-BQBrHyNX.js} +1 -1
- package/dist/assets/{ja-JP-DBVTYXUO-Bv1UlT27.js → ja-JP-DBVTYXUO-Du4WTTaW.js} +1 -1
- package/dist/assets/{journeyDiagram-NVQOT4AX-BTt_pEMU.js → journeyDiagram-NVQOT4AX-CqMX3_WG.js} +1 -1
- package/dist/assets/{kaa-6HZHGXH3-8npzSm2a.js → kaa-6HZHGXH3-Bo5EFmb6.js} +1 -1
- package/dist/assets/{kab-KAB-ZGHBKWFO-CaZcRM83.js → kab-KAB-ZGHBKWFO-BdDfKoBj.js} +1 -1
- package/dist/assets/{kanban-definition-27J2QSJJ-D-G3OBet.js → kanban-definition-27J2QSJJ-CVHLUZgL.js} +1 -1
- package/dist/assets/{kk-KZ-P5N5QNE5-CxQyKSyv.js → kk-KZ-P5N5QNE5-CAh1Y5jc.js} +1 -1
- package/dist/assets/{km-KH-HSX4SM5Z-V8OjL1Bl.js → km-KH-HSX4SM5Z-hKbAxeAh.js} +1 -1
- package/dist/assets/{ko-KR-MTYHY66A-B0wXD7N4.js → ko-KR-MTYHY66A-o2sO5hDq.js} +1 -1
- package/dist/assets/{ku-TR-6OUDTVRD-CMBKccMT.js → ku-TR-6OUDTVRD-FfQLXHUr.js} +1 -1
- package/dist/assets/{line-CrpWAl76.js → line-DO4IhPrT.js} +1 -1
- package/dist/assets/{lt-LT-XHIRWOB4-DbvMd7cf.js → lt-LT-XHIRWOB4-BgTll3dm.js} +1 -1
- package/dist/assets/{lv-LV-5QDEKY6T-CcVyKrXT.js → lv-LV-5QDEKY6T-SQ5GlAMC.js} +1 -1
- package/dist/assets/{mindmap-definition-FAOFIHXS-mqp4ZTYN.js → mindmap-definition-FAOFIHXS-DcHHgonR.js} +1 -1
- package/dist/assets/{mr-IN-CRQNXWMA-CNOOlQht.js → mr-IN-CRQNXWMA-Ck6AkepR.js} +1 -1
- package/dist/assets/{my-MM-5M5IBNSE-DjkiaDat.js → my-MM-5M5IBNSE-BAhHoRGK.js} +1 -1
- package/dist/assets/{nb-NO-T6EIAALU-Bd44Suvp.js → nb-NO-T6EIAALU-BBuuSR88.js} +1 -1
- package/dist/assets/{nl-NL-IS3SIHDZ-SM_SkVLB.js → nl-NL-IS3SIHDZ-CnJEjKKB.js} +1 -1
- package/dist/assets/{nn-NO-6E72VCQL-DSKLyYDg.js → nn-NO-6E72VCQL-jTJohU5V.js} +1 -1
- package/dist/assets/{note-importer-Dw1ql6-a.js → note-importer-Cpv9RIOB.js} +2 -2
- package/dist/assets/{oc-FR-POXYY2M6-B4iIFHGK.js → oc-FR-POXYY2M6-tma3hLex.js} +1 -1
- package/dist/assets/{pa-IN-N4M65BXN-Ds8L6qNK.js → pa-IN-N4M65BXN-CuRTFi90.js} +1 -1
- package/dist/assets/{pegDiagram-VL7TDLO6-UgkfsYgb.js → pegDiagram-VL7TDLO6-BZ_xzAVa.js} +1 -1
- package/dist/assets/percentages-BXMCSKIN-Cpf7yEjF.js +1 -0
- package/dist/assets/{pieDiagram-7S7Q4E2Y-CuunvjrY.js → pieDiagram-7S7Q4E2Y-DxRXmXGF.js} +1 -1
- package/dist/assets/{pl-PL-T2D74RX3-BMKppRd4.js → pl-PL-T2D74RX3-Do0CK573.js} +1 -1
- package/dist/assets/{pt-BR-5N22H2LF-CI8WUlHK.js → pt-BR-5N22H2LF-BZKm8JWn.js} +1 -1
- package/dist/assets/{pt-PT-UZXXM6DQ-Df5hggGE.js → pt-PT-UZXXM6DQ-3knDcRgP.js} +1 -1
- package/dist/assets/{quadrantDiagram-CIZ2JOQS-yEBOYISm.js → quadrantDiagram-CIZ2JOQS-C-TFCVny.js} +1 -1
- package/dist/assets/{railroadDiagram-AXF67PYL-Ln_Y4jCv.js → railroadDiagram-AXF67PYL-VE71W4xx.js} +1 -1
- package/dist/assets/{requirementDiagram-LRYGKXZP-EA30r3fZ.js → requirementDiagram-LRYGKXZP-DOzB9gJr.js} +1 -1
- package/dist/assets/{ro-RO-JPDTUUEW-P3tfRtvz.js → ro-RO-JPDTUUEW-UU5kxtYz.js} +1 -1
- package/dist/assets/{ru-RU-B4JR7IUQ-CA3cEi50.js → ru-RU-B4JR7IUQ-DViF0hKW.js} +1 -1
- package/dist/assets/{sankeyDiagram-W5VNT64P-CNKrECEO.js → sankeyDiagram-W5VNT64P-CMChBBWY.js} +1 -1
- package/dist/assets/{sequenceDiagram-SI44F4Z6-BvdjVQbA.js → sequenceDiagram-SI44F4Z6-CsCJDjr7.js} +1 -1
- package/dist/assets/{si-LK-N5RQ5JYF-tM-3UppH.js → si-LK-N5RQ5JYF-GNX5JSgo.js} +1 -1
- package/dist/assets/{sk-SK-C5VTKIMK-DC2X7DTF.js → sk-SK-C5VTKIMK-C8c-w1rm.js} +1 -1
- package/dist/assets/{sl-SI-NN7IZMDC-jq0SAevq.js → sl-SI-NN7IZMDC-DNOemdZG.js} +1 -1
- package/dist/assets/{stateDiagram-OKZ733FA-BZu09Xf-.js → stateDiagram-OKZ733FA-C5l2AvV6.js} +1 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-1e7yB6oD.js +1 -0
- package/dist/assets/subset-shared.chunk-CYfMjPhk.js +1 -0
- package/dist/assets/{subset-worker.chunk-MHoUNfZZ.js → subset-worker.chunk-DEJaxHl_.js} +1 -1
- package/dist/assets/{sv-SE-XGPEYMSR-CkPEItbe.js → sv-SE-XGPEYMSR-C_eHgZ5g.js} +1 -1
- package/dist/assets/{swimlanes-SLNWSIFB-DlZcUIAu.js → swimlanes-SLNWSIFB-BRk_3k9f.js} +1 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-DnPcduU0.js +8 -0
- package/dist/assets/{ta-IN-2NMHFXQM-DsTCk6yJ.js → ta-IN-2NMHFXQM-CBDy1tMh.js} +1 -1
- package/dist/assets/{th-TH-HPSO5L25-BmHnp2Ey.js → th-TH-HPSO5L25-BL2V5EcV.js} +1 -1
- package/dist/assets/{timeline-definition-Z64GVDOM-GE_aq93q.js → timeline-definition-Z64GVDOM-Wo_gaJ0f.js} +1 -1
- package/dist/assets/{tr-TR-DEFEU3FU-e7sJYlFU.js → tr-TR-DEFEU3FU-B-rcgqhE.js} +1 -1
- package/dist/assets/{uk-UA-QMV73CPH-wkU-bdqU.js → uk-UA-QMV73CPH-CPMawntT.js} +1 -1
- package/dist/assets/{vennDiagram-T6HMQDX7-CR6fe_9D.js → vennDiagram-T6HMQDX7-Dpxf_AlP.js} +1 -1
- package/dist/assets/{vi-VN-M7AON7JQ-DT02JT2G.js → vi-VN-M7AON7JQ-DEdcwMei.js} +1 -1
- package/dist/assets/{wardleyDiagram-T6FBY63Y-BeUX_fEe.js → wardleyDiagram-T6FBY63Y-CFLY5JoA.js} +1 -1
- package/dist/assets/{xychartDiagram-ELKLHX3M-7kum3OGb.js → xychartDiagram-ELKLHX3M-DD28oMAq.js} +1 -1
- package/dist/assets/{zh-CN-LNUGB5OW-xn033ol4.js → zh-CN-LNUGB5OW-DiuZ3n3w.js} +1 -1
- package/dist/assets/{zh-HK-E62DVLB3-DuJInGme.js → zh-HK-E62DVLB3-D4iB4bZT.js} +1 -1
- package/dist/assets/{zh-TW-RAJ6MFWO-2tKoLdwh.js → zh-TW-RAJ6MFWO-DqFeM2bj.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/dist/assets/channel-PiqH2EIA.js +0 -1
- package/dist/assets/classDiagram-JCYQIIEL-DOwiLxIp.js +0 -1
- package/dist/assets/classDiagram-v2-OCEON4UE-DOwiLxIp.js +0 -1
- package/dist/assets/flowDiagram-UKHOOZJN-BJrbFSFd.js +0 -1
- package/dist/assets/image-GAAHSSAO-DEEriWi-.js +0 -1
- package/dist/assets/percentages-BXMCSKIN-CrLpL8B7.js +0 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-ZjumyB9f.js +0 -1
- package/dist/assets/subset-shared.chunk-C1F3agk-.js +0 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-D3f1dajS.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r,d as i}from"./chunk-BV7QT456-CCzugQp2.js";import{r as a}from"./utils-TcK2FSyg.js";import{t as o}from"./check-DcrFpa6g.js";import{t as ee}from"./plus-CSlTmvRo.js";import{n as s}from"./api-D87lw-98.js";import{t as c}from"./input-CluuKyQT.js";import{O as l}from"./note-importer-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r,d as i}from"./chunk-BV7QT456-CCzugQp2.js";import{r as a}from"./utils-TcK2FSyg.js";import{t as o}from"./check-DcrFpa6g.js";import{t as ee}from"./plus-CSlTmvRo.js";import{n as s}from"./api-D87lw-98.js";import{t as c}from"./input-CluuKyQT.js";import{O as l}from"./note-importer-Cpv9RIOB.js";import"./WorkspaceProvider-CCtybqSH.js";import{n as u}from"./WorkspaceContext-O7njKDwj.js";import{An as d,Nt as f,fn as p,jn as m,xn as h}from"./index-ClgzsBw5.js";var g=e(t(),1),_=n(),v=[{id:`notes`,label:`Notes`,icon:h,route:`/notes`},{id:`erd`,label:`ERD Builder`,icon:d,route:`/diagrams`},{id:`db-client`,label:`DB Client`,icon:m,route:`/db-client`},{id:`flowchart`,label:`Flowchart`,icon:p,route:`/flowcharts`},{id:`drawings`,label:`Drawings`,icon:f,route:`/drawings`}],y=e=>e.title||e.name||`Untitled`,b=e=>e.uid||e.id,x=e=>new Date(e.created_at||e.createdAt||0).getTime(),S=3e4,C=new Map,w=new Map,T=(e,t)=>{let n=e?.uid??e?.id;return n==null?null:{type:t,uid:String(n),title:y(e),createdAt:e.created_at??e.createdAt}};function E(e,t){let n=t=>!t.is_deleted&&!t.isDeleted&&String(t.project_id??t.projectId)===String(e),r=(e,t)=>e.filter(n).map(e=>T(e,t)).filter(e=>e!==null);return[...r(t.notes,`notes`),...r(t.diagrams.filter(e=>(e.source_type??e.sourceType)!==`production_db`),`erd`),...r(t.flowcharts,`flowchart`),...r(t.drawings,`drawings`)]}function te(...e){return[...new Map(e.flatMap(e=>e.map(e=>[`${e.type}-${e.uid}`,e]))).values()].sort((e,t)=>x(e)-x(t))}async function ne(e,t){let n=String(e),r=`${t}:${n}`,i=C.get(r);if(i&&i.expiresAt>Date.now())return i;let a=w.get(r);if(a)return a;let o=s(`/api/projects/${encodeURIComponent(n)}/files`).then(async e=>{if(!e.ok)throw Error(`Failed to load project files`);let t=await e.json(),n={files:Array.isArray(t.data)?t.data:[]};return C.set(r,{...n,expiresAt:Date.now()+S}),n}).finally(()=>w.delete(r));return w.set(r,o),o}function D({currentView:e,currentFile:t}){let[n,s]=(0,g.useState)(!1),[d,f]=(0,g.useState)(`notes`),[p,m]=(0,g.useState)(``),[h,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)({projectKey:``,files:[]}),w=(0,g.useRef)(null),D=(0,g.useRef)(null),O=r(),[k]=i(),{user:A,isGuest:j,activeProjectId:M,notes:N,diagrams:P,drawings:F,flowcharts:I,activeDiagram:L,activeNote:R,activeDrawing:z,activeFlowchart:B,activeDiagramId:V,activeNoteUid:H,activeDrawingId:U,activeFlowchartId:W,handleDiagramSelect:G,handleSidebarDiagramCreate:K,handleSidebarNoteCreate:q,handleSidebarDrawingCreate:J,handleSidebarFlowchartCreate:Y}=u();(0,g.useEffect)(()=>{if(!n)return;let e=e=>{w.current?.contains(e.target)||(s(!1),m(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,g.useEffect)(()=>{n&&setTimeout(()=>D.current?.focus(),0)},[n,d]);let X=(0,g.useMemo)(()=>{let n=t??(e===`notes`?R:e===`erd`?L:e===`flowchart`?B:z);return n?.project_id??n?.projectId??(M&&M!==`all`?M:k.get(`pid`))},[M,R,L,B,z,t,e,k]),re=X==null?``:String(X),Z=S.projectKey===re?S.files:[],Q=(0,g.useMemo)(()=>X?E(X,{notes:N,diagrams:P,drawings:F,flowcharts:I}):[],[X,N,P,F,I]);(0,g.useEffect)(()=>{if(!X){C({projectKey:``,files:[]});return}if(!j&&A?.id==null)return;let e=!1,t=String(X);return(async()=>{try{let n;if(j){let[e,t,r,i]=await Promise.all([l.getAllResources(`notes`),l.getAllResources(`erd`),l.getAllResources(`flowchart`),l.getAllResources(`drawings`)]);n=E(X,{notes:e,diagrams:t,flowcharts:r,drawings:i})}else n=(await ne(X,A.id)).files;e||C({projectKey:t,files:n})}catch{e||C({projectKey:t,files:[]})}})(),()=>{e=!0}},[X,j,A?.id]);let ie=(0,g.useMemo)(()=>{if(!X)return[];let n=t??(e===`notes`?R:e===`erd`?L:e===`flowchart`?B:z),r=n?T(n,e):null;return te(Z,Q,r?[r]:[]).map(e=>({file:e,type:e.type}))},[X,Z,Q,e,t,R,L,B,z]),ae=t?b(t):e===`notes`?H:e===`erd`?L?.uid||V:e===`flowchart`?B?.uid||W:z?.uid||U,oe=(e,t)=>{if(e===`erd`){G(String(b(t)));return}let n=v.find(t=>t.id===e);if(!n)return;let r=new URLSearchParams({pid:String(X)});O(`${n.route}/${b(t)}?${r}`)},$=async()=>{let e=p.trim();if(!(!e||h||!X)){x(!0);try{let t=String(X);d===`notes`?await q(e,t):d===`erd`?await K(e,t):d===`flowchart`?await Y(e,t):await J(e,t),s(!1),m(``)}finally{x(!1)}}};return X?(0,_.jsxs)(`div`,{className:`flex min-h-12 items-center border-b bg-background shrink-0`,children:[(0,_.jsx)(`div`,{className:`flex-1 min-w-0 overflow-x-auto scrollbar-hide`,children:(0,_.jsx)(`div`,{className:`flex items-center justify-start gap-1 px-3 py-2`,children:ie.map(({file:t,type:n})=>{let r=v.find(e=>e.id===n),i=r.icon,o=b(t);return(0,_.jsxs)(`button`,{onClick:()=>oe(n,t),className:a(`flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition-colors`,e===n&&String(ae)===String(o)?`bg-primary text-primary-foreground shadow-sm`:`bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground`),title:`${r.label}: ${y(t)}`,children:[(0,_.jsx)(i,{className:`size-3.5`}),(0,_.jsx)(`span`,{className:`truncate`,children:y(t)})]},`${n}-${o}`)})})}),(0,_.jsxs)(`div`,{ref:w,className:`relative shrink-0 self-stretch border-l bg-background px-2 py-2`,children:[(0,_.jsx)(`button`,{onClick:()=>s(e=>!e),className:`flex size-8 items-center justify-center rounded-md bg-primary text-primary-foreground shadow-sm hover:bg-primary/90`,"aria-label":`Create file`,"aria-expanded":n,children:(0,_.jsx)(ee,{className:`size-4`})}),n&&(0,_.jsxs)(`div`,{className:`absolute right-2 top-full z-50 mt-1 w-72 overflow-hidden rounded-lg border bg-popover text-popover-foreground shadow-md`,children:[(0,_.jsx)(`div`,{className:`max-h-56 overflow-y-auto p-1`,children:v.filter(e=>e.id!==`db-client`).map(e=>{let t=e.icon;return(0,_.jsxs)(`button`,{onClick:()=>f(e.id),className:a(`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent`,d===e.id&&`bg-accent text-accent-foreground`),children:[(0,_.jsx)(t,{className:`size-4`}),(0,_.jsx)(`span`,{className:`flex-1`,children:e.label}),d===e.id&&(0,_.jsx)(o,{className:`size-4`})]},e.id)})}),(0,_.jsxs)(`div`,{className:`sticky bottom-0 flex gap-2 border-t bg-popover p-2`,children:[(0,_.jsx)(c,{ref:D,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&$(),e.key===`Escape`&&(s(!1),m(``))},placeholder:`New file name`,className:`h-8 text-xs`,disabled:h}),(0,_.jsx)(`button`,{onClick:$,disabled:!p.trim()||h,className:`h-8 shrink-0 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:`Create`})]})]})]})]}):null}export{D as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r}from"./chunk-BV7QT456-CCzugQp2.js";import{_ as i}from"./composite-DpzKouN6.js";import{n as a}from"./dist-DDYEjsV2.js";import{t as o}from"./arrow-left-sRwyfx9m.js";import{n as s}from"./api-D87lw-98.js";import{a as c,i as l,n as u,o as d,r as f,t as p}from"./table-wBdalafB.js";import{n as m}from"./useAuth-B8-lFzUV.js";import{t as h}from"./ConfirmModal-td6IXKfM.js";import{$ as g,Mt as _}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r}from"./chunk-BV7QT456-CCzugQp2.js";import{_ as i}from"./composite-DpzKouN6.js";import{n as a}from"./dist-DDYEjsV2.js";import{t as o}from"./arrow-left-sRwyfx9m.js";import{n as s}from"./api-D87lw-98.js";import{a as c,i as l,n as u,o as d,r as f,t as p}from"./table-wBdalafB.js";import{n as m}from"./useAuth-B8-lFzUV.js";import{t as h}from"./ConfirmModal-td6IXKfM.js";import{$ as g,Mt as _}from"./index-ClgzsBw5.js";var v=e(t(),1),y=n(),b=e=>e===`active`?`default`:e===`quarantined`?`destructive`:`secondary`,x=e=>e===`quarantined`?`Quarantined`:e.charAt(0).toUpperCase()+e.slice(1);function S(){let e=r(),{user:t}=m(),n=!!(t?.isSuperAdmin||t?.is_super_admin),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(!0),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(null),[A,j]=(0,v.useState)(null),M=(0,v.useCallback)(async()=>{T(!0),D(``);try{let e=await s(`/api/teams/inventory`),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Unable to load Team workspaces.`);C(t)}catch(e){D(e?.message||`Unable to load Team workspaces.`)}finally{T(!1)}},[]),N=async e=>{let t=e.status===`active`?`inactive`:`active`;j(e.id);try{let n=await s(`/api/teams/${encodeURIComponent(e.id)}/status`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:t})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||`Team status could not be changed.`);window.dispatchEvent(new CustomEvent(`team-status-changed`,{detail:{teamId:e.id,status:t}})),a.success(t===`active`?`Team activated`:`Team deactivated; its data was retained.`),await M()}catch(e){a.error(e?.message||`Team status could not be changed.`)}finally{j(null)}},P=S?.license&&(S.license.maxTeams!==null&&S.usage.teamCount>S.license.maxTeams||S.license.maxMembers!==null&&S.usage.memberCount>S.license.maxMembers),F=P?`License capacity exceeded. Deactivate Teams or memberships until active usage fits; data remains stored.`:S&&!S.license?`Check or activate the instance license in Settings to change Team status.`:`Review status and manage local Team workspaces.`;return(0,v.useEffect)(()=>{n&&M()},[n,M]),n?(0,y.jsxs)(`main`,{className:`-m-4 flex-1 overflow-auto bg-background`,children:[(0,y.jsxs)(`div`,{className:`flex w-full flex-col gap-6 p-6 lg:p-8`,children:[(0,y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(i,{variant:`ghost`,size:`icon`,onClick:()=>e(`/`),"aria-label":`Back to dashboard`,children:(0,y.jsx)(o,{})}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Team Workspaces`}),(0,y.jsx)(`p`,{role:P?`alert`:void 0,className:`mt-1 text-sm ${P?`text-destructive`:`text-muted-foreground`}`,children:F})]})]}),(0,y.jsxs)(i,{variant:`outline`,onClick:()=>void M(),disabled:w,children:[(0,y.jsx)(_,{className:w?`animate-spin`:``}),` Refresh`]})]}),E&&(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:E}),(0,y.jsx)(`div`,{className:`rounded-lg border`,children:(0,y.jsxs)(p,{children:[(0,y.jsx)(c,{children:(0,y.jsxs)(d,{children:[(0,y.jsx)(l,{children:`Team`}),(0,y.jsx)(l,{children:`Status`}),(0,y.jsx)(l,{children:`Memberships`}),(0,y.jsx)(l,{children:`Created`}),(0,y.jsx)(l,{className:`w-52 text-right`,children:`Action`})]})}),(0,y.jsx)(u,{children:w?(0,y.jsx)(d,{children:(0,y.jsx)(f,{colSpan:5,className:`h-24 text-center text-muted-foreground`,children:`Loading Team workspaces…`})}):E?(0,y.jsx)(d,{children:(0,y.jsx)(f,{colSpan:5,className:`h-24 text-center text-muted-foreground`,children:`Team workspaces could not be loaded.`})}):S?.teams.length?S.teams.map(t=>(0,y.jsxs)(d,{children:[(0,y.jsx)(f,{className:`font-medium`,children:t.name}),(0,y.jsx)(f,{children:(0,y.jsx)(g,{variant:b(t.status),children:x(t.status)})}),(0,y.jsxs)(f,{children:[t.activeMemberCount,` active / `,t.memberCount,` total`]}),(0,y.jsx)(f,{className:`text-muted-foreground`,children:new Date(t.createdAt).toLocaleDateString()}),(0,y.jsx)(f,{children:(0,y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.canChangeStatus&&(0,y.jsx)(i,{variant:`outline`,size:`sm`,disabled:A!==null||!S?.license,onClick:()=>k(t),children:t.status===`active`?`Deactivate`:`Activate`}),(0,y.jsx)(i,{variant:`outline`,size:`sm`,onClick:()=>e(`/teams/${encodeURIComponent(t.id)}?from=team-workspaces`),children:`Review`})]})})]},t.id)):(0,y.jsx)(d,{children:(0,y.jsx)(f,{colSpan:5,className:`h-24 text-center text-muted-foreground`,children:`No Team workspaces found.`})})})]})})]}),(0,y.jsx)(h,{isOpen:!!O,title:O?.status===`active`?`Deactivate this Team?`:`Activate this Team?`,message:O?.status===`active`?`${O.name} will stop accepting Team access. Its documents and memberships will be retained; inactive Teams do not use an active Team slot.`:`${O?.name||`This Team`} will become available to its active members if active Team and member limits allow it.`,confirmText:O?.status===`active`?`Deactivate`:`Activate`,cancelText:`Cancel`,variant:`warning`,onCancel:()=>k(null),onConfirm:()=>{let e=O;k(null),e&&N(e)}})]}):(0,y.jsx)(`main`,{className:`flex flex-1 items-start p-6`,children:(0,y.jsx)(`p`,{children:`Only the SuperAdmin can view Team workspaces.`})})}export{S as TeamInventoryRoute,S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r,d as i,r as ee,u as a}from"./chunk-BV7QT456-CCzugQp2.js";import{a as o,i as s,l as c,n as l,o as u,s as te,t as d}from"./dialog-C4O82yNc.js";import{_ as f}from"./composite-DpzKouN6.js";import{S as p,_ as m,f as ne,g as h,h as g,i as _,m as v,n as y,o as b,s as x,t as S}from"./select-D-sac3DW.js";import{n as C}from"./dist-DDYEjsV2.js";import{t as w}from"./arrow-left-sRwyfx9m.js";import{n as T}from"./minus-DU5tWN1g.js";import{a as E,i as re,n as D,r as O,t as k}from"./users-DyYyhq63.js";import{n as A}from"./api-D87lw-98.js";import{a as j,n as M,o as N,r as P,t as F}from"./card-Dy6p8t6g.js";import{t as I}from"./input-CluuKyQT.js";import{t as ie}from"./checkbox-Duz4tSop.js";import{a as ae,i as L,n as oe,o as se,r as R,t as ce}from"./table-wBdalafB.js";import{n as le}from"./useAuth-B8-lFzUV.js";import{n as ue}from"./WorkspaceContext-O7njKDwj.js";import{t as de}from"./ConfirmModal-td6IXKfM.js";import{$ as fe,Dn as pe,En as z,Mt as B,On as me,Xt as he,at as V,it as H,st as U}from"./index-eaTZrxyp.js";var W=e(t(),1),G=n(),K=`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%`;function q(){let e=new Uint32Array(18);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>K[e%62]).join(``)}async function J(e,t){let n=await e.json().catch(()=>({}));return Error(typeof n.error==`string`?n.error:t)}function ge({teamId:e,open:t,onOpenChange:n,onAdded:r}){let[i,ee]=(0,W.useState)(null),[a,p]=(0,W.useState)(``),[m,ne]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(!1),[x,S]=(0,W.useState)(!1),[w,T]=(0,W.useState)(`staff`),[E,re]=(0,W.useState)(!1),D=E&&_.length>0&&h!==_,O=()=>{n(!1),p(``),ne(``),g(``),v(``),b(!1),S(!1),re(!1),T(`staff`)},k=()=>{g(q()),v(``),b(!1),S(!1)},j=e=>{re(e),e?k():(g(``),v(``),b(!1),S(!1))};return(0,G.jsx)(d,{open:t,onOpenChange:e=>e?n(!0):O(),children:(0,G.jsx)(s,{size:`md`,children:(0,G.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),!(!e||!a.trim())){if(E&&h!==_){C.error(`Passwords do not match.`);return}ee(`add-member`);try{let t=await A(`/api/teams/${encodeURIComponent(e)}/members`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:a.trim(),...E?{name:m.trim(),password:h,confirmPassword:_}:{},role:w})});if(!t.ok)throw await J(t,`Member could not be added.`);r(await t.json()),O(),C.success(`Member added`)}catch(e){C.error(e?.message||`Member could not be added.`)}finally{ee(null)}}},children:[(0,G.jsxs)(te,{children:[(0,G.jsx)(c,{children:`Add member`}),(0,G.jsx)(o,{children:`Add an existing account, or create a new account for this Team.`})]}),(0,G.jsxs)(l,{className:`space-y-4`,children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{htmlFor:`team-member-email`,children:`Email`}),(0,G.jsx)(I,{id:`team-member-email`,type:`email`,value:a,onChange:e=>p(e.target.value),placeholder:`member@example.com`,required:!0,autoFocus:!0})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{children:`Role`}),(0,G.jsx)(`div`,{role:`radiogroup`,"aria-label":`Member role`,className:`grid gap-2 sm:grid-cols-2`,children:[`manager`,`staff`].map(e=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg border p-3 has-checked:border-primary has-checked:bg-primary/5`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`team-member-role`,value:e,checked:w===e,onChange:()=>T(e),className:`mt-0.5 size-4 accent-primary`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`block text-sm font-medium capitalize`,children:e}),(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e===`manager`?`Can manage this Team and its members.`:`Can collaborate on this Team's work.`})]})]},e))})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,G.jsx)(ie,{checked:E,onCheckedChange:e=>j(e===!0)}),`Create a new account`]}),E&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{htmlFor:`team-member-name`,children:`Name`}),(0,G.jsx)(I,{id:`team-member-name`,value:m,onChange:e=>ne(e.target.value),required:!0})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{htmlFor:`team-member-password`,children:`Temporary password`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(I,{id:`team-member-password`,type:y?`text`:`password`,value:h,readOnly:!0,"aria-readonly":`true`,minLength:8,required:!0,className:`pr-10`}),(0,G.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute right-1 top-1/2 -translate-y-1/2`,onClick:()=>b(e=>!e),"aria-label":y?`Hide temporary password`:`Show temporary password`,"aria-pressed":y,children:y?(0,G.jsx)(pe,{}):(0,G.jsx)(z,{})})]}),(0,G.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:k,children:[(0,G.jsx)(B,{"data-icon":`inline-start`}),` Generate new`]})]}),(0,G.jsx)(V,{children:`Generated automatically. Share it securely; changing this password after signing in is optional.`})]}),(0,G.jsxs)(H,{"data-invalid":D,children:[(0,G.jsx)(U,{htmlFor:`team-member-confirm-password`,children:`Confirm password`}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(I,{id:`team-member-confirm-password`,type:x?`text`:`password`,value:_,onChange:e=>v(e.target.value),minLength:8,required:!0,"aria-invalid":D,className:`pr-10`}),(0,G.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute right-1 top-1/2 -translate-y-1/2`,onClick:()=>S(e=>!e),"aria-label":x?`Hide confirm password`:`Show confirm password`,"aria-pressed":x,children:x?(0,G.jsx)(pe,{}):(0,G.jsx)(z,{})})]}),D?(0,G.jsx)(V,{className:`text-destructive`,children:`Passwords do not match.`}):(0,G.jsx)(V,{children:`Enter the same password again.`})]})]})]}),(0,G.jsxs)(u,{children:[(0,G.jsx)(f,{type:`button`,variant:`outline`,onClick:O,disabled:i!==null,children:`Cancel`}),(0,G.jsxs)(f,{type:`submit`,disabled:i!==null||!a.trim()||E&&(!m.trim()||h.length<8||_.length<8||h!==_),children:[i===`add-member`&&(0,G.jsx)(he,{className:`animate-spin`}),` Add member`]})]})]})})})}var _e={manager:`Manager`,staff:`Staff`};function ve(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString()}async function Y(e,t){let n=await e.json().catch(()=>({}));return Error(typeof n.error==`string`?n.error:t)}function X(){let{id:e}=a(),t=r(),[n]=i(),o=n.get(`from`)===`team-workspaces`?`/team-workspaces`:`/`,{user:s}=le(),[c,l]=(0,W.useState)(null),[u,te]=(0,W.useState)(null),[d,ie]=(0,W.useState)(``),[pe,z]=(0,W.useState)(!0),[B,V]=(0,W.useState)(null),[H,U]=(0,W.useState)(!1),[K,q]=(0,W.useState)(null),[J,X]=(0,W.useState)(null),[ye,be]=(0,W.useState)(``),xe=!!s?.isSso,Z=!!(s?.isSuperAdmin||s?.is_super_admin),{setBreadcrumbLabel:Q}=ue(),$=(0,W.useCallback)(async()=>{if(e){z(!0),be(``),l(null),te(null);try{let t=await A(`/api/teams/${encodeURIComponent(e)}`);if(!t.ok){let n=await t.json().catch(()=>({}));if(Z&&n.code===`TEAM_INTEGRITY_UNAVAILABLE`){let t=await A(`/api/teams/${encodeURIComponent(e)}/integrity-review`);if(t.ok){te(await t.json());return}}throw Error(typeof n.error==`string`?n.error:`Team could not be loaded.`)}l(await t.json())}catch(e){be(e?.message||`Team could not be loaded.`)}finally{z(!1)}}},[e,Z]);if((0,W.useEffect)(()=>{$()},[$]),(0,W.useEffect)(()=>{if(!xe)return;let t=t=>{t.detail?.teamId===e&&$()};return window.addEventListener(`cloud-workspace-sync`,t),()=>window.removeEventListener(`cloud-workspace-sync`,t)},[$,e,xe]),(0,W.useEffect)(()=>(Q(c?.name||`Team management`),()=>Q(null)),[Q,c?.name]),(0,W.useEffect)(()=>{ie(c?.name||``)},[c?.name]),!Z&&c&&!c.canManage)return(0,G.jsx)(ee,{to:`/`,replace:!0});let Se=async(t,n)=>{if(e){V(`role:${t}`);try{let r=await A(`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({role:n})});if(!r.ok)throw await Y(r,`Member role could not be updated.`);l(await r.json()),C.success(`Member role updated`)}catch(e){C.error(e?.message||`Member role could not be updated.`)}finally{V(null)}}},Ce=async()=>{if(!(!e||!d.trim()||d.trim()===c?.name)){V(`rename-team`);try{let t=await A(`/api/teams/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:d.trim()})});if(!t.ok)throw await Y(t,`Team name could not be updated.`);l(await t.json()),C.success(`Team name updated`)}catch(e){C.error(e?.message||`Team name could not be updated.`)}finally{V(null)}}},we=async(t,n)=>{if(e){V(`remove:${t}`);try{let n=await A(`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok)throw await Y(n,`Member could not be removed.`);await $(),C.success(`Member deactivated`)}catch(e){C.error(e?.message||`Member could not be removed.`)}finally{V(null)}}},Te=async(t,n)=>{if(e){V(`ban:${t}`);try{let n=await A(`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}/ban`,{method:`POST`});if(!n.ok)throw await Y(n,`Member could not be banned.`);await $(),C.success(`Member banned`)}catch(e){C.error(e?.message||`Member could not be banned.`)}finally{V(null)}}},Ee=async n=>{if(e){V(`quarantine:${n.kind}`);try{let r=n.kind===`team`?`/api/teams/${encodeURIComponent(e)}/integrity/quarantine`:`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(n.userId)}/integrity/quarantine`,i=await A(r,{method:`POST`});if(!i.ok)throw await Y(i,`Integrity issue could not be quarantined.`);X(null),C.success(n.kind===`team`?`Team quarantined; its data was retained.`:`Membership quarantined; its data was retained.`),n.kind===`team`?(window.dispatchEvent(new CustomEvent(`team-quarantined`,{detail:{teamId:e}})),t(`/`,{replace:!0})):await $()}catch(e){C.error(e?.message||`Integrity issue could not be quarantined.`)}finally{V(null)}}},De=async t=>{if(e){V(`reactivate:${t}`);try{let n=await A(`/api/teams/${encodeURIComponent(e)}/members`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t})});if(!n.ok)throw await Y(n,`Member could not be reactivated.`);l(await n.json()),C.success(`Member reactivated`)}catch(e){C.error(e?.message||`Member could not be reactivated.`)}finally{V(null)}}};if(pe)return(0,G.jsx)(`main`,{className:`flex flex-1 items-center justify-center`,children:(0,G.jsx)(he,{className:`size-5 animate-spin`,"aria-label":`Loading Team`})});if(!c&&u){let e=u.members.filter(e=>e.status===`active`&&!e.signatureValid),n=!u.teamSignatureValid&&u.team.status!==`quarantined`,r=u.teamSignatureValid&&u.team.status===`active`&&e.length>0;return(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,G.jsxs)(f,{variant:`ghost`,onClick:()=>t(o),children:[(0,G.jsx)(w,{}),` Back`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Team integrity issue`}),(0,G.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[u.team.name,` management is blocked. This review only allows quarantine when a provisioning signature is invalid; it never changes signatures or deletes data, and every action is audited.`]})]}),!u.teamSignatureValid&&(0,G.jsxs)(F,{className:`w-full max-w-2xl`,children:[(0,G.jsxs)(j,{children:[(0,G.jsx)(N,{children:`Team signature is invalid`}),(0,G.jsx)(P,{children:`Disable this Team to block access while preserving its projects and other data.`})]}),(0,G.jsx)(M,{children:n?(0,G.jsx)(f,{variant:`destructive`,disabled:B!==null,onClick:()=>X({kind:`team`,name:u.team.name}),children:`Quarantine Team`}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Team is already quarantined. Its data is retained.`})})]}),u.teamSignatureValid&&e.length>0&&(0,G.jsxs)(F,{className:`w-full max-w-2xl`,children:[(0,G.jsxs)(j,{children:[(0,G.jsx)(N,{children:`Membership signatures are invalid`}),(0,G.jsx)(P,{children:`Disable only the affected memberships. The user account and other Team memberships stay intact.`})]}),(0,G.jsx)(M,{className:`space-y-3`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-md border p-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:e.name||`Unnamed member`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.email||`—`})]}),(0,G.jsx)(f,{variant:`destructive`,size:`sm`,disabled:B!==null,onClick:()=>X({kind:`member`,userId:e.userId,name:e.name||e.email||`this member`}),children:`Quarantine membership`})]},e.id))})]}),!n&&!r&&u.teamSignatureValid&&e.length===0&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active invalid signatures were found. Check this installation’s license and capacity limits.`}),(0,G.jsx)(de,{isOpen:!!J,title:J?.kind===`team`?`Quarantine this Team?`:`Quarantine this membership?`,message:`${J?.name||`This record`} will be deactivated. Its data and signature will be kept, and the action will be recorded in the audit log.`,confirmText:`Quarantine`,cancelText:`Cancel`,variant:`danger`,onCancel:()=>X(null),onConfirm:()=>{let e=J;X(null),e&&Ee(e)}})]})}if(!c)return(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,G.jsxs)(f,{variant:`ghost`,onClick:()=>t(o),children:[(0,G.jsx)(w,{}),` Back`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Team unavailable`}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:ye||`This Team does not exist or is not accessible.`})]})]});if(xe){let e=c.manageUrl;return(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,G.jsxs)(f,{variant:`ghost`,onClick:()=>t(o),children:[(0,G.jsx)(w,{}),` Back`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Team management is in ERDBPro SaaS`}),(0,G.jsxs)(`p`,{className:`mt-1 max-w-xl text-sm text-muted-foreground`,children:[c.name,` is managed from your ERDBPro SaaS account. This workspace stays available here for collaboration.`]})]}),e&&(0,G.jsxs)(f,{onClick:()=>window.location.assign(e),children:[(0,G.jsx)(me,{}),` Open ERDBPro SaaS`]})]})}return(0,G.jsxs)(`main`,{className:`-m-4 flex-1 overflow-auto bg-background`,children:[(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-6 p-6 lg:p-8`,children:[(0,G.jsx)(`header`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(f,{variant:`ghost`,size:`icon`,onClick:()=>t(o),"aria-label":o===`/team-workspaces`?`Back to Team workspaces`:`Back to dashboard`,children:(0,G.jsx)(w,{})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(I,{value:d,onChange:e=>ie(e.target.value),className:`h-9 w-64 text-xl font-semibold`,"aria-label":`Team name`}),(0,G.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>void Ce(),disabled:B!==null||!d.trim()||d.trim()===c.name,children:`Save name`})]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage members, roles, and this Team's projects.`})]})]})}),c.capacity?.exceeded&&(0,G.jsx)(`p`,{role:`alert`,className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm`,children:`License capacity exceeded. Deactivate excess Teams or members to bring active usage within the limit. Data remains stored.`}),c.status===`inactive`&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Team is inactive. Its documents and memberships remain stored; its members count again if the Team is reactivated.`}),(0,G.jsx)(`div`,{className:`grid gap-4`,children:(0,G.jsxs)(F,{className:`min-w-0`,children:[(0,G.jsxs)(j,{className:`flex flex-row items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,G.jsx)(k,{className:`size-4`}),` Members`]}),(0,G.jsxs)(P,{children:[c.memberCount||0,` active memberships. Unique members count once across active Teams.`]})]}),(0,G.jsxs)(f,{disabled:c.status===`inactive`||c.capacity?.exceeded,onClick:()=>U(!0),children:[(0,G.jsx)(re,{}),` Add member`]})]}),(0,G.jsx)(M,{className:`space-y-4`,children:(0,G.jsx)(`div`,{className:`rounded-lg border`,children:(0,G.jsxs)(ce,{children:[(0,G.jsx)(ae,{children:(0,G.jsxs)(se,{children:[(0,G.jsx)(L,{children:`Member`}),(0,G.jsx)(L,{children:`Email`}),(0,G.jsx)(L,{children:`Role`}),(0,G.jsx)(L,{children:`Status`}),(0,G.jsx)(L,{children:`Joined`}),(0,G.jsx)(L,{className:`w-16 text-right`,children:`Action`})]})}),(0,G.jsxs)(oe,{children:[c.members.length===0&&(0,G.jsx)(se,{children:(0,G.jsx)(R,{colSpan:6,className:`h-24 text-center text-muted-foreground`,children:`No members have been added.`})}),c.members.map(e=>(0,G.jsxs)(se,{children:[(0,G.jsx)(R,{className:`font-medium`,children:e.name||`Unnamed member`}),(0,G.jsx)(R,{className:`text-muted-foreground`,children:e.email||`—`}),(0,G.jsx)(R,{children:(0,G.jsxs)(S,{value:e.role,onValueChange:t=>t&&void Se(e.id,t),disabled:B!==null||e.status!==`active`||c.status===`inactive`,children:[(0,G.jsx)(b,{size:`sm`,className:`w-28`,children:(0,G.jsx)(x,{children:_e[e.role]})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(_,{value:`manager`,children:_e.manager}),(0,G.jsx)(_,{value:`staff`,children:_e.staff})]})]})}),(0,G.jsx)(R,{children:(0,G.jsx)(fe,{variant:`secondary`,children:e.status===`active`?`Active`:e.status===`quarantined`?`Quarantined`:e.status})}),(0,G.jsx)(R,{className:`text-muted-foreground`,children:ve(e.joinedAt)}),(0,G.jsx)(R,{className:`text-right`,children:(Z||e.id!==s?.id)&&(0,G.jsxs)(ne,{children:[(0,G.jsx)(p,{render:(0,G.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${e.name||e.email||`member`}`,disabled:B!==null,children:(0,G.jsx)(T,{})})}),(0,G.jsx)(v,{align:`end`,className:`w-48`,children:(0,G.jsxs)(g,{children:[(0,G.jsx)(m,{children:`Member actions`}),e.status===`active`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(h,{onClick:()=>q({kind:`remove`,userId:e.id,name:e.name||e.email}),children:[(0,G.jsx)(O,{}),` Deactivate member`]}),Z&&(0,G.jsxs)(h,{variant:`destructive`,onClick:()=>q({kind:`ban`,userId:e.id,name:e.name||e.email}),children:[(0,G.jsx)(D,{}),` Ban member`]})]}):e.status===`quarantined`?(0,G.jsxs)(h,{disabled:!0,children:[(0,G.jsx)(D,{}),` Quarantined`]}):(0,G.jsxs)(h,{disabled:!e.email||c.status===`inactive`||c.capacity?.exceeded,onClick:()=>e.email&&void De(e.email),children:[(0,G.jsx)(E,{}),` Reactivate member`]})]})})]})})]},e.id))]})]})})})]})})]}),(0,G.jsx)(ge,{teamId:e,open:H,onOpenChange:U,onAdded:l}),(0,G.jsx)(de,{isOpen:!!K,title:K?.kind===`ban`?`Ban member?`:`Deactivate member?`,message:K?.kind===`ban`?`${K.name||`This member`} cannot be added to this Team again.`:`${K?.name||`This member`} will lose access to this Team.`,confirmText:K?.kind===`ban`?`Ban member`:`Deactivate member`,cancelText:`Cancel`,variant:`danger`,onCancel:()=>q(null),onConfirm:()=>{let e=K;q(null),e&&(e.kind===`ban`?Te(e.userId,e.name):we(e.userId,e.name))}})]})}export{X as TeamManagementRoute,X as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r,d as i,r as ee,u as a}from"./chunk-BV7QT456-CCzugQp2.js";import{a as o,i as s,l as c,n as l,o as u,s as te,t as d}from"./dialog-C4O82yNc.js";import{_ as f}from"./composite-DpzKouN6.js";import{S as p,_ as m,f as ne,g as h,h as g,i as _,m as v,n as y,o as b,s as x,t as S}from"./select-D-sac3DW.js";import{n as C}from"./dist-DDYEjsV2.js";import{t as w}from"./arrow-left-sRwyfx9m.js";import{n as T}from"./minus-DU5tWN1g.js";import{a as E,i as re,n as D,r as O,t as k}from"./users-DyYyhq63.js";import{n as A}from"./api-D87lw-98.js";import{a as j,n as M,o as N,r as P,t as F}from"./card-Dy6p8t6g.js";import{t as I}from"./input-CluuKyQT.js";import{t as ie}from"./checkbox-Duz4tSop.js";import{a as ae,i as L,n as oe,o as se,r as R,t as ce}from"./table-wBdalafB.js";import{n as le}from"./useAuth-B8-lFzUV.js";import{n as ue}from"./WorkspaceContext-O7njKDwj.js";import{t as de}from"./ConfirmModal-td6IXKfM.js";import{$ as fe,Dn as pe,En as z,Mt as B,On as me,Xt as he,at as V,it as H,st as U}from"./index-ClgzsBw5.js";var W=e(t(),1),G=n(),K=`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%`;function q(){let e=new Uint32Array(18);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>K[e%62]).join(``)}async function J(e,t){let n=await e.json().catch(()=>({}));return Error(typeof n.error==`string`?n.error:t)}function ge({teamId:e,open:t,onOpenChange:n,onAdded:r}){let[i,ee]=(0,W.useState)(null),[a,p]=(0,W.useState)(``),[m,ne]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(!1),[x,S]=(0,W.useState)(!1),[w,T]=(0,W.useState)(`staff`),[E,re]=(0,W.useState)(!1),D=E&&_.length>0&&h!==_,O=()=>{n(!1),p(``),ne(``),g(``),v(``),b(!1),S(!1),re(!1),T(`staff`)},k=()=>{g(q()),v(``),b(!1),S(!1)},j=e=>{re(e),e?k():(g(``),v(``),b(!1),S(!1))};return(0,G.jsx)(d,{open:t,onOpenChange:e=>e?n(!0):O(),children:(0,G.jsx)(s,{size:`md`,children:(0,G.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),!(!e||!a.trim())){if(E&&h!==_){C.error(`Passwords do not match.`);return}ee(`add-member`);try{let t=await A(`/api/teams/${encodeURIComponent(e)}/members`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:a.trim(),...E?{name:m.trim(),password:h,confirmPassword:_}:{},role:w})});if(!t.ok)throw await J(t,`Member could not be added.`);r(await t.json()),O(),C.success(`Member added`)}catch(e){C.error(e?.message||`Member could not be added.`)}finally{ee(null)}}},children:[(0,G.jsxs)(te,{children:[(0,G.jsx)(c,{children:`Add member`}),(0,G.jsx)(o,{children:`Add an existing account, or create a new account for this Team.`})]}),(0,G.jsxs)(l,{className:`space-y-4`,children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{htmlFor:`team-member-email`,children:`Email`}),(0,G.jsx)(I,{id:`team-member-email`,type:`email`,value:a,onChange:e=>p(e.target.value),placeholder:`member@example.com`,required:!0,autoFocus:!0})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{children:`Role`}),(0,G.jsx)(`div`,{role:`radiogroup`,"aria-label":`Member role`,className:`grid gap-2 sm:grid-cols-2`,children:[`manager`,`staff`].map(e=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg border p-3 has-checked:border-primary has-checked:bg-primary/5`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`team-member-role`,value:e,checked:w===e,onChange:()=>T(e),className:`mt-0.5 size-4 accent-primary`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`block text-sm font-medium capitalize`,children:e}),(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e===`manager`?`Can manage this Team and its members.`:`Can collaborate on this Team's work.`})]})]},e))})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,G.jsx)(ie,{checked:E,onCheckedChange:e=>j(e===!0)}),`Create a new account`]}),E&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{htmlFor:`team-member-name`,children:`Name`}),(0,G.jsx)(I,{id:`team-member-name`,value:m,onChange:e=>ne(e.target.value),required:!0})]}),(0,G.jsxs)(H,{children:[(0,G.jsx)(U,{htmlFor:`team-member-password`,children:`Temporary password`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(I,{id:`team-member-password`,type:y?`text`:`password`,value:h,readOnly:!0,"aria-readonly":`true`,minLength:8,required:!0,className:`pr-10`}),(0,G.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute right-1 top-1/2 -translate-y-1/2`,onClick:()=>b(e=>!e),"aria-label":y?`Hide temporary password`:`Show temporary password`,"aria-pressed":y,children:y?(0,G.jsx)(pe,{}):(0,G.jsx)(z,{})})]}),(0,G.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:k,children:[(0,G.jsx)(B,{"data-icon":`inline-start`}),` Generate new`]})]}),(0,G.jsx)(V,{children:`Generated automatically. Share it securely; changing this password after signing in is optional.`})]}),(0,G.jsxs)(H,{"data-invalid":D,children:[(0,G.jsx)(U,{htmlFor:`team-member-confirm-password`,children:`Confirm password`}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(I,{id:`team-member-confirm-password`,type:x?`text`:`password`,value:_,onChange:e=>v(e.target.value),minLength:8,required:!0,"aria-invalid":D,className:`pr-10`}),(0,G.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute right-1 top-1/2 -translate-y-1/2`,onClick:()=>S(e=>!e),"aria-label":x?`Hide confirm password`:`Show confirm password`,"aria-pressed":x,children:x?(0,G.jsx)(pe,{}):(0,G.jsx)(z,{})})]}),D?(0,G.jsx)(V,{className:`text-destructive`,children:`Passwords do not match.`}):(0,G.jsx)(V,{children:`Enter the same password again.`})]})]})]}),(0,G.jsxs)(u,{children:[(0,G.jsx)(f,{type:`button`,variant:`outline`,onClick:O,disabled:i!==null,children:`Cancel`}),(0,G.jsxs)(f,{type:`submit`,disabled:i!==null||!a.trim()||E&&(!m.trim()||h.length<8||_.length<8||h!==_),children:[i===`add-member`&&(0,G.jsx)(he,{className:`animate-spin`}),` Add member`]})]})]})})})}var _e={manager:`Manager`,staff:`Staff`};function ve(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString()}async function Y(e,t){let n=await e.json().catch(()=>({}));return Error(typeof n.error==`string`?n.error:t)}function X(){let{id:e}=a(),t=r(),[n]=i(),o=n.get(`from`)===`team-workspaces`?`/team-workspaces`:`/`,{user:s}=le(),[c,l]=(0,W.useState)(null),[u,te]=(0,W.useState)(null),[d,ie]=(0,W.useState)(``),[pe,z]=(0,W.useState)(!0),[B,V]=(0,W.useState)(null),[H,U]=(0,W.useState)(!1),[K,q]=(0,W.useState)(null),[J,X]=(0,W.useState)(null),[ye,be]=(0,W.useState)(``),xe=!!s?.isSso,Z=!!(s?.isSuperAdmin||s?.is_super_admin),{setBreadcrumbLabel:Q}=ue(),$=(0,W.useCallback)(async()=>{if(e){z(!0),be(``),l(null),te(null);try{let t=await A(`/api/teams/${encodeURIComponent(e)}`);if(!t.ok){let n=await t.json().catch(()=>({}));if(Z&&n.code===`TEAM_INTEGRITY_UNAVAILABLE`){let t=await A(`/api/teams/${encodeURIComponent(e)}/integrity-review`);if(t.ok){te(await t.json());return}}throw Error(typeof n.error==`string`?n.error:`Team could not be loaded.`)}l(await t.json())}catch(e){be(e?.message||`Team could not be loaded.`)}finally{z(!1)}}},[e,Z]);if((0,W.useEffect)(()=>{$()},[$]),(0,W.useEffect)(()=>{if(!xe)return;let t=t=>{t.detail?.teamId===e&&$()};return window.addEventListener(`cloud-workspace-sync`,t),()=>window.removeEventListener(`cloud-workspace-sync`,t)},[$,e,xe]),(0,W.useEffect)(()=>(Q(c?.name||`Team management`),()=>Q(null)),[Q,c?.name]),(0,W.useEffect)(()=>{ie(c?.name||``)},[c?.name]),!Z&&c&&!c.canManage)return(0,G.jsx)(ee,{to:`/`,replace:!0});let Se=async(t,n)=>{if(e){V(`role:${t}`);try{let r=await A(`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({role:n})});if(!r.ok)throw await Y(r,`Member role could not be updated.`);l(await r.json()),C.success(`Member role updated`)}catch(e){C.error(e?.message||`Member role could not be updated.`)}finally{V(null)}}},Ce=async()=>{if(!(!e||!d.trim()||d.trim()===c?.name)){V(`rename-team`);try{let t=await A(`/api/teams/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:d.trim()})});if(!t.ok)throw await Y(t,`Team name could not be updated.`);l(await t.json()),C.success(`Team name updated`)}catch(e){C.error(e?.message||`Team name could not be updated.`)}finally{V(null)}}},we=async(t,n)=>{if(e){V(`remove:${t}`);try{let n=await A(`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok)throw await Y(n,`Member could not be removed.`);await $(),C.success(`Member deactivated`)}catch(e){C.error(e?.message||`Member could not be removed.`)}finally{V(null)}}},Te=async(t,n)=>{if(e){V(`ban:${t}`);try{let n=await A(`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}/ban`,{method:`POST`});if(!n.ok)throw await Y(n,`Member could not be banned.`);await $(),C.success(`Member banned`)}catch(e){C.error(e?.message||`Member could not be banned.`)}finally{V(null)}}},Ee=async n=>{if(e){V(`quarantine:${n.kind}`);try{let r=n.kind===`team`?`/api/teams/${encodeURIComponent(e)}/integrity/quarantine`:`/api/teams/${encodeURIComponent(e)}/members/${encodeURIComponent(n.userId)}/integrity/quarantine`,i=await A(r,{method:`POST`});if(!i.ok)throw await Y(i,`Integrity issue could not be quarantined.`);X(null),C.success(n.kind===`team`?`Team quarantined; its data was retained.`:`Membership quarantined; its data was retained.`),n.kind===`team`?(window.dispatchEvent(new CustomEvent(`team-quarantined`,{detail:{teamId:e}})),t(`/`,{replace:!0})):await $()}catch(e){C.error(e?.message||`Integrity issue could not be quarantined.`)}finally{V(null)}}},De=async t=>{if(e){V(`reactivate:${t}`);try{let n=await A(`/api/teams/${encodeURIComponent(e)}/members`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t})});if(!n.ok)throw await Y(n,`Member could not be reactivated.`);l(await n.json()),C.success(`Member reactivated`)}catch(e){C.error(e?.message||`Member could not be reactivated.`)}finally{V(null)}}};if(pe)return(0,G.jsx)(`main`,{className:`flex flex-1 items-center justify-center`,children:(0,G.jsx)(he,{className:`size-5 animate-spin`,"aria-label":`Loading Team`})});if(!c&&u){let e=u.members.filter(e=>e.status===`active`&&!e.signatureValid),n=!u.teamSignatureValid&&u.team.status!==`quarantined`,r=u.teamSignatureValid&&u.team.status===`active`&&e.length>0;return(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,G.jsxs)(f,{variant:`ghost`,onClick:()=>t(o),children:[(0,G.jsx)(w,{}),` Back`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Team integrity issue`}),(0,G.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[u.team.name,` management is blocked. This review only allows quarantine when a provisioning signature is invalid; it never changes signatures or deletes data, and every action is audited.`]})]}),!u.teamSignatureValid&&(0,G.jsxs)(F,{className:`w-full max-w-2xl`,children:[(0,G.jsxs)(j,{children:[(0,G.jsx)(N,{children:`Team signature is invalid`}),(0,G.jsx)(P,{children:`Disable this Team to block access while preserving its projects and other data.`})]}),(0,G.jsx)(M,{children:n?(0,G.jsx)(f,{variant:`destructive`,disabled:B!==null,onClick:()=>X({kind:`team`,name:u.team.name}),children:`Quarantine Team`}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Team is already quarantined. Its data is retained.`})})]}),u.teamSignatureValid&&e.length>0&&(0,G.jsxs)(F,{className:`w-full max-w-2xl`,children:[(0,G.jsxs)(j,{children:[(0,G.jsx)(N,{children:`Membership signatures are invalid`}),(0,G.jsx)(P,{children:`Disable only the affected memberships. The user account and other Team memberships stay intact.`})]}),(0,G.jsx)(M,{className:`space-y-3`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-md border p-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:e.name||`Unnamed member`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.email||`—`})]}),(0,G.jsx)(f,{variant:`destructive`,size:`sm`,disabled:B!==null,onClick:()=>X({kind:`member`,userId:e.userId,name:e.name||e.email||`this member`}),children:`Quarantine membership`})]},e.id))})]}),!n&&!r&&u.teamSignatureValid&&e.length===0&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active invalid signatures were found. Check this installation’s license and capacity limits.`}),(0,G.jsx)(de,{isOpen:!!J,title:J?.kind===`team`?`Quarantine this Team?`:`Quarantine this membership?`,message:`${J?.name||`This record`} will be deactivated. Its data and signature will be kept, and the action will be recorded in the audit log.`,confirmText:`Quarantine`,cancelText:`Cancel`,variant:`danger`,onCancel:()=>X(null),onConfirm:()=>{let e=J;X(null),e&&Ee(e)}})]})}if(!c)return(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,G.jsxs)(f,{variant:`ghost`,onClick:()=>t(o),children:[(0,G.jsx)(w,{}),` Back`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Team unavailable`}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:ye||`This Team does not exist or is not accessible.`})]})]});if(xe){let e=c.manageUrl;return(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,G.jsxs)(f,{variant:`ghost`,onClick:()=>t(o),children:[(0,G.jsx)(w,{}),` Back`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Team management is in ERDBPro SaaS`}),(0,G.jsxs)(`p`,{className:`mt-1 max-w-xl text-sm text-muted-foreground`,children:[c.name,` is managed from your ERDBPro SaaS account. This workspace stays available here for collaboration.`]})]}),e&&(0,G.jsxs)(f,{onClick:()=>window.location.assign(e),children:[(0,G.jsx)(me,{}),` Open ERDBPro SaaS`]})]})}return(0,G.jsxs)(`main`,{className:`-m-4 flex-1 overflow-auto bg-background`,children:[(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-6 p-6 lg:p-8`,children:[(0,G.jsx)(`header`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(f,{variant:`ghost`,size:`icon`,onClick:()=>t(o),"aria-label":o===`/team-workspaces`?`Back to Team workspaces`:`Back to dashboard`,children:(0,G.jsx)(w,{})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(I,{value:d,onChange:e=>ie(e.target.value),className:`h-9 w-64 text-xl font-semibold`,"aria-label":`Team name`}),(0,G.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>void Ce(),disabled:B!==null||!d.trim()||d.trim()===c.name,children:`Save name`})]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage members, roles, and this Team's projects.`})]})]})}),c.capacity?.exceeded&&(0,G.jsx)(`p`,{role:`alert`,className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm`,children:`License capacity exceeded. Deactivate excess Teams or members to bring active usage within the limit. Data remains stored.`}),c.status===`inactive`&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This Team is inactive. Its documents and memberships remain stored; its members count again if the Team is reactivated.`}),(0,G.jsx)(`div`,{className:`grid gap-4`,children:(0,G.jsxs)(F,{className:`min-w-0`,children:[(0,G.jsxs)(j,{className:`flex flex-row items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,G.jsx)(k,{className:`size-4`}),` Members`]}),(0,G.jsxs)(P,{children:[c.memberCount||0,` active memberships. Unique members count once across active Teams.`]})]}),(0,G.jsxs)(f,{disabled:c.status===`inactive`||c.capacity?.exceeded,onClick:()=>U(!0),children:[(0,G.jsx)(re,{}),` Add member`]})]}),(0,G.jsx)(M,{className:`space-y-4`,children:(0,G.jsx)(`div`,{className:`rounded-lg border`,children:(0,G.jsxs)(ce,{children:[(0,G.jsx)(ae,{children:(0,G.jsxs)(se,{children:[(0,G.jsx)(L,{children:`Member`}),(0,G.jsx)(L,{children:`Email`}),(0,G.jsx)(L,{children:`Role`}),(0,G.jsx)(L,{children:`Status`}),(0,G.jsx)(L,{children:`Joined`}),(0,G.jsx)(L,{className:`w-16 text-right`,children:`Action`})]})}),(0,G.jsxs)(oe,{children:[c.members.length===0&&(0,G.jsx)(se,{children:(0,G.jsx)(R,{colSpan:6,className:`h-24 text-center text-muted-foreground`,children:`No members have been added.`})}),c.members.map(e=>(0,G.jsxs)(se,{children:[(0,G.jsx)(R,{className:`font-medium`,children:e.name||`Unnamed member`}),(0,G.jsx)(R,{className:`text-muted-foreground`,children:e.email||`—`}),(0,G.jsx)(R,{children:(0,G.jsxs)(S,{value:e.role,onValueChange:t=>t&&void Se(e.id,t),disabled:B!==null||e.status!==`active`||c.status===`inactive`,children:[(0,G.jsx)(b,{size:`sm`,className:`w-28`,children:(0,G.jsx)(x,{children:_e[e.role]})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(_,{value:`manager`,children:_e.manager}),(0,G.jsx)(_,{value:`staff`,children:_e.staff})]})]})}),(0,G.jsx)(R,{children:(0,G.jsx)(fe,{variant:`secondary`,children:e.status===`active`?`Active`:e.status===`quarantined`?`Quarantined`:e.status})}),(0,G.jsx)(R,{className:`text-muted-foreground`,children:ve(e.joinedAt)}),(0,G.jsx)(R,{className:`text-right`,children:(Z||e.id!==s?.id)&&(0,G.jsxs)(ne,{children:[(0,G.jsx)(p,{render:(0,G.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":`Actions for ${e.name||e.email||`member`}`,disabled:B!==null,children:(0,G.jsx)(T,{})})}),(0,G.jsx)(v,{align:`end`,className:`w-48`,children:(0,G.jsxs)(g,{children:[(0,G.jsx)(m,{children:`Member actions`}),e.status===`active`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(h,{onClick:()=>q({kind:`remove`,userId:e.id,name:e.name||e.email}),children:[(0,G.jsx)(O,{}),` Deactivate member`]}),Z&&(0,G.jsxs)(h,{variant:`destructive`,onClick:()=>q({kind:`ban`,userId:e.id,name:e.name||e.email}),children:[(0,G.jsx)(D,{}),` Ban member`]})]}):e.status===`quarantined`?(0,G.jsxs)(h,{disabled:!0,children:[(0,G.jsx)(D,{}),` Quarantined`]}):(0,G.jsxs)(h,{disabled:!e.email||c.status===`inactive`||c.capacity?.exceeded,onClick:()=>e.email&&void De(e.email),children:[(0,G.jsx)(E,{}),` Reactivate member`]})]})})]})})]},e.id))]})]})})})]})})]}),(0,G.jsx)(ge,{teamId:e,open:H,onOpenChange:U,onAdded:l}),(0,G.jsx)(de,{isOpen:!!K,title:K?.kind===`ban`?`Ban member?`:`Deactivate member?`,message:K?.kind===`ban`?`${K.name||`This member`} cannot be added to this Team again.`:`${K?.name||`This member`} will lose access to this Team.`,confirmText:K?.kind===`ban`?`Ban member`:`Deactivate member`,cancelText:`Cancel`,variant:`danger`,onCancel:()=>q(null),onConfirm:()=>{let e=K;q(null),e&&(e.kind===`ban`?Te(e.userId,e.name):we(e.userId,e.name))}})]})}export{X as TeamManagementRoute,X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-C0FnF6B9.js";import{n as e,t}from"./jsx-runtime-DSr1VPkp.js";import{_ as n}from"./composite-DpzKouN6.js";import{t as r}from"./refresh-ccw-DFj0g7WT.js";import{t as i}from"./trash-2-eV2xsHmQ.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./table-wBdalafB.js";import{n as d}from"./useAuth-B8-lFzUV.js";import{$ as f,An as p,Bt as m,Nt as h,Xt as g,d as _,f as v,jn as y,l as b,mt as x,pn as S,u as C,vt as w,z as T}from"./index-eaTZrxyp.js";e();var E=t();function D({clients:e,restore:t,permanentlyDelete:d}){return(0,E.jsxs)(`section`,{children:[(0,E.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,E.jsx)(y,{size:18,className:`text-cyan-400`}),` DB Clients`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.length,` Items`]})]}),e.length===0?(0,E.jsx)(`div`,{className:`rounded-lg border border-dashed py-12 text-center text-muted-foreground`,children:`No deleted DB Clients`}):(0,E.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`DB Client Name`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`flex items-center gap-2 font-medium`,children:[(0,E.jsx)(y,{size:14}),e.name]}),(0,E.jsx)(l,{className:`text-xs font-semibold text-muted-foreground`,children:e.project?.name||`-`}),(0,E.jsx)(l,{className:`text-xs text-muted-foreground`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:()=>t(e),children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),`Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>d(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),`Delete`]})]})})]},e.id))})]})})]})}function O({trashData:e,restoreProject:t,restoreDiagram:y,restoreNote:O,restoreDrawing:k,restoreFlowchart:A,restoreDbClient:j,fetchTrash:M,handleProjectPermanentDelete:N,handleDiagramPermanentDelete:P,handleNotePermanentDelete:F,handleDrawingPermanentDelete:I,handleFlowchartPermanentDelete:L,handleDbClientPermanentDelete:R,isLoading:z=!1}){let{user:B,isGuest:V}=d(),H=e=>T(e,B?.id,V);return(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 border rounded-xl bg-background overflow-hidden relative`,children:[z&&e.projects.length===0&&(0,E.jsxs)(`div`,{className:`absolute inset-0 z-50 flex flex-col items-center justify-center bg-background/60 backdrop-blur-[1px]`,children:[(0,E.jsx)(g,{className:`w-8 h-8 text-primary animate-spin opacity-60`}),(0,E.jsx)(`p`,{className:`mt-2 text-xs font-medium text-muted-foreground`,children:`Loading trash...`})]}),(0,E.jsxs)(`div`,{className:`p-6 border-b shrink-0`,children:[(0,E.jsxs)(`h2`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,E.jsx)(x,{size:24,className:`text-muted-foreground`}),`Trash Bin`]}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage your deleted files and projects. Items can be restored or permanently deleted.`})]}),(0,E.jsxs)(b,{defaultValue:`projects`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,E.jsx)(`div`,{className:`shrink-0 overflow-x-auto border-b px-6 py-3 custom-scrollbar`,children:(0,E.jsxs)(_,{className:`w-max`,children:[(0,E.jsxs)(v,{value:`projects`,children:[`Projects (`,e.projects.length,`)`]}),(0,E.jsxs)(v,{value:`diagrams`,children:[`ERD (`,e.diagrams.length,`)`]}),(0,E.jsxs)(v,{value:`db-clients`,children:[`DB Client (`,e.dbClients?.length||0,`)`]}),(0,E.jsxs)(v,{value:`notes`,children:[`Notes (`,e.notes.length,`)`]}),(0,E.jsxs)(v,{value:`drawings`,children:[`Drawings (`,e.drawings.length,`)`]}),(0,E.jsxs)(v,{value:`flowcharts`,children:[`Flowcharts (`,e.flowcharts?.length||0,`)`]})]})}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar`,children:(0,E.jsxs)(`div`,{className:`p-6`,children:[(0,E.jsxs)(C,{value:`projects`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(S,{size:18,className:`text-orange-400`}),`Projects`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.projects.length,` Items`]})]}),e.projects.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted projects`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Project Name`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.projects.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(S,{size:14,className:`text-muted-foreground`}),e.name]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at||e.created_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await t(e.id),M()},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>N(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsxs)(C,{value:`diagrams`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(p,{size:18,className:`text-blue-400`}),`Diagrams`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.diagrams.length,` Items`]})]}),e.diagrams.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted diagrams`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Diagram Name`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.diagrams.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(p,{size:14,className:`text-muted-foreground`}),e.name]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await y(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>P(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsx)(C,{value:`db-clients`,className:`mt-0`,children:(0,E.jsx)(D,{clients:e.dbClients||[],restore:j,permanentlyDelete:R})}),(0,E.jsxs)(C,{value:`notes`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(w,{size:18,className:`text-yellow-400`}),`Notes`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.notes.length,` Items`]})]}),e.notes.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted notes`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Note Title`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.notes.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(w,{size:14,className:`text-muted-foreground`}),e.title]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await O(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>F(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsxs)(C,{value:`drawings`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(h,{size:18,className:`text-purple-400`}),`Drawings`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.drawings.length,` Items`]})]}),e.drawings.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted drawings`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Drawing Title`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.drawings.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(h,{size:14,className:`text-muted-foreground`}),e.title]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await k(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>I(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsxs)(C,{value:`flowcharts`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(m,{size:18,className:`text-green-400`}),`Flowcharts`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.flowcharts?.length||0,` Items`]})]}),!e.flowcharts||e.flowcharts.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted flowcharts`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Flowchart Title`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.flowcharts.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(m,{size:14,className:`text-muted-foreground`}),e.title]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await A(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>L(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]})]})})]})]})}export{O as TrashView};
|
|
1
|
+
import"./rolldown-runtime-C0FnF6B9.js";import{n as e,t}from"./jsx-runtime-DSr1VPkp.js";import{_ as n}from"./composite-DpzKouN6.js";import{t as r}from"./refresh-ccw-DFj0g7WT.js";import{t as i}from"./trash-2-eV2xsHmQ.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./table-wBdalafB.js";import{n as d}from"./useAuth-B8-lFzUV.js";import{$ as f,An as p,Bt as m,Nt as h,Xt as g,d as _,f as v,jn as y,l as b,mt as x,pn as S,u as C,vt as w,z as T}from"./index-ClgzsBw5.js";e();var E=t();function D({clients:e,restore:t,permanentlyDelete:d}){return(0,E.jsxs)(`section`,{children:[(0,E.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,E.jsx)(y,{size:18,className:`text-cyan-400`}),` DB Clients`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.length,` Items`]})]}),e.length===0?(0,E.jsx)(`div`,{className:`rounded-lg border border-dashed py-12 text-center text-muted-foreground`,children:`No deleted DB Clients`}):(0,E.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`DB Client Name`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`flex items-center gap-2 font-medium`,children:[(0,E.jsx)(y,{size:14}),e.name]}),(0,E.jsx)(l,{className:`text-xs font-semibold text-muted-foreground`,children:e.project?.name||`-`}),(0,E.jsx)(l,{className:`text-xs text-muted-foreground`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:()=>t(e),children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),`Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>d(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),`Delete`]})]})})]},e.id))})]})})]})}function O({trashData:e,restoreProject:t,restoreDiagram:y,restoreNote:O,restoreDrawing:k,restoreFlowchart:A,restoreDbClient:j,fetchTrash:M,handleProjectPermanentDelete:N,handleDiagramPermanentDelete:P,handleNotePermanentDelete:F,handleDrawingPermanentDelete:I,handleFlowchartPermanentDelete:L,handleDbClientPermanentDelete:R,isLoading:z=!1}){let{user:B,isGuest:V}=d(),H=e=>T(e,B?.id,V);return(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 border rounded-xl bg-background overflow-hidden relative`,children:[z&&e.projects.length===0&&(0,E.jsxs)(`div`,{className:`absolute inset-0 z-50 flex flex-col items-center justify-center bg-background/60 backdrop-blur-[1px]`,children:[(0,E.jsx)(g,{className:`w-8 h-8 text-primary animate-spin opacity-60`}),(0,E.jsx)(`p`,{className:`mt-2 text-xs font-medium text-muted-foreground`,children:`Loading trash...`})]}),(0,E.jsxs)(`div`,{className:`p-6 border-b shrink-0`,children:[(0,E.jsxs)(`h2`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,E.jsx)(x,{size:24,className:`text-muted-foreground`}),`Trash Bin`]}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage your deleted files and projects. Items can be restored or permanently deleted.`})]}),(0,E.jsxs)(b,{defaultValue:`projects`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,E.jsx)(`div`,{className:`shrink-0 overflow-x-auto border-b px-6 py-3 custom-scrollbar`,children:(0,E.jsxs)(_,{className:`w-max`,children:[(0,E.jsxs)(v,{value:`projects`,children:[`Projects (`,e.projects.length,`)`]}),(0,E.jsxs)(v,{value:`diagrams`,children:[`ERD (`,e.diagrams.length,`)`]}),(0,E.jsxs)(v,{value:`db-clients`,children:[`DB Client (`,e.dbClients?.length||0,`)`]}),(0,E.jsxs)(v,{value:`notes`,children:[`Notes (`,e.notes.length,`)`]}),(0,E.jsxs)(v,{value:`drawings`,children:[`Drawings (`,e.drawings.length,`)`]}),(0,E.jsxs)(v,{value:`flowcharts`,children:[`Flowcharts (`,e.flowcharts?.length||0,`)`]})]})}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar`,children:(0,E.jsxs)(`div`,{className:`p-6`,children:[(0,E.jsxs)(C,{value:`projects`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(S,{size:18,className:`text-orange-400`}),`Projects`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.projects.length,` Items`]})]}),e.projects.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted projects`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Project Name`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.projects.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(S,{size:14,className:`text-muted-foreground`}),e.name]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at||e.created_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await t(e.id),M()},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>N(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsxs)(C,{value:`diagrams`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(p,{size:18,className:`text-blue-400`}),`Diagrams`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.diagrams.length,` Items`]})]}),e.diagrams.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted diagrams`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Diagram Name`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.diagrams.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(p,{size:14,className:`text-muted-foreground`}),e.name]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await y(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>P(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsx)(C,{value:`db-clients`,className:`mt-0`,children:(0,E.jsx)(D,{clients:e.dbClients||[],restore:j,permanentlyDelete:R})}),(0,E.jsxs)(C,{value:`notes`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(w,{size:18,className:`text-yellow-400`}),`Notes`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.notes.length,` Items`]})]}),e.notes.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted notes`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Note Title`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.notes.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(w,{size:14,className:`text-muted-foreground`}),e.title]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await O(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>F(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsxs)(C,{value:`drawings`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(h,{size:18,className:`text-purple-400`}),`Drawings`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.drawings.length,` Items`]})]}),e.drawings.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted drawings`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Drawing Title`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.drawings.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(h,{size:14,className:`text-muted-foreground`}),e.title]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await k(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>I(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]}),(0,E.jsxs)(C,{value:`flowcharts`,className:`mt-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,E.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,E.jsx)(m,{size:18,className:`text-green-400`}),`Flowcharts`]}),(0,E.jsxs)(f,{variant:`outline`,children:[e.flowcharts?.length||0,` Items`]})]}),!e.flowcharts||e.flowcharts.length===0?(0,E.jsx)(`div`,{className:`text-center py-12 border rounded-lg border-dashed text-muted-foreground`,children:`No deleted flowcharts`}):(0,E.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,E.jsxs)(u,{children:[(0,E.jsx)(a,{children:(0,E.jsxs)(c,{children:[(0,E.jsx)(o,{children:`Flowchart Title`}),(0,E.jsx)(o,{children:`Project`}),(0,E.jsx)(o,{children:`Deleted At`}),(0,E.jsx)(o,{className:`text-right`,children:`Actions`})]})}),(0,E.jsx)(s,{children:e.flowcharts.map(e=>(0,E.jsxs)(c,{children:[(0,E.jsxs)(l,{className:`font-medium flex items-center gap-2`,children:[(0,E.jsx)(m,{size:14,className:`text-muted-foreground`}),e.title]}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs font-semibold`,children:e.projects?.name||`-`}),(0,E.jsx)(l,{className:`text-muted-foreground text-xs`,children:new Date(e.deleted_at||e.updated_at).toLocaleString()}),(0,E.jsx)(l,{className:`text-right`,children:H(e)?(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsxs)(n,{variant:`outline`,size:`sm`,onClick:async()=>{await A(e)},children:[(0,E.jsx)(r,{size:14,className:`mr-1`}),` Restore`]}),(0,E.jsxs)(n,{variant:`destructive`,size:`sm`,onClick:()=>L(e),children:[(0,E.jsx)(i,{size:14,className:`mr-1`}),` Delete`]})]}):(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Creator only`})})]},e.id))})]})})]})]})})]})]})}export{O as TrashView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r}from"./chunk-BV7QT456-CCzugQp2.js";import{a as i,f as a,i as o,l as s,n as c,o as l,s as u,t as d}from"./dialog-C4O82yNc.js";import{_ as f}from"./composite-DpzKouN6.js";import{n as p}from"./dist-DDYEjsV2.js";import{t as m}from"./arrow-left-sRwyfx9m.js";import{t as h}from"./copy-BasccFFL.js";import{t as g}from"./search-hNBtHxSg.js";import{t as _}from"./user-cog-plxf2Kur.js";import{n as v}from"./api-D87lw-98.js";import{n as y,t as b}from"./card-Dy6p8t6g.js";import{t as x}from"./input-CluuKyQT.js";import{a as S,i as C,n as w,o as T,r as E,t as D}from"./table-wBdalafB.js";import{n as O}from"./useAuth-B8-lFzUV.js";import{t as k}from"./ConfirmModal-td6IXKfM.js";import{$ as A,Gn as j,Mt as M,Xt as N,d as P,f as F,l as I,u as L}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{c as r}from"./chunk-BV7QT456-CCzugQp2.js";import{a as i,f as a,i as o,l as s,n as c,o as l,s as u,t as d}from"./dialog-C4O82yNc.js";import{_ as f}from"./composite-DpzKouN6.js";import{n as p}from"./dist-DDYEjsV2.js";import{t as m}from"./arrow-left-sRwyfx9m.js";import{t as h}from"./copy-BasccFFL.js";import{t as g}from"./search-hNBtHxSg.js";import{t as _}from"./user-cog-plxf2Kur.js";import{n as v}from"./api-D87lw-98.js";import{n as y,t as b}from"./card-Dy6p8t6g.js";import{t as x}from"./input-CluuKyQT.js";import{a as S,i as C,n as w,o as T,r as E,t as D}from"./table-wBdalafB.js";import{n as O}from"./useAuth-B8-lFzUV.js";import{t as k}from"./ConfirmModal-td6IXKfM.js";import{$ as A,Gn as j,Mt as M,Xt as N,d as P,f as F,l as I,u as L}from"./index-ClgzsBw5.js";var R=e(t(),1),z=n(),B=e=>{let t=e?Date.parse(e):NaN;return Number.isNaN(t)?`—`:new Date(t).toLocaleDateString()},V=e=>{let t=Array.isArray(e.teamMemberships)?e.teamMemberships:[];return t.length?t.map(e=>`${e.team?.name||`Unknown Team`} (Team: ${e.team?.status||`unknown`}; membership: ${e.status})`).join(`, `):`No Team`},H={page:1,pageSize:20,total:0,totalPages:1},U=e=>({...e,createdAt:e.createdAt??e.created_at??null,teamMemberships:e.teamMemberships??e.team_memberships??[]});function W(){let e=r(),{user:t}=O(),[n,a]=(0,R.useState)(`all`),[S,C]=(0,R.useState)([]),[w,T]=(0,R.useState)([]),[E,D]=(0,R.useState)(H),[A,j]=(0,R.useState)(``),[M,N]=(0,R.useState)(!0),[B,V]=(0,R.useState)(``),[W,q]=(0,R.useState)(null),[J,Y]=(0,R.useState)(null),[X,Z]=(0,R.useState)(null),Q=(0,R.useCallback)(async(e,t,n)=>{N(!0),V(``);try{if(e===`invitations`){let e=await v(`/api/users/invitations`),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Unable to load invitations.`);T(Array.isArray(t.data)?t.data:[])}else{let r=new URLSearchParams({kind:e,page:String(t),pageSize:`20`});n.trim()&&r.set(`search`,n.trim());let i=await v(`/api/users?${r.toString()}`),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(a.error||`Unable to load users.`);C(Array.isArray(a.data)?a.data.map(U):[]),D(a.pagination||H)}}catch(e){let t=e?.message||`Unable to load user management.`;V(t),p.error(t)}finally{N(!1)}},[]);if((0,R.useEffect)(()=>{let e=window.setTimeout(()=>void Q(n,E.page,A),A?250:0);return()=>window.clearTimeout(e)},[Q,E.page,A,n]),!(t?.isSuperAdmin||t?.is_super_admin))return null;if(B&&!M)return(0,z.jsxs)(`main`,{className:`flex flex-1 flex-col items-start gap-4 p-6`,children:[(0,z.jsxs)(f,{variant:`ghost`,onClick:()=>e(`/`),children:[(0,z.jsx)(m,{}),` Back`]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-xl font-semibold`,children:`User Management unavailable`}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:B})]})]});let $=async e=>{q(e.id);try{let t=await v(`/api/users/${encodeURIComponent(e.id)}/reset-password`,{method:`POST`}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Unable to reset password.`);let r=[n.temporaryPassword,n.temporary_password,n.data?.temporaryPassword,n.data?.temporary_password].find(e=>typeof e==`string`&&e.length>0);if(!r)throw Error(`The temporary password was not returned. Restart the server and reset the password again.`);Y(r),p.success(`Temporary password generated`)}catch(e){p.error(e?.message||`Unable to reset password.`)}finally{q(null)}},ee=async()=>{J&&(await navigator.clipboard.writeText(J),p.success(`Temporary password copied`))};return(0,z.jsxs)(`main`,{className:`-m-4 flex-1 overflow-auto bg-background`,children:[(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 p-6 lg:p-8`,children:[(0,z.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(f,{variant:`ghost`,size:`icon`,onClick:()=>e(`/`),"aria-label":`Back to dashboard`,children:(0,z.jsx)(m,{})}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold`,children:[(0,z.jsx)(_,{className:`size-5`}),` User Management`]}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage Team accounts, memberships, and invitations.`})]})]}),(0,z.jsx)(b,{children:(0,z.jsx)(y,{children:(0,z.jsxs)(I,{value:n,onValueChange:e=>{a(e),D(e=>({...e,page:1}))},children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsxs)(P,{children:[(0,z.jsx)(F,{value:`all`,children:`All users`}),(0,z.jsx)(F,{value:`no-team`,children:`No Team`}),(0,z.jsx)(F,{value:`former`,children:`Former members`}),(0,z.jsx)(F,{value:`invitations`,children:`Invitations`})]}),n!==`invitations`&&(0,z.jsxs)(`div`,{className:`relative w-full sm:ml-auto sm:w-72`,children:[(0,z.jsx)(g,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(x,{value:A,onChange:e=>{j(e.target.value),D(e=>({...e,page:1}))},placeholder:`Search name or email`,"aria-label":`Search users by name or email`,className:`pl-9`})]})]}),[`all`,`no-team`,`former`].map(e=>(0,z.jsx)(L,{value:e,className:`mt-4`,children:(0,z.jsx)(G,{users:S,loading:M,action:W,onReset:e=>Z(e),pagination:E,onPageChange:e=>D(t=>({...t,page:e}))})},e)),(0,z.jsx)(L,{value:`invitations`,className:`mt-4`,children:(0,z.jsx)(K,{invitations:w,loading:M})})]})})})]}),(0,z.jsx)(d,{open:!!J,onOpenChange:e=>!e&&Y(null),children:(0,z.jsxs)(o,{size:`sm`,children:[(0,z.jsxs)(u,{children:[(0,z.jsx)(s,{children:`Temporary password`}),(0,z.jsx)(i,{children:`Copy and share this once through a secure channel. It will not be shown again.`})]}),(0,z.jsx)(c,{children:(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(x,{value:J||``,readOnly:!0}),(0,z.jsx)(f,{type:`button`,variant:`outline`,size:`icon`,onClick:()=>void ee(),"aria-label":`Copy temporary password`,children:(0,z.jsx)(h,{})})]})}),(0,z.jsx)(l,{children:(0,z.jsx)(f,{onClick:()=>Y(null),children:`Done`})})]})}),(0,z.jsx)(k,{isOpen:!!X,title:`Reset member password?`,message:`A new temporary password will be created for ${X?.email||`this member`}. Existing sessions will be signed out.`,confirmText:`Reset password`,cancelText:`Cancel`,variant:`warning`,onCancel:()=>Z(null),onConfirm:()=>{let e=X;Z(null),e&&$(e)}})]})}function G({users:e,loading:t,action:n,onReset:r,pagination:i,onPageChange:o}){let s=i.total===0?0:(i.page-1)*i.pageSize+1,c=Math.min(i.page*i.pageSize,i.total);return(0,z.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,z.jsxs)(D,{children:[(0,z.jsx)(S,{children:(0,z.jsxs)(T,{children:[(0,z.jsx)(C,{children:`User`}),(0,z.jsx)(C,{children:`Team history`}),(0,z.jsx)(C,{children:`Created`}),(0,z.jsx)(C,{className:`w-36 text-right`,children:`Action`})]})}),(0,z.jsx)(w,{children:t?(0,z.jsx)(T,{children:(0,z.jsx)(E,{colSpan:4,className:`h-24 text-center`,children:(0,z.jsx)(N,{className:`mx-auto size-4 animate-spin`})})}):e.length===0?(0,z.jsx)(T,{children:(0,z.jsx)(E,{colSpan:4,className:`h-24 text-center text-muted-foreground`,children:`No users found.`})}):e.map(e=>(0,z.jsxs)(T,{children:[(0,z.jsxs)(E,{children:[(0,z.jsx)(`div`,{className:`font-medium`,children:e.name||`Unnamed member`}),(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.email})]}),(0,z.jsx)(E,{className:`text-muted-foreground`,children:V(e)}),(0,z.jsx)(E,{className:`text-muted-foreground`,children:B(e.createdAt)}),(0,z.jsx)(E,{className:`text-right`,children:(0,z.jsxs)(f,{variant:`outline`,size:`sm`,disabled:n!==null,onClick:()=>r(e),children:[n===e.id?(0,z.jsx)(N,{className:`animate-spin`}):(0,z.jsx)(M,{}),` Reset password`]})})]},e.id))})]}),i.totalPages>1&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t px-3 py-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[s,`–`,c,` of `,i.total]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(f,{variant:`outline`,size:`icon-xs`,"aria-label":`Previous page`,disabled:t||i.page<=1,onClick:()=>o(i.page-1),children:(0,z.jsx)(j,{})}),(0,z.jsxs)(`span`,{className:`min-w-20 text-center`,children:[`Page `,i.page,` of `,i.totalPages]}),(0,z.jsx)(f,{variant:`outline`,size:`icon-xs`,"aria-label":`Next page`,disabled:t||i.page>=i.totalPages,onClick:()=>o(i.page+1),children:(0,z.jsx)(a,{})})]})]})]})}function K({invitations:e,loading:t}){return(0,z.jsx)(`div`,{className:`rounded-lg border`,children:(0,z.jsxs)(D,{children:[(0,z.jsx)(S,{children:(0,z.jsxs)(T,{children:[(0,z.jsx)(C,{children:`Email`}),(0,z.jsx)(C,{children:`Team`}),(0,z.jsx)(C,{children:`Status`}),(0,z.jsx)(C,{children:`Sent`})]})}),(0,z.jsx)(w,{children:t?(0,z.jsx)(T,{children:(0,z.jsx)(E,{colSpan:4,className:`h-24 text-center`,children:(0,z.jsx)(N,{className:`mx-auto size-4 animate-spin`})})}):e.length===0?(0,z.jsx)(T,{children:(0,z.jsx)(E,{colSpan:4,className:`h-24 text-center text-muted-foreground`,children:`No invitations found.`})}):e.map(e=>(0,z.jsxs)(T,{children:[(0,z.jsx)(E,{children:e.email}),(0,z.jsx)(E,{children:e.team.name}),(0,z.jsx)(E,{children:(0,z.jsx)(A,{variant:`secondary`,children:e.acceptedAt?`Accepted`:new Date(e.expiresAt)<new Date?`Expired`:`Pending`})}),(0,z.jsx)(E,{className:`text-muted-foreground`,children:B(e.createdAt)})]},e.id))})]})})}export{W as UserManagementRoute,W as default};
|