PageSourceSearch

https://profisealabs.com/cabinet/static/js/AMAddUpdateAzureSubscription-COKRrkIS.js

js profisealabs.com collected 2026-09-25 18:33:52 UTC 9,587 bytes, 1 lines download raw bytes

1import{d as E,j as e,b1 as F,br as O,bu as R,ah as U,I as B}from"./index-ChxFcAuc.js";import{a as p}from"./vendor-core-C0v-OB8t.js";import{w as W}from"./withBackBtn-BONWhaYS.js";import{A as J}from"./AMManualPopup-CDckMpCt.js";import{e as L,j as V,A as f,a as Y,b as Z,m as H}from"./AMAddUpdateAzureTenantForm-B_bHA6_i.js";import{F as g,aZ as G,bX as K,a_ as X}from"./App-B3uEhegP.js";import{u as D}from"./useSubmitAMAddUpdate-Boq0UmoD.js";import{u as Q,R as q,o as $}from"./index-Be87oYsD.js";import{F as r}from"./FormHorizontalFieldGroup-CJ0Vs0dE.js";import{R as w}from"./Radio-CuOBtoku.js";import{S as ee,A as P}from"./AMAddUpdatePolicyModal-DBRmXt8q.js";import{S as te}from"./remove-DA-faswS.js";import{F as ie}from"./FormObserver-DciaNEU-.js";import{b as ae}from"./main-B_G75NJ-.js";import"./vendor-ant-ui-DEh1p71x.js";import"./PulsatingCircleAlarm-C5WCZoxH.js";import"./useGetEnvsData-DkXREWrz.js";import"./CodeBlock-GR_VrOKS.js";const se="wrapper_NCCZ5",ne="title_efzSv",re="subTitle_mEBJK",oe="radioWrapper_WsGbs",le="radio_uNLpO",ce="radioText_kiEa2",de="radioCaption_hXOFZ",pe="stackPolicy_jqp5M",me="stackButtons_RkD2x",ue="upload_PKJII",he="uploadInput_oYdCU",xe="file_WmXU4",je="fileText_Jrgho",fe="fileRemove_mRGfw",ge="policy_wipPR",ye="policyIcon_EDKQi",be="policyText_m7Cxm",Ie="jsonHeader_fnN8I",Ce="highlighterContainer_lQDMZ",Ne="errorMsg_FvVUu",t={wrapper:se,title:ne,subTitle:re,radioWrapper:oe,radio:le,radioText:ce,radioCaption:de,stackPolicy:pe,stackButtons:me,upload:ue,uploadInput:he,file:xe,fileText:je,fileRemove:fe,policy:ge,policyIcon:ye,policyText:be,jsonHeader:Ie,highlighterContainer:Ce,errorMsg:Ne},C={width:360,height:45},Se=({envData:s,mode:u,setMode:l,connection:n,setConnection:c,onViewInstructionsClick:y,azureScript:b})=>{const _=i=>{const a={},{name:d,subscriptionId:o,tenantId:h,clientId:_e,clientSecret:Ae,principalId:ke}=i;return d.length>f.maxEnvNameLength&&(a.name="Name must be at most 32 characters"),a},{handleAdd:x,handleUpdate:I}=D(),A=E().id,[N,m]=p.useState(!1),[j,k]=p.useState(""),z=()=>m(!0),M=i=>!i.subscriptionId||!i.clientId||!i.clientSecret||!i.principalId||!i.tenantId,[T,S]=p.useState("");p.useEffect(()=>{try{if(j){const i=JSON.parse(j);i.subscription_id&&i.client_id&&i.principal_id&&i.client_secret&&i.tenant_id?S(""):S("Wrong format or there is no some of keys")}else S("")}catch(i){const a=i;S(a.message),console.log(a)}},[j]);const v=i=>{if(n==="automatic")return!j||T.length>0;if(n==="manual")return M(i)};return e.jsx(F,{initialValues:{credentials:null,subscriptionId:"",tenantId:"",clientId:"",clientSecret:"",principalId:"",name:(s==null?void 0:s.name)||"",save:!0},validate:_,onSubmit:async(i,{setSubmitting:a,setStatus:d})=>{a(!0);const o={auth_data:"",auth_type:"access_key",name:i.name,provider:U.azure,save_credentials:!0,organization:A};if(n==="automatic")if(i.credentials&&i.credentials.type!=="application/json")d("Credentials should be in json file");else{const h=btoa(j);o.auth_data=h}else n==="manual"&&(M(i)||(o.auth_data={client_id:i.clientId,client_secret:i.clientSecret,principal_id:i.principalId,tenant_id:i.tenantId,subscription_id:i.subscriptionId}));o.auth_data!==""?s?await I({id:s.id,data:o,setStatus:d}):await x({data:o,setStatus:d}):(d("Credentials should be filed"),console.log("Credentials should be filed")),a(!1)},children:({isSubmitting:i,values:a,status:d,setFieldValue:o})=>e.jsxs(O,{children:[e.jsx(ie,{credentials:a.credentials,setCredentials:k}),d&&e.jsx(r,{label:"",children:e.jsx("div",{style:{marginBottom:8,color:"red"},children:d})}),e.jsx(r,{label:"Account name",children:e.jsx(g,{name:"name",inputStyle:{width:360,height:45},placeholder:"e.g. Azure Stage",disabled:!!s})}),e.jsx(r,{label:"Access",style:{alignItems:"flex-start"},children:e.jsxs("div",{className:t.radios,children:[e.jsxs("div",{className:t.radioWrapper,children:[e.jsxs("div",{className:t.radio,onClick:()=>l("write"),children:[e.jsx(w,{style:{marginRight:0},value:"write",checked:u==="write",onChange:()=>l("write"),name:"write"}),e.jsx("p",{className:t.radioText,children:"Read/write"})]}),e.jsx("p",{className:t.radioCaption,children:"You will be able to actively save money and fix all issues"})]}
1),e.jsxs("div",{className:t.radioWrapper,children:[e.jsxs("div",{className:t.radio,onClick:()=>l("read"),children:[e.jsx(w,{style:{marginRight:0},value:"read",checked:u==="read",onChange:()=>l("read"),name:"read"}),e.jsx("p",{className:t.radioText,children:"Read-only"})]}),e.jsx("p",{className:t.radioCaption,children:"You will get full visibility of your cloud environment and optimization insights"})]})]})}),e.jsx(r,{label:"Connection",style:{alignItems:"flex-start"},children:e.jsxs("div",{className:t.radios,children:[e.jsxs("div",{className:t.radioWrapper,children:[e.jsxs("div",{className:t.radio,onClick:()=>c("automatic"),children:[e.jsx(w,{style:{marginRight:0},value:"automatic",checked:n==="automatic",onChange:()=>c("automatic"),name:"automatic"}),e.jsx("p",{className:t.radioText,children:"Automatic"})]}),e.jsx("p",{className:t.radioCaption,children:"JSON key file will be automatically created by shell script"}),n==="automatic"&&e.jsxs("div",{className:t.stackButtons,children:[e.jsx(R,{style:{padding:"0 12px",width:"auto",height:28,borderRadius:8,fontSize:11},text:"View Instructions",onClick:y}),e.jsxs("div",{className:t.policy,onClick:z,children:[e.jsx(ee,{className:t.policyIcon}),e.jsx("p",{className:t.policyText,children:"View script"})]}),N&&e.jsx(P,{title:"Azure subscription connection shell script ",code:b,onClose:()=>m(!1)})]})]}),e.jsxs("div",{className:t.radioWrapper,children:[e.jsxs("div",{className:t.radio,onClick:()=>c("manual"),children:[e.jsx(w,{style:{marginRight:0},value:"manual",checked:n==="manual",onChange:()=>c("manual"),name:"manual"}),e.jsx("p",{className:t.radioText,children:"Manual"})]}),e.jsx("p",{className:t.radioCaption,children:"You will need to create a new Service Principal manually and provide connection metadata"}),n==="manual"&&e.jsxs("div",{className:t.stackButtons,children:[e.jsx(R,{style:{padding:"0 12px",width:"auto",height:28,borderRadius:8,fontSize:11},text:"View Instructions",onClick:y}),e.jsx(G,{icon:{src:L,width:16},text:{value:"View script",className:t.stackPolicy},onClick:z}),N&&e.jsx(P,{title:"Azure subscription connection shell script ",code:b,onClose:()=>m(!1)})]})]})]})}),n==="automatic"&&e.jsxs(r,{label:"JSON key file",style:{alignItems:"flex-start"},children:[e.jsxs("div",{className:t.jsonHeader,children:[e.jsx("p",{className:t.radioCaption,children:"Paste JSON from the key file"}),typeof a.credentials!="string"&&a.credentials?e.jsxs("div",{className:t.file,children:[e.jsx("p",{className:t.fileText,children:a.credentials.name}),e.jsx(te,{className:t.fileRemove,onClick:()=>{o("credentials",null),k("")}})]}):e.jsxs("label",{className:t.upload,children:[e.jsx("img",{src:Q,alt:""}),"Upload .JSON",e.jsx("input",{className:t.uploadInput,name:"credentials",type:"file",accept:".json",onChange:h=>{h.currentTarget.files&&o("credentials",h.currentTarget.files[0])}})]})]}),e.jsxs("div",{className:t.highlighterContainer,children:[e.jsx(q,{value:j,height:"200px",theme:$,extensions:[V()],onChange:h=>{k(h),o("credentials",null)}}),T&&e.jsx("p",{className:t.errorMsg,children:T})]})]}),n==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx(r,{label:"Subscription ID",children:e.jsx(g,{name:"subscriptionId",inputStyle:C,placeholder:"Paste Subscription ID here",counterMax:f.maxConnectionFieldsLength})}),e.jsx(r,{label:"Tenant ID",children:e.jsx(g,{name:"tenantId",inputStyle:C,placeholder:"Paste Tenant ID here",counterMax:f.maxConnectionFieldsLength})}),e.jsx(r,{label:"Client ID",children:e.jsx(g,{name:"clientId",inputStyle:C,placeholder:"Paste Client ID here",counterMax:f.maxConnectionFieldsLength})}),e.jsx(r,{label:"Client Secret",children:e.jsx(g,{name:"clientSecret",inputStyle:C,placeholder:"Paste Client Secret here",type:"password",counterMax:f.maxConnectionFieldsLength})}),e.jsx(r,{label:"Principal ID",children:e.jsx(g,{name:"principalId",inputStyle:C,placeholder:"Paste Principal ID here",counterMax:f.maxConnectionFieldsLength})})]}),e.jsx(r,{label:"",children:e.jsx(R,{text:s?"reconnect subscription":"connect subscription",style:{width:200,height:48},type:"submit",isDisabled:i||v(a),isSubmitting:i})})]})})},we=({envData:s,mode:u})=>{const[l,n]=p.useState(u||"write"),[c,y]=p.useState("automatic"),[b,_]=p.useState(null),x=p.useMemo(()=>ae[c][l],[c,l]),{showIntercomArticle:I}=K(x);p.useEffect(()=>{(async()=>{try{const m=await B({url:Y,method:"get"})();m.status===200&&_(m.data)}catch(m){console.log(m)}})()},[]);const A=()=>{if(u){if(u==="write")return"Switch to read/write";if(u==="read")return"Switch to read-only"}return s?"Update account":"Connect your Azure subscription"},N=s?s.type===X.management:!1;return e.jsxs("div",{className:t.wrapper,style:{flex:1},children:[e.jsx("h3",{className:t.title,children:A()}
1),e.jsx("h5",{className:t.subTitle,children:"You can grant read-only or read/write access. You can switch between access modes and/or cancel the connection at any time."}),N?e.jsx(Z,{envData:s,mode:l,setMode:n,connection:c,setConnection:y,onViewInstructionsClick:()=>I(x),azureScript:b}):e.jsx(Se,{envData:s,mode:l,setMode:n,connection:c,setConnection:y,onViewInstructionsClick:()=>I(x),azureScript:b}),e.jsx(J,{moreThan1Manual:!0,position:{bottom:"30px",right:"50px"},popupPosition:{bottom:"10px",right:"0px"},image:H,title:"Azure project connection",description:"Learn how to grant secure access to your Azure subscription.",onClick:()=>I(x)})]})},Ge=W(we);export{Ge 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.