1import{$ as x,P as o,O as l,V as r,r as u,ac as M,j as s,bC as g,M as A,aM as v,bI as y,cD as k,bK as b,bM as c,cr as I,cs as w,eY as j,b$ as D,N as S,W as m}from"./index-3f23923e.js";import{T as d}from"./DndContainer-3e233927.js";import{C as N}from"./FilteredTable-3cf54822.js";import{M as K}from"./Modal-f9cdfa74.js";import{c as T}from"./index-224f1ec9.js";import{C as O}from"./index-f3ff713c.js";import"./createSvgIcon-6546fa8e.js";import"./Link-d078b140.js";import"./SharedRoot-a0002675.js";import"./Snackbar-208e6032.js";import"./Alert-d83b9a10.js";import"./Google-59119d51.js";import"./index-1f39b086.js";import"./DropDown-031ea054.js";import"./_baseMap-0ffab789.js";import"./_defineProperty-129c14c3.js";import"./_setToString-ec252ae9.js";import"./tracer-logo-color-3e396a96.js";import"./ComponentError-800a1539.js";import"./WindowScroller-c66b7466.js";import"./ReferentialUrlPreview-edb87702.js";import"./hooks-60bfb2bc.js";import"./HoverPopover-db2dae39.js";import"./index-67f2aca4.js";import"./default-image-bd8784f0.js";import"./SearchEnginesPlatforms-018f8951.js";import"./TableCell-e97216c8.js";import"./ImageIframe-56a0c84b.js";import"./KeyboardArrowRight-b9e9b41e.js";import"./LastPage-9febbd81.js";import"./MenuItem-5555170a.js";import"./index.es-6df2d751.js";import"./WarningModal-66072b69.js";import"./SanitizedHTML-cc60ee9b.js";const p=x.REACT_APP_AUTH_URL,n=()=>t=>o.get(`${p}/access-key/${l()}`).then(e=>{t(E(e.data))}).catch(()=>{r.error("There was an error getting access keys.")}),$=()=>t=>o.post(`${p}/access-key/${l()}`).then(e=>(r.success("Successfully created access key."),t(n()),e.data)).catch(()=>{r.error("There was an error creating access key.")}),Y=t=>e=>o.post(`${p}/access-key/${l()}/inactivate`,t).then(()=>{r.success("Successfully deactivated access key."),e(n())}).catch(()=>{r.error("There was an error deactivating access key.")}),U=t=>e=>o.post(`${p}/access-key/${l()}/activate`,t).then(()=>{e(n()),r.success("Successfully activated access key."),e(n())}).catch(()=>{r.error("There was an error activating access key.")}),F=t=>e=>o.post(`${p}/access-key/${l()}/delete`,t).then(()=>{r.success("The access key was successfully deleted."),e(n())}).catch(()=>{r.error("There was an error deleting the access key.")}),E=t=>({payload:t,type:"SET_ACCESS_KEYS"});class _ extends u.Component{constructor(e){super(e),this.state={accessKeyCsv:null,hasMounted:!0,isLoading:!1}}componentDidUpdate(e){!M.isEqual(e.createdAccessKey,this.props.createdAccessKey)&&this.state?.hasMounted&&this.props.createdAccessKey&&this.getTokenData(),e.isOpen&&!this.props.isOpen&&this.setState({accessKeyCsv:null})}getTokenData(){this.setState({accessKeyCsv:[this.props.createdAccessKey]})}render(){return!this.props?.createdAccessKey&&this.props?.isOpen?s.jsx("span",{children:s.jsx("i",{className:"fas fa-spinner fa-spin fa-3x"})}):s.jsx(K,{ariaHideApp:!g,bounds:"html",handleCloseClick:this.props.close,isDraggable:!0,isModalOpen:this.props.isOpen,shape:"wide",title:"Add Access Key",children:{content:s.jsx(A.Fragment,{children:s.jsx("div",{className:"grid grid-cols-12 flush-top",children:s.jsxs("div",{className:"col-span-12 flush-top",children:[s.jsxs("div",{className:"CreateAccessKeyModal-infoContainer",children:[s.jsx("i",{className:"far fa-check-circle fa-2x CreateAccessKeyModal-infoCheck"}),s.jsxs("span",{children:[s.jsx("div",{className:"CreateAccessKeyModal-infoSuccess",children:"Success"}),s.jsx("div",{className:"CreateAccessKeyModal-infoMessage",children:"This is the only time that the secret access key will be displayed. You cannot recover it later. However, you can create new access keys at any time."})]})]}),s.jsx("h4",{className:"adx-h4 CreateAccessKeyModal-label",children:"Access Key ID"}),s.jsx("div",{className:"CreateAccessKeyModal-idValue",children:this.props?.createdAccessKey?.accessKeyId??""}),s.jsx("h4",{className:"adx-h4 CreateAccessKeyModal-label",children:"Secret Access Key"}),s.jsxs("div",{children:[s.jsx("div",{className:"CreateAccessKeyModal-secret",title:this.props?.createdAccessKey?.accessKeyToken,children:this.props?.createdAccessKey?.accessKeyToken??""}),s.jsxs("div",{children:[s.jsx("button",{className:"button primary table-action copy-btn CreateAccessKeyModal-copyButton",onClick:()=>T(this.props?.createdAccessKey?.accessKeyToken),children:"Copy"}),this.state?.accessKeyCsv&&s.jsx(O,{data:this.state.accessKeyCsv,filename:`${this.props?.createdAccessKey?.accessKeyId}.csv`,children:"Download CSV"})]})]})]})})})}})}}class L extends u.Component{constructor(e){super(e),this.state={confirmModalIsOpen:!1,createAccessKeyModalIsOpen:!1,createdAccessKey:void 0,mappedFields:[],selectedItems:[]},this.headers=[{classNames:"checkbox-col",field:"checkbox",getUid:a=>a.id,type:"checkbox",value:"",width:28},{classNames:"text-col",field:"id",name:"ID",type:"text"},{classNames:"text-col",field:"recentUsage",name:"Last Used",type:"text"},{classNames:"text-col",field:"status",name:"Status",type:"text"},{classNames:"text-col",field:"createdOn",name:"Created On",type:"text"}]}cellDataGetter({dataKey:e,rowData:a}
1){if(a)switch(e){case"recentUsage":const i=new y(a.recentUsage).format("MMM DD, YYYY hh:mm a");return i==="Invalid date"?"":i;case"createdOn":return new y(a.createdOn).format("MMM DD, YYYY hh:mm a");case"checkbox":return a.id;default:return a[e]}}componentDidMount(){this.props.getAccessKeys(),this.getMappedFields()}downloadCsv(){const e=`Index Column Name, Display Name, Description 2`+this.state?.mappedFields?.map(a=>[`"${a.indexColumnName?.replace(/[\n\r]/g," ")}"`,`"${a.displayName?.replace(/[\n\r]/g," ")}"`,`"${a.description?.replace(/[\n\r]/g," ")??""}"`]).join(` 3`);k(e,`${this.props?.currentAccount?.accountName}_Account${this.props?.currentAccount?.accountId}_Mapped_UDFs.csv`,"text/csv")}getActions(){return{left:[{icon:s.jsx(d,{icon:b}),label:"Delete",onClick:()=>{this.state.selectedItems.length<1?c.warning("You must select a row to delete."):this.state.selectedItems.length>1?c.warning("You may only delete 1 row at once."):this.setState({confirmModalIsOpen:!0})}},{icon:s.jsx(d,{icon:I}),label:"Deactivate",onClick:()=>{if(this.state.selectedItems.length<1)c.warning("You must select a row to deactivate.");else if(this.state.selectedItems.length>1)c.warning("You may only deactivate 1 row at once.");else if(this.props.tableData.find(e=>e.id===this.state.selectedItems[0])?.status==="INACTIVE")c.warning("The access key you have selected is already inactive.");else try{this.toggleAccessKeyStatus()}catch{c.error("An error occurred while trying to deactivate access key.")}}},{icon:s.jsx(d,{icon:w}),label:"Activate",onClick:()=>{if(this.state.selectedItems.length<1)c.warning("You must select a row to activate");else if(this.state.selectedItems.length>1)c.warning("You may only activate 1 row at once");else if(this.props.tableData.find(e=>e.id===this.state.selectedItems[0])?.status==="ACTIVE")c.warning("The access key you have selected is already active");else try{this.toggleAccessKeyStatus()}catch{c.error("An error occurred while trying to activate access key.")}}},{icon:s.jsx(d,{icon:j}),label:"Download Mapped UDFs",onClick:()=>{this.downloadCsv()}}],right:[{icon:s.jsx(d,{icon:D}),label:"Add Access Key",onClick:()=>{this.handleAccessKeyCreation()}}]}}getMappedFields(){const e=`${S}/udf/${l()}`;o.get(e).then(a=>{const i=a.data._embedded.udfs.map(({description:h,displayName:f,indexColumnName:C})=>({description:h,displayName:f,indexColumnName:C})).filter(h=>!h.indexColumnName.includes("customNumber"));this.setState({mappedFields:i})}).catch(()=>{c.error("There was an error downloading mapped udfs. Contact your account manager if the issue persists.")})}getUid(e){return e?.tableIndex}handleAccessKeyCreation(){this.props.createAccessKey()?.then(e=>{this.setState({createdAccessKey:e}),this.toggleCreateAccessKeyModal()})}handleDeleteAccessKey(){const a={accessKeyId:this.props.tableData.filter(i=>this.state.selectedItems.includes(i.id))[0].id};this.props.deleteAccessKey(a)}render(){return s.jsxs(A.Fragment,{children:[s.jsx(_,{close:this.toggleCreateAccessKeyModal.bind(this),createdAccessKey:this.state.createdAccessKey,isOpen:this.state.createAccessKeyModalIsOpen}),s.jsx(K,{ariaHideApp:!g,bounds:"html",handleCloseClick:()=>this.setState({confirmModalIsOpen:!1}),isDraggable:!0,isModalOpen:this.state.confirmModalIsOpen,shape:"wide",size:"small",title:"Delete Access Key?",children:{actions:{primary:s.jsx(m,{onClick:()=>{this.handleDeleteAccessKey(),this.setState({confirmModalIsOpen:!1})},variant:"contained",children:"Delete"}),secondary:s.jsx(m,{onClick:()=>this.setState({confirmModalIsOpen:!1}),variant:"outlined",children:"Cancel"})},content:s.jsx("p",{children:"Are you sure you want to delete the selected access key?"})}}),s.jsx(N,{actions:this.getActions(),cellDataGetter:this.cellDataGetter.bind(this),fixedColumnCount:2,forwardSelected:this.setSelected.bind(this),getUid:this.getUid(),headers:this.headers,hideFilters:!0,hideSearch:!0,hideStats:!0,isLoading:this.props.isLoading,refresh:this.props.getAccessKeys,tableData:this.props.tableData.map((e,a)=>Object.assign({},e,{tableIndex:a})),tableHeight:.85})]})}setSelected(e){this.setState({selectedItems:e})}toggleAccessKeyStatus(){const e=this.props.tableData.filter(i=>this.state.selectedItems.includes(i.id)),a={accessKeyId:e[0].id};e[0].status==="INACTIVE"?this.props.activateAccessKey(a):this.props.deactivateAccessKey(a)}toggleConfirmModal(){this.setState(e=>({confirmModalOpen:!e.confirmModalOpen}))}toggleCreateAccessKeyModal(){this.setState(e=>({createAccessKeyModalIsOpen:!e.createAccessKeyModalIsOpen}),()=>{this.state.assignModalIsOpen||this.props.getAccessKeys()})}}const xe=v(t=>({accessKeys:t.apiManagement.accessKeys?t.apiManagement.accessKeys:{},currentAccount:t.accounts.currentAccount,isLoading:t.accessKeys?t.accessKeys.isLoading:!1,tableData:t.apiManagement.accessKeys&&t.apiManagement.accessKeys.data?t.apiManagement.accessKeys.data:[]}),t=>({activateAccessKey:e=>t(U(e)),createAccessKey:()=>t($()),deactivateAccessKey:e=>
3t(Y(e)),deleteAccessKey:e=>t(F(e)),getAccessKeys:()=>t(n())}))(L);export{L as ApiManagement,xe 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.