PageSourceSearch

https://penbrief.com/build/assets/Edit-BlbznHzY.js

js penbrief.com collected 2026-10-08 05:34:06 UTC 7,588 bytes, 1 lines download raw bytes

1import{j as e}from"./app-Bn8axf2m.js";import{u as D,r as C,H as B,b as F,L as E}from"./vendor-D8BamyIx.js";import{A as R,S as $}from"./AppLayout-DDnh82Xe.js";import{I as m}from"./InputError-9fJul_yf.js";import{A as M,a as Y,b as G,c as O,d as q,e as J,f as K,g as Q,h as U}from"./alert-dialog-BKfR5d2V.js";import{B as V}from"./badge-DSA_tntd.js";import{B as c}from"./button-BJHJ0j8Y.js";import{C as p,b as h,c as x,d as S,a as u}from"./card-D0Qy6Ld2.js";import{C as W}from"./checkbox-BwmQmhgX.js";import{I as b}from"./input-Jv8uXHpu.js";import{L as j}from"./label-Cg1Qz0vJ.js";import{T as X}from"./textarea-BtuvhiLj.js";import{c as Z}from"./utils-DCADjnpI.js";import{L as A}from"./lock-8C4Xc0CT.js";import{T as ee}from"./trash-2-DOnMnHQN.js";import{A as se}from"./arrow-left-ZcmZgAi1.js";/* empty css            */import"./AppLogo-DcmacEfU.js";import"./createLucideIcon-CsuOtgaI.js";import"./UserAvatar-xayue2JR.js";import"./index-BYAuPZuj.js";import"./index-CPzEHnIt.js";import"./index-xw87Tvjh.js";import"./dropdown-menu-CW2iYoX1.js";import"./index-DFaUj89F.js";import"./index-DFcVNo6o.js";import"./file-text-DaylnC7C.js";import"./globe-CJdHktb2.js";import"./gauge-CJYVPv0v.js";import"./sparkles-B8Vum2j7.js";import"./shield-check-DX9si8b9.js";import"./FlashMessages-VEWLDp2I.js";import"./info-rA2aT-3L.js";import"./triangle-alert-P9Ytexve.js";import"./circle-check-PhDoMN55.js";import"./x-CrTk-_Ms.js";import"./index-BlkunbP1.js";import"./check-s0EwGkyq.js";function $e({role:{data:t},assigned:k,permissions:g,grantable:y,can:o,maxLevel:w}){const i=D({name:t.name,description:t.description??"",level:String(t.level)}),r=D({permissions:k}),f=C.useMemo(()=>new Set(y),[y]),L=C.useMemo(()=>{const s=new Map;for(const a of g.data){const l=s.get(a.group)??{label:a.group_label,items:[]};l.items.push(a),s.set(a.group,l)}return[...s.entries()]},[g.data]);function T(s){s.preventDefault(),i.patch(`/admin/roles/${t.id}`,{preserveScroll:!0})}function _(s){s.preventDefault(),r.put(`/admin/roles/${t.id}/permissions`,{preserveScroll:!0})}function I(s,a){r.setData("permissions",a?[...r.data.permissions,s]:r.data.permissions.filter(l=>l!==s))}function H(s,a){const l=s.filter(d=>f.has(d.slug)).map(d=>d.id);r.setData("permissions",a?[...new Set([...r.data.permissions,...l])]:r.data.permissions.filter(d=>!l.includes(d)))}return e.jsxs(R,{title:t.name,description:t.is_system?"System role — read-only":t.slug,actions:e.jsx(c,{asChild:!0,variant:"outline",children:e.jsxs(E,{href:"/admin/roles",children:[e.jsx(se,{className:"size-4"}),"Back"]})}),children:[e.jsx(B,{title:`Role — ${t.name}`}),t.is_system&&e.jsxs("div",{className:"bg-muted/50 flex items-start gap-2 rounded-lg border p-4 text-sm",children:[e.jsx(A,{className:"mt-0.5 size-4 shrink-0"}),e.jsxs("p",{children:["This is a system role. It is defined by ",e.jsx("code",{children:"RoleSeeder"})," ","and is read-only here — editing it in the database would drift from what ships, and re-seeding would silently revert it. Create a custom role instead."]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(p,{children:[e.jsxs(h,{children:[e.jsx(x,{children:"Permissions"}),e.jsxs(S,{children:[r.data.permissions.length," of"," ",g.data.length," granted.",!o.managePermissions&&" You do not have permission to change these."]})]}),e.jsx(u,{children:e.jsxs("form",{onSubmit:_,className:"space-y-6",children:[L.map(([s,a])=>{const l=a.items.filter(n=>f.has(n.slug)),d=l.length>0&&l.every(n=>r.data.permissions.includes(n.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:a.label}),o.managePermissions&&l.length>0&&e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground text-xs",onClick:()=>H(a.items,!d),children:d?"Clear all":"Select all"})]}),e.jsx("div",{className:"grid gap-1 sm:grid-cols-2",children:a.items.map(n=>{const v=f.has(n.slug),P=r.data.permissions.includes(n.id),N=!o.managePermissions||!v;return e.jsxs("label",{className:Z("flex items-start gap-2 rounded-md p-2 text-sm",N?"opacity-60":"hover:bg-accent/50 cursor-pointer"),title:v?n.description??void 0:"You do not hold this permission, so you cannot grant it.",children:[e.jsx(W,{className:"mt-0.5",checked:P,disabled:N,onCheckedChange:z=>I(n.id,z===!0)}),e.jsxs("span",{children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[n.name,!v&&e.jsx(A,{className:"size-3 shrink-0"})]}),e.jsx("span",{className:"text-muted-foreground block font-mono text-[10px]",children:n.slug})]})]},n.id)})})]},s)}),e.jsx(m,{message:r.errors.permissions}),o.managePermissions&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(c,{type:"submit",disabled:r.processing,children:"Save permissions"}),r.recentlySuccessful&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"Saved."})]})]})})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(p,{children:[e.jsx(h,{children:e.jsx(x,{children:"Details"})}),e.jsx(u,{children:e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"name",children:"Name"}),e.jsx(b,{id:"name",value:i.data.name,disabled:!o.update,onChange:s=>i.setData("name",s.target.value)}),e.jsx(m,{message:i.errors.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Slug"}),e.jsx(b,{value:t.slug,disabled:!0,readOnly:!0}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Immutable — route middleware references it by name."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(X,{id:"description",rows:2,value:i.data.description,disabled:!o.update,onChange:s=>i.setData("description",s.target.value)}),e.jsx(m,{message:i.errors.description})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"level",children:"Level"}),e.jsx(b,{id:"level",type:"number",min:1,max:w,value:i.data.level,disabled:!o.update,onChange:s=>i.setData("level",s.target.value)}),e.jsx(m,{message:i.errors.level})]}),o.update&&e.jsx(c,{type:"submit",disabled:i.processing,children:"Save details"})]})})]}),e.jsxs(p,{children:[e.jsx(h,{children:e.jsx(x,{children:"Holders"})}),e.jsx(u,{className:"text-sm",children:e.jsxs(V,{variant:"secondary",children:[t.users_count??0," account",t.users_count===1?"":"s"]})})]}),o.delete&&e.jsxs(p,{className:"border-destructive/40",children:[e.jsxs(h,{children:[e.jsx(x,{className:"text-destructive",children:"Delete role"}),e.jsx(S,{children:"Holders are not deleted — they are left with no role, and therefore no permissions."})]}),e.jsx(u,{children:e.jsxs(M,{children:[e.jsx(Y,{asChild:!0,children:e.jsxs(c,{variant:"destructive",children:[e.jsx(ee,{className:"size-4"}),"Delete role"]})}),e.jsxs(G,{children:[e.jsxs(O,{children:[e.jsxs(q,{children:["Delete “",t.name,"”?"]}
1),e.jsxs(J,{children:[t.users_count??0," account(s) will be left with no role and no permissions until someone reassigns them."]})]}),e.jsxs(K,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(U,{onClick:()=>F.delete(`/admin/roles/${t.id}`),children:"Delete"})]})]})]})})]}),e.jsxs("p",{className:"text-muted-foreground flex items-start gap-2 text-xs",children:[e.jsx($,{className:"mt-0.5 size-3.5 shrink-0"}),"You can only grant permissions you hold yourself. Locked entries are enforced on the server too — the checkbox state is a courtesy, not the control."]})]})]})]})}export{$e 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.