"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1324],{87315:(U,m,e)=>{e.d(m,{X:()=>$});var a=e(41407),d=e(86832),o=e.n(d),t=e(39953),i=e(48993),n=e(27366),s=e(82803),M=e(41245),_=e(9558),g=e(12190),D=e(4236),r=e(3532),E=e(39017),C=e(74602),P=e(78354),u=e(57721),O=e(52106),c=e(73278),h=e(88617),v=e(79493),W=e(14949),p=e(95712),x=e(76716),b=(l=>(l.Ascending="alpha-asc",l.Descending="alpha-desc",l))(b||{});const Z=[{label:"Alphabetically [A-Z]",value:"alpha-asc"},{label:"Alphabetically [Z-A]",value:"alpha-desc"}],$=({folder:l})=>{const I=(0,s.wW)(V),T=(0,u.useDispatch)(),F=A=>{const H=(0,W.vB)(f,A);R(H)};(0,t.useEffect)(()=>{T((0,v.y6)({rulesSourceName:p.GC})),T((0,v.UR)({rulesSourceName:p.GC}))},[T]);const L=(0,O.Zo)(p.GC),{nameFilter:K,labelFilter:f,sortOrder:B,setNameFilter:y,setLabelFilter:R,setSortOrder:X}=S(),j=L.find(A=>A.name===l.title)?.groups.flatMap(A=>A.rules)??[],G=N(j,K,f,B??"alpha-asc"),J=j.length===0||G.length===0,{page:Q,numberOfPages:Y,onPageChange:w,pageItems:k}=(0,c.h)(G,1,C.gN);return t.createElement("div",{className:I.container},t.createElement(n.K,{direction:"column",gap:3},t.createElement(M.H,{value:K,onChange:y,placeholder:"Search alert rules by name","data-testid":"name-filter"}),t.createElement(n.K,{direction:"row"},t.createElement(_.Ph,{value:B,onChange:({value:A})=>A&&X(A),options:Z,width:25,"aria-label":"Sort",placeholder:"Sort (Default A-Z)",prefix:t.createElement(g.J,{name:B==="alpha-asc"?"sort-amount-up":"sort-amount-down"})}),t.createElement(M.H,{value:f,onChange:R,placeholder:"Search alerts by labels",className:I.filterLabelsInput,"data-testid":"label-filter"})),t.createElement(n.K,{gap:1},k.map(A=>t.createElement(D.Z,{key:A.name,href:(0,x.V2)("grafana",A,""),className:I.card,"data-testid":"alert-card-row"},t.createElement(D.Z.Heading,null,A.name),t.createElement(D.Z.Tags,null,t.createElement(r.P,{onClick:F,tags:Object.entries(A.labels).map(([H,q])=>`${H}=${q}`)})),t.createElement(D.Z.Meta,null,t.createElement("div",null,t.createElement(g.J,{name:"folder"})," ",l.title))))),J&&t.createElement("div",{className:I.noResults},"No alert rules found"),t.createElement("div",{className:I.pagination},t.createElement(E.t,{currentPage:Q,numberOfPages:Y,onNavigate:w,hideWhenSinglePage:!0}))))};var z=(l=>(l.nameFilter="nameFilter",l.labelFilter="labelFilter",l.sortOrder="sort",l))(z||{});function S(){const[l,I]=(0,h.j)(),[T,F]=(0,t.useState)(l.get("nameFilter")??""),[L,K]=(0,t.useState)(l.get("labelFilter")??""),f=l.get("sort"),[B,y]=(0,t.useState)(f==="alpha-asc"?"alpha-asc":f==="alpha-desc"?"alpha-desc":void 0);return(0,i.Z)(()=>I({nameFilter:(0,P.sB)(T),labelFilter:(0,P.sB)(L),sort:(0,P.sB)(B)},!0),400,[T,L,B]),{nameFilter:T,labelFilter:L,sortOrder:B,setNameFilter:F,setLabelFilter:K,setSortOrder:y}}function N(l,I,T,F){const L=(0,W.Zh)(T);let K=l.filter(f=>f.name.toLowerCase().includes(I.toLowerCase())&&(0,W.eD)(f.labels,L));return(0,d.orderBy)(K,f=>f.name.toLowerCase(),[F==="alpha-asc"?"asc":"desc"])}const V=l=>({container:(0,a.css)`
    padding: ${l.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: ${l.spacing(2)};
    background-color: ${l.colors.background.secondary};
    font-style: italic;
  `})},88617:(U,m,e)=>{e.d(m,{j:()=>t});var a=e(39953),d=e(53721),o=e(13601);function t(){const{search:i}=(0,d.TH)(),n=(0,a.useMemo)(()=>new URLSearchParams(i),[i]),s=(0,a.useCallback)((M,_)=>{o.E1.partial(M,_)},[]);return[n,s]}},49255:(U,m,e)=>{e.r(m),e.d(m,{BrowseFolderAlertingPage:()=>M,default:()=>_});var a=e(39953),d=e(13253),o=e(82744),t=e(57721),i=e(87315),n=e(46347),s=e(34112);function M({match:g}){const{uid:D}=g.params,{data:r}=(0,n.t4)(D),E=(0,t.useSelector)(O=>O.folder),[C]=(0,n.vN)(),P=(0,a.useMemo)(()=>{if(!r)return;const O=(0,o.B1)(r),c=(0,o.W3)(r.uid),h=O.children?.find(v=>v.id===c);return h&&(h.active=!0),O},[r]),u=D?async O=>{if(r){const c=await C({...r,title:O});if("error"in c)throw c.error}}:void 0;return a.createElement(d.T,{navId:"dashboards/browse",pageNav:P,onEditTitle:u,actions:a.createElement(a.Fragment,null,r&&a.createElement(s.A,{folder:r}))},a.createElement(d.T.Contents,null,a.createElement(i.X,{folder:E})))}const _=M},62719:(U,m,e)=>{e.d(m,{p:()=>g});var a=e(39953),d=e(30623),o=e(32688),t=e(32840),i=e(98632),n=e(33155),s=e(62679),M=e(46347),_=e(83408);const g=({onConfirm:D,onDismiss:r,selectedItems:E,...C})=>{const{data:P}=(0,M.zs)(E),u=!o.config.featureToggles.nestedFolders&&P&&(P.alertRule||P.libraryPanel),[O,c]=(0,a.useState)(!1),h=async()=>{c(!0);try{await D(),c(!1),r()}catch{c(!1)}};return a.createElement(t.s,{body:a.createElement(a.Fragment,null,a.createElement(i.x,{element:"p"},a.createElement(s.cC,{i18nKey:"browse-dashboards.action.delete-modal-text"},"This action will delete the following content:")),a.createElement(_.X,{selectedItems:E}),a.createElement(d.T,{v:2})),description:a.createElement(a.Fragment,null,u?a.createElement(n.b,{severity:"warning",title:(0,s.t)("browse-dashboards.action.delete-modal-invalid-title","Cannot delete folder")},a.createElement(s.cC,{i18nKey:"browse-dashboards.action.delete-modal-invalid-text"},"One or more folders contain library panels or alert rules. Delete these first in order to proceed.")):null),confirmationText:"Delete",confirmText:O?(0,s.t)("browse-dashboards.action.deleting","Deleting..."):(0,s.t)("browse-dashboards.action.delete-button","Delete"),onDismiss:r,onConfirm:h,title:(0,s.t)("browse-dashboards.action.delete-modal-title","Delete"),...C})}},44081:(U,m,e)=>{e.d(m,{_:()=>D});var a=e(39953),d=e(30623),o=e(73075),t=e(33155),i=e(98632),n=e(96227),s=e(4919),M=e(15296),_=e(62679),g=e(83408);const D=({onConfirm:r,onDismiss:E,selectedItems:C,...P})=>{const[u,O]=(0,a.useState)(),[c,h]=(0,a.useState)(!1),v=Object.keys(C.folder).filter(p=>C.folder[p]),W=async()=>{if(u!==void 0){h(!0);try{await r(u),h(!1),E()}catch{h(!1)}}};return a.createElement(o.u,{title:(0,_.t)("browse-dashboards.action.move-modal-title","Move"),onDismiss:E,...P},v.length>0&&a.createElement(t.b,{severity:"info",title:(0,_.t)("browse-dashboards.action.move-modal-alert","Moving this item may change its permissions.")}),a.createElement(i.x,{element:"p"},a.createElement(_.cC,{i18nKey:"browse-dashboards.action.move-modal-text"},"This action will move the following content:")),a.createElement(g.X,{selectedItems:C}),a.createElement(d.T,{v:3}),a.createElement(n.g,{label:(0,_.t)("browse-dashboards.action.move-modal-field-label","Folder name")},a.createElement(M.E,{value:u,excludeUIDs:v,onChange:O})),a.createElement(o.u.ButtonRow,null,a.createElement(s.zx,{onClick:E,variant:"secondary",fill:"outline"},a.createElement(_.cC,{i18nKey:"browse-dashboards.action.cancel-button"},"Cancel")),a.createElement(s.zx,{disabled:u===void 0||c,onClick:W,variant:"primary"},c?(0,_.t)("browse-dashboards.action.moving","Moving..."):(0,_.t)("browse-dashboards.action.move-button","Move"))))}},34112:(U,m,e)=>{e.d(m,{A:()=>h});var a=e(39953),d=e(32688),o=e(72639),t=e(13601),i=e(13767),n=e(85001),s=e(58047),M=e(4919),_=e(12190),g=e(87722),D=e(88206),r=e(21308),E=e(62679),C=e(73431),P=e(46347),u=e(33188),O=e(62719),c=e(44081);function h({folder:v}){const[W,p]=(0,a.useState)(!1),[x,b]=(0,a.useState)(!1),[Z]=(0,P.OH)(),[$]=(0,P.yC)(),{canEditFolders:z,canDeleteFolders:S,canViewPermissions:N,canSetPermissions:V}=(0,u.a)(v),l=d.config.featureToggles.nestedFolders&&z,I=async R=>{await Z({folder:v,destinationUID:R}),(0,o.ff)("grafana_manage_dashboards_item_moved",{item_counts:{folder:1,dashboard:0},source:"folder_actions"})},T=async()=>{await $(v),(0,o.ff)("grafana_manage_dashboards_item_deleted",{item_counts:{folder:1,dashboard:0},source:"folder_actions"});const{parents:R}=v,X=R&&R.length?R[R.length-1].url:"/dashboards";t.E1.push(X)},F=()=>{r.h$.publish(new C.Dn({component:c._,props:{selectedItems:{folder:{[v.uid]:!0},dashboard:{},panel:{},$all:!1},onConfirm:I}}))},L=()=>{r.h$.publish(new C.Dn({component:O.p,props:{selectedItems:{folder:{[v.uid]:!0},dashboard:{},panel:{},$all:!1},onConfirm:T}}))},K=(0,E.t)("browse-dashboards.folder-actions-button.manage-permissions","Manage permissions"),f=(0,E.t)("browse-dashboards.folder-actions-button.move","Move"),B=(0,E.t)("browse-dashboards.folder-actions-button.delete","Delete"),y=a.createElement(i.v,null,N&&a.createElement(n.s,{onClick:()=>b(!0),label:K}),l&&a.createElement(n.s,{onClick:F,label:f}),S&&a.createElement(n.s,{destructive:!0,onClick:L,label:B}));return!N&&!l&&!S?null:a.createElement(a.Fragment,null,a.createElement(s.L,{overlay:y,onVisibleChange:p},a.createElement(M.zx,{variant:"secondary"},a.createElement(E.cC,{i18nKey:"browse-dashboards.folder-actions-button.folder-actions"},"Folder actions"),a.createElement(_.J,{name:W?"angle-up":"angle-down"}))),x&&a.createElement(g.d,{title:(0,E.t)("browse-dashboards.action.manage-permissions-button","Manage permissions"),subtitle:v.title,onClose:()=>b(!1),size:"md"},a.createElement(D.P,{resource:"folders",resourceId:v.uid,canSetPermissions:V})))}},33188:(U,m,e)=>{e.d(m,{a:()=>i});var a=e(32688),d=e(21308),o=e(57721);function t(n,s){return s?d.Vt.hasPermissionInMetadata(n,s):d.Vt.hasPermission(n)}function i(n){const s=t(o.AccessControlAction.DashboardsCreate,n),M=!!((!n||a.config.featureToggles.nestedFolders)&&t(o.AccessControlAction.FoldersCreate)),_=t(o.AccessControlAction.FoldersDelete,n),g=t(o.AccessControlAction.DashboardsWrite,n),D=t(o.AccessControlAction.FoldersWrite,n),r=t(o.AccessControlAction.FoldersPermissionsWrite,n),E=t(o.AccessControlAction.FoldersPermissionsRead,n);return{canCreateDashboards:s,canCreateFolders:M,canDeleteFolders:_,canEditDashboards:g,canEditFolders:D,canSetPermissions:r,canViewPermissions:E}}},9473:(U,m,e)=>{e.r(m),e.d(m,{default:()=>g});var a=e(39953),d=e(20653),o=e(13253),t=e(45015),i=e(57721),n=e(87315),s=e(83600),M=e(82744);const g=({match:D})=>{const r=(0,i.useDispatch)(),E=(0,i.useSelector)(c=>c.navIndex),C=(0,i.useSelector)(c=>c.folder),P=D.params.uid,u=(0,t.ht)(E,`folder-alerting-${P}`,(0,M._l)(1)),{loading:O}=(0,d.Z)(async()=>r((0,s.Pb)(P)),[s.Pb,P]);return a.createElement(o.T,{navId:"dashboards/browse",pageNav:u.main},a.createElement(o.T.Contents,{isLoading:O},a.createElement(n.X,{folder:C})))}}}]);

//# sourceMappingURL=FolderAlerting.7e43b6d4ee453f528691.js.map