1import{j as e}from"./react-DJo-hRcj.js";import{ao as h,k as _,m as b,T as G,g as P}from"./index-B5XNITP8.js";import"./lodash-D9U91hCZ.js";import{B as v}from"./ButtonSubmit-BPJrgxF_.js";import{al as F,I as f,bd as x,c8 as y,b$ as T,bV as k,bc as g}from"./vendors-_9dKRPAn.js";import{H as C}from"./index-DSSmR8GK.js";import{C as E}from"./index-BKy_m-tN.js";import{L as U}from"./Layout-hleQVaK2.js";import{U as w,a as M,b as N}from"./UserGroupList-vFxA5HbQ.js";import{a as V}from"./notificationHelpers-Bj0-Ak9u.js";import{t as B}from"./toastifyPromise-B9uqvGnu.js";import{U as L}from"./UserGroupQueryRepository-CIMHIT8X.js";import{u as D,M as H}from"./index-AhqtHWMA.js";import{aq as m,an as O}from"./mui-core-DIGHSUz9.js";import"./mui-x-WaaF4sFd.js";import"./index-wDYjRIOv.js";import"./useCheckPermissionSidebar-BJ_M-sXv.js";import"./LocalStorageManager-Brbsb2wO.js";import"./index-C6hXkfvS.js";import"./useUrlParams-9vBjnh_J.js";import"./Search-BtClgkYE.js";import"./ModalV2-Bwgoj2D8.js";import"./toastifyV2-JsPZrQKQ.js";import"./org-switch-rules-CALv74Cz.js";import"./useOrgList-CLYvyZdj.js";import"./DashboardQueryRepository-BaKnPLob.js";import"./Search-CSvDv4Dl.js";import"./Building-_OqbRV1u.js";import"./Check-DzZWfpvT.js";import"./languageManager-_RIZidnS.js";import"./SharedComponents-CFIIYYlL.js";import"./LocalStorageManager-Cf9EMmua.js";import"./constants-BhQb0AAi.js";import"./getHttpStatusCode-D6Fy-dO9.js";import"./getTenantId-D-FzaJmc.js";import"./index-DrXyz3GH.js";import"./Folder-3heqG_AK.js";import"./CaretSortRight-CqF8P7qc.js";const l={selectedGroupId:[],selectedReportFolder:[]},R=F(r=>({...l,setSelectedGroupId:t=>r({selectedGroupId:t}),setSelectedReportFolder:t=>r({selectedReportFolder:t}),reset:()=>r(l)}));function Q(){const{t:r}=f(),{selectedGroupId:t,setSelectedGroupId:s,selectedReportFolder:i,reset:p}=R(),a=x(),{id:o,tenantId:n}=y(),I=T(),S=new L({projectId:o,queryClient:I}),{mutateAsync:j}=k(S.updateMultiUserGroupPermissionMutation({onSuccess:()=>{p();const d=g(h,{id:o,tenantId:n});a.push(d)}}));return{selectedGroupId:t,setSelectedGroupId:s,handleSubmit:()=>{_({eventName:"user_group_multiple_report_permission_update",eventType:b["click-button"],tenantId:n,workspaceId:o});const d=t,u=(i?.filter(c=>c.id.startsWith("report-"))||[]).map(c=>({resourceId:`${c.value}`,resourceType:"report",hasPermission:!0,permissionType:"report-view"}));if(!d.length||!u.length){V(r("please_select_group_and_report"));return}B(j({groupIds:d,permissions:u,resourceTypes:["report"]}))}}}function q(){const{selectedReportFolder:r,setSelectedReportFolder:t}=R(),{reportTree:s,isLoading:i,isError:p}=D(),a=o=>{t(o)};return i?e.jsx(w,{}):p?e.jsx(M,{}):!s||s.children?.length===0?e.jsx("div",{children:"No reports found."}):e.jsx(H,{treeViewKey:"report-permission",rootNode:s,onChange:a,initialChecked:r?.map(o=>o.id)||[]})}function Ee(){const{t:r}=f(),{id:t,tenantId:s}=y(),i=x(),{selectedGroupId:p,setSelectedGroupId:a,handleSubmit:o}=Q();return e.jsxs(U,{children:[e.jsx(C,{title:r("add_reports_to_multiple_user_groups"),breadcrumbs:[{id:1,label:r("user_groups"),value:g(h,{tenantId:s,id:t})},{id:2,label:r("add_reports")}],onClickItem:n=>{n.value&&i.push(n.value)}}),e.jsxs(E,{children:[e.jsxs(m,{direction:"row",spacing:2,sx:{height:"calc(100vh - 240px)"},children:[e.jsx(O,{sx:{flex:1},children:e.jsx(N,{selectedItems:p,setSelectedItems:a})}),e.jsxs(m,{flex:1,height:"100%",p:4,sx:{backgroundColor:"#FFF",borderRadius:2,gap:4},children:[e.jsx(G,{variant:"h4SMedium",component:"p",color:P.txt.normal.secondary,children:r("USER_GROUP.REPORT_VIEW_PERMISSON")}),e.jsx(q,{})]})]}),e.jsx(m,{direction:"row",spacing:2,mt:5,children:e.jsx(v,{style:{marginLeft:"auto"},type:"submit",variant:"primary",onClick:o,children:r("Save changes")})})]})]})}export{Ee 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.