PageSourceSearch

https://procontent.renewedvision.com/js/procontent/assets/OrganizationDebugModesModal-Btgqhgg2.js

js renewedvision.com collected 2026-09-24 17:47:51 UTC 8,335 bytes, 1 lines download raw bytes

1import{r,j as e,d as S}from"./app-BeGqF6ux.js";import{M as z,b as d,B as M}from"./Tooltip-DYcxt1UG.js";import"./index-Dkf2GVy1.js";import{d as c}from"./dayjs-BlgjZc9C.js";import"./button.styles-7lPNyjJO.js";import"./iconBase-CN8tsjra.js";import"./useTranslation-kJHeU9i8.js";import"./helpers-CgA5RTdO.js";const q=[{value:.5,label:"30 minutes"},{value:1,label:"1 hour"},{value:2,label:"2 hours"},{value:4,label:"4 hours"},{value:8,label:"8 hours"},{value:24,label:"24 hours"},{value:48,label:"48 hours"},{value:168,label:"1 week"}];function ae({organizationId:o,open:m,onClose:$}){const[f,u]=r.useState(null),[_,D]=r.useState(!0),[l,A]=r.useState([]),[E,O]=r.useState([]),[T,H]=r.useState(new Date),[t,v]=r.useState(1),[x,k]=r.useState(""),[n,h]=r.useState(null),[Y,b]=r.useState(!1);r.useEffect(()=>{m&&j()},[m,o]),r.useEffect(()=>{const s=setInterval(()=>{H(new Date)},1e3);return()=>clearInterval(s)},[]);const j=async()=>{D(!0);try{const s=await fetch(route("admin.organization.debug-modes.index",{organization:o}));if(!s.ok)throw new Error(`Failed to fetch debug modes data: ${s.status} ${s.statusText}`);const a=await s.json();A(a.activations),O(a.debugModes)}catch(s){console.error("Failed to fetch debug modes data:",s)}finally{D(!1)}},I=()=>t==="custom"&&x?new Date(x).toISOString():c().add(t,"hour").toISOString(),P=s=>{h(s),v(1),k(""),b(!0)},F=()=>{if(!n)return;const s=`enable-${n.id}`;u(s),S.post(route("admin.organization.debug-modes.enable",{organization:o}),{debug_mode_id:n.id,expires_at:I()},{onFinish:()=>{u(null),b(!1),h(null),j()},preserveScroll:!0})},L=s=>{const a=`disable-${s.id}`;u(a),S.post(route("admin.organization.debug-modes.disable",{organization:o}),{debug_mode_id:s.id},{onFinish:()=>{u(null),j()},preserveScroll:!0})},B=s=>l.some(a=>a.debug_modes?.some(i=>i.id===s)),R=s=>l.filter(a=>a.debug_modes?.some(i=>i.id===s)).length,U=s=>{const a=c(s).utc(!0),i=c(T),w=a.diff(i);if(w<=0)return"Expired";const g=c.duration(w),C=Math.floor(g.asDays()),y=g.hours(),p=g.minutes(),N=g.seconds();return C>0?`${C}d ${y}h ${p}m`:y>0?`${y}h ${p}m ${N}s`:p>0?`${p}m ${N}s`:`${N}s`},W=()=>c().add(5,"minute").format("YYYY-MM-DDTHH:mm"),X=()=>c().add(1,"year").format("YYYY-MM-DDTHH:mm");return Y&&n?e.jsx(z,{header:{title:`Enable ${n.display_name} for All Devices`,variant:"default"},onClose:()=>{b(!1),h(null)},size:"standard",open:m,footer:{primaryAction:{label:"Enable Debug Mode",onClick:F,loading:f===`enable-${n.id}`,variant:"primary",disabled:t==="custom"&&!x},secondaryAction:{label:"Back",onClick:()=>{b(!1),h(null)},variant:"tertiary"}},children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"mb-4 text-paragraph-1 text-type-black-primary",children:["Enable ",n.display_name," for all ",l.length," device(s) in this organization."]}),e.jsx("p",{className:"text-paragraph-2 text-type-black-secondary",children:"Select when the debug mode should expire:"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-input-bold text-type-black-primary",children:"Duration"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:q.map(s=>e.jsxs("label",{className:`flex cursor-pointer items-center justify-center rounded-lg border-2 p-3 transition-all ${t===s.value?"border-blue-500 bg-blue-50 text-blue-700":"border-gray-200 hover:border-gray-300 hover:bg-gray-50"}`,children:[e.jsx("input",{type:"radio",name:"duration",value:s.value,checked:t===s.value,onChange:()=>v(s.value),className:"sr-only"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[t===s.value?e.jsx(d,{name:"HiCheckCircle",size:"sm",className:"shrink-0"}):e.jsx("span",{"aria-hidden":"true",className:"m-0.5 h-5 w-5 shrink-0 rounded-full border-2 border-gray-400"}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]})]},s.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-input-bold text-type-black-primary",children:"Or select a custom date and time"}),e.jsxs("div",{className:`rounded-lg border-2 p-3 transition-all ${t==="custom"?"border-blue-500 bg-blue-50":"border-gray-200"}`,children:[e.jsxs("label",{className:`flex items-center ${t==="custom"?"text-blue-700":""}`,children:[e.jsx("input",{type:"radio",name:"duration",checked:t==="custom",onChange:()=>v("custom"),className:"sr-only"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[t==="custom"?e.jsx(d,{name:"HiCheckCircle",size:"sm",className:"shrink-0"}):e.jsx("span",{"aria-hidden":"true",className:"m-0.5 h-5 w-5 shrink-0 rounded-full border-2 border-gray-400"}),e.jsx("span",{className:"text-sm font-medium",children:"Custom expiration"})]})]}),t==="custom"&&e.jsx("div",{className:"mt-3",children:e.jsx("input",{type:"datetime-local",value:x,onChange:s=>k(s.target.value),min:W(),max:X(),className:"w-full rounded-lg border border-gray-300 p-2 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"})})]})]})]})}):e.jsx(z,{header:{title:"Organization Debug Modes",variant:"default"},onClose:$,size:"lg",open:m,children:_?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-500 border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(d,{name:"HiOutlineInformationCircle",size:"sm",className:"mt-0.5 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-800",children:"Organization-Wide Debug Modes"}),e.jsxs("p",{className:"mt-1 text-sm text-blue-700",children:["Enabling a debug mode here will apply to all ",l.length," device(s) across all workspaces in this organization."]})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Debug Mode Controls"}),E.map(s=>{const a=B(s.id),i=R(s.id);return e.jsxs("div",{className:"flex flex-col space-y-3 rounded-lg border border-gray-200 p-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("span",{className:"text-lg font-medium text-gray-900",children:s.display_name}),a&&e.jsxs("span",{className:"bg-green-100 text-green-800 inline-flex items-center rounded-full px-2 py-1 text-xs font-medium",children:[e.jsx(d,{name:"HiCheckCircle",size:"xs",className:"mr-1"}),"Active on ",i," device(s)"]})]})}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs(M,{onClick:()=>P(s),variant:"secondary",size:"sm",loading:f===`enable-${s.id}`,children:[e.jsx(d,{name:"HiOutlinePlus",size:"sm",className:"mr-2"}),"Enable for All Devices"]}),a&&e.jsxs(M,{onClick:()=>L(s),variant:"destructive",size:"sm",loading:f===`disable-${s.id}`,children:[e.jsx(d,{name:"HiOutlineXMark",size:"sm",className:"mr-2"}),"Disable for All Devices"]})]})]},s.id)})]}),l.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Device Status (",l.length,")"]}),e.jsx("div",{className:"max-h-96 space-y-3 overflow-y-auto",children:l.map(s=>e.jsx("div",{className:"rounded-lg border border-gray-200 p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900",children:s.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Last synced:"," ",c(s.last_synced_at).format("MM/DD/YY [at] h:mmA")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.debug_modes?.map(a=>e.jsxs("span",{className:"inline-flex items-center rounded-full bg-blue-100 px-2 py-1 text-xs font-medium text-blue-800",children:[a.display_name,a.metadata?.expires_at&&e.jsxs("span",{className:"ml-1 text-blue-600",children:["(",U(a.metadata.expires_at),")"]})]},a.id)),(!s.debug_modes||s.debug_modes.length===0)&&e.jsx("span",{className:"text-xs text-gray-400",children:"No active debug modes"})]})]})},s.id))})]}),l.length===0&&e.jsxs("div",{className:"py-8 text-center text-gray-500",children:[e.jsx(d,{name:"HiOutlineDevicePhoneMobile",size:"lg",className:"mx-auto mb-2"}),e.jsx("p",{children:"No devices found for this organization"})]})]})})}export{ae as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.