apiconnect-explorer
Version:
- [Getting Started](#getting-started) - [Configuration](#configuration) * [Required](#required) * [Optional](#optional) - [Usage in React](#usage-in-react) - [Usage outside of React](#usage-outside-of-react) - [Detailed description of options](#detail
1 lines • 2.6 kB
JavaScript
function a(a,d){return g(a)||f(a,d)||c(a,d)||b()}function b(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(b,c){if(b){if("string"==typeof b)return d(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?d(b,c):void 0}}function d(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function f(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function g(a){if(Array.isArray(a))return a}import h,{useState as i,useMemo as j,useEffect as k}from"react";import{useTranslation as l}from"react-i18next";import{Button as m,TextInput as n}from"@carbon/react";import{View as o,ViewOff as p}from"@carbon/react/icons";import q from"../utils/invoker";import{getMixedContentMessage as r}from"../utils/error-message-handler";function s(b){var c=b.config,d=b.onChange,e=i({code:""}),f=a(e,2),g=f[0],s=f[1],u=i({}),v=a(u,2),w=v[0],x=v[1],y=i(!1),z=a(y,2),A=z[0],B=z[1],C=j(function(){return new q},[]),D=l(),E=D.t;k(function(){g.code||s({code:""})},[g.code]);return h.createElement("div",{className:"accessCode"},h.createElement(m,{className:"accessCodeButton",onClick:function(){return"https:"===window.location.protocol&&0!==c.flags.selectedTokenUrl.lastIndexOf(window.location.protocol)?(s({code:""}),void x(r(E))):void C.authorize(c.flags,c.identification.clientID,c.scopes,c.identification.redirectUri)}},E("explorer_authorize")),h.createElement(n,{className:"accessCodeField",labelText:E("access_code"),type:A?"text":"password",id:"accessCodeField",value:g.code,onChange:function(a){var b={code:a.target.value};s(b),d&&"function"==typeof d&&d(b)}}),h.createElement(m,{hasIconOnly:!0,className:"togglePassword",kind:"ghost",iconDescription:A?"Hide access code":"Show access code",renderIcon:A?p:o,onClick:function(){B(!A)}}),w&&w.highlightedText&&h.createElement("div",{className:"authError"},h.createElement("pre",null,h.createElement("code",{className:"boundedSection hljs oauthError",dangerouslySetInnerHTML:w.highlightedText}))))}export default s;