"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5318,800],{20851:(y,g,s)=>{s.d(g,{GU:()=>l,YO:()=>E,qm:()=>v});var t=s(74848),a=s(32196),m=s(96540),_=s(40845),c=s(19361),f=s(38645);const v=({children:i,enterAnimation:u=!0})=>{const p=(0,_.of)(E);return(0,t.jsx)("div",{className:(0,a.cx)(p.loginInnerBox,u&&p.enterAnimation),children:i})},l=({children:i,branding:u,isChangingPassword:p})=>{const d=(0,_.of)(E),[T,o]=(0,m.useState)(!1),e=u?.loginSubtitle??c.M.GetLoginSubTitle(),n=u?.loginTitle??c.M.LoginTitle,r=u?.loginBoxBackground||c.M.LoginBoxBackground(),x=u?.loginLogo,h=u?.hideEdition??c.M.HideEdition;return(0,m.useEffect)(()=>o(!0),[]),(0,t.jsxs)(c.M.LoginBackground,{className:(0,a.cx)(d.container,T&&d.loginAnim,u?.loginBackground),children:[(0,t.jsx)("div",{className:d.loginMain,children:(0,t.jsxs)("div",{className:(0,a.cx)(d.loginContent,r,"login-content-box"),children:[(0,t.jsxs)("div",{className:d.loginLogoWrapper,children:[(0,t.jsx)(c.M.LoginLogo,{className:d.loginLogo,logo:x}),(0,t.jsx)("div",{className:d.titleWrapper,children:p?(0,t.jsx)("h1",{className:d.mainTitle,children:"Update your password"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h1",{className:d.mainTitle,children:n}),e&&(0,t.jsx)("h3",{className:d.subTitle,children:e})]})})]}),(0,t.jsx)("div",{className:d.loginOuterBox,children:i})]})}),u?.hideFooter?(0,t.jsx)(t.Fragment,{}):(0,t.jsx)(f.wi,{hideEdition:h,customLinks:u?.footerLinks})]})},D=(0,a.keyframes)`
from{
  opacity: 0;
  transform: translate(-60px, 0px);
}

to{
  opacity: 1;
  transform: translate(0px, 0px);
}`,E=i=>({loginMain:(0,a.css)({flexGrow:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minWidth:"100%"}),container:(0,a.css)({minHeight:"100%",backgroundPosition:"center",backgroundRepeat:"no-repeat",flex:1,minWidth:"100%",marginLeft:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}),loginAnim:(0,a.css)({"&:before":{opacity:1},".login-content-box":{opacity:1}}),submitButton:(0,a.css)({justifyContent:"center",width:"100%"}),loginLogo:(0,a.css)({width:"100%",maxWidth:60,marginBottom:i.spacing(2),[i.breakpoints.up("sm")]:{maxWidth:100}}),loginLogoWrapper:(0,a.css)({display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",padding:i.spacing(3)}),titleWrapper:(0,a.css)({textAlign:"center"}),mainTitle:(0,a.css)({fontSize:22,[i.breakpoints.up("sm")]:{fontSize:32}}),subTitle:(0,a.css)({fontSize:i.typography.size.md,color:i.colors.text.secondary}),loginContent:(0,a.css)({maxWidth:478,width:"calc(100% - 2rem)",display:"flex",alignItems:"stretch",flexDirection:"column",position:"relative",justifyContent:"flex-start",zIndex:1,minHeight:320,borderRadius:i.shape.radius.default,padding:i.spacing(2,0),opacity:0,[i.transitions.handleMotion("no-preference","reduce")]:{transition:"opacity 0.5s ease-in-out"},[i.breakpoints.up("sm")]:{minHeight:i.spacing(40),justifyContent:"center"}}),loginOuterBox:(0,a.css)({display:"flex",overflowY:"hidden",alignItems:"center",justifyContent:"center"}),loginInnerBox:(0,a.css)({padding:i.spacing(0,2,2,2),display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexGrow:1,maxWidth:415,width:"100%",transform:"translate(0px, 0px)",[i.transitions.handleMotion("no-preference")]:{transition:"0.25s ease"}}),enterAnimation:(0,a.css)({[i.transitions.handleMotion("no-preference")]:{animation:`${D} ease-out 0.2s`}})})},81054:(y,g,s)=>{s.r(g),s.d(g,{default:()=>x});var t=s(74848),a=s(32196),m=s(49785),_=s(54148),c=s(13544),f=s(40845),v=s(88575),l=s(10354),D=s(55852),E=s(62930),i=s(20851),u=s(83277),p=s(72254),d=s(50800),T=s(19042);const o=(0,a.css)`
  justify-content: center;
  width: 100%;
`,e=c.Tp.pages.RequestViewAccess,n=()=>{const h=(0,f.of)(r),{accessToken:b=""}=(0,_.g)(),[{error:P}]=(0,u.s)(),[L,{isLoading:R,isSuccess:A}]=(0,d.useRequestAccessMutation)(),{register:I,handleSubmit:B,formState:{errors:M},reset:U}=(0,m.mN)({mode:"onSubmit"}),O=(0,T.Z)(P?String(P):void 0),S=async C=>{await L({accessToken:b,email:C.email}).unwrap(),U()};return(0,t.jsx)(i.GU,{branding:{loginTitle:O.title,loginSubtitle:O.description,hideFooter:!0},children:(0,t.jsx)(i.qm,{children:(0,t.jsxs)("form",{className:o,onSubmit:B(S),children:[(0,t.jsx)(v.D,{label:"Email",error:M?.email?.message,invalid:!!M.email,children:(0,t.jsx)(l.p,{"data-testid":e.recipientInput,placeholder:"email",autoCapitalize:"none",...I("email",{required:"Email is required",pattern:{value:p._l,message:"Invalid email"}})})}),(0,t.jsxs)(D.$n,{"data-testid":e.submitButton,disabled:A,type:"submit",className:o,children:[A?"Access requested":"Request access"," ",R&&(0,t.jsx)(E.y,{className:h.loadingSpinner})]})]})})})},r=h=>({loadingSpinner:(0,a.css)`
    margin-left: ${h.spacing(1)};
  `}),x=n},50800:(y,g,s)=>{s.r(g),s.d(g,{default:()=>T,useConfirmAccessMutation:()=>d,useGetActiveUserDashboardsQuery:()=>u,useGetActiveUsersQuery:()=>p,useRequestAccessMutation:()=>i});var t=s(17172),a=s(32264),m=s(82467),_=s(3169),c=s(8484),f=s(72686),v=s(19042);function l(o){return typeof o=="object"&&o!=null&&"error"in o}function D(o){return l(o)&&(0,t.NF)(o.error)}const E=f.Sm.injectEndpoints({endpoints:o=>({requestAccess:o.mutation({query:e=>({url:"/public/dashboards/share/request-access",method:"POST",data:e})}),confirmAccess:o.mutation({query:({magicLinkToken:e,accessToken:n})=>({url:`/public/dashboards/share/${e}`,method:"POST"}),async onQueryStarted({accessToken:e},{dispatch:n,queryFulfilled:r}){try{await r,n((0,m.dx)((0,_.tZ)((0,c.t)("public-dashboard.email-sharing.success-confirm-access","Access confirmed!")))),window.location.assign(a.$.appSubUrl+`public-dashboards/${e}`)}catch(x){if(D(x)){const{data:{messageId:h}}=x.error;h&&Object.values(v.b5).includes(h)&&window.location.assign(a.$.appSubUrl+`public-dashboards/${e}/request-access?error=${h}`)}}}}),addRecipient:o.mutation({query:({recipient:e,uid:n})=>({url:`/public-dashboards/${n}/share/recipients`,method:"POST",data:{recipient:e}}),async onQueryStarted(e,{dispatch:n,queryFulfilled:r}){await r,n((0,m.dx)((0,_.tZ)((0,c.t)("public-dashboard.email-sharing.success-send-recipient-invitation","The email invitation has been sent."))))},invalidatesTags:(e,n,{dashboardUid:r})=>[{type:"PublicDashboard",id:r}]}),deleteRecipient:o.mutation({query:({uid:e,recipientUid:n})=>({url:`/public-dashboards/${e}/share/recipients/${n}`,method:"DELETE"}),async onQueryStarted({recipientEmail:e},{dispatch:n,queryFulfilled:r}){await r,n((0,m.dx)((0,_.tZ)((0,c.t)("public-dashboard.email-sharing.success-revoke-access-title","Access Revoked"),(0,c.t)("public-dashboard.email-sharing.success-revoke-access-description","You have successfully revoked access for {{recipientEmail}}.",{recipientEmail:e}))))},invalidatesTags:(e,n,{dashboardUid:r})=>[{type:"PublicDashboard",id:r},"UsersWithActiveSessions","ActiveUserDashboards"]}),reshareAccessToRecipient:o.mutation({query:({uid:e,recipientUid:n})=>({url:`/public-dashboards/${e}/share/recipients/${n}`,method:"PATCH"}),async onQueryStarted(e,{dispatch:n,queryFulfilled:r}){await r,n((0,m.dx)((0,_.tZ)((0,c.t)("public-dashboard.email-sharing.success-resend-recipient-invitation","The email invitation has been resent."))))}}),getActiveUsers:o.query({query:()=>({url:"/public-dashboards/share/users?status=active"}),providesTags:["UsersWithActiveSessions"]}),getActiveUserDashboards:o.query({query:e=>({url:`/public-dashboards/share/users/${e}/dashboards?status=active`}),providesTags:(e,n,r)=>[{type:"ActiveUserDashboards",id:r}]}),revokeAllAccess:o.mutation({query:({email:e})=>({url:`/public-dashboards/share/users/${e}`,method:"DELETE"}),async onQueryStarted({email:e},{dispatch:n,queryFulfilled:r}){await r,n((0,m.dx)((0,_.tZ)((0,c.t)("public-dashboard.email-sharing.success-revoke-all-accesses-title","Access Revoked"),(0,c.t)("public-dashboard.email-sharing.success-revoke-all-accesses-description","{{email}}'s access to all public dashboards has been successfully removed.",{email:e}))))},invalidatesTags:["UsersWithActiveSessions"]})}),overrideExisting:!0}),{useRequestAccessMutation:i,useGetActiveUserDashboardsQuery:u,useGetActiveUsersQuery:p,useConfirmAccessMutation:d}=E,T=E},19042:(y,g,s)=>{s.d(g,{Z:()=>v,b5:()=>t});var t=(l=>(l.NOT_FOUND_MAGIC_LINK="publicdashboards.magicLinkNotFound",l.EXPIRED_MAGIC_LINK="publicdashboards.magicLinkExpired",l))(t||{}),a=(l=>(l.INTERNAL_SERVER_ERROR="publicdashboards.internalServerError",l.INVALID_SESSION="publicdashboards.invalidSession",l.EXPIRED_SESSION="publicdashboards.sessionExpired",l))(a||{});const m={title:"Request access",description:"You'll receive an email with a one-time link."},_="Something went wrong",c="To request access to the dashboard again, enter your email. You'll receive an email with a one-time link.",f={"publicdashboards.internalServerError":_,"publicdashboards.magicLinkNotFound":"This link has expired or already been used","publicdashboards.magicLinkExpired":"This magic link has expired","publicdashboards.invalidSession":"You no longer have access","publicdashboards.sessionExpired":"Your access has expired"},v=l=>l?{title:f[String(l)]||_,description:c}:m}}]);

//# sourceMappingURL=RequestViewAccessPage.54374d5b33f42bba64c3.js.map