⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.72
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
grafana
/
public
/
build
/
View File Name :
AlertingUpgrade.c757b99e306db50cdb16.js
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7391],{57957:(X,F,s)=>{s.r(F),s.d(F,{UpgradePage:()=>ne,UpgradeTabs:()=>le,default:()=>Oe,getStyles:()=>z});var g=s(32196),I=s(53076),D=s(1081),b=s(2543),N=s(55127),T=s.n(N),e=s(96540),Z=s(24180),H=s(78685),u=s(46819),Q=s(12131),B=s(42418),y=s(40845),R=s(72109),k=s(63021),P=s(40675),V=s(40980),M=s(55852),q=s(96374),W=s(94753),O=s(56034),A=s(14578),w=s(39938),K=s(50720),_=s(62930),me=s(67647),ue=s(64149),pe=s(66864),fe=s(39558),re=s(36830),he=s(83277),Ee=s(82076),G=s(17172),p=s(3169),f=s(16001),ye=s(49962);function j(t){return typeof t=="object"&&t!=null&&"error"in t}const C=ye.H.injectEndpoints({endpoints:t=>({upgradeChannel:t.mutation({query:({channelId:n,skipExisting:l})=>({url:`/api/v1/upgrade/channels/${n}${l?"?skipExisting=true":""}`,method:"POST",showSuccessAlert:!1,showErrorAlert:!1}),invalidatesTags:["OrgMigrationState"],async onQueryStarted({channelId:n},{dispatch:l,queryFulfilled:r}){try{l(C.util.updateQueryData("getOrgUpgradeSummary",void 0,o=>{const c=(o.migratedChannels??[]).findIndex(d=>d.legacyChannel?.id===n);c!==-1&&(o.migratedChannels[c].isUpgrading=!0)}));const{data:a}=await r;a.hasErrors?l((0,f.dx)((0,p.q8)(`Failed to upgrade notification channel '${n}'`))):a.removed?l((0,f.dx)((0,p.tZ)(`Notification channel '${n}' not found, removed from list of upgrades`))):l((0,f.dx)((0,p.tZ)(`Upgraded notification channel '${n}'`)))}catch(a){j(a)&&(0,G.NF)(a.error)?l((0,f.dx)((0,p.gi)("Request failed",a.error.data.message))):l((0,f.dx)((0,p.gi)("Request failed")))}}}),upgradeAllChannels:t.mutation({query:({skipExisting:n})=>({url:`/api/v1/upgrade/channels${n?"?skipExisting=true":""}`,method:"POST",showSuccessAlert:!1,showErrorAlert:!1}),invalidatesTags:["OrgMigrationState"],async onQueryStarted({skipExisting:n},{dispatch:l,queryFulfilled:r}){try{const{data:a}=await r;a.hasErrors?l((0,f.dx)((0,p.q8)(`Issues while upgrading ${a.newChannels} ${n?"new ":""}notification channels`))):l((0,f.dx)((0,p.tZ)(`Upgraded ${a.newChannels} ${n?"new ":""}notification channels`)))}catch(a){j(a)&&(0,G.NF)(a.error)?l((0,f.dx)((0,p.gi)("Request failed",a.error.data.message))):l((0,f.dx)((0,p.gi)("Request failed")))}}}),upgradeAlert:t.mutation({query:({dashboardId:n,panelId:l,skipExisting:r})=>({url:`/api/v1/upgrade/dashboards/${n}/panels/${l}${r?"?skipExisting=true":""}`,method:"POST",showSuccessAlert:!1,showErrorAlert:!1}),invalidatesTags:["OrgMigrationState"],async onQueryStarted({dashboardId:n,panelId:l},{dispatch:r,queryFulfilled:a}){try{r(C.util.updateQueryData("getOrgUpgradeSummary",void 0,c=>{const d=(c.migratedDashboards??[]).findIndex(m=>m.dashboardId===n);if(d!==-1){const m=(c.migratedDashboards[d]?.migratedAlerts??[]).findIndex(v=>v.legacyAlert?.panelId===l);m!==-1&&(c.migratedDashboards[d].migratedAlerts[m].isUpgrading=!0)}}));const{data:o}=await a;o.hasErrors?r((0,f.dx)((0,p.q8)(`Failed to upgrade alert from dashboard '${n}', panel '${l}'`))):o.removed?r((0,f.dx)((0,p.tZ)(`Alert from dashboard '${n}', panel '${l}' not found, removed from list of upgrades`))):r((0,f.dx)((0,p.tZ)(`Upgraded alert from dashboard '${n}', panel '${l}'`)))}catch(o){j(o)&&(0,G.NF)(o.error)?r((0,f.dx)((0,p.gi)("Request failed",o.error.data.message))):r((0,f.dx)((0,p.gi)("Request failed")))}}}),upgradeDashboard:t.mutation({query:({dashboardId:n,skipExisting:l})=>({url:`/api/v1/upgrade/dashboards/${n}${l?"?skipExisting=true":""}`,method:"POST",showSuccessAlert:!1,showErrorAlert:!1}),invalidatesTags:["OrgMigrationState"],async onQueryStarted({dashboardId:n,skipExisting:l},{dispatch:r,queryFulfilled:a}){try{r(C.util.updateQueryData("getOrgUpgradeSummary",void 0,c=>{const d=(c.migratedDashboards??[]).findIndex(m=>m.dashboardId===n);d!==-1&&(c.migratedDashboards[d].isUpgrading=!0)}));const{data:o}=await a;o.hasErrors?r((0,f.dx)((0,p.q8)(`Issues while upgrading ${o.newAlerts} ${l?"new ":""}alerts from dashboard '${n}'`))):o.removed?r((0,f.dx)((0,p.tZ)(`Dashboard '${n}' not found, removed from list of upgrades`))):r((0,f.dx)((0,p.tZ)(`Upgraded ${o.newAlerts} ${l?"new ":""}alerts from dashboard '${n}'`)))}catch(o){j(o)&&(0,G.NF)(o.error)?r((0,f.dx)((0,p.gi)("Request failed",o.error.data.message))):r((0,f.dx)((0,p.gi)("Request failed")))}}}),upgradeAllDashboards:t.mutation({query:({skipExisting:n})=>({url:`/api/v1/upgrade/dashboards${n?"?skipExisting=true":""}`,method:"POST",showSuccessAlert:!1,showErrorAlert:!1}),invalidatesTags:["OrgMigrationState"],async onQueryStarted({skipExisting:n},{dispatch:l,queryFulfilled:r}){try{const{data:a}=await r;a.hasErrors?l((0,f.dx)((0,p.q8)(`Issues while upgrading ${a.newAlerts} ${n?"new ":""}alerts in ${a.newDashboards} dashboards`))):l((0,f.dx)((0,p.tZ)(`Upgraded ${a.newAlerts} ${n?"new ":""}alerts in ${a.newDashboards} dashboards`)))}catch(a){j(a)&&(0,G.NF)(a.error)?l((0,f.dx)((0,p.gi)("Request failed",a.error.data.message))):l((0,f.dx)((0,p.gi)("Request failed")))}}}),upgradeOrg:t.mutation({query:({skipExisting:n})=>({url:`/api/v1/upgrade/org${n?"?skipExisting=true":""}`,method:"POST",showSuccessAlert:!1,showErrorAlert:!1}),invalidatesTags:["OrgMigrationState"],async onQueryStarted({skipExisting:n},{dispatch:l,getCacheEntry:r,queryFulfilled:a}){try{const{data:o}=await a;o.hasErrors?l((0,f.dx)((0,p.q8)(`Issues while upgrading ${o.newAlerts} ${n?"new ":""}alerts in ${o.newDashboards} dashboards and ${o.newChannels} ${n?"new ":""}notification channels`))):l((0,f.dx)((0,p.tZ)(`Upgraded ${o.newAlerts} ${n?"new ":""}alerts in ${o.newDashboards} dashboards and ${o.newChannels} ${n?"new ":""}notification channels`)))}catch(o){j(o)&&(0,G.NF)(o.error)?l((0,f.dx)((0,p.gi)("Request failed",o.error.data.message))):l((0,f.dx)((0,p.gi)("Request failed")))}}}),cancelOrgUpgrade:t.mutation({query:()=>({url:"/api/v1/upgrade/org",method:"DELETE"}),invalidatesTags:["OrgMigrationState"],async onQueryStarted(n,{dispatch:l}){try{l(C.util.updateQueryData("getOrgUpgradeSummary",n,r=>{Object.assign(r,{orgId:0,migratedDashboards:[],migratedChannels:[],errors:[]})}))}catch{}}}),getOrgUpgradeSummary:t.query({query:()=>({url:"/api/v1/upgrade/org"}),providesTags:["OrgMigrationState"],transformResponse:n=>(n.migratedDashboards=n.migratedDashboards??[],n.migratedChannels=n.migratedChannels??[],n.errors=n.errors??[],n.migratedDashboards.forEach(l=>{l.migratedAlerts=l.migratedAlerts??[],l.error=l.error??"",l.warning=l.warning??"",l.migratedAlerts.sort((r,a)=>{const o=(a.error??"").localeCompare(r.error??"");return o!==0?o:(r.legacyAlert?.name??"").localeCompare(a.legacyAlert?.name??"")})}),n.migratedDashboards.sort((l,r)=>{const a=(r.error??"").localeCompare(l.error??"");if(a!==0)return a;const o=r.migratedAlerts.filter(m=>m.error).length-l.migratedAlerts.filter(m=>m.error).length;if(o!==0)return o;const c=(r.warning??"").localeCompare(l.warning??"");if(c!==0)return c;const d=l.folderName.localeCompare(r.folderName);return d!==0?d:l.dashboardName.localeCompare(r.dashboardName)}),n.migratedChannels.sort((l,r)=>{const a=(r.error?1:0)-(l.error?1:0);return a!==0?a:(l.legacyChannel?.name??"").localeCompare(r.legacyChannel?.name??"")}),n)})})});var te=s(75591),ae=s(10562),Ce=s(26928),L=s(72275),Y=s(56361),ee=s(3704);const ne=()=>{const[,{isLoading:t}]=C.useUpgradeOrgMutation({fixedCacheKey:"upgrade-org-loading"}),[,{isLoading:n}]=C.useCancelOrgUpgradeMutation({fixedCacheKey:"cancel-org-upgrade-loading"}),{currentData:l,isError:r,error:a,isLoading:o}=C.useGetOrgUpgradeSummaryQuery(void 0,{pollingInterval:1e4,skip:n||t}),c=(l?.migratedDashboards??[]).reduce((x,E)=>x+(E?.migratedAlerts?.length??0),0),d=l?.migratedChannels?.length??0,m=l?.errors??[],v=c>0||d>0||m.length>0,U=(0,e.useMemo)(()=>!r&&v?e.createElement(be,null):null,[r,v]),$=r,i=o,h=!o&&!r&&v;return e.createElement(re.Y,{navId:"alerting-upgrade",actions:U},e.createElement(re.Y.Contents,null,$&&e.createElement(B.F,{severity:"error",title:"Error loading Grafana Alerting upgrade information"},a instanceof Error?a.message:"Unknown error."),i&&e.createElement(de,{text:"Loading..."}),h&&e.createElement(e.Fragment,null,e.createElement(Be,{errors:m}),e.createElement(le,{alertCount:c,contactCount:d}))))},le=({alertCount:t,contactCount:n})=>{const l=(0,y.of)(z),[r,a]=(0,he.s)(),{tab:o}=xe(r),[c,d]=(0,e.useState)(o);return(0,e.useEffect)(()=>{d(o)},[o]),e.createElement(e.Fragment,null,e.createElement(B.F,{severity:"info",title:"Grafana Alerting upgrade guide"},e.createElement("p",null,"Preview of how your existing alert rules and notification channels wll be upgraded to the new Grafana Alerting.",e.createElement("br",null),"Once you are happy with the results, you can permanently upgrade by modifying the Grafana configuration."),e.createElement("p",null,"For more information, please refer to the ",e.createElement(R.Y,{external:!0,href:"https://grafana.com/docs/grafana/latest/alerting/set-up/migrating-alerts/"},"Grafana Alerting Migration Guide"))),e.createElement(k.U,null,e.createElement(P.o,{label:"Upgraded alert rules",active:c==="alerts",counter:t,icon:"bell",onChangeTab:()=>{d("alerts"),a({tab:"alerts"})}}),e.createElement(P.o,{label:"Upgraded notification channels",active:c==="contacts",counter:n,icon:"at",onChangeTab:()=>{d("contacts"),a({tab:"contacts"})}})),e.createElement(V.J,{className:l.tabContent},e.createElement(e.Fragment,null,c==="alerts"&&e.createElement(oe,null),c==="contacts"&&e.createElement(se,null))))},be=()=>{const t=(0,y.of)(z),[n]=C.useCancelOrgUpgradeMutation({fixedCacheKey:"cancel-org-upgrade-loading"}),[l,r]=(0,e.useState)(!1),a=async()=>{n(),r(!1)};return e.createElement(e.Fragment,null,e.createElement(M.$n,{size:"md",variant:"destructive",onClick:()=>r(!0),icon:"trash-alt",className:""},"Reset upgrade"),l&&e.createElement(q.u,{isOpen:!0,title:"Reset upgrade",body:e.createElement(u.B,{direction:"column",gap:.5},e.createElement(W.E,{color:"primary"},"All new Grafana Alerting resources will be deleted."),e.createElement(W.E,{color:"secondary",variant:"bodySmall"},"This includes: alert rules, contact points, notification policies, silences, mute timings, and any manual changes you have made."),e.createElement("span",{className:t.separator}),e.createElement(W.E,{color:"primary"},"No legacy alerts or notification channels will be affected.")),confirmText:"Reset upgrade",onConfirm:a,dismissText:"Keep reviewing",onDismiss:()=>r(!1)}))};var ve=(t=>(t.Alerts="alerts",t.Contacts="contacts",t))(ve||{});function xe(t){let n="alerts";return t.tab==="alerts"&&(n="alerts"),t.tab==="contacts"&&(n="contacts"),{tab:n}}const oe=()=>{const t=Me(),n="alertFilter",[l,r]=ie(n),[a,{isLoading:o}]=C.useUpgradeAllDashboardsMutation({fixedCacheKey:"upgrade-alerts-loading"}),[c,{isLoading:d}]=C.useUpgradeAllChannelsMutation({fixedCacheKey:"upgrade-channels-loading"}),m=d||o,v=(0,e.useMemo)(()=>{const E=[];return(0,D.Mz)(S=>S?.migratedDashboards??[],S=>S??E)},[]),{items:U}=C.useGetOrgUpgradeSummaryQuery(void 0,{selectFromResult:({data:E})=>({items:v(E)})}),$=(0,e.useCallback)(E=>`${E.folderName} ${E.dashboardName} ${E.newFolderName} ${E.migratedAlerts.map(S=>S.legacyAlert?.name??"").join(" ")}`,[]),i=(0,e.useCallback)(({data:E})=>e.createElement(De,{dashboardUid:E.dashboardUid??"",dashboardId:E.dashboardId,showGuidelines:!0}),[]),h=(0,e.useMemo)(()=>{const E=async()=>{await a({skipExisting:!0})};return e.createElement(O.m,{theme:"info-alt",content:m?"Upgrade in progress...":"Upgrade all newly created legacy alerts since the previous run.",placement:"top"},e.createElement(M.$n,{size:"md",variant:"secondary",onClick:E,icon:"plus-circle",disabled:m},"Upgrade New Alerts"))},[a,m]),x=(0,e.useMemo)(()=>{const E=async()=>{await a({skipExisting:!1})};return e.createElement(O.m,{theme:"info-alt",content:m?"Upgrade in progress...":"Upgrade all legacy alerts from scratch.",placement:"top"},e.createElement(M.$n,{size:"md",variant:"secondary",onClick:E,icon:"sync",disabled:m},"Upgrade All Alerts"))},[a,m]);return e.createElement(we,{rows:U,queryParam:l,updateQueryParam:r,searchSpaceMap:$,searchPlaceholder:(0,Ee.wT)(!1),syncNewButton:h,syncAllButton:x,isUpgrading:m,emptyMessage:"No alert upgrades found.",columns:t,isExpandable:!0,renderExpandedContent:i})};oe.displayName="AlertTabContentWrapper";const se=()=>{const t=Ie(),n="contactFilter",[l,r]=ie(n),[a,{isLoading:o}]=C.useUpgradeAllChannelsMutation({fixedCacheKey:"upgrade-channels-loading"}),[,{isLoading:c}]=C.useUpgradeAllDashboardsMutation({fixedCacheKey:"upgrade-alerts-loading"}),d=o||c,m=(0,e.useMemo)(()=>{const h=[];return(0,D.Mz)(x=>x?.migratedChannels??[],x=>x??h)},[]),{items:v}=C.useGetOrgUpgradeSummaryQuery(void 0,{selectFromResult:({data:h})=>({items:m(h)})}),U=(0,e.useCallback)(h=>`${h.legacyChannel?.name} ${h.contactPoint?.name} ${h.legacyChannel?.type}`,[]),$=(0,e.useMemo)(()=>{const h=async()=>{await a({skipExisting:!0})};return e.createElement(O.m,{theme:"info-alt",content:d?"Upgrade in progress...":"Upgrade all newly created legacy notification channels since the previous run.",placement:"top"},e.createElement(M.$n,{size:"md",variant:"secondary",onClick:h,icon:"plus-circle",disabled:d},"Upgrade New Channels"))},[a,d]),i=(0,e.useMemo)(()=>{const h=async()=>{await a({skipExisting:!1})};return e.createElement(O.m,{theme:"info-alt",content:d?"Upgrade in progress...":"Upgrade all legacy notification channels from scratch.",placement:"top"},e.createElement(M.$n,{size:"md",variant:"secondary",onClick:h,icon:"sync",disabled:d},"Upgrade All Channels"))},[a,d]);return e.createElement(Ae,{rows:v,queryParam:l,updateQueryParam:r,searchSpaceMap:U,searchPlaceholder:"Search for channel and contact point names",syncNewButton:$,syncAllButton:i,isUpgrading:d,emptyMessage:"No channel upgrades found.",columns:t})};se.displayName="ChannelTabContentWrapper";function ie(t){const{search:n}=(0,Z.zy)(),l=(0,e.useMemo)(()=>new URLSearchParams(n).get(t)||"",[t,n]),r=(0,e.useCallback)(a=>Q.Ny.partial({[t]:a||null}),[t]);return[l,r]}const ce=({rows:t=[],queryParam:n,updateQueryParam:l,searchSpaceMap:r,columns:a,isExpandable:o=!1,renderExpandedContent:c,emptyMessage:d,searchPlaceholder:m,syncNewButton:v,syncAllButton:U,isUpgrading:$})=>{const i=(0,y.of)(z),h=$||$,x=(0,e.useMemo)(()=>Ne(r,t),[r,t]),E=(0,e.useMemo)(()=>x(n).map((J,Fe)=>({id:`${r(J)} - ${Fe}`,data:J})),[r,x,n]),S=!1,ge=(0,g.cx)(i.wrapper,{[i.wrapperMargin]:S}),Le=S?ae.B:te.E,Ue=(0,e.useMemo)(()=>({itemsPerPage:50}),[]);return e.createElement(e.Fragment,null,e.createElement("div",{className:i.searchWrapper},e.createElement(u.B,{direction:"column",gap:1},e.createElement(u.B,{direction:"row",gap:1},e.createElement(Se,{placeholder:m,searchFn:J=>{l?.(J||"")},searchPhrase:n||""}),v,U))),h&&e.createElement(de,{text:$?"Upgrade in progress...":"Loading..."}),!h&&!!E.length&&e.createElement("div",{className:ge},e.createElement(Le,{cols:a,isExpandable:o,items:E,renderExpandedContent:c,pagination:Ue,paginationStyles:i.pagination})),!h&&!E.length&&e.createElement("div",{className:(0,g.cx)(ge,i.emptyMessage)},d))},Ae=e.memo(ce),we=e.memo(ce),Ie=()=>{const t=(0,y.of)(z),{useUpgradeChannelMutation:n}=C,[l]=n();return(0,e.useMemo)(()=>[{id:"contact-level-error",label:"",renderCell:({data:r})=>{if(!r.error)return null;const a=r?.error==="channel not upgraded"||r?.error==="channel no longer exists";return e.createElement(O.m,{theme:"error",content:r.error},e.createElement(A.I,{name:"exclamation-circle",className:a?t.warningIcon:t.errorIcon,size:"lg"}))},size:"45px"},{id:"legacyChannel",label:"Legacy Channel",renderCell:({data:r})=>r?.legacyChannel?!r.legacyChannel.name&&r.contactPoint?.name?e.createElement(w.E,{color:"red",text:`Deleted Channel (ID: ${r.legacyChannel?.id})`}):r.legacyChannel.name?e.createElement(u.B,{direction:"row",gap:1},e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:t.textLink,href:(0,ee.c)(`/alerting-legacy/notifications/receivers/${encodeURIComponent(r.legacyChannel.id)}/edit`,{})},r.legacyChannel.name),r.legacyChannel?.type&&e.createElement(w.E,{color:"blue",text:r.legacyChannel.type})):e.createElement(w.E,{color:"red",text:`Unknown Channel (ID: ${r.legacyChannel?.id})`}):null,size:5},{id:"arrow",label:"",renderCell:({data:r})=>r?.contactPoint?e.createElement(A.I,{name:"arrow-right"}):null,size:"45px"},{id:"route",label:"Notification Policy",renderCell:({data:r})=>e.createElement(Ce.s,{matchers:r?.contactPoint?.routeMatchers??[]}),size:5},{id:"arrow2",label:"",renderCell:({data:r})=>r?.contactPoint?e.createElement(A.I,{name:"arrow-right"}):null,size:"45px"},{id:"contactPoint",label:"Contact Point",renderCell:({data:r})=>e.createElement(u.B,{direction:"row",gap:1},r?.contactPoint&&e.createElement(e.Fragment,null,e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:t.textLink,href:(0,Y.bg)(r.contactPoint.name,"grafana")},r.contactPoint.name),e.createElement(w.E,{color:"blue",text:r.contactPoint.type}))),size:5},{id:"provisioned",label:"",renderCell:({data:r})=>r.provisioned?e.createElement(w.E,{color:"purple",text:"Provisioned",className:t.badge}):null,size:"100px"},{id:"actions",label:"Actions",renderCell:({data:r})=>!r?.legacyChannel||r.legacyChannel.id<=0?null:r.isUpgrading?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(_.y,{size:"sm",inline:!0,className:t.spinner})):r?.error==="channel not upgraded"?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"upgrade legacy notification channel",key:"upgrade-channel",icon:"plus",tooltip:"upgrade legacy notification channel",onClick:()=>l({channelId:r.legacyChannel.id,skipExisting:!1})})):r?.error==="channel no longer exists"?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"remove upgraded notification channel",key:"upgrade-channel",icon:"minus",tooltip:"remove upgraded notification channel",onClick:()=>l({channelId:r.legacyChannel.id,skipExisting:!1})})):e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"re-upgrade legacy notification channel",key:"upgrade-channel",icon:"sync",tooltip:"re-upgrade legacy notification channel",onClick:()=>l({channelId:r.legacyChannel.id,skipExisting:!1})})),size:"70px"}],[t.textLink,t.errorIcon,t.warningIcon,t.badge,t.spinner,l])},Me=()=>{const t=(0,y.of)(z),{useUpgradeDashboardMutation:n}=C,[l]=n();return(0,e.useMemo)(()=>[{id:"dashboard-level-error",label:"",renderCell:({data:r})=>{if(!r.error)return null;const a=r?.error==="dashboard not upgraded"||r?.error==="dashboard no longer exists";return e.createElement(O.m,{theme:"error",content:r.error},e.createElement(A.I,{name:"exclamation-circle",className:a?t.warningIcon:t.errorIcon,size:"lg"}))},size:"45px"},{id:"folder",label:"Folder",renderCell:({data:r})=>r.folderName?e.createElement(u.B,{alignItems:"center",gap:.5},e.createElement(A.I,{name:"folder"}),e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:t.textLink,href:(0,Y.c$)(r.folderUid,r.folderName)},r.folderName)):e.createElement(u.B,{alignItems:"center",gap:.5},e.createElement(A.I,{name:"folder"}),e.createElement(w.E,{color:"red",text:"Unknown Folder"})),size:2},{id:"dashboard",label:"Dashboard",renderCell:({data:r})=>r.dashboardName?e.createElement(u.B,{alignItems:"center",gap:.5},e.createElement(A.I,{name:"apps"}),e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:t.textLink,href:(0,Y.JM)(r.dashboardUid)},r.dashboardName)):e.createElement(u.B,{alignItems:"center",gap:.5},e.createElement(A.I,{name:"apps"}),e.createElement(w.E,{color:"red",text:`Unknown Dashboard (ID: ${r.dashboardId})`})),size:2},{id:"new-folder-arrow",label:"",renderCell:({data:r})=>{const a=r?.newFolderUid;return a&&a!==r.folderUid&&r?.newFolderName?e.createElement(A.I,{name:"arrow-right"}):null},size:"45px"},{id:"new-folder",label:"New folder",renderCell:({data:r})=>{const a=r?.newFolderUid;if(a&&a!==r.folderUid&&r?.newFolderName){const o=r.warning.includes("dashboard alerts moved");return e.createElement(u.B,{alignItems:"center",gap:.5},e.createElement(A.I,{name:"folder"}),e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:t.textLink,href:(0,Y.c$)(a,r.newFolderName)},r.newFolderName),o&&e.createElement(O.m,{theme:"info-alt",content:r.warning,placement:"top"},e.createElement(A.I,{name:"info-circle"})))}return null},size:3},{id:"provisioned",label:"",className:t.tableBadges,renderCell:({data:r})=>{const a=r.warning.includes("provisioned status:");return e.createElement(e.Fragment,null,r.provisioned&&e.createElement(w.E,{color:"purple",text:a?"Unknown":"Provisioned",tooltip:r.warning,icon:a?"exclamation-triangle":void 0,className:t.badge}))},size:"100px"},{id:"error-badge",label:"",className:t.tableBadges,renderCell:({data:r})=>{const o=(r?.migratedAlerts??[]).map(c=>c.error??"").filter(c=>!!c);return o.length===0?null:e.createElement(w.E,{color:"red",key:"errors",text:`${o.length} errors`,className:t.badge})},size:"90px"},{id:"alert-count-badge",label:"",className:t.tableBadges,renderCell:({data:r})=>{const a=r?.migratedAlerts??[];return e.createElement(w.E,{color:"green",key:"alerts",text:`${a.length} alert rules`,className:t.badge})},size:"115px"},{id:"actions",label:"Actions",renderCell:({data:r})=>r.isUpgrading?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(_.y,{size:"sm",inline:!0,className:t.spinner})):r?.error==="dashboard not upgraded"?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"upgrade legacy alerts for this dashboard",key:"upgrade-dashboard",icon:"plus",tooltip:"upgrade legacy alerts for this dashboard",onClick:()=>l({dashboardId:r.dashboardId,skipExisting:!1})})):r?.error==="dashboard no longer exists"?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"remove upgraded alerts for this dashboard",key:"upgrade-dashboard",icon:"minus",tooltip:"remove upgraded alerts for this dashboard",onClick:()=>l({dashboardId:r.dashboardId,skipExisting:!1})})):e.createElement(u.B,{gap:.5,alignItems:"center"},r.dashboardId&&e.createElement(L.M,{"aria-label":"re-upgrade legacy alerts for this dashboard",key:"upgrade-dashboard",icon:"sync",tooltip:"re-upgrade legacy alerts for this dashboard",onClick:()=>l({dashboardId:r.dashboardId,skipExisting:!1})})),size:"70px"}],[t.tableBadges,t.errorIcon,t.warningIcon,t.textLink,t.badge,t.spinner,l])},$e=new I.A({intraMode:1,intraIns:1,intraSub:1,intraTrn:1,intraDel:1}),Ne=(t,n)=>{const l=n.map(t);return r=>{if(!r)return n;const[a,o,c]=$e.search(l,r,5);return o&&c?c.map(d=>n[o.idx[d]]):a?a.map(d=>n[d]):n}},Se=({searchFn:t,searchPhrase:n,placeholder:l})=>{const[r,a]=(0,e.useState)(n),o=(0,e.useMemo)(()=>(0,b.debounce)(t,600),[t]);return(0,e.useEffect)(()=>(a(n),()=>{o?.cancel()}),[o,n]),e.createElement(me.Z,{placeholder:l,value:r,width:55,escapeRegex:!1,onChange:c=>{a(c||""),c===""?(o?.cancel(),t("")):o(c||"")}})},De=({dashboardId:t,dashboardUid:n,showGuidelines:l=!1,emptyMessage:r="No alert upgrades found."})=>{const a=(0,y.of)(z),o=(0,e.useMemo)(()=>{const i=[];return(0,D.Mz)(h=>h?.migratedDashboards??[],(h,x)=>x,(h,x)=>h?.find(E=>E.dashboardId===x)?.migratedAlerts.map((E,S)=>({id:`${E?.legacyAlert?.id}-${S}`,data:E}))??i)},[]),{items:c}=C.useGetOrgUpgradeSummaryQuery(void 0,{selectFromResult:({data:i})=>({items:o(i,t)})}),{useUpgradeAlertMutation:d}=C,[m]=d(),v=(0,g.cx)(a.wrapper,a.rulesTable,{[a.wrapperMargin]:l}),U=[{id:"alert-level-error",label:"",renderCell:({data:i})=>{if(!i.error)return null;const h=i?.error==="alert not upgraded"||i?.error.endsWith("no longer exists");return e.createElement(O.m,{theme:"error",content:i.error},e.createElement(A.I,{name:"exclamation-circle",className:h?a.warningIcon:a.errorIcon,size:"lg"}))},size:"45px"},{id:"legacyAlert",label:"Legacy alert rule",renderCell:({data:i})=>i?.legacyAlert?(i.error??"").endsWith("no longer exists")?e.createElement(w.E,{color:"red",text:`Deleted Alert: (ID: ${i.legacyAlert?.panelId})`}):e.createElement(e.Fragment,null,n?e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:i.legacyAlert.name?a.textLink:a.errorLink,href:(0,ee.c)(`/d/${encodeURIComponent(n)}`,{editPanel:String(i.legacyAlert.panelId),tab:"alert"})},i.legacyAlert.name||"Missing Title"):e.createElement(w.E,{color:"red",text:i.legacyAlert.name||"Unknown Alert"})):null,size:5},{id:"arrow",label:"",renderCell:({data:i})=>i?.legacyAlert?e.createElement(A.I,{name:"arrow-right"}):null,size:"45px"},{id:"alertRule",label:"New alert rule",renderCell:({data:i})=>e.createElement(u.B,{direction:"row",gap:1},i?.alertRule&&e.createElement(K.N,{rel:"noreferrer",target:"_blank",className:a.textLink,href:(0,ee.c)(`/alerting/grafana/${i.alertRule?.uid??""}/view`,{})},i.alertRule?.title??"")),size:5},{id:"contacts",label:"Sends To",renderCell:({data:i})=>e.createElement(e.Fragment,null,i?.alertRule&&e.createElement(ue.L,{tags:i?.alertRule?.sendsTo??[],displayMax:3,className:(0,g.css)({justifyContent:"flex-start",width:"100%"})})),size:3},{id:"actions",label:"Actions",renderCell:({data:i})=>!i?.legacyAlert||i.legacyAlert.dashboardId<=0||i.legacyAlert.panelId<=0?null:i.isUpgrading?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(_.y,{size:"sm",inline:!0,className:a.spinner})):i?.error==="alert not upgraded"?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"upgrade legacy alert",key:"upgrade-alert",icon:"plus",tooltip:"upgrade legacy alert",onClick:()=>m({dashboardId:i.legacyAlert.dashboardId,panelId:i.legacyAlert.panelId,skipExisting:!1})})):i?.error?.endsWith("no longer exists")?e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"remove upgraded alert",key:"upgrade-alert",icon:"minus",tooltip:"remove upgraded alert",onClick:()=>m({dashboardId:i.legacyAlert.dashboardId,panelId:i.legacyAlert.panelId,skipExisting:!1})})):e.createElement(u.B,{gap:.5,alignItems:"center"},e.createElement(L.M,{"aria-label":"re-upgrade legacy alert",key:"upgrade-alert",icon:"sync",tooltip:"re-upgrade legacy alert",onClick:()=>m({dashboardId:i.legacyAlert.dashboardId,panelId:i.legacyAlert.panelId,skipExisting:!1})})),size:"70px"}];if(!c.length)return e.createElement("div",{className:(0,g.cx)(v,a.emptyMessage)},r);const $=l?ae.B:te.E;return e.createElement("div",{className:v,"data-testid":"rules-table"},e.createElement($,{cols:U,items:c,pagination:{itemsPerPage:50},paginationStyles:a.pagination}))},Te=({count:t,onClick:n})=>e.createElement(pe.Gy,{height:"auto",justify:"flex-start"},e.createElement(O.m,{content:"Show all errors",placement:"top"},e.createElement(M.$n,{fill:"text",variant:"destructive",icon:"exclamation-circle",onClick:n},t>1?e.createElement(e.Fragment,null,t," errors"):e.createElement(e.Fragment,null,"1 error")))),Be=({errors:t})=>{const[n,l]=(0,e.useState)(!1),[r,a]=(0,H.A)("grafana.unifiedalerting.upgrade.hideErrors",!0),o=(0,y.of)(z);return e.createElement(e.Fragment,null,!!t.length&&r&&e.createElement(Te,{count:t.length,onClick:()=>a(!1)}),!!t.length&&!r&&e.createElement(B.F,{"data-testid":"upgrade-errors",title:"Errors upgrading to Grafana Alerting",severity:"error",onRemove:()=>a(!0)},n&&t.map((c,d)=>e.createElement("div",{key:d},c)),!n&&e.createElement(e.Fragment,null,e.createElement("div",null,t[0]),t.length>=2&&e.createElement(M.$n,{className:o.moreButton,fill:"text",icon:"angle-right",size:"sm",onClick:()=>l(!0)},t.length-1," more ",T()("error",t.length-1)))))},de=({text:t="Loading..."})=>e.createElement("div",{className:"page-loader-wrapper"},e.createElement(fe._,{text:t})),z=t=>({wrapperMargin:(0,g.css)({[t.breakpoints.up("md")]:{marginLeft:"36px"}}),emptyMessage:(0,g.css)({padding:t.spacing(1)}),wrapper:(0,g.css)({width:"auto",borderRadius:t.shape.radius.default}),pagination:(0,g.css)({display:"flex",margin:"0",paddingTop:t.spacing(1),paddingBottom:t.spacing(.25),justifyContent:"center",borderLeft:`1px solid ${t.colors.border.medium}`,borderRight:`1px solid ${t.colors.border.medium}`,borderBottom:`1px solid ${t.colors.border.medium}`}),rulesTable:(0,g.css)({marginTop:t.spacing(3)}),errorIcon:(0,g.css)({fill:t.colors.error.text}),warningIcon:(0,g.css)({fill:t.colors.warning.text}),searchWrapper:(0,g.css)({marginBottom:t.spacing(2)}),textLink:(0,g.css)({color:t.colors.text.link,cursor:"pointer","&:hover":{textDecoration:"underline"}}),errorLink:(0,g.css)({color:t.colors.error.text,cursor:"pointer","&:hover":{textDecoration:"underline"}}),tabContent:(0,g.css)({marginTop:t.spacing(2)}),moreButton:(0,g.css)({padding:"0"}),tableBadges:(0,g.css)({justifyContent:"flex-end"}),badge:(0,g.css)({width:"100%",justifyContent:"center"}),separator:(0,g.css)({borderBottom:`1px solid ${t.colors.border.weak}`,marginTop:t.spacing(2)}),spinner:(0,g.css)({display:"flex",alignItems:"center",justifyContent:"center",width:t.spacing(3),height:t.spacing(3)})}),Oe=ne},26928:(X,F,s)=>{s.d(F,{s:()=>u});var g=s(32196),I=s(2543),D=s.n(I),b=s(96540),N=s(40845),T=s(67061),e=s(69613),Z=s(32642),H=s(35108);const u=({matchers:y,formatter:R="default"})=>{const k=(0,N.of)(B),P=5,V=(0,I.take)(y,P),M=(0,I.takeRight)(y,y.length-P),q=M.length>0;return b.createElement("span",{"data-testid":"label-matchers"},b.createElement(T.B,{direction:"row",gap:1,alignItems:"center",wrap:"wrap"},V.map(W=>b.createElement(Q,{key:(0,I.uniqueId)(),matcher:W,formatter:R})),q&&b.createElement(H.j,{arrow:!0,placement:"top",content:b.createElement(b.Fragment,null,M.map(W=>b.createElement(Q,{key:(0,I.uniqueId)(),matcher:W})))},b.createElement("span",null,b.createElement("div",{className:k.metadata},`and ${M.length} more`)))))},Q=({matcher:y,formatter:R="default"})=>{const k=(0,N.of)(B);return b.createElement("div",{className:k.matcher(y[0]).wrapper},b.createElement(T.B,{direction:"row",gap:0,alignItems:"baseline"},Z.t8[R](y)))},B=y=>({matcher:R=>{const{color:k,borderColor:P}=(0,e.MC)(R);return{wrapper:(0,g.css)` color: #fff; background: ${k}; padding: ${y.spacing(.33)} ${y.spacing(.66)}; font-size: ${y.typography.bodySmall.fontSize}; border: solid 1px ${P}; border-radius: ${y.shape.borderRadius(2)}; `}},metadata:(0,g.css)` color: ${y.colors.text.secondary}; font-size: ${y.typography.bodySmall.fontSize}; font-weight: ${y.typography.bodySmall.fontWeight}; `})},72275:(X,F,s)=>{s.d(F,{M:()=>b});var g=s(96540),I=s(56034),D=s(55852);const b=({tooltip:N,icon:T,to:e,target:Z,onClick:H,className:u,tooltipPlacement:Q="top",...B})=>{const y=typeof N=="string"?N:void 0;return g.createElement(I.m,{content:N,placement:Q},e?g.createElement(D.z9,{variant:"secondary",fill:"text",icon:T,href:e,size:"sm",target:Z,...B,"aria-label":y}):g.createElement(D.$n,{className:u,variant:"secondary",fill:"text",size:"sm",icon:T,type:"button",onClick:H,...B,"aria-label":y}))}},82076:(X,F,s)=>{s.d(F,{CD:()=>b,Oj:()=>T,ZX:()=>N,m0:()=>D,wT:()=>I});var g=s(44836);function I(e=!1){return e?(0,g.t)("search.search-input.include-panels-placeholder","Search for dashboards, folders, and panels"):(0,g.t)("search.search-input.placeholder","Search for dashboards and folders")}function D(){return(0,g.t)("search.dashboard-actions.new-dashboard","New dashboard")}function b(){return(0,g.t)("search.dashboard-actions.new-folder","New folder")}function N(){return(0,g.t)("search.dashboard-actions.import","Import")}function T(){return(0,g.t)("search.dashboard-actions.new","New")}}}]); //# sourceMappingURL=AlertingUpgrade.c757b99e306db50cdb16.js.map