⚝
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 :
ApiKeysPage.12b0cd511f7b1e9c50dc.js
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4196],{9699:(re,p,a)=>{a.r(p),a.d(p,{ApiKeysPageUnconnected:()=>C,MigrationSummary:()=>S,default:()=>ae});var e=a(96540),w=a(69733),h=a(66864),E=a(14186),T=a(15292),f=a(37390),y=a(55852),A=a(36830),v=a(10096),b=a(32901),I=a(80348),F=a(67647);const R=({searchQuery:t,disabled:n,onSearchChange:l})=>e.createElement("div",{className:"page-action-bar"},e.createElement(E.I,{grow:!0},e.createElement(F.Z,{placeholder:"Search keys",value:t,onChange:l})));var m=a(32196),x=a(72724),K=a(40845),N=a(56034),B=a(14578),$=a(91605);const Q=({apiKeys:t,timeZone:n,onDelete:l,onMigrate:s})=>{const o=(0,K.$j)(),i=j(o);return e.createElement("table",{className:"filter-table"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Name"),e.createElement("th",null,"Role"),e.createElement("th",null,"Expires"),e.createElement("th",null,"Last used at"),e.createElement("th",{style:{width:"34px"}}))),t.length>0?e.createElement("tbody",null,t.map(r=>{const c=!!(r.expiration&&Date.now()>new Date(r.expiration).getTime());return e.createElement("tr",{key:r.id,className:i.tableRow(c)},e.createElement("td",null,r.name),e.createElement("td",null,r.role),e.createElement("td",null,O(r.expiration,n),c&&e.createElement("span",{className:i.tooltipContainer},e.createElement(N.m,{content:"This API key has expired."},e.createElement(B.I,{name:"exclamation-triangle"})))),e.createElement("td",null,L(n,r.lastUsedAt)),e.createElement("td",null,e.createElement(h.Gy,{justify:"flex-end"},e.createElement(y.$n,{size:"sm",onClick:()=>s(r)},"Migrate to service account"),e.createElement($.e,{"aria-label":"Delete API key",size:"sm",onConfirm:()=>l(r),disabled:!v.TP.hasPermissionInMetadata(I.AccessControlAction.ActionAPIKeysDelete,r)}))))})):null)};function L(t,n){return n?(0,x.LE)(n,{timeZone:t}):"Never"}function O(t,n){return t?(0,x.LE)(t,{timeZone:n}):"No expiration date"}const j=t=>({tableRow:n=>(0,m.css)` color: ${n?t.colors.text.secondary:t.colors.text.primary}; `,tooltipContainer:(0,m.css)` margin-left: ${t.spacing(1)}; `});var P=a(42418),U=a(96374);const V=({onMigrate:t,apikeysCount:n,disabled:l})=>{const[s,o]=(0,e.useState)(!1),i=(0,K.of)(W),r=e.createElement("a",{className:"external-link",href:"https://grafana.com/docs/grafana/latest/administration/api-keys/#migrate-api-keys-to-grafana-service-accounts",target:"_blank",rel:"noopener noreferrer"},"Find out more about the migration here."),c=e.createElement("span",null,"Migrating all API keys will hide the API keys tab.",e.createElement("br",null),e.createElement("br",null),"The API keys API will remain available for you to create new API keys, but we strongly encourage you to use Service accounts instead.");return e.createElement(e.Fragment,null,n>0&&e.createElement(P.F,{title:"Switch from API keys to service accounts",severity:"warning"},e.createElement("div",{className:i.text},"We will soon deprecate API keys. Each API key will be migrated into a service account with a token and will continue to work as they were. We encourage you to migrate your API keys to service accounts now. ",r),e.createElement("div",{className:i.actionRow},e.createElement(y.$n,{className:i.actionButton,onClick:()=>o(!0)},"Migrate all service accounts"),e.createElement(U.u,{title:"Migrate API keys to Service accounts",isOpen:s,body:c,confirmText:"Yes, migrate now",onConfirm:t,onDismiss:()=>o(!1),confirmVariant:"primary",confirmButtonVariant:"primary"}))),n===0&&e.createElement(e.Fragment,null,e.createElement(P.F,{title:"No API keys found",severity:"warning"},e.createElement("div",{className:i.text},"No API keys were found. If you reload the browser, this tab will be not available. If any API keys are created, this tab will appear again."))))},W=t=>({text:(0,m.css)` margin-bottom: ${t.spacing(2)}; `,actionRow:(0,m.css)` display: flex; align-items: center; `,actionButton:(0,m.css)` margin-right: ${t.spacing(2)}; `});var u=a(27677),d=a(93584);function g(){return async t=>{t((0,d.h8)());const[n,l]=await Promise.all([(0,u.AI)().get("/api/auth/keys?includeExpired=false&accesscontrol=true"),(0,u.AI)().get("/api/auth/keys?includeExpired=true&accesscontrol=true")]);t((0,d.Sf)({keys:n,keysIncludingExpired:l}))}}function Y(t){return async n=>{(0,u.AI)().delete(`/api/auth/keys/${t}`).then(()=>n(g()))}}function z(t){return async n=>{try{await(0,u.AI)().post(`/api/serviceaccounts/migrate/${t}`)}finally{n(g())}}}function Z(){return async t=>{try{const n=await(0,u.AI)().post("/api/serviceaccounts/migrate");t((0,d.QB)(n))}finally{t(g())}}}function G(){return t=>{t((0,d.cV)())}}const H=t=>t.includeExpired?t.keysIncludingExpired.length:t.keys.length,J=t=>{const n=RegExp(t.searchQuery,"i");return(t.includeExpired?t.keysIncludingExpired:t.keys).filter(s=>n.test(s.name)||n.test(s.role))},X=t=>t.includeExpired,q=t=>t.keys.length===0&&t.keysIncludingExpired.length>0;function _(t){const n=v.TP.hasPermission(I.AccessControlAction.ActionAPIKeysCreate);return{apiKeys:J(t.apiKeys),searchQuery:t.apiKeys.searchQuery,apiKeysCount:H(t.apiKeys),hasFetched:t.apiKeys.hasFetched,timeZone:(0,b.O)(t.user),includeExpired:X(t.apiKeys),includeExpiredDisabled:q(t.apiKeys),canCreate:n,migrationResult:t.apiKeys.migrationResult}}const ee={navId:"apikeys"},te={loadApiKeys:g,deleteApiKey:Y,migrateApiKey:z,migrateAll:Z,setSearchQuery:d.Ri,toggleIncludeExpired:G},ne=(0,w.connect)(_,te);class C extends e.PureComponent{constructor(n){super(n),this.onDeleteApiKey=l=>{this.props.deleteApiKey(l.id)},this.onMigrateApiKey=l=>{this.props.migrateApiKey(l.id)},this.onSearchQueryChange=l=>{this.props.setSearchQuery(l)},this.onIncludeExpiredChange=l=>{this.props.toggleIncludeExpired()},this.onMigrateApiKeys=async()=>{try{await this.props.migrateAll(),this.setState({showMigrationResult:!0})}catch(l){console.error(l)}},this.dismissModal=async()=>{this.setState({showMigrationResult:!1})},this.state={showMigrationResult:!1}}componentDidMount(){this.fetchApiKeys()}async fetchApiKeys(){await this.props.loadApiKeys()}render(){const{hasFetched:n,apiKeysCount:l,apiKeys:s,searchQuery:o,timeZone:i,includeExpired:r,includeExpiredDisabled:c,canCreate:le,migrationResult:D}=this.props,k=l>0;return e.createElement(A.Y,{...ee},e.createElement(A.Y.Contents,{isLoading:!n},e.createElement(e.Fragment,null,e.createElement(V,{onMigrate:this.onMigrateApiKeys,apikeysCount:l}),k?e.createElement(R,{searchQuery:o,disabled:!le,onSearchChange:this.onSearchQueryChange}):null,k?e.createElement(h.gW,null,e.createElement(E.I,{disabled:c,label:"Include expired keys"},e.createElement(T.K,{id:"showExpired",value:r,onChange:this.onIncludeExpiredChange})),e.createElement(Q,{apiKeys:s,timeZone:i,onMigrate:this.onMigrateApiKey,onDelete:this.onDeleteApiKey})):null)),D&&e.createElement(S,{visible:this.state.showMigrationResult,data:D,onDismiss:this.dismissModal}))}}const M={migrationSummary:{padding:"20px"},infoText:{color:"#007bff"},summaryDetails:{marginTop:"20px"},summaryParagraph:{margin:"10px 0"}},S=({visible:t,data:n,onDismiss:l})=>e.createElement(f.a,{title:"Migration summary",isOpen:t,closeOnBackdropClick:!0,onDismiss:l},n.failedApikeyIDs.length===0&&e.createElement("div",{style:M.migrationSummary},e.createElement("p",null,"Migration Successful!"),e.createElement("p",null,e.createElement("strong",null,"Total: "),n.total),e.createElement("p",null,e.createElement("strong",null,"Migrated: "),n.migrated)),n.failedApikeyIDs.length!==0&&e.createElement("div",{style:M.migrationSummary},e.createElement("p",null,"Migration Complete! Please note, while there might be a few API keys flagged as `failed migrations`, rest assured, all of your API keys are fully functional and operational. Please try again or contact support."),e.createElement("hr",null),e.createElement("p",null,e.createElement("strong",null,"Total: "),n.total),e.createElement("p",null,e.createElement("strong",null,"Migrated: "),n.migrated),e.createElement("p",null,e.createElement("strong",null,"Failed: "),n.failed),e.createElement("p",null,e.createElement("strong",null,"Failed Api Key IDs: "),n.failedApikeyIDs.join(", ")),e.createElement("p",null,e.createElement("strong",null,"Failed Details: "),n.failedDetails.join(", "))),e.createElement(f.a.ButtonRow,null,e.createElement(y.$n,{variant:"secondary",onClick:l},"Close"))),ae=ne(C)}}]); //# sourceMappingURL=ApiKeysPage.12b0cd511f7b1e9c50dc.js.map