"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1324],{38395:(p,i,e)=>{e.d(i,{X:()=>b});var a=e(42844),c=e(89949),m=e.n(c),t=e(27702),o=e(29956),E=e(23852),M=e(66310),P=e(33716),r=e(28580),h=e(73453),l=e(50230),s=e(86004),_=e(50852),O=e(97957),v=e(76897),A=e(18771),g=e(52467),D=e(92367),d=e(79003),I=e(47702),K=e(76658),U=e(22513),y=e(39036),x=(n=>(n.Ascending="alpha-asc",n.Descending="alpha-desc",n))(x||{});const Z=[{label:"Alphabetically [A-Z]",value:"alpha-asc"},{label:"Alphabetically [Z-A]",value:"alpha-desc"}],b=({folder:n})=>{const T=(0,M.wW)(V),L=(0,A.useDispatch)(),W=f=>{const z=(0,K.vB)(C,f);X(z)};(0,t.useEffect)(()=>{L((0,I.y6)({rulesSourceName:U.GC})),L((0,I.UR)({rulesSourceName:U.GC}))},[L]);const B=(0,g.Zo)(U.GC),{nameFilter:R,labelFilter:C,sortOrder:u,setNameFilter:F,setLabelFilter:X,setSortOrder:G}=S(),H=B.find(f=>f.name===n.title)?.groups.flatMap(f=>f.rules)??[],j=N(H,R,C,u??"alpha-asc"),J=H.length===0||j.length===0,{page:Q,numberOfPages:Y,onPageChange:w,pageItems:k}=(0,D.h)(j,1,O.gN);return t.createElement("div",{className:T.container},t.createElement(E.K,{direction:"column",gap:3},t.createElement(P.H,{value:R,onChange:F,placeholder:"Search alert rules by name","data-testid":"name-filter"}),t.createElement(E.K,{direction:"row"},t.createElement(r.Ph,{value:u,onChange:({value:f})=>f&&G(f),options:Z,width:25,"aria-label":"Sort",placeholder:"Sort (Default A-Z)",prefix:t.createElement(h.J,{name:u==="alpha-asc"?"sort-amount-up":"sort-amount-down"})}),t.createElement(P.H,{value:C,onChange:X,placeholder:"Search alerts by labels",className:T.filterLabelsInput,"data-testid":"label-filter"})),t.createElement(E.K,{gap:1},k.map(f=>t.createElement(l.Z,{key:f.name,href:(0,y.V2)("grafana",f,""),className:T.card,"data-testid":"alert-card-row"},t.createElement(l.Z.Heading,null,f.name),t.createElement(l.Z.Tags,null,t.createElement(s.P,{onClick:W,tags:Object.entries(f.labels).map(([z,q])=>`${z}=${q}`)})),t.createElement(l.Z.Meta,null,t.createElement("div",null,t.createElement(h.J,{name:"folder"})," ",n.title))))),J&&t.createElement("div",{className:T.noResults},"No alert rules found"),t.createElement("div",{className:T.pagination},t.createElement(_.t,{currentPage:Q,numberOfPages:Y,onNavigate:w,hideWhenSinglePage:!0}))))};var $=(n=>(n.nameFilter="nameFilter",n.labelFilter="labelFilter",n.sortOrder="sort",n))($||{});function S(){const[n,T]=(0,d.j)(),[L,W]=(0,t.useState)(n.get("nameFilter")??""),[B,R]=(0,t.useState)(n.get("labelFilter")??""),C=n.get("sort"),[u,F]=(0,t.useState)(C==="alpha-asc"?"alpha-asc":C==="alpha-desc"?"alpha-desc":void 0);return(0,o.Z)(()=>T({nameFilter:(0,v.sB)(L),labelFilter:(0,v.sB)(B),sort:(0,v.sB)(u)},!0),400,[L,B,u]),{nameFilter:L,labelFilter:B,sortOrder:u,setNameFilter:W,setLabelFilter:R,setSortOrder:F}}function N(n,T,L,W){const B=(0,K.Zh)(L);let R=n.filter(C=>C.name.toLowerCase().includes(T.toLowerCase())&&(0,K.eD)(C.labels,B));return(0,c.orderBy)(R,C=>C.name.toLowerCase(),[W==="alpha-asc"?"asc":"desc"])}const V=n=>({container:(0,a.css)`
    padding: ${n.spacing(1)};
  `,card:(0,a.css)`
    grid-template-columns: auto 1fr 2fr;
    margin: 0;
  `,pagination:(0,a.css)`
    align-self: center;
  `,filterLabelsInput:(0,a.css)`
    flex: 1;
    width: auto;
    min-width: 240px;
  `,noResults:(0,a.css)`
    padding: ${n.spacing(2)};
    background-color: ${n.colors.background.secondary};
    font-style: italic;
  `})},79003:(p,i,e)=>{e.d(i,{j:()=>t});var a=e(27702),c=e(7662),m=e(26129);function t(){const{search:o}=(0,c.TH)(),E=(0,a.useMemo)(()=>new URLSearchParams(o),[o]),M=(0,a.useCallback)((P,r)=>{m.E1.partial(P,r)},[]);return[E,M]}},48493:(p,i,e)=>{e.r(i),e.d(i,{BrowseFolderAlertingPage:()=>P,default:()=>r});var a=e(27702),c=e(44644),m=e(40127),t=e(18771),o=e(38395),E=e(67572),M=e(72760);function P({match:h}){const{uid:l}=h.params,{data:s}=(0,E.t4)(l),_=(0,t.useSelector)(g=>g.folder),[O]=(0,E.vN)(),v=(0,a.useMemo)(()=>{if(!s)return;const g=(0,m.B1)(s),D=(0,m.W3)(s.uid),d=g.children?.find(I=>I.id===D);return d&&(d.active=!0),g},[s]),A=l?async g=>{if(s){const D=await O({...s,title:g});if("error"in D)throw D.error}}:void 0;return a.createElement(c.T,{navId:"dashboards/browse",pageNav:v,onEditTitle:A,actions:a.createElement(a.Fragment,null,s&&a.createElement(M.A,{folder:s}))},a.createElement(c.T.Contents,null,a.createElement(o.X,{folder:_})))}const r=P},11297:(p,i,e)=>{e.d(i,{p:()=>M});var a=e(27702),c=e(60426),m=e(3613),t=e(21323),o=e(65322),E=e(50837);const M=({onConfirm:P,onDismiss:r,selectedItems:h,...l})=>{const[s,_]=(0,a.useState)(!1),O=async()=>{_(!0);try{await P(),_(!1),r()}catch{_(!1)}};return a.createElement(m.s,{body:a.createElement(a.Fragment,null,a.createElement(t.x,{element:"p"},a.createElement(o.cC,{i18nKey:"browse-dashboards.action.delete-modal-text"},"This action will delete the following content:")),a.createElement(E.X,{selectedItems:h}),a.createElement(c.T,{v:2})),confirmationText:"Delete",confirmText:s?(0,o.t)("browse-dashboards.action.deleting","Deleting..."):(0,o.t)("browse-dashboards.action.delete-button","Delete"),onDismiss:r,onConfirm:O,title:(0,o.t)("browse-dashboards.action.delete-modal-title","Delete"),...l})}},78222:(p,i,e)=>{e.d(i,{_:()=>l});var a=e(27702),c=e(60426),m=e(13741),t=e(63439),o=e(22209),E=e(66670),M=e(21323),P=e(74729),r=e(65322),h=e(50837);const l=({onConfirm:s,onDismiss:_,selectedItems:O,...v})=>{const[A,g]=(0,a.useState)(),[D,d]=(0,a.useState)(!1),I=Object.keys(O.folder).filter(U=>O.folder[U]),K=async()=>{if(A!==void 0){d(!0);try{await s(A),d(!1),_()}catch{d(!1)}}};return a.createElement(m.u,{title:(0,r.t)("browse-dashboards.action.move-modal-title","Move"),onDismiss:_,...v},I.length>0&&a.createElement(t.b,{severity:"info",title:(0,r.t)("browse-dashboards.action.move-modal-alert","Moving this item may change its permissions.")}),a.createElement(M.x,{element:"p"},a.createElement(r.cC,{i18nKey:"browse-dashboards.action.move-modal-text"},"This action will move the following content:")),a.createElement(h.X,{selectedItems:O}),a.createElement(c.T,{v:3}),a.createElement(o.g,{label:(0,r.t)("browse-dashboards.action.move-modal-field-label","Folder name")},a.createElement(P.E,{value:A,excludeUIDs:I,onChange:g})),a.createElement(m.u.ButtonRow,null,a.createElement(E.zx,{onClick:_,variant:"secondary",fill:"outline"},a.createElement(r.cC,{i18nKey:"browse-dashboards.action.cancel-button"},"Cancel")),a.createElement(E.zx,{disabled:A===void 0||D,onClick:K,variant:"primary"},D?(0,r.t)("browse-dashboards.action.moving","Moving..."):(0,r.t)("browse-dashboards.action.move-button","Move"))))}},72760:(p,i,e)=>{e.d(i,{A:()=>D});var a=e(27702),c=e(86312),m=e(26129),t=e(89746),o=e(79655),E=e(80434),M=e(66670),P=e(73453),r=e(14574),h=e(1541),l=e(66574),s=e(65322),_=e(18771),O=e(43620),v=e(67572),A=e(11297),g=e(78222);function D({folder:d}){const[I,K]=(0,a.useState)(!1),[U,y]=(0,a.useState)(!1),[x]=(0,v.OH)(),[Z]=(0,v.yC)(),b=l.Vt.hasPermission(_.AccessControlAction.FoldersPermissionsRead),$=l.Vt.hasPermission(_.AccessControlAction.FoldersPermissionsWrite),S=l.Vt.hasPermission(_.AccessControlAction.FoldersWrite),N=l.Vt.hasPermission(_.AccessControlAction.FoldersDelete),V=async u=>{await x({folder:d,destinationUID:u}),(0,c.ff)("grafana_manage_dashboards_item_moved",{item_counts:{folder:1,dashboard:0},source:"folder_actions"})},n=async()=>{await Z(d),(0,c.ff)("grafana_manage_dashboards_item_deleted",{item_counts:{folder:1,dashboard:0},source:"folder_actions"});const{parents:u}=d,F=u&&u.length?u[u.length-1].url:"/dashboards";m.E1.push(F)},T=()=>{l.h$.publish(new O.Dn({component:g._,props:{selectedItems:{folder:{[d.uid]:!0},dashboard:{},panel:{},$all:!1},onConfirm:V}}))},L=()=>{l.h$.publish(new O.Dn({component:A.p,props:{selectedItems:{folder:{[d.uid]:!0},dashboard:{},panel:{},$all:!1},onConfirm:n}}))},W=(0,s.t)("browse-dashboards.folder-actions-button.manage-permissions","Manage permissions"),B=(0,s.t)("browse-dashboards.folder-actions-button.move","Move"),R=(0,s.t)("browse-dashboards.folder-actions-button.delete","Delete"),C=a.createElement(t.v,null,b&&a.createElement(o.s,{onClick:()=>y(!0),label:W}),S&&a.createElement(o.s,{onClick:T,label:B}),N&&a.createElement(o.s,{destructive:!0,onClick:L,label:R}));return!b&&!S&&!N?null:a.createElement(a.Fragment,null,a.createElement(E.L,{overlay:C,onVisibleChange:K},a.createElement(M.zx,{variant:"secondary"},a.createElement(s.cC,{i18nKey:"browse-dashboards.folder-actions-button.folder-actions"},"Folder actions"),a.createElement(P.J,{name:I?"angle-up":"angle-down"}))),U&&a.createElement(r.d,{title:(0,s.t)("browse-dashboards.action.manage-permissions-button","Manage permissions"),subtitle:d.title,scrollableContent:!0,onClose:()=>y(!1),size:"md"},a.createElement(h.P,{resource:"folders",resourceId:d.uid,canSetPermissions:$})))}},81124:(p,i,e)=>{e.r(i),e.d(i,{default:()=>h});var a=e(27702),c=e(25111),m=e(44644),t=e(86809),o=e(18771),E=e(38395),M=e(35381),P=e(40127);const h=({match:l})=>{const s=(0,o.useDispatch)(),_=(0,o.useSelector)(D=>D.navIndex),O=(0,o.useSelector)(D=>D.folder),v=l.params.uid,A=(0,t.ht)(_,`folder-alerting-${v}`,(0,P._l)(1)),{loading:g}=(0,c.Z)(async()=>s((0,M.Pb)(v)),[M.Pb,v]);return a.createElement(m.T,{navId:"dashboards/browse",pageNav:A.main},a.createElement(m.T.Contents,{isLoading:g},a.createElement(E.X,{folder:O})))}}}]);

//# sourceMappingURL=FolderAlerting.61c9d7c33a4c16b8de8c.js.map