@kuadrant/kuadrant-backstage-plugin-frontend 0.0.2-dev-1cc1a15 → 0.0.2-dev-7d09bfa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/components/ApiAccessCard/ApiAccessCard.esm.js +229 -11
  2. package/dist/components/ApiAccessCard/ApiAccessCard.esm.js.map +1 -1
  3. package/dist/components/ApiKeyManagementTab/ApiKeyManagementTab.esm.js +15 -151
  4. package/dist/components/ApiKeyManagementTab/ApiKeyManagementTab.esm.js.map +1 -1
  5. package/dist/components/ApiProductDetailPage/ApiProductDetailPage.esm.js +10 -15
  6. package/dist/components/ApiProductDetailPage/ApiProductDetailPage.esm.js.map +1 -1
  7. package/dist/components/ApiProductDetails/ApiProductDetails.esm.js +6 -1
  8. package/dist/components/ApiProductDetails/ApiProductDetails.esm.js.map +1 -1
  9. package/dist/components/ApiProductInfoCard/ApiProductInfoCard.esm.js +15 -2
  10. package/dist/components/ApiProductInfoCard/ApiProductInfoCard.esm.js.map +1 -1
  11. package/dist/components/CreateAPIProductDialog/CreateAPIProductDialog.esm.js +2 -4
  12. package/dist/components/CreateAPIProductDialog/CreateAPIProductDialog.esm.js.map +1 -1
  13. package/dist/components/OidcProviderCard/OidcProviderCard.esm.js +23 -0
  14. package/dist/components/OidcProviderCard/OidcProviderCard.esm.js.map +1 -0
  15. package/dist/components/RequestAccessDialog/RequestAccessDialog.esm.js +167 -0
  16. package/dist/components/RequestAccessDialog/RequestAccessDialog.esm.js.map +1 -0
  17. package/dist/index.d.ts +1 -2
  18. package/dist/index.esm.js +1 -1
  19. package/dist/plugin.esm.js +1 -9
  20. package/dist/plugin.esm.js.map +1 -1
  21. package/dist/utils/validation.esm.js.map +1 -1
  22. package/dist-scalprum/configSchema.json +27 -1
  23. package/dist-scalprum/internal.plugin-kuadrant.5d9e1e73c7f21bbed39a.js +2 -0
  24. package/dist-scalprum/internal.plugin-kuadrant.5d9e1e73c7f21bbed39a.js.map +1 -0
  25. package/dist-scalprum/plugin-manifest.json +2 -2
  26. package/dist-scalprum/static/1994.19e6a1c5.chunk.js +3 -0
  27. package/dist-scalprum/static/1994.19e6a1c5.chunk.js.map +1 -0
  28. package/dist-scalprum/static/{2628.6619bf8b.chunk.js → 2628.0605e07f.chunk.js} +3 -3
  29. package/dist-scalprum/static/2628.0605e07f.chunk.js.map +1 -0
  30. package/dist-scalprum/static/2752.df63f31c.chunk.js +2 -0
  31. package/dist-scalprum/static/2752.df63f31c.chunk.js.map +1 -0
  32. package/dist-scalprum/static/2822.27a4ac5b.chunk.js +2 -0
  33. package/dist-scalprum/static/2822.27a4ac5b.chunk.js.map +1 -0
  34. package/dist-scalprum/static/2967.8d9c1b1f.chunk.js +2 -0
  35. package/dist-scalprum/static/2967.8d9c1b1f.chunk.js.map +1 -0
  36. package/dist-scalprum/static/{3097.4bd6b35f.chunk.js → 3097.582b68d3.chunk.js} +2 -2
  37. package/dist-scalprum/static/{3097.4bd6b35f.chunk.js.map → 3097.582b68d3.chunk.js.map} +1 -1
  38. package/dist-scalprum/static/327.cd6b3fee.chunk.js +2 -0
  39. package/dist-scalprum/static/327.cd6b3fee.chunk.js.map +1 -0
  40. package/dist-scalprum/static/3459.a7c29521.chunk.js +2 -0
  41. package/dist-scalprum/static/3459.a7c29521.chunk.js.map +1 -0
  42. package/dist-scalprum/static/3584.c820a5c7.chunk.js +2 -0
  43. package/dist-scalprum/static/3584.c820a5c7.chunk.js.map +1 -0
  44. package/dist-scalprum/static/3587.490690d6.chunk.js +2 -0
  45. package/dist-scalprum/static/3587.490690d6.chunk.js.map +1 -0
  46. package/dist-scalprum/static/{3647.b96f9b3e.chunk.js → 3647.67079e5f.chunk.js} +2 -2
  47. package/dist-scalprum/static/{3647.b96f9b3e.chunk.js.map → 3647.67079e5f.chunk.js.map} +1 -1
  48. package/dist-scalprum/static/3650.4f0dc550.chunk.js +2 -0
  49. package/dist-scalprum/static/3650.4f0dc550.chunk.js.map +1 -0
  50. package/dist-scalprum/static/3947.7458971d.chunk.js +2 -0
  51. package/dist-scalprum/static/3947.7458971d.chunk.js.map +1 -0
  52. package/dist-scalprum/static/3984.7bc07774.chunk.js +2 -0
  53. package/dist-scalprum/static/3984.7bc07774.chunk.js.map +1 -0
  54. package/dist-scalprum/static/4302.9a59485e.chunk.js +2 -0
  55. package/dist-scalprum/static/4302.9a59485e.chunk.js.map +1 -0
  56. package/dist-scalprum/static/441.f708f1e0.chunk.js +2 -0
  57. package/dist-scalprum/static/441.f708f1e0.chunk.js.map +1 -0
  58. package/dist-scalprum/static/4611.0d064cdf.chunk.js +2 -0
  59. package/dist-scalprum/static/4611.0d064cdf.chunk.js.map +1 -0
  60. package/dist-scalprum/static/4651.c85cecc4.chunk.js +2 -0
  61. package/dist-scalprum/static/4651.c85cecc4.chunk.js.map +1 -0
  62. package/dist-scalprum/static/{4682.6959fcd1.chunk.js → 4682.3c7098a8.chunk.js} +2 -2
  63. package/dist-scalprum/static/{4682.6959fcd1.chunk.js.map → 4682.3c7098a8.chunk.js.map} +1 -1
  64. package/dist-scalprum/static/501.87de76da.chunk.js +3 -0
  65. package/dist-scalprum/static/501.87de76da.chunk.js.LICENSE.txt +21 -0
  66. package/dist-scalprum/static/501.87de76da.chunk.js.map +1 -0
  67. package/dist-scalprum/static/{5010.a4aa0f8e.chunk.js → 5010.2228c754.chunk.js} +3 -3
  68. package/dist-scalprum/static/{5010.a4aa0f8e.chunk.js.map → 5010.2228c754.chunk.js.map} +1 -1
  69. package/dist-scalprum/static/5203.43732b3f.chunk.js +2 -0
  70. package/dist-scalprum/static/5203.43732b3f.chunk.js.map +1 -0
  71. package/dist-scalprum/static/5235.2a59dc45.chunk.js +2 -0
  72. package/dist-scalprum/static/5235.2a59dc45.chunk.js.map +1 -0
  73. package/dist-scalprum/static/5453.b3ee2392.chunk.js +2 -0
  74. package/dist-scalprum/static/5453.b3ee2392.chunk.js.map +1 -0
  75. package/dist-scalprum/static/{7556.aa8a002f.chunk.js → 5568.5dbce633.chunk.js} +3 -3
  76. package/dist-scalprum/static/{3466.43dfe991.chunk.js.LICENSE.txt → 5568.5dbce633.chunk.js.LICENSE.txt} +9 -0
  77. package/dist-scalprum/static/5568.5dbce633.chunk.js.map +1 -0
  78. package/dist-scalprum/static/6272.ef31cb1c.chunk.js +2 -0
  79. package/dist-scalprum/static/6272.ef31cb1c.chunk.js.map +1 -0
  80. package/dist-scalprum/static/6371.c4899d73.chunk.js +3 -0
  81. package/dist-scalprum/static/6371.c4899d73.chunk.js.map +1 -0
  82. package/dist-scalprum/static/6386.6386.ce38cef3.css +5 -0
  83. package/dist-scalprum/static/6386.6386.ce38cef3.css.map +1 -0
  84. package/dist-scalprum/static/6386.903891f3.chunk.js +3 -0
  85. package/dist-scalprum/static/6386.903891f3.chunk.js.LICENSE.txt +26 -0
  86. package/dist-scalprum/static/6386.903891f3.chunk.js.map +1 -0
  87. package/dist-scalprum/static/65.0e01be7c.chunk.js +2 -0
  88. package/dist-scalprum/static/65.0e01be7c.chunk.js.map +1 -0
  89. package/dist-scalprum/static/6753.76832e72.chunk.js +2 -0
  90. package/dist-scalprum/static/6753.76832e72.chunk.js.map +1 -0
  91. package/dist-scalprum/static/{8563.7e068fb0.chunk.js → 6763.d6cd937f.chunk.js} +3 -3
  92. package/dist-scalprum/static/6763.d6cd937f.chunk.js.map +1 -0
  93. package/dist-scalprum/static/{6800.736d5da3.chunk.js → 6800.8ec3a2eb.chunk.js} +2 -2
  94. package/dist-scalprum/static/6800.8ec3a2eb.chunk.js.map +1 -0
  95. package/dist-scalprum/static/{6840.4728fab9.chunk.js → 6840.6cc88a16.chunk.js} +2 -2
  96. package/dist-scalprum/static/6840.6cc88a16.chunk.js.map +1 -0
  97. package/dist-scalprum/static/7076.8745d395.chunk.js +2 -0
  98. package/dist-scalprum/static/7076.8745d395.chunk.js.map +1 -0
  99. package/dist-scalprum/static/7367.62c9669e.chunk.js +3 -0
  100. package/dist-scalprum/static/7367.62c9669e.chunk.js.LICENSE.txt +21 -0
  101. package/dist-scalprum/static/7367.62c9669e.chunk.js.map +1 -0
  102. package/dist-scalprum/static/7791.55db7365.chunk.js +2 -0
  103. package/dist-scalprum/static/7791.55db7365.chunk.js.map +1 -0
  104. package/dist-scalprum/static/8172.e89bbae7.chunk.js +2 -0
  105. package/dist-scalprum/static/8172.e89bbae7.chunk.js.map +1 -0
  106. package/dist-scalprum/static/8627.111cbac9.chunk.js +2 -0
  107. package/dist-scalprum/static/8627.111cbac9.chunk.js.map +1 -0
  108. package/dist-scalprum/static/8799.4ea4639c.chunk.js +2 -0
  109. package/dist-scalprum/static/8799.4ea4639c.chunk.js.map +1 -0
  110. package/dist-scalprum/static/9510.e4112e19.chunk.js +3 -0
  111. package/dist-scalprum/static/{2946.167c50c2.chunk.js.LICENSE.txt → 9510.e4112e19.chunk.js.LICENSE.txt} +0 -10
  112. package/dist-scalprum/static/9510.e4112e19.chunk.js.map +1 -0
  113. package/dist-scalprum/static/9644.7d342123.chunk.js +2 -0
  114. package/dist-scalprum/static/9644.7d342123.chunk.js.map +1 -0
  115. package/dist-scalprum/static/993.c164940e.chunk.js +2 -0
  116. package/dist-scalprum/static/993.c164940e.chunk.js.map +1 -0
  117. package/dist-scalprum/static/exposed-PluginRoot.5b6638e2.chunk.js +2 -0
  118. package/dist-scalprum/static/exposed-PluginRoot.5b6638e2.chunk.js.map +1 -0
  119. package/package.json +3 -1
  120. package/dist/components/PlanPolicyDetailPage/PlanPolicyDetailPage.esm.js +0 -89
  121. package/dist/components/PlanPolicyDetailPage/PlanPolicyDetailPage.esm.js.map +0 -1
  122. package/dist/components/PlanPolicyDetailPage/index.esm.js +0 -2
  123. package/dist/components/PlanPolicyDetailPage/index.esm.js.map +0 -1
  124. package/dist-scalprum/internal.plugin-kuadrant.58a9d553e354df0eed24.js +0 -2
  125. package/dist-scalprum/internal.plugin-kuadrant.58a9d553e354df0eed24.js.map +0 -1
  126. package/dist-scalprum/static/1085.536aa0fa.chunk.js +0 -3
  127. package/dist-scalprum/static/1085.536aa0fa.chunk.js.map +0 -1
  128. package/dist-scalprum/static/1613.71f0fccd.chunk.js +0 -3
  129. package/dist-scalprum/static/1613.71f0fccd.chunk.js.LICENSE.txt +0 -10
  130. package/dist-scalprum/static/1613.71f0fccd.chunk.js.map +0 -1
  131. package/dist-scalprum/static/1836.b74b4c40.chunk.js +0 -3
  132. package/dist-scalprum/static/1836.b74b4c40.chunk.js.LICENSE.txt +0 -10
  133. package/dist-scalprum/static/1836.b74b4c40.chunk.js.map +0 -1
  134. package/dist-scalprum/static/2198.5905970e.chunk.js +0 -2
  135. package/dist-scalprum/static/2198.5905970e.chunk.js.map +0 -1
  136. package/dist-scalprum/static/2628.6619bf8b.chunk.js.map +0 -1
  137. package/dist-scalprum/static/2759.fceb317f.chunk.js +0 -2
  138. package/dist-scalprum/static/2759.fceb317f.chunk.js.map +0 -1
  139. package/dist-scalprum/static/2928.4303c12e.chunk.js +0 -3
  140. package/dist-scalprum/static/2928.4303c12e.chunk.js.map +0 -1
  141. package/dist-scalprum/static/2946.167c50c2.chunk.js +0 -3
  142. package/dist-scalprum/static/2946.167c50c2.chunk.js.map +0 -1
  143. package/dist-scalprum/static/2967.ac3a4bee.chunk.js +0 -2
  144. package/dist-scalprum/static/2967.ac3a4bee.chunk.js.map +0 -1
  145. package/dist-scalprum/static/2987.1da15560.chunk.js +0 -2
  146. package/dist-scalprum/static/2987.1da15560.chunk.js.map +0 -1
  147. package/dist-scalprum/static/3459.5c90b5a3.chunk.js +0 -2
  148. package/dist-scalprum/static/3459.5c90b5a3.chunk.js.map +0 -1
  149. package/dist-scalprum/static/3466.43dfe991.chunk.js +0 -3
  150. package/dist-scalprum/static/3466.43dfe991.chunk.js.map +0 -1
  151. package/dist-scalprum/static/3503.66b6e510.chunk.js +0 -2
  152. package/dist-scalprum/static/3503.66b6e510.chunk.js.map +0 -1
  153. package/dist-scalprum/static/3650.515c743a.chunk.js +0 -2
  154. package/dist-scalprum/static/3650.515c743a.chunk.js.map +0 -1
  155. package/dist-scalprum/static/3657.59d45756.chunk.js +0 -3
  156. package/dist-scalprum/static/3657.59d45756.chunk.js.LICENSE.txt +0 -10
  157. package/dist-scalprum/static/3657.59d45756.chunk.js.map +0 -1
  158. package/dist-scalprum/static/428.0a290bc6.chunk.js +0 -2
  159. package/dist-scalprum/static/428.0a290bc6.chunk.js.map +0 -1
  160. package/dist-scalprum/static/441.9f02e61b.chunk.js +0 -2
  161. package/dist-scalprum/static/441.9f02e61b.chunk.js.map +0 -1
  162. package/dist-scalprum/static/5453.280127dd.chunk.js +0 -2
  163. package/dist-scalprum/static/5453.280127dd.chunk.js.map +0 -1
  164. package/dist-scalprum/static/5603.05d9ca7f.chunk.js +0 -2
  165. package/dist-scalprum/static/5603.05d9ca7f.chunk.js.map +0 -1
  166. package/dist-scalprum/static/6272.b5ee5195.chunk.js +0 -3
  167. package/dist-scalprum/static/6272.b5ee5195.chunk.js.LICENSE.txt +0 -9
  168. package/dist-scalprum/static/6272.b5ee5195.chunk.js.map +0 -1
  169. package/dist-scalprum/static/6371.c83dc422.chunk.js +0 -2
  170. package/dist-scalprum/static/6371.c83dc422.chunk.js.map +0 -1
  171. package/dist-scalprum/static/6422.97baf774.chunk.js +0 -2
  172. package/dist-scalprum/static/6422.97baf774.chunk.js.map +0 -1
  173. package/dist-scalprum/static/6800.736d5da3.chunk.js.map +0 -1
  174. package/dist-scalprum/static/6840.4728fab9.chunk.js.map +0 -1
  175. package/dist-scalprum/static/7556.aa8a002f.chunk.js.LICENSE.txt +0 -8
  176. package/dist-scalprum/static/7556.aa8a002f.chunk.js.map +0 -1
  177. package/dist-scalprum/static/7601.4df83556.chunk.js +0 -3
  178. package/dist-scalprum/static/7601.4df83556.chunk.js.LICENSE.txt +0 -9
  179. package/dist-scalprum/static/7601.4df83556.chunk.js.map +0 -1
  180. package/dist-scalprum/static/7791.39417f8c.chunk.js +0 -2
  181. package/dist-scalprum/static/7791.39417f8c.chunk.js.map +0 -1
  182. package/dist-scalprum/static/7984.c8511b89.chunk.js +0 -2
  183. package/dist-scalprum/static/7984.c8511b89.chunk.js.map +0 -1
  184. package/dist-scalprum/static/8365.d3360f18.chunk.js +0 -2
  185. package/dist-scalprum/static/8365.d3360f18.chunk.js.map +0 -1
  186. package/dist-scalprum/static/8563.7e068fb0.chunk.js.map +0 -1
  187. package/dist-scalprum/static/8799.7c749838.chunk.js +0 -2
  188. package/dist-scalprum/static/8799.7c749838.chunk.js.map +0 -1
  189. package/dist-scalprum/static/exposed-PluginRoot.a5792fb2.chunk.js +0 -2
  190. package/dist-scalprum/static/exposed-PluginRoot.a5792fb2.chunk.js.map +0 -1
  191. /package/dist-scalprum/static/{2928.4303c12e.chunk.js.LICENSE.txt → 1994.19e6a1c5.chunk.js.LICENSE.txt} +0 -0
  192. /package/dist-scalprum/static/{2628.6619bf8b.chunk.js.LICENSE.txt → 2628.0605e07f.chunk.js.LICENSE.txt} +0 -0
  193. /package/dist-scalprum/static/{5010.a4aa0f8e.chunk.js.LICENSE.txt → 5010.2228c754.chunk.js.LICENSE.txt} +0 -0
  194. /package/dist-scalprum/static/{1085.536aa0fa.chunk.js.LICENSE.txt → 6371.c4899d73.chunk.js.LICENSE.txt} +0 -0
  195. /package/dist-scalprum/static/{8563.7e068fb0.chunk.js.LICENSE.txt → 6763.d6cd937f.chunk.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkinternal_plugin_kuadrant=self.webpackChunkinternal_plugin_kuadrant||[]).push([[4682],{5030:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a=n(85608),s=n(95478),r=a.__importDefault(n(10009));t.default=function(e,t,n){void 0===t&&(t=[]),void 0===n&&(n={loading:!1});var i=s.useRef(0),o=r.default(),l=s.useState(n),c=l[0],d=l[1],u=s.useCallback(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var s=++i.current;return c.loading||d(function(e){return a.__assign(a.__assign({},e),{loading:!0})}),e.apply(void 0,t).then(function(e){return o()&&s===i.current&&d({value:e,loading:!1}),e},function(e){return o()&&s===i.current&&d({error:e,loading:!1}),e})},t);return[c,u]}},10009:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a=n(95478);t.default=function(){var e=a.useRef(!1),t=a.useCallback(function(){return e.current},[]);return a.useEffect(function(){return e.current=!0,function(){e.current=!1}},[]),t}},12229:(e,t,n)=>{n.d(t,{Z:()=>A});var a=n(31085),s=n(95478),r=n.n(s),i=n(10394),o=n(72501),l=n(64947),c=n(37197),d=n(69621),u=n(12981),p=n(86901),m=n(69076),h=n(58837),v=n(6924),g=n(23164);const f=(0,h.A)(e=>({root:{width:240,minWidth:240,padding:e.spacing(2),borderRight:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.background.paper,height:"100%",overflowY:"auto"},sectionTitle:{fontWeight:600,fontSize:"0.75rem",textTransform:"uppercase",letterSpacing:"0.05em",color:e.palette.text.secondary,marginBottom:e.spacing(1),display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",userSelect:"none"},filterSection:{marginBottom:e.spacing(2)},checkbox:{padding:e.spacing(.5)},checkboxLabel:{fontSize:"0.875rem"},clearButton:{marginTop:e.spacing(2)},count:{fontSize:"0.75rem",color:e.palette.text.secondary,marginLeft:e.spacing(1)}})),A=({sections:e,filters:t,onChange:n,onClear:s})=>{const h=f(),[A,x]=r().useState(new Set(e.filter(e=>e.collapsed).map(e=>e.id))),j=Object.values(t).some(e=>e.length>0);return(0,a.jsxs)(i.A,{className:h.root,children:[(0,a.jsxs)(i.A,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[(0,a.jsx)(o.A,{variant:"subtitle2",children:"Filters"}),j&&(0,a.jsx)(l.A,{size:"small",color:"primary",onClick:()=>{const t={};e.forEach(e=>{t[e.id]=[]}),n(t),null==s||s()},children:"Clear all"})]}),(0,a.jsx)(c.A,{}),e.map(e=>{const s=A.has(e.id),r=(t[e.id]||[]).length;return(0,a.jsxs)(i.A,{className:h.filterSection,mt:2,children:[(0,a.jsxs)(i.A,{className:h.sectionTitle,onClick:()=>{return t=e.id,void x(e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t},children:[(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)("span",{children:e.title}),r>0&&(0,a.jsxs)("span",{className:h.count,children:["(",r,")"]})]}),s?(0,a.jsx)(v.A,{fontSize:"small"}):(0,a.jsx)(g.A,{fontSize:"small"})]}),(0,a.jsx)(d.A,{in:!s,children:(0,a.jsx)(u.A,{children:e.options.map(s=>(0,a.jsx)(p.A,{control:(0,a.jsx)(m.A,{checked:(t[e.id]||[]).includes(s.value),onChange:()=>((e,a)=>{const s=t[e]||[],r=s.includes(a)?s.filter(e=>e!==a):[...s,a];n({...t,[e]:r})})(e.id,s.value),size:"small",className:h.checkbox,color:"primary"}),label:(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)("span",{className:h.checkboxLabel,children:s.label}),void 0!==s.count&&(0,a.jsxs)("span",{className:h.count,children:["(",s.count,")"]})]})},s.value))})})]},e.id)})]})}},14682:(e,t,n)=>{n.r(t),n.d(t,{ApiKeysPage:()=>se});var a=n(31085),s=n(95478),r=n.n(s),i=n(10394),o=n(31653),l=n(38605),c=n(289),d=n(15831),u=n(45210),p=n(46681),m=n(38599),h=n(42469),v=n(37725),g=n(86687),f=n(42367),A=n(25010),x=n(22097),j=n(91638),y=n(58837),b=n(72501),k=n(67720),w=n(71677),P=n(29365),S=n(78467),C=n(37757),q=n(26343),I=n(76891),R=n(61477),$=n(46805),z=n(93453),T=n(64947),B=n(32269),N=n(61524),M=n(99594),E=n(77225),_=n(39590),L=n(16397),F=n(63221),O=n(12229),D=n(46299);const W=(0,y.A)(e=>({container:{display:"flex",height:"100%",minHeight:400},tableContainer:{flex:1,overflow:"auto",padding:10},useCasePanel:{padding:e.spacing(2),backgroundColor:e.palette.background.default},useCaseLabel:{fontWeight:600,marginBottom:e.spacing(1),color:e.palette.text.secondary,textTransform:"uppercase",fontSize:"0.75rem"},rejectedBanner:{backgroundColor:e.palette.error.light,border:`1px solid ${e.palette.error.main}`,borderRadius:e.shape.borderRadius,padding:e.spacing(1.5,2),marginBottom:e.spacing(2),display:"flex",alignItems:"center",gap:e.spacing(1)}})),K=({request:e})=>{var t,n;const s=W(),r="Rejected"===(null===(t=e.status)||void 0===t?void 0:t.phase),o=(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown";return(0,a.jsxs)(i.A,{className:s.useCasePanel,onClick:e=>e.stopPropagation(),children:[r&&(0,a.jsxs)(i.A,{className:s.rejectedBanner,children:[(0,a.jsx)(E.A,{color:"error",fontSize:"small"}),(0,a.jsxs)(b.A,{variant:"body2",children:["This API key was rejected."," ",(0,a.jsx)(v.N_,{to:`/catalog/default/api/${o}/api-keys`,children:"Request a new API key"})]})]}),(0,a.jsx)(b.A,{className:s.useCaseLabel,children:"Use Case"}),(0,a.jsx)(b.A,{variant:"body2",children:e.spec.useCase||"No use case provided"})]})},U=()=>{var e,t;const n=W(),r=(0,h.useNavigate)(),o=(0,x.useApi)(x.configApiRef),l=(0,x.useApi)(x.fetchApiRef),c=(0,x.useApi)(x.alertApiRef),d=o.getString("backend.baseUrl"),[u,p]=(0,s.useState)(new Set),[m,y]=(0,s.useState)(null),[U,H]=(0,s.useState)(null),[V,Y]=(0,s.useState)({open:!1,request:null,plans:[]}),[Z,J]=(0,s.useState)(0),[X,G]=(0,s.useState)(null),[Q,ee]=(0,s.useState)({open:!1,request:null}),[te,ne]=(0,s.useState)(new Map),[ae,se]=(0,s.useState)(new Set),[re,ie]=(0,s.useState)(new Set),[oe,le]=(0,s.useState)(!1),[ce,de]=(0,s.useState)(null),[ue,pe]=(0,s.useState)(new Set),[me,he]=(0,s.useState)({status:[],apiProduct:[],tier:[]}),{value:ve,loading:ge,error:fe}=(0,j.A)(async()=>{const[e,t]=await Promise.all([l.fetch(`${d}/api/kuadrant/requests/my`),l.fetch(`${d}/api/kuadrant/apiproducts`)]);if(!e.ok)throw new Error("failed to fetch requests");const n=(await e.json()).items||[];let a=[];t.ok&&(a=(await t.json()).items||[]);const s=new Map;return a.forEach(e=>{var t;const n=`${e.metadata.namespace}/${e.metadata.name}`,a=(null===(t=e.metadata.annotations)||void 0===t?void 0:t["backstage.io/owner"])||"unknown";s.set(n,a)}),{requests:n,products:a,ownerMap:s}},[d,l,Z]),Ae=(0,s.useMemo)(()=>(null==ve?void 0:ve.requests)?ve.requests.filter(e=>!ue.has(e.metadata.name)):[],[null==ve?void 0:ve.requests,ue]),xe=(0,s.useMemo)(()=>{const e={Approved:0,Pending:0,Rejected:0},t=new Map,n=new Map;return Ae.forEach(a=>{var s,r;const i=(null===(s=a.status)||void 0===s?void 0:s.phase)||"Pending";e[i]++;const o=(null===(r=a.spec.apiProductRef)||void 0===r?void 0:r.name)||"unknown";t.set(o,(t.get(o)||0)+1);const l=a.spec.planTier||"unknown";n.set(l,(n.get(l)||0)+1)}),[{id:"status",title:"Status",options:[{value:"Approved",label:"Active",count:e.Approved},{value:"Pending",label:"Pending",count:e.Pending},{value:"Rejected",label:"Rejected",count:e.Rejected}]},{id:"apiProduct",title:"API Product",options:Array.from(t.entries()).map(([e,t])=>({value:e,label:e,count:t})),collapsed:t.size>5},{id:"tier",title:"Tier",options:Array.from(n.entries()).map(([e,t])=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1),count:t}))}]},[Ae]),je=(0,s.useMemo)(()=>Ae.filter(e=>{if(me.status.length>0){var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending";if(!me.status.includes(n))return!1}if(me.apiProduct.length>0){var n;const t=(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown";if(!me.apiProduct.includes(t))return!1}if(me.tier.length>0){const t=e.spec.planTier||"unknown";if(!me.tier.includes(t))return!1}return!0}),[Ae,me]),ye=e=>{p(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},be=()=>{y(null),H(null)},ke=async()=>{if(!U)return;const e=U;be();try{var t;const a=null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name,s=e.metadata.namespace,r=await l.fetch(`${d}/api/kuadrant/apiproducts/${s}/${a}`);if(r.ok){var n;const t=(null===(n=(await r.json()).spec)||void 0===n?void 0:n.plans)||[];Y({open:!0,request:e,plans:t})}else Y({open:!0,request:e,plans:[]})}catch(t){console.error("Error fetching plans:",t),Y({open:!0,request:e,plans:[]})}},we=()=>{if(!U)return;const e=U;be(),ee({open:!0,request:e})},Pe=[{title:"API Product",field:"spec.apiProductRef.name",render:e=>{var t;const n=(null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name)||"unknown";return(0,a.jsx)(v.N_,{to:`/catalog/default/api/${n}/api-keys`,children:(0,a.jsx)("strong",{children:n})})}},{title:"Owner",field:"owner",render:e=>{var t,n;const s=`${e.metadata.namespace}/${null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name}`,r=((null==ve||null===(n=ve.ownerMap)||void 0===n?void 0:n.get(s))||"unknown").replace(/^user:default\//,"");return(0,a.jsx)(b.A,{variant:"body2",children:r})}},{title:"Status",field:"status.phase",render:e=>{var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending",s="Approved"===n?"Active":n;return(0,a.jsx)(k.A,{label:s,size:"small",style:(0,D.S)(n)})}},{title:"Tier",field:"spec.planTier",render:e=>(0,a.jsx)(k.A,{label:e.spec.planTier,size:"small",variant:"outlined"})},{title:"API Key",field:"status.secretRef",filtering:!1,render:e=>{var t,n,s,r;if("Approved"!==(null===(t=e.status)||void 0===t?void 0:t.phase))return(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"-"});const o=`${e.metadata.namespace}/${e.metadata.name}`,l=null===(s=e.status)||void 0===s||null===(n=s.secretRef)||void 0===n?void 0:n.name,d=u.has(e.metadata.name),p=ae.has(o),m=te.get(o),h=!1!==(null===(r=e.status)||void 0===r?void 0:r.canReadSecret),v=re.has(o)||!h;return l?v&&!m?(0,a.jsx)(w.Ay,{title:"This API key has already been viewed and cannot be retrieved again",children:(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",style:{fontFamily:"monospace",marginRight:8},children:"Already viewed"}),(0,a.jsx)(N.A,{fontSize:"small",color:"disabled"})]})}):(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,a.jsx)(i.A,{fontFamily:"monospace",fontSize:"0.875rem",children:p?"Loading...":d&&m?m:"•".repeat(20)+"..."}),d&&m&&(0,a.jsx)(w.Ay,{title:"Copy to clipboard",children:(0,a.jsx)(P.A,{size:"small",onClick:async()=>{m&&(await navigator.clipboard.writeText(m),c.post({message:"API key copied to clipboard",severity:"success",display:"transient"}))},children:(0,a.jsx)(M.A,{fontSize:"small"})})}),(0,a.jsx)(w.Ay,{title:d?"Hide API key":"Reveal API key (one-time only)",children:(0,a.jsx)("span",{children:(0,a.jsx)(P.A,{size:"small",onClick:()=>{d?(((e,t)=>{const n=`${e}/${t}`;ne(e=>{const t=new Map(e);return t.delete(n),t})})(e.metadata.namespace,e.metadata.name),ye(e.metadata.name)):v||(de({namespace:e.metadata.namespace,name:e.metadata.name}),le(!0))},disabled:p||v&&!m,children:d?(0,a.jsx)(N.A,{fontSize:"small"}):(0,a.jsx)(B.A,{fontSize:"small"})})})})]}):(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"Awaiting secret..."})}},{title:"Requested",field:"metadata.creationTimestamp",render:e=>{if(!e.metadata.creationTimestamp)return(0,a.jsx)(b.A,{variant:"body2",children:"-"});const t=new Date(e.metadata.creationTimestamp);return(0,a.jsx)(b.A,{variant:"body2",children:t.toLocaleDateString()})}},{title:"Actions",filtering:!1,width:"100px",render:e=>X===e.metadata.name?(0,a.jsx)(S.A,{size:20}):(0,a.jsxs)(i.A,{display:"flex",style:{gap:4},children:[(0,a.jsx)(w.Ay,{title:"View details",children:(0,a.jsx)(P.A,{size:"small",onClick:t=>{t.stopPropagation(),r(`/kuadrant/api-keys/${e.metadata.namespace}/${e.metadata.name}`)},children:(0,a.jsx)(B.A,{fontSize:"small"})})}),(0,a.jsx)(w.Ay,{title:"Delete",children:(0,a.jsx)(P.A,{size:"small",onClick:t=>{t.stopPropagation(),ee({open:!0,request:e})},children:(0,a.jsx)(_.A,{fontSize:"small"})})})]})}],Se=(0,s.useMemo)(()=>[{render:e=>{var t;const n=e.rowData;return(null==n||null===(t=n.metadata)||void 0===t?void 0:t.name)?(0,a.jsx)(K,{request:n}):(0,a.jsx)(i.A,{})}}],[]);return ge?(0,a.jsx)(g.k,{}):fe?(0,a.jsx)(f._,{error:fe}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i.A,{className:n.container,children:[(0,a.jsx)(O.Z,{sections:xe,filters:me,onChange:he}),(0,a.jsx)(i.A,{className:n.tableContainer,children:0===je.length?(0,a.jsx)(i.A,{p:4,textAlign:"center",children:(0,a.jsx)(b.A,{variant:"body1",color:"textSecondary",children:0===Ae.length?"No API keys found. Request access to an API to get started.":"No API keys match the selected filters."})}):(0,a.jsx)(A.X,{options:{paging:je.length>10,pageSize:20,search:!0,filtering:!1,debounceInterval:300,toolbar:!0,emptyRowsWhenPaging:!1},columns:Pe,data:je.map(e=>({...e,id:e.metadata.name})),detailPanel:Se})})]}),(0,a.jsx)(C.A,{id:"myapikeys-menu",open:Boolean(m),onClose:be,anchorReference:"anchorPosition",anchorPosition:m||{top:0,left:0},children:U&&(()=>{const e=[];var t;return e.push((0,a.jsx)(q.A,{onClick:()=>{r(`/kuadrant/api-keys/${U.metadata.namespace}/${U.metadata.name}`),be()},children:"View Details"},"view")),(t=U).status&&"Pending"!==t.status.phase||e.push((0,a.jsx)(q.A,{onClick:ke,children:"Edit"},"edit")),e.push((0,a.jsx)(q.A,{onClick:we,children:"Delete"},"delete")),e})()}),V.request&&(0,a.jsx)(L.e,{open:V.open,request:V.request,availablePlans:V.plans,onClose:()=>Y({open:!1,request:null,plans:[]}),onSuccess:()=>{Y({open:!1,request:null,plans:[]}),J(e=>e+1)}}),(0,a.jsx)(F.K,{open:Q.open,title:"Delete API Key",description:`Are you sure you want to delete this API key for ${(null===(t=Q.request)||void 0===t||null===(e=t.spec.apiProductRef)||void 0===e?void 0:e.name)||"this API"}?`,deleting:null!==X,onConfirm:async()=>{if(!Q.request)return;const e=Q.request,t=e.metadata.name;pe(e=>new Set(e).add(t)),G(t);try{if(!(await l.fetch(`${d}/api/kuadrant/requests/${e.metadata.namespace}/${e.metadata.name}`,{method:"DELETE"})).ok)throw new Error("Failed to delete request");J(e=>e+1),c.post({message:"API key deleted",severity:"success",display:"transient"}),ee({open:!1,request:null})}catch(e){console.error("Error deleting request:",e),pe(e=>{const n=new Set(e);return n.delete(t),n}),c.post({message:"Failed to delete API key",severity:"error",display:"transient"})}finally{G(null)}},onCancel:()=>{ee({open:!1,request:null})}}),(0,a.jsxs)(I.A,{open:oe,onClose:()=>{le(!1),de(null)},maxWidth:"sm",children:[(0,a.jsx)(R.A,{children:(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)(E.A,{color:"primary",style:{marginRight:8}}),"View API Key"]})}),(0,a.jsxs)($.A,{children:[(0,a.jsxs)(b.A,{variant:"body1",paragraph:!0,children:["This API key can only be viewed ",(0,a.jsx)("strong",{children:"once"}),". After you reveal it, you will not be able to retrieve it again."]}),(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"Make sure to copy and store it securely before closing this view."})]}),(0,a.jsxs)(z.A,{children:[(0,a.jsx)(T.A,{onClick:()=>{le(!1),de(null)},children:"Cancel"}),(0,a.jsx)(T.A,{variant:"contained",color:"primary",onClick:()=>{ce&&((async(e,t)=>{const n=`${e}/${t}`;if(!ae.has(n)){se(e=>new Set(e).add(n));try{const a=await l.fetch(`${d}/api/kuadrant/apikeys/${e}/${t}/secret`);if(a.ok){const e=await a.json();ne(t=>new Map(t).set(n,e.apiKey)),ie(e=>new Set(e).add(n))}else 403===a.status&&(ie(e=>new Set(e).add(n)),c.post({message:"This API key has already been viewed and cannot be retrieved again.",severity:"warning",display:"transient"}))}catch(e){const t=e instanceof Error?e.message:"unknown error occurred";c.post({message:`Failed to fetch api key: ${t}`,severity:"error",display:"transient"})}finally{se(e=>{const t=new Set(e);return t.delete(n),t})}}})(ce.namespace,ce.name),ye(ce.name)),le(!1),de(null)},children:"Reveal API Key"})]})]})]})};var H=n(35015),V=n(34955),Y=n(46205),Z=n(16249),J=n(55429),X=n(92399);const G=(0,y.A)(e=>({container:{display:"flex",height:"100%",minHeight:400},tableContainer:{flex:1,overflow:"auto",padding:10},useCasePanel:{padding:e.spacing(2),backgroundColor:e.palette.background.default},useCaseLabel:{fontWeight:600,marginBottom:e.spacing(1),color:e.palette.text.secondary,textTransform:"uppercase",fontSize:"0.75rem"},bulkActions:{padding:e.spacing(2),backgroundColor:e.palette.background.default,borderBottom:`1px solid ${e.palette.divider}`,display:"flex",alignItems:"center",justifyContent:"space-between"}})),Q=({open:e,request:t,action:n,processing:s,onClose:o,onConfirm:l})=>{var c,d;const[u,p]=r().useState(""),m="approve"===n?"Approve":"Reject",h="approve"===n?"Approving...":"Rejecting...",v="reject"===n,g=(null==t||null===(c=t.spec.requestedBy)||void 0===c?void 0:c.userId)||"",f=!v||u===g;return r().useEffect(()=>{e||p("")},[e]),(0,a.jsxs)(I.A,{open:e,onClose:s?void 0:o,maxWidth:"sm",fullWidth:!0,children:[(0,a.jsx)(R.A,{children:v?(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,a.jsx)(X.A,{color:"error"}),(0,a.jsxs)("span",{children:[m," API Key"]})]}):(0,a.jsxs)("span",{children:[m," API Key"]})}),(0,a.jsx)($.A,{children:t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"User:"})," ",t.spec.requestedBy.userId]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"API:"})," ",(null===(d=t.spec.apiProductRef)||void 0===d?void 0:d.name)||"unknown"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Tier:"})," ",t.spec.planTier]}),(0,a.jsxs)(i.A,{mb:2,children:[(0,a.jsx)(b.A,{variant:"body2",component:"span",style:{fontWeight:"bold"},children:"Use Case:"})," ",(0,a.jsx)(b.A,{variant:"body2",component:"span",style:{whiteSpace:"pre-wrap"},children:t.spec.useCase||"-"})]}),v&&(0,a.jsxs)(i.A,{mt:2,children:[(0,a.jsxs)(b.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Type ",(0,a.jsx)("strong",{children:g})," to confirm rejection:"]}),(0,a.jsx)(Z.A,{fullWidth:!0,variant:"outlined",size:"small",value:u,onChange:e=>p(e.target.value),disabled:s,autoFocus:!0,placeholder:g})]})]})}),(0,a.jsxs)(z.A,{children:[(0,a.jsx)(T.A,{onClick:o,disabled:s,children:"Cancel"}),(0,a.jsx)(T.A,{onClick:l,color:"approve"===n?"primary":"secondary",variant:"contained",disabled:s||!f,startIcon:s?(0,a.jsx)(S.A,{size:16,color:"inherit"}):void 0,children:s?h:m})]})]})},ee=({open:e,requests:t,action:n,processing:s,onClose:r,onConfirm:o})=>{const l="approve"===n,c=l?"Approve All":"Reject All",d=l?"Approving...":"Rejecting...";return(0,a.jsxs)(I.A,{open:e,onClose:s?void 0:r,maxWidth:"md",fullWidth:!0,children:[(0,a.jsxs)(R.A,{children:[l?"Approve":"Reject"," ",t.length," API Keys"]}),(0,a.jsxs)($.A,{children:[(0,a.jsxs)(b.A,{variant:"body2",paragraph:!0,children:["You are about to ",l?"approve":"reject"," the following API keys:"]}),(0,a.jsx)(i.A,{mb:2,maxHeight:200,overflow:"auto",children:t.map(e=>{var t;return(0,a.jsx)(i.A,{mb:1,p:1,bgcolor:"background.default",children:(0,a.jsxs)(b.A,{variant:"body2",children:[(0,a.jsx)("strong",{children:e.spec.requestedBy.userId})," -"," ",(null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name)||"unknown"," (",e.spec.planTier,")"]})},`${e.metadata.namespace}/${e.metadata.name}`)})})]}),(0,a.jsxs)(z.A,{children:[(0,a.jsx)(T.A,{onClick:r,disabled:s,children:"Cancel"}),(0,a.jsx)(T.A,{onClick:o,color:l?"primary":"secondary",variant:"contained",disabled:s,startIcon:s?(0,a.jsx)(S.A,{size:16,color:"inherit"}):void 0,children:s?d:c})]})]})},te=({request:e})=>{const t=G();return(0,a.jsxs)(i.A,{className:t.useCasePanel,onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(b.A,{className:t.useCaseLabel,children:"Use Case"}),(0,a.jsx)(b.A,{variant:"body2",children:e.spec.useCase||"No use case provided"})]})},ne=()=>{var e;const t=G(),n=(0,x.useApi)(x.configApiRef),r=(0,x.useApi)(x.fetchApiRef),o=(0,x.useApi)(x.identityApiRef),l=(0,x.useApi)(x.alertApiRef),c=n.getString("backend.baseUrl"),[d,u]=(0,s.useState)(0),[p,m]=(0,s.useState)([]),[h,j]=(0,s.useState)({open:!1,request:null,action:"approve",processing:!1}),[y,w]=(0,s.useState)({open:!1,requests:[],action:"approve",processing:!1}),[P,S]=(0,s.useState)({status:[],apiProduct:[],tier:[]}),{allowed:C,loading:q,error:I}=(0,Y.l)(V.z4),{allowed:R,loading:$,error:z}=(0,Y.l)(V.q0),B=q||$,N=I||z,{value:M,loading:E,error:_}=(0,H.A)(async()=>{const e=(await o.getBackstageIdentity()).userEntityRef,[t,n]=await Promise.all([r.fetch(`${c}/api/kuadrant/requests`),r.fetch(`${c}/api/kuadrant/apiproducts`)]);if(!t.ok)return{allRequests:[],reviewedBy:e,ownedApiProducts:new Set};const a=t.headers.get("content-type");if(!(null==a?void 0:a.includes("application/json")))return l.post({message:"Unexpected content-type from the server response.",display:"transient",severity:"warning"}),{allRequests:[],reviewedBy:e,ownedApiProducts:new Set};const s=(await t.json()).items||[],i=new Set;if(n.ok){const t=await n.json();for(const n of t.items||[]){var d,u;(null===(u=n.metadata)||void 0===u||null===(d=u.annotations)||void 0===d?void 0:d["backstage.io/owner"])===e&&i.add(`${n.metadata.namespace}/${n.metadata.name}`)}}return{allRequests:s,reviewedBy:e,ownedApiProducts:i}},[c,r,o,d]),L=(0,s.useMemo)(()=>{if(!(null==M?void 0:M.allRequests))return[];const e={Approved:0,Pending:0,Rejected:0},t=new Map,n=new Map;return M.allRequests.forEach(a=>{var s,r;const i=(null===(s=a.status)||void 0===s?void 0:s.phase)||"Pending";e[i]++;const o=(null===(r=a.spec.apiProductRef)||void 0===r?void 0:r.name)||"unknown";t.set(o,(t.get(o)||0)+1);const l=a.spec.planTier||"unknown";n.set(l,(n.get(l)||0)+1)}),[{id:"status",title:"Status",options:[{value:"Pending",label:"Pending",count:e.Pending},{value:"Approved",label:"Approved",count:e.Approved},{value:"Rejected",label:"Rejected",count:e.Rejected}]},{id:"apiProduct",title:"API Product",options:Array.from(t.entries()).map(([e,t])=>({value:e,label:e,count:t})),collapsed:t.size>5},{id:"tier",title:"Tier",options:Array.from(n.entries()).map(([e,t])=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1),count:t}))}]},[null==M?void 0:M.allRequests]),F=(0,s.useMemo)(()=>(null==M?void 0:M.allRequests)?M.allRequests.filter(e=>{if(P.status.length>0){var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending";if(!P.status.includes(n))return!1}if(P.apiProduct.length>0){var n;const t=(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown";if(!P.apiProduct.includes(t))return!1}if(P.tier.length>0){const t=e.spec.planTier||"unknown";if(!P.tier.includes(t))return!1}return!0}):[],[null==M?void 0:M.allRequests,P]),W=e=>new Date(e).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric"}),K=[{title:"Requester",field:"spec.requestedBy.userId",render:e=>(0,a.jsx)(b.A,{variant:"body2",children:e.spec.requestedBy.userId})},{title:"API Product",field:"spec.apiProductRef.name",render:e=>{var t;const n=(null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name)||"unknown";return(0,a.jsx)(v.N_,{to:`/catalog/default/api/${n}`,children:(0,a.jsx)("strong",{children:n})})}},{title:"Status",field:"status.phase",render:e=>{var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending";return(0,a.jsx)(k.A,{label:n,size:"small",style:(0,D.S)(n)})}},{title:"Tier",field:"spec.planTier",render:e=>(0,a.jsx)(k.A,{label:e.spec.planTier,size:"small",variant:"outlined"})},{title:"Requested",field:"metadata.creationTimestamp",render:e=>(0,a.jsx)(b.A,{variant:"body2",children:e.metadata.creationTimestamp?W(e.metadata.creationTimestamp):"-"})},{title:"Reviewed By",field:"status.reviewedBy",render:e=>{var t;if(!(null===(t=e.status)||void 0===t?void 0:t.reviewedBy))return(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"-"});const n=e.status.reviewedBy.replace(/^user:default\//,""),s="system"===n;return(0,a.jsxs)(i.A,{children:[(0,a.jsx)(b.A,{variant:"body2",children:s?"Automatic":n}),e.status.reviewedAt&&(0,a.jsx)(b.A,{variant:"caption",color:"textSecondary",children:W(e.status.reviewedAt)})]})}},{title:"Actions",filtering:!1,render:e=>{var t,n,s;if("Pending"!==((null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending"))return null;const r=`${e.metadata.namespace}/${(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown"}`;var o;const l=null!==(o=null==M||null===(s=M.ownedApiProducts)||void 0===s?void 0:s.has(r))&&void 0!==o&&o;return C||R&&l?(0,a.jsxs)(i.A,{display:"flex",style:{gap:8},children:[(0,a.jsx)(T.A,{size:"small",startIcon:(0,a.jsx)(J.A,{}),onClick:()=>{j({open:!0,request:e,action:"approve",processing:!1})},color:"primary",variant:"outlined",children:"Approve"}),(0,a.jsx)(T.A,{size:"small",startIcon:(0,a.jsx)(X.A,{}),onClick:()=>{j({open:!0,request:e,action:"reject",processing:!1})},color:"secondary",variant:"outlined",children:"Reject"})]}):null}}],U=(0,s.useMemo)(()=>[{render:e=>{var t;const n=e.rowData;return(null==n||null===(t=n.metadata)||void 0===t?void 0:t.name)?(0,a.jsx)(te,{request:n}):(0,a.jsx)(i.A,{})}}],[]);if(E||B)return(0,a.jsx)(g.k,{});if(_)return(0,a.jsx)(f._,{error:_});if(N)return(0,a.jsx)(i.A,{p:2,children:(0,a.jsxs)(b.A,{color:"error",children:["Unable to check permissions: ",N.message]})});const Z=C||R;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i.A,{className:t.container,children:[(0,a.jsx)(O.Z,{sections:L,filters:P,onChange:S}),(0,a.jsxs)(i.A,{className:t.tableContainer,children:[p.length>0&&(0,a.jsxs)(i.A,{className:t.bulkActions,children:[(0,a.jsxs)(b.A,{variant:"body2",children:[p.length," request",1!==p.length?"s":""," selected"]}),(0,a.jsxs)(i.A,{display:"flex",style:{gap:8},children:[(0,a.jsx)(T.A,{size:"small",variant:"contained",color:"primary",startIcon:(0,a.jsx)(J.A,{}),onClick:()=>{0!==p.length&&w({open:!0,requests:p,action:"approve",processing:!1})},children:"Approve Selected"}),(0,a.jsx)(T.A,{size:"small",variant:"contained",color:"secondary",startIcon:(0,a.jsx)(X.A,{}),onClick:()=>{0!==p.length&&w({open:!0,requests:p,action:"reject",processing:!1})},children:"Reject Selected"})]})]}),0===F.length?(0,a.jsx)(i.A,{p:4,textAlign:"center",children:(0,a.jsx)(b.A,{variant:"body1",color:"textSecondary",children:0===(null==M||null===(e=M.allRequests)||void 0===e?void 0:e.length)?"No API keys found.":"No API keys match the selected filters."})}):(0,a.jsx)(A.X,{options:{selection:Z,showSelectAllCheckbox:F.some(e=>{var t;return!(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending"===e.status.phase}),selectionProps:e=>{var t,n;return{disabled:"Pending"!==(null===(t=e.status)||void 0===t?void 0:t.phase)&&void 0!==(null===(n=e.status)||void 0===n?void 0:n.phase)}},paging:F.length>10,pageSize:20,search:!0,filtering:!1,debounceInterval:300,showTextRowsSelected:!1,toolbar:!0,emptyRowsWhenPaging:!1},columns:K,data:F.map(e=>{const t=p.some(t=>t.metadata.name===e.metadata.name&&t.metadata.namespace===e.metadata.namespace);return{...e,id:e.metadata.name,tableData:{checked:t}}}),onSelectionChange:e=>{const t=e.filter(e=>{var t;return!(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending"===e.status.phase});m(t)},detailPanel:U})]})]}),(0,a.jsx)(Q,{open:h.open,request:h.request,action:h.action,processing:h.processing,onClose:()=>j({open:!1,request:null,action:"approve",processing:!1}),onConfirm:async()=>{if(!h.request||!M)return;j(e=>({...e,processing:!0}));const e="approve"===h.action?`${c}/api/kuadrant/requests/${h.request.metadata.namespace}/${h.request.metadata.name}/approve`:`${c}/api/kuadrant/requests/${h.request.metadata.namespace}/${h.request.metadata.name}/reject`;try{if(!(await r.fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewedBy:M.reviewedBy})})).ok)throw new Error(`failed to ${h.action} request`);j({open:!1,request:null,action:"approve",processing:!1}),m(e=>e.filter(e=>{var t,n;return e.metadata.name!==(null===(t=h.request)||void 0===t?void 0:t.metadata.name)||e.metadata.namespace!==(null===(n=h.request)||void 0===n?void 0:n.metadata.namespace)})),u(e=>e+1);const t="approve"===h.action?"approved":"rejected";l.post({message:`API key ${t}`,severity:"success",display:"transient"})}catch(e){console.error(`error ${h.action}ing request:`,e),j(e=>({...e,processing:!1})),l.post({message:`Failed to ${h.action} API key`,severity:"error",display:"transient"})}}}),(0,a.jsx)(ee,{open:y.open,requests:y.requests,action:y.action,processing:y.processing,onClose:()=>w({open:!1,requests:[],action:"approve",processing:!1}),onConfirm:async()=>{if(!M||0===y.requests.length)return;w(e=>({...e,processing:!0}));const e="approve"===y.action,t=e?`${c}/api/kuadrant/requests/bulk-approve`:`${c}/api/kuadrant/requests/bulk-reject`;try{if(!(await r.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requests:y.requests.map(e=>({namespace:e.metadata.namespace,name:e.metadata.name})),reviewedBy:M.reviewedBy})})).ok)throw new Error(`failed to bulk ${y.action} requests`);const n=y.requests.length,a=e?"approved":"rejected";w({open:!1,requests:[],action:"approve",processing:!1}),m([]),u(e=>e+1),l.post({message:`${n} API keys ${a}`,severity:"success",display:"transient"})}catch(e){console.error(`error bulk ${y.action}ing requests:`,e),w(e=>({...e,processing:!1})),l.post({message:`Failed to bulk ${y.action} API keys`,severity:"error",display:"transient"})}}})]})},ae=()=>{const[e,t]=(0,s.useState)(0),{allowed:n,loading:r}=(0,Y.l)(V.KV);return(0,a.jsxs)(c.Y,{themeId:"tool",children:[(0,a.jsx)(d.Y,{title:"API Keys",subtitle:"API keys management for Kubernetes",children:(0,a.jsx)(u.Y,{children:"Manage your API keys and access requests"})}),(0,a.jsxs)(p.U,{children:[(0,a.jsx)(i.A,{mb:2,children:(0,a.jsxs)(o.A,{value:e,onChange:(e,n)=>{t(n)},indicatorColor:"primary",textColor:"primary",children:[(0,a.jsx)(l.A,{label:"My API keys","data-testid":"my-api-keys-tab"}),!r&&n&&(0,a.jsx)(l.A,{label:"API keys approval","data-testid":"api-keys-approval-tab"})]})}),0===e&&(0,a.jsx)(U,{}),1===e&&n&&(0,a.jsx)(ne,{})]})]})},se=()=>(0,a.jsx)(m.B,{permission:V.DS,errorMessage:"you don't have permission to view the API Keys page",children:(0,a.jsx)(ae,{})})},23164:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");t.A=i},27799:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M21 5v6.59l-3-3.01-4 4.01-4-4-4 4-3-3.01V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42l3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l3 2.99 4-4 4 4 4-3.99z"}),"BrokenImage");t.A=i},38599:(e,t,n)=>{n.d(t,{B:()=>l});var a=n(31085),s=(n(95478),n(10394)),r=n(72501),i=n(86687),o=n(46205);const l=({children:e,permission:t,fallback:n,errorMessage:l})=>{const{allowed:c,loading:d,error:u}=(0,o.l)(t);return d?(0,a.jsx)(i.k,{}):u?(0,a.jsxs)(s.A,{p:4,children:[(0,a.jsxs)(r.A,{color:"error",children:["Unable to check permissions: ",u.message]}),(0,a.jsx)(r.A,{variant:"body2",color:"textSecondary",children:"Please try again or contact your administrator"})]}):c?(0,a.jsx)(a.Fragment,{children:e}):n?(0,a.jsx)(a.Fragment,{children:n}):(0,a.jsxs)(s.A,{p:4,children:[(0,a.jsx)(r.A,{color:"textSecondary",children:l||"You don't have permission to view this page"}),(0,a.jsx)(s.A,{mt:1,children:(0,a.jsxs)(r.A,{variant:"caption",color:"textSecondary",children:["Required permission: ",t.name]})})]})}},39590:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");t.A=i},45210:(e,t,n)=>{n.d(t,{Y:()=>I});var a=n(31085),s=n(22097),r=n(10394),i=n(64947),o=n(93453),l=n(29365),c=n(46423),d=n(5951),u=n(26343),p=n(28233),m=n(55197),h=n(37976),v=n(72501),g=n(5893),f=n(95478),A=(n(45250),n(42469),n(16098)),x=n(67550);const j=()=>{const{t:e}=(0,x.i)(A.O);return{url:"https://github.com/backstage/backstage/issues",items:[{title:e("supportConfig.default.title"),icon:"warning",links:[{title:e("supportConfig.default.linkTitle"),url:"https://github.com/backstage/backstage/blob/master/app-config.yaml"}]}]}};var y=n(27799);function b(e){const{id:t,Fallback:n=y.A,...r}=e,i=(0,s.useApp)().getSystemIcon(t)??n;return(0,a.jsx)(i,{...r})}function k(e){return(0,a.jsx)(b,{id:"help",...e})}var w=n(37725);const P=(0,h.makeStyles)({popoverList:{minWidth:260,maxWidth:400},menuItem:{whiteSpace:"normal"}},{name:"BackstageSupportButton"}),S=({icon:e})=>{const t=(0,s.useApp)(),n=e?t.getSystemIcon(e)??k:k;return(0,a.jsx)(n,{})},C=({link:e})=>(0,a.jsx)(w.N_,{to:e.url,children:e.title??e.url}),q=({item:e})=>(0,a.jsxs)(u.A,{button:!1,children:[(0,a.jsx)(c.A,{children:(0,a.jsx)(S,{icon:e.icon})}),(0,a.jsx)(d.A,{primary:e.title,secondary:e.links?.reduce((e,t,n)=>[...e,n>0&&(0,a.jsx)("br",{},n),(0,a.jsx)(C,{link:t},t.url)],[])})]});function I(e){const{t}=(0,x.i)(A.O),{title:n,items:c,children:d}=e,{items:h}=function(){const e=(0,s.useApiHolder)().get(s.configApiRef),t=e?.getOptionalConfig("app.support"),n=j();return t?{url:t.getString("url"),items:t.getConfigArray("items").flatMap(e=>({title:e.getString("title"),icon:e.getOptionalString("icon"),links:(e.getOptionalConfigArray("links")??[]).flatMap(e=>({url:e.getString("url"),title:e.getOptionalString("title")??""}))}))}:n}(),[y,b]=(0,f.useState)(!1),[w,S]=(0,f.useState)(null),C=P(),I=(0,s.useApi)(s.configApiRef).getOptionalConfig("app.support"),R=(0,g.A)(e=>e.breakpoints.down("sm")),$=e=>{S(e.currentTarget),b(!0)},z=()=>{b(!1)};return I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.A,{display:"flex",ml:1,children:R?(0,a.jsx)(l.A,{color:"primary",size:"small",onClick:$,"data-testid":"support-button","aria-label":"Support",children:(0,a.jsx)(k,{})}):(0,a.jsx)(i.A,{"data-testid":"support-button","aria-label":"Support",color:"primary",onClick:$,startIcon:(0,a.jsx)(k,{}),children:t("supportButton.title")})}),(0,a.jsxs)(m.Ay,{"data-testid":"support-button-popover",open:y,anchorEl:w,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},onClose:z,children:[(0,a.jsxs)(p.A,{className:C.popoverList,autoFocusItem:Boolean(w),children:[n&&(0,a.jsx)(u.A,{button:!1,alignItems:"flex-start",className:C.menuItem,children:(0,a.jsx)(v.A,{variant:"subtitle1",children:n})}),f.Children.map(d,(e,t)=>(0,a.jsx)(u.A,{button:!1,alignItems:"flex-start",className:C.menuItem,children:e},`child-${t}`)),(c??h).map((e,t)=>(0,a.jsx)(q,{item:e},`item-${t}`))]}),(0,a.jsx)(o.A,{children:(0,a.jsx)(i.A,{color:"primary",onClick:z,"aria-label":"Close",children:t("supportButton.close")})})]})]}):null}},46299:(e,t,n)=>{n.d(t,{S:()=>a});const a=e=>{const t={border:"none"};switch(e){case"Approved":return{...t,backgroundColor:"#4caf50",color:"#fff"};case"Rejected":return{...t,backgroundColor:"#f44336",color:"#fff"};default:return{...t,backgroundColor:"#ff9800",color:"#fff"}}}},55429:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckCircle");t.A=i},91638:(e,t,n)=>{var a=n(85608),s=n(95478),r=a.__importDefault(n(5030));t.A=function(e,t){void 0===t&&(t=[]);var n=r.default(e,t,{loading:!0}),a=n[0],i=n[1];return s.useEffect(function(){i()},[i]),a}}}]);
2
- //# sourceMappingURL=4682.6959fcd1.chunk.js.map
1
+ "use strict";(self.webpackChunkinternal_plugin_kuadrant=self.webpackChunkinternal_plugin_kuadrant||[]).push([[4682],{5030:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a=n(85608),s=n(95478),r=a.__importDefault(n(10009));t.default=function(e,t,n){void 0===t&&(t=[]),void 0===n&&(n={loading:!1});var i=s.useRef(0),o=r.default(),l=s.useState(n),c=l[0],d=l[1],u=s.useCallback(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var s=++i.current;return c.loading||d(function(e){return a.__assign(a.__assign({},e),{loading:!0})}),e.apply(void 0,t).then(function(e){return o()&&s===i.current&&d({value:e,loading:!1}),e},function(e){return o()&&s===i.current&&d({error:e,loading:!1}),e})},t);return[c,u]}},10009:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a=n(95478);t.default=function(){var e=a.useRef(!1),t=a.useCallback(function(){return e.current},[]);return a.useEffect(function(){return e.current=!0,function(){e.current=!1}},[]),t}},12229:(e,t,n)=>{n.d(t,{Z:()=>A});var a=n(31085),s=n(95478),r=n.n(s),i=n(10394),o=n(72501),l=n(64947),c=n(37197),d=n(69621),u=n(12981),p=n(86901),m=n(69076),h=n(58837),v=n(6924),g=n(23164);const f=(0,h.A)(e=>({root:{width:240,minWidth:240,padding:e.spacing(2),borderRight:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.background.paper,height:"100%",overflowY:"auto"},sectionTitle:{fontWeight:600,fontSize:"0.75rem",textTransform:"uppercase",letterSpacing:"0.05em",color:e.palette.text.secondary,marginBottom:e.spacing(1),display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",userSelect:"none"},filterSection:{marginBottom:e.spacing(2)},checkbox:{padding:e.spacing(.5)},checkboxLabel:{fontSize:"0.875rem"},clearButton:{marginTop:e.spacing(2)},count:{fontSize:"0.75rem",color:e.palette.text.secondary,marginLeft:e.spacing(1)}})),A=({sections:e,filters:t,onChange:n,onClear:s})=>{const h=f(),[A,x]=r().useState(new Set(e.filter(e=>e.collapsed).map(e=>e.id))),j=Object.values(t).some(e=>e.length>0);return(0,a.jsxs)(i.A,{className:h.root,children:[(0,a.jsxs)(i.A,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[(0,a.jsx)(o.A,{variant:"subtitle2",children:"Filters"}),j&&(0,a.jsx)(l.A,{size:"small",color:"primary",onClick:()=>{const t={};e.forEach(e=>{t[e.id]=[]}),n(t),null==s||s()},children:"Clear all"})]}),(0,a.jsx)(c.A,{}),e.map(e=>{const s=A.has(e.id),r=(t[e.id]||[]).length;return(0,a.jsxs)(i.A,{className:h.filterSection,mt:2,children:[(0,a.jsxs)(i.A,{className:h.sectionTitle,onClick:()=>{return t=e.id,void x(e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t},children:[(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)("span",{children:e.title}),r>0&&(0,a.jsxs)("span",{className:h.count,children:["(",r,")"]})]}),s?(0,a.jsx)(v.A,{fontSize:"small"}):(0,a.jsx)(g.A,{fontSize:"small"})]}),(0,a.jsx)(d.A,{in:!s,children:(0,a.jsx)(u.A,{children:e.options.map(s=>(0,a.jsx)(p.A,{control:(0,a.jsx)(m.A,{checked:(t[e.id]||[]).includes(s.value),onChange:()=>((e,a)=>{const s=t[e]||[],r=s.includes(a)?s.filter(e=>e!==a):[...s,a];n({...t,[e]:r})})(e.id,s.value),size:"small",className:h.checkbox,color:"primary"}),label:(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)("span",{className:h.checkboxLabel,children:s.label}),void 0!==s.count&&(0,a.jsxs)("span",{className:h.count,children:["(",s.count,")"]})]})},s.value))})})]},e.id)})]})}},14682:(e,t,n)=>{n.r(t),n.d(t,{ApiKeysPage:()=>se});var a=n(31085),s=n(95478),r=n.n(s),i=n(10394),o=n(31653),l=n(38605),c=n(289),d=n(15831),u=n(45210),p=n(46681),m=n(38599),h=n(49634),v=n(37725),g=n(86687),f=n(42367),A=n(25010),x=n(22097),j=n(91638),y=n(58837),b=n(72501),k=n(67720),w=n(71677),P=n(29365),S=n(78467),C=n(37757),q=n(26343),I=n(76891),R=n(61477),$=n(46805),z=n(93453),T=n(64947),B=n(32269),N=n(61524),M=n(99594),E=n(77225),_=n(39590),L=n(16397),F=n(63221),O=n(12229),D=n(46299);const W=(0,y.A)(e=>({container:{display:"flex",height:"100%",minHeight:400},tableContainer:{flex:1,overflow:"auto",padding:10},useCasePanel:{padding:e.spacing(2),backgroundColor:e.palette.background.default},useCaseLabel:{fontWeight:600,marginBottom:e.spacing(1),color:e.palette.text.secondary,textTransform:"uppercase",fontSize:"0.75rem"},rejectedBanner:{backgroundColor:e.palette.error.light,border:`1px solid ${e.palette.error.main}`,borderRadius:e.shape.borderRadius,padding:e.spacing(1.5,2),marginBottom:e.spacing(2),display:"flex",alignItems:"center",gap:e.spacing(1)}})),K=({request:e})=>{var t,n;const s=W(),r="Rejected"===(null===(t=e.status)||void 0===t?void 0:t.phase),o=(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown";return(0,a.jsxs)(i.A,{className:s.useCasePanel,onClick:e=>e.stopPropagation(),children:[r&&(0,a.jsxs)(i.A,{className:s.rejectedBanner,children:[(0,a.jsx)(E.A,{color:"error",fontSize:"small"}),(0,a.jsxs)(b.A,{variant:"body2",children:["This API key was rejected."," ",(0,a.jsx)(v.N_,{to:`/catalog/default/api/${o}/api-keys`,children:"Request a new API key"})]})]}),(0,a.jsx)(b.A,{className:s.useCaseLabel,children:"Use Case"}),(0,a.jsx)(b.A,{variant:"body2",children:e.spec.useCase||"No use case provided"})]})},U=()=>{var e,t;const n=W(),r=(0,h.useNavigate)(),o=(0,x.useApi)(x.configApiRef),l=(0,x.useApi)(x.fetchApiRef),c=(0,x.useApi)(x.alertApiRef),d=o.getString("backend.baseUrl"),[u,p]=(0,s.useState)(new Set),[m,y]=(0,s.useState)(null),[U,H]=(0,s.useState)(null),[V,Y]=(0,s.useState)({open:!1,request:null,plans:[]}),[Z,J]=(0,s.useState)(0),[X,G]=(0,s.useState)(null),[Q,ee]=(0,s.useState)({open:!1,request:null}),[te,ne]=(0,s.useState)(new Map),[ae,se]=(0,s.useState)(new Set),[re,ie]=(0,s.useState)(new Set),[oe,le]=(0,s.useState)(!1),[ce,de]=(0,s.useState)(null),[ue,pe]=(0,s.useState)(new Set),[me,he]=(0,s.useState)({status:[],apiProduct:[],tier:[]}),{value:ve,loading:ge,error:fe}=(0,j.A)(async()=>{const[e,t]=await Promise.all([l.fetch(`${d}/api/kuadrant/requests/my`),l.fetch(`${d}/api/kuadrant/apiproducts`)]);if(!e.ok)throw new Error("failed to fetch requests");const n=(await e.json()).items||[];let a=[];t.ok&&(a=(await t.json()).items||[]);const s=new Map;return a.forEach(e=>{var t;const n=`${e.metadata.namespace}/${e.metadata.name}`,a=(null===(t=e.metadata.annotations)||void 0===t?void 0:t["backstage.io/owner"])||"unknown";s.set(n,a)}),{requests:n,products:a,ownerMap:s}},[d,l,Z]),Ae=(0,s.useMemo)(()=>(null==ve?void 0:ve.requests)?ve.requests.filter(e=>!ue.has(e.metadata.name)):[],[null==ve?void 0:ve.requests,ue]),xe=(0,s.useMemo)(()=>{const e={Approved:0,Pending:0,Rejected:0},t=new Map,n=new Map;return Ae.forEach(a=>{var s,r;const i=(null===(s=a.status)||void 0===s?void 0:s.phase)||"Pending";e[i]++;const o=(null===(r=a.spec.apiProductRef)||void 0===r?void 0:r.name)||"unknown";t.set(o,(t.get(o)||0)+1);const l=a.spec.planTier||"unknown";n.set(l,(n.get(l)||0)+1)}),[{id:"status",title:"Status",options:[{value:"Approved",label:"Active",count:e.Approved},{value:"Pending",label:"Pending",count:e.Pending},{value:"Rejected",label:"Rejected",count:e.Rejected}]},{id:"apiProduct",title:"API Product",options:Array.from(t.entries()).map(([e,t])=>({value:e,label:e,count:t})),collapsed:t.size>5},{id:"tier",title:"Tier",options:Array.from(n.entries()).map(([e,t])=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1),count:t}))}]},[Ae]),je=(0,s.useMemo)(()=>Ae.filter(e=>{if(me.status.length>0){var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending";if(!me.status.includes(n))return!1}if(me.apiProduct.length>0){var n;const t=(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown";if(!me.apiProduct.includes(t))return!1}if(me.tier.length>0){const t=e.spec.planTier||"unknown";if(!me.tier.includes(t))return!1}return!0}),[Ae,me]),ye=e=>{p(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},be=()=>{y(null),H(null)},ke=async()=>{if(!U)return;const e=U;be();try{var t;const a=null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name,s=e.metadata.namespace,r=await l.fetch(`${d}/api/kuadrant/apiproducts/${s}/${a}`);if(r.ok){var n;const t=(null===(n=(await r.json()).spec)||void 0===n?void 0:n.plans)||[];Y({open:!0,request:e,plans:t})}else Y({open:!0,request:e,plans:[]})}catch(t){console.error("Error fetching plans:",t),Y({open:!0,request:e,plans:[]})}},we=()=>{if(!U)return;const e=U;be(),ee({open:!0,request:e})},Pe=[{title:"API Product",field:"spec.apiProductRef.name",render:e=>{var t;const n=(null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name)||"unknown";return(0,a.jsx)(v.N_,{to:`/catalog/default/api/${n}/api-keys`,children:(0,a.jsx)("strong",{children:n})})}},{title:"Owner",field:"owner",render:e=>{var t,n;const s=`${e.metadata.namespace}/${null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name}`,r=((null==ve||null===(n=ve.ownerMap)||void 0===n?void 0:n.get(s))||"unknown").replace(/^user:default\//,"");return(0,a.jsx)(b.A,{variant:"body2",children:r})}},{title:"Status",field:"status.phase",render:e=>{var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending",s="Approved"===n?"Active":n;return(0,a.jsx)(k.A,{label:s,size:"small",style:(0,D.S)(n)})}},{title:"Tier",field:"spec.planTier",render:e=>(0,a.jsx)(k.A,{label:e.spec.planTier,size:"small",variant:"outlined"})},{title:"API Key",field:"status.secretRef",filtering:!1,render:e=>{var t,n,s,r;if("Approved"!==(null===(t=e.status)||void 0===t?void 0:t.phase))return(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"-"});const o=`${e.metadata.namespace}/${e.metadata.name}`,l=null===(s=e.status)||void 0===s||null===(n=s.secretRef)||void 0===n?void 0:n.name,d=u.has(e.metadata.name),p=ae.has(o),m=te.get(o),h=!1!==(null===(r=e.status)||void 0===r?void 0:r.canReadSecret),v=re.has(o)||!h;return l?v&&!m?(0,a.jsx)(w.Ay,{title:"This API key has already been viewed and cannot be retrieved again",children:(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",style:{fontFamily:"monospace",marginRight:8},children:"Already viewed"}),(0,a.jsx)(N.A,{fontSize:"small",color:"disabled"})]})}):(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,a.jsx)(i.A,{fontFamily:"monospace",fontSize:"0.875rem",children:p?"Loading...":d&&m?m:"•".repeat(20)+"..."}),d&&m&&(0,a.jsx)(w.Ay,{title:"Copy to clipboard",children:(0,a.jsx)(P.A,{size:"small",onClick:async()=>{m&&(await navigator.clipboard.writeText(m),c.post({message:"API key copied to clipboard",severity:"success",display:"transient"}))},children:(0,a.jsx)(M.A,{fontSize:"small"})})}),(0,a.jsx)(w.Ay,{title:d?"Hide API key":"Reveal API key (one-time only)",children:(0,a.jsx)("span",{children:(0,a.jsx)(P.A,{size:"small",onClick:()=>{d?(((e,t)=>{const n=`${e}/${t}`;ne(e=>{const t=new Map(e);return t.delete(n),t})})(e.metadata.namespace,e.metadata.name),ye(e.metadata.name)):v||(de({namespace:e.metadata.namespace,name:e.metadata.name}),le(!0))},disabled:p||v&&!m,children:d?(0,a.jsx)(N.A,{fontSize:"small"}):(0,a.jsx)(B.A,{fontSize:"small"})})})})]}):(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"Awaiting secret..."})}},{title:"Requested",field:"metadata.creationTimestamp",render:e=>{if(!e.metadata.creationTimestamp)return(0,a.jsx)(b.A,{variant:"body2",children:"-"});const t=new Date(e.metadata.creationTimestamp);return(0,a.jsx)(b.A,{variant:"body2",children:t.toLocaleDateString()})}},{title:"Actions",filtering:!1,width:"100px",render:e=>X===e.metadata.name?(0,a.jsx)(S.A,{size:20}):(0,a.jsxs)(i.A,{display:"flex",style:{gap:4},children:[(0,a.jsx)(w.Ay,{title:"View details",children:(0,a.jsx)(P.A,{size:"small",onClick:t=>{t.stopPropagation(),r(`/kuadrant/api-keys/${e.metadata.namespace}/${e.metadata.name}`)},children:(0,a.jsx)(B.A,{fontSize:"small"})})}),(0,a.jsx)(w.Ay,{title:"Delete",children:(0,a.jsx)(P.A,{size:"small",onClick:t=>{t.stopPropagation(),ee({open:!0,request:e})},children:(0,a.jsx)(_.A,{fontSize:"small"})})})]})}],Se=(0,s.useMemo)(()=>[{render:e=>{var t;const n=e.rowData;return(null==n||null===(t=n.metadata)||void 0===t?void 0:t.name)?(0,a.jsx)(K,{request:n}):(0,a.jsx)(i.A,{})}}],[]);return ge?(0,a.jsx)(g.k,{}):fe?(0,a.jsx)(f._,{error:fe}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i.A,{className:n.container,children:[(0,a.jsx)(O.Z,{sections:xe,filters:me,onChange:he}),(0,a.jsx)(i.A,{className:n.tableContainer,children:0===je.length?(0,a.jsx)(i.A,{p:4,textAlign:"center",children:(0,a.jsx)(b.A,{variant:"body1",color:"textSecondary",children:0===Ae.length?"No API keys found. Request access to an API to get started.":"No API keys match the selected filters."})}):(0,a.jsx)(A.X,{options:{paging:je.length>10,pageSize:20,search:!0,filtering:!1,debounceInterval:300,toolbar:!0,emptyRowsWhenPaging:!1},columns:Pe,data:je.map(e=>({...e,id:e.metadata.name})),detailPanel:Se})})]}),(0,a.jsx)(C.A,{id:"myapikeys-menu",open:Boolean(m),onClose:be,anchorReference:"anchorPosition",anchorPosition:m||{top:0,left:0},children:U&&(()=>{const e=[];var t;return e.push((0,a.jsx)(q.A,{onClick:()=>{r(`/kuadrant/api-keys/${U.metadata.namespace}/${U.metadata.name}`),be()},children:"View Details"},"view")),(t=U).status&&"Pending"!==t.status.phase||e.push((0,a.jsx)(q.A,{onClick:ke,children:"Edit"},"edit")),e.push((0,a.jsx)(q.A,{onClick:we,children:"Delete"},"delete")),e})()}),V.request&&(0,a.jsx)(L.e,{open:V.open,request:V.request,availablePlans:V.plans,onClose:()=>Y({open:!1,request:null,plans:[]}),onSuccess:()=>{Y({open:!1,request:null,plans:[]}),J(e=>e+1)}}),(0,a.jsx)(F.K,{open:Q.open,title:"Delete API Key",description:`Are you sure you want to delete this API key for ${(null===(t=Q.request)||void 0===t||null===(e=t.spec.apiProductRef)||void 0===e?void 0:e.name)||"this API"}?`,deleting:null!==X,onConfirm:async()=>{if(!Q.request)return;const e=Q.request,t=e.metadata.name;pe(e=>new Set(e).add(t)),G(t);try{if(!(await l.fetch(`${d}/api/kuadrant/requests/${e.metadata.namespace}/${e.metadata.name}`,{method:"DELETE"})).ok)throw new Error("Failed to delete request");J(e=>e+1),c.post({message:"API key deleted",severity:"success",display:"transient"}),ee({open:!1,request:null})}catch(e){console.error("Error deleting request:",e),pe(e=>{const n=new Set(e);return n.delete(t),n}),c.post({message:"Failed to delete API key",severity:"error",display:"transient"})}finally{G(null)}},onCancel:()=>{ee({open:!1,request:null})}}),(0,a.jsxs)(I.A,{open:oe,onClose:()=>{le(!1),de(null)},maxWidth:"sm",children:[(0,a.jsx)(R.A,{children:(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",children:[(0,a.jsx)(E.A,{color:"primary",style:{marginRight:8}}),"View API Key"]})}),(0,a.jsxs)($.A,{children:[(0,a.jsxs)(b.A,{variant:"body1",paragraph:!0,children:["This API key can only be viewed ",(0,a.jsx)("strong",{children:"once"}),". After you reveal it, you will not be able to retrieve it again."]}),(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"Make sure to copy and store it securely before closing this view."})]}),(0,a.jsxs)(z.A,{children:[(0,a.jsx)(T.A,{onClick:()=>{le(!1),de(null)},children:"Cancel"}),(0,a.jsx)(T.A,{variant:"contained",color:"primary",onClick:()=>{ce&&((async(e,t)=>{const n=`${e}/${t}`;if(!ae.has(n)){se(e=>new Set(e).add(n));try{const a=await l.fetch(`${d}/api/kuadrant/apikeys/${e}/${t}/secret`);if(a.ok){const e=await a.json();ne(t=>new Map(t).set(n,e.apiKey)),ie(e=>new Set(e).add(n))}else 403===a.status&&(ie(e=>new Set(e).add(n)),c.post({message:"This API key has already been viewed and cannot be retrieved again.",severity:"warning",display:"transient"}))}catch(e){const t=e instanceof Error?e.message:"unknown error occurred";c.post({message:`Failed to fetch api key: ${t}`,severity:"error",display:"transient"})}finally{se(e=>{const t=new Set(e);return t.delete(n),t})}}})(ce.namespace,ce.name),ye(ce.name)),le(!1),de(null)},children:"Reveal API Key"})]})]})]})};var H=n(35015),V=n(34955),Y=n(46205),Z=n(16249),J=n(55429),X=n(92399);const G=(0,y.A)(e=>({container:{display:"flex",height:"100%",minHeight:400},tableContainer:{flex:1,overflow:"auto",padding:10},useCasePanel:{padding:e.spacing(2),backgroundColor:e.palette.background.default},useCaseLabel:{fontWeight:600,marginBottom:e.spacing(1),color:e.palette.text.secondary,textTransform:"uppercase",fontSize:"0.75rem"},bulkActions:{padding:e.spacing(2),backgroundColor:e.palette.background.default,borderBottom:`1px solid ${e.palette.divider}`,display:"flex",alignItems:"center",justifyContent:"space-between"}})),Q=({open:e,request:t,action:n,processing:s,onClose:o,onConfirm:l})=>{var c,d;const[u,p]=r().useState(""),m="approve"===n?"Approve":"Reject",h="approve"===n?"Approving...":"Rejecting...",v="reject"===n,g=(null==t||null===(c=t.spec.requestedBy)||void 0===c?void 0:c.userId)||"",f=!v||u===g;return r().useEffect(()=>{e||p("")},[e]),(0,a.jsxs)(I.A,{open:e,onClose:s?void 0:o,maxWidth:"sm",fullWidth:!0,children:[(0,a.jsx)(R.A,{children:v?(0,a.jsxs)(i.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,a.jsx)(X.A,{color:"error"}),(0,a.jsxs)("span",{children:[m," API Key"]})]}):(0,a.jsxs)("span",{children:[m," API Key"]})}),(0,a.jsx)($.A,{children:t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"User:"})," ",t.spec.requestedBy.userId]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"API:"})," ",(null===(d=t.spec.apiProductRef)||void 0===d?void 0:d.name)||"unknown"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Tier:"})," ",t.spec.planTier]}),(0,a.jsxs)(i.A,{mb:2,children:[(0,a.jsx)(b.A,{variant:"body2",component:"span",style:{fontWeight:"bold"},children:"Use Case:"})," ",(0,a.jsx)(b.A,{variant:"body2",component:"span",style:{whiteSpace:"pre-wrap"},children:t.spec.useCase||"-"})]}),v&&(0,a.jsxs)(i.A,{mt:2,children:[(0,a.jsxs)(b.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Type ",(0,a.jsx)("strong",{children:g})," to confirm rejection:"]}),(0,a.jsx)(Z.A,{fullWidth:!0,variant:"outlined",size:"small",value:u,onChange:e=>p(e.target.value),disabled:s,autoFocus:!0,placeholder:g})]})]})}),(0,a.jsxs)(z.A,{children:[(0,a.jsx)(T.A,{onClick:o,disabled:s,children:"Cancel"}),(0,a.jsx)(T.A,{onClick:l,color:"approve"===n?"primary":"secondary",variant:"contained",disabled:s||!f,startIcon:s?(0,a.jsx)(S.A,{size:16,color:"inherit"}):void 0,children:s?h:m})]})]})},ee=({open:e,requests:t,action:n,processing:s,onClose:r,onConfirm:o})=>{const l="approve"===n,c=l?"Approve All":"Reject All",d=l?"Approving...":"Rejecting...";return(0,a.jsxs)(I.A,{open:e,onClose:s?void 0:r,maxWidth:"md",fullWidth:!0,children:[(0,a.jsxs)(R.A,{children:[l?"Approve":"Reject"," ",t.length," API Keys"]}),(0,a.jsxs)($.A,{children:[(0,a.jsxs)(b.A,{variant:"body2",paragraph:!0,children:["You are about to ",l?"approve":"reject"," the following API keys:"]}),(0,a.jsx)(i.A,{mb:2,maxHeight:200,overflow:"auto",children:t.map(e=>{var t;return(0,a.jsx)(i.A,{mb:1,p:1,bgcolor:"background.default",children:(0,a.jsxs)(b.A,{variant:"body2",children:[(0,a.jsx)("strong",{children:e.spec.requestedBy.userId})," -"," ",(null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name)||"unknown"," (",e.spec.planTier,")"]})},`${e.metadata.namespace}/${e.metadata.name}`)})})]}),(0,a.jsxs)(z.A,{children:[(0,a.jsx)(T.A,{onClick:r,disabled:s,children:"Cancel"}),(0,a.jsx)(T.A,{onClick:o,color:l?"primary":"secondary",variant:"contained",disabled:s,startIcon:s?(0,a.jsx)(S.A,{size:16,color:"inherit"}):void 0,children:s?d:c})]})]})},te=({request:e})=>{const t=G();return(0,a.jsxs)(i.A,{className:t.useCasePanel,onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(b.A,{className:t.useCaseLabel,children:"Use Case"}),(0,a.jsx)(b.A,{variant:"body2",children:e.spec.useCase||"No use case provided"})]})},ne=()=>{var e;const t=G(),n=(0,x.useApi)(x.configApiRef),r=(0,x.useApi)(x.fetchApiRef),o=(0,x.useApi)(x.identityApiRef),l=(0,x.useApi)(x.alertApiRef),c=n.getString("backend.baseUrl"),[d,u]=(0,s.useState)(0),[p,m]=(0,s.useState)([]),[h,j]=(0,s.useState)({open:!1,request:null,action:"approve",processing:!1}),[y,w]=(0,s.useState)({open:!1,requests:[],action:"approve",processing:!1}),[P,S]=(0,s.useState)({status:[],apiProduct:[],tier:[]}),{allowed:C,loading:q,error:I}=(0,Y.l)(V.z4),{allowed:R,loading:$,error:z}=(0,Y.l)(V.q0),B=q||$,N=I||z,{value:M,loading:E,error:_}=(0,H.A)(async()=>{const e=(await o.getBackstageIdentity()).userEntityRef,[t,n]=await Promise.all([r.fetch(`${c}/api/kuadrant/requests`),r.fetch(`${c}/api/kuadrant/apiproducts`)]);if(!t.ok)return{allRequests:[],reviewedBy:e,ownedApiProducts:new Set};const a=t.headers.get("content-type");if(!(null==a?void 0:a.includes("application/json")))return l.post({message:"Unexpected content-type from the server response.",display:"transient",severity:"warning"}),{allRequests:[],reviewedBy:e,ownedApiProducts:new Set};const s=(await t.json()).items||[],i=new Set;if(n.ok){const t=await n.json();for(const n of t.items||[]){var d,u;(null===(u=n.metadata)||void 0===u||null===(d=u.annotations)||void 0===d?void 0:d["backstage.io/owner"])===e&&i.add(`${n.metadata.namespace}/${n.metadata.name}`)}}return{allRequests:s,reviewedBy:e,ownedApiProducts:i}},[c,r,o,d]),L=(0,s.useMemo)(()=>{if(!(null==M?void 0:M.allRequests))return[];const e={Approved:0,Pending:0,Rejected:0},t=new Map,n=new Map;return M.allRequests.forEach(a=>{var s,r;const i=(null===(s=a.status)||void 0===s?void 0:s.phase)||"Pending";e[i]++;const o=(null===(r=a.spec.apiProductRef)||void 0===r?void 0:r.name)||"unknown";t.set(o,(t.get(o)||0)+1);const l=a.spec.planTier||"unknown";n.set(l,(n.get(l)||0)+1)}),[{id:"status",title:"Status",options:[{value:"Pending",label:"Pending",count:e.Pending},{value:"Approved",label:"Approved",count:e.Approved},{value:"Rejected",label:"Rejected",count:e.Rejected}]},{id:"apiProduct",title:"API Product",options:Array.from(t.entries()).map(([e,t])=>({value:e,label:e,count:t})),collapsed:t.size>5},{id:"tier",title:"Tier",options:Array.from(n.entries()).map(([e,t])=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1),count:t}))}]},[null==M?void 0:M.allRequests]),F=(0,s.useMemo)(()=>(null==M?void 0:M.allRequests)?M.allRequests.filter(e=>{if(P.status.length>0){var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending";if(!P.status.includes(n))return!1}if(P.apiProduct.length>0){var n;const t=(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown";if(!P.apiProduct.includes(t))return!1}if(P.tier.length>0){const t=e.spec.planTier||"unknown";if(!P.tier.includes(t))return!1}return!0}):[],[null==M?void 0:M.allRequests,P]),W=e=>new Date(e).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric"}),K=[{title:"Requester",field:"spec.requestedBy.userId",render:e=>(0,a.jsx)(b.A,{variant:"body2",children:e.spec.requestedBy.userId})},{title:"API Product",field:"spec.apiProductRef.name",render:e=>{var t;const n=(null===(t=e.spec.apiProductRef)||void 0===t?void 0:t.name)||"unknown";return(0,a.jsx)(v.N_,{to:`/catalog/default/api/${n}`,children:(0,a.jsx)("strong",{children:n})})}},{title:"Status",field:"status.phase",render:e=>{var t;const n=(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending";return(0,a.jsx)(k.A,{label:n,size:"small",style:(0,D.S)(n)})}},{title:"Tier",field:"spec.planTier",render:e=>(0,a.jsx)(k.A,{label:e.spec.planTier,size:"small",variant:"outlined"})},{title:"Requested",field:"metadata.creationTimestamp",render:e=>(0,a.jsx)(b.A,{variant:"body2",children:e.metadata.creationTimestamp?W(e.metadata.creationTimestamp):"-"})},{title:"Reviewed By",field:"status.reviewedBy",render:e=>{var t;if(!(null===(t=e.status)||void 0===t?void 0:t.reviewedBy))return(0,a.jsx)(b.A,{variant:"body2",color:"textSecondary",children:"-"});const n=e.status.reviewedBy.replace(/^user:default\//,""),s="system"===n;return(0,a.jsxs)(i.A,{children:[(0,a.jsx)(b.A,{variant:"body2",children:s?"Automatic":n}),e.status.reviewedAt&&(0,a.jsx)(b.A,{variant:"caption",color:"textSecondary",children:W(e.status.reviewedAt)})]})}},{title:"Actions",filtering:!1,render:e=>{var t,n,s;if("Pending"!==((null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending"))return null;const r=`${e.metadata.namespace}/${(null===(n=e.spec.apiProductRef)||void 0===n?void 0:n.name)||"unknown"}`;var o;const l=null!==(o=null==M||null===(s=M.ownedApiProducts)||void 0===s?void 0:s.has(r))&&void 0!==o&&o;return C||R&&l?(0,a.jsxs)(i.A,{display:"flex",style:{gap:8},children:[(0,a.jsx)(T.A,{size:"small",startIcon:(0,a.jsx)(J.A,{}),onClick:()=>{j({open:!0,request:e,action:"approve",processing:!1})},color:"primary",variant:"outlined",children:"Approve"}),(0,a.jsx)(T.A,{size:"small",startIcon:(0,a.jsx)(X.A,{}),onClick:()=>{j({open:!0,request:e,action:"reject",processing:!1})},color:"secondary",variant:"outlined",children:"Reject"})]}):null}}],U=(0,s.useMemo)(()=>[{render:e=>{var t;const n=e.rowData;return(null==n||null===(t=n.metadata)||void 0===t?void 0:t.name)?(0,a.jsx)(te,{request:n}):(0,a.jsx)(i.A,{})}}],[]);if(E||B)return(0,a.jsx)(g.k,{});if(_)return(0,a.jsx)(f._,{error:_});if(N)return(0,a.jsx)(i.A,{p:2,children:(0,a.jsxs)(b.A,{color:"error",children:["Unable to check permissions: ",N.message]})});const Z=C||R;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i.A,{className:t.container,children:[(0,a.jsx)(O.Z,{sections:L,filters:P,onChange:S}),(0,a.jsxs)(i.A,{className:t.tableContainer,children:[p.length>0&&(0,a.jsxs)(i.A,{className:t.bulkActions,children:[(0,a.jsxs)(b.A,{variant:"body2",children:[p.length," request",1!==p.length?"s":""," selected"]}),(0,a.jsxs)(i.A,{display:"flex",style:{gap:8},children:[(0,a.jsx)(T.A,{size:"small",variant:"contained",color:"primary",startIcon:(0,a.jsx)(J.A,{}),onClick:()=>{0!==p.length&&w({open:!0,requests:p,action:"approve",processing:!1})},children:"Approve Selected"}),(0,a.jsx)(T.A,{size:"small",variant:"contained",color:"secondary",startIcon:(0,a.jsx)(X.A,{}),onClick:()=>{0!==p.length&&w({open:!0,requests:p,action:"reject",processing:!1})},children:"Reject Selected"})]})]}),0===F.length?(0,a.jsx)(i.A,{p:4,textAlign:"center",children:(0,a.jsx)(b.A,{variant:"body1",color:"textSecondary",children:0===(null==M||null===(e=M.allRequests)||void 0===e?void 0:e.length)?"No API keys found.":"No API keys match the selected filters."})}):(0,a.jsx)(A.X,{options:{selection:Z,showSelectAllCheckbox:F.some(e=>{var t;return!(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending"===e.status.phase}),selectionProps:e=>{var t,n;return{disabled:"Pending"!==(null===(t=e.status)||void 0===t?void 0:t.phase)&&void 0!==(null===(n=e.status)||void 0===n?void 0:n.phase)}},paging:F.length>10,pageSize:20,search:!0,filtering:!1,debounceInterval:300,showTextRowsSelected:!1,toolbar:!0,emptyRowsWhenPaging:!1},columns:K,data:F.map(e=>{const t=p.some(t=>t.metadata.name===e.metadata.name&&t.metadata.namespace===e.metadata.namespace);return{...e,id:e.metadata.name,tableData:{checked:t}}}),onSelectionChange:e=>{const t=e.filter(e=>{var t;return!(null===(t=e.status)||void 0===t?void 0:t.phase)||"Pending"===e.status.phase});m(t)},detailPanel:U})]})]}),(0,a.jsx)(Q,{open:h.open,request:h.request,action:h.action,processing:h.processing,onClose:()=>j({open:!1,request:null,action:"approve",processing:!1}),onConfirm:async()=>{if(!h.request||!M)return;j(e=>({...e,processing:!0}));const e="approve"===h.action?`${c}/api/kuadrant/requests/${h.request.metadata.namespace}/${h.request.metadata.name}/approve`:`${c}/api/kuadrant/requests/${h.request.metadata.namespace}/${h.request.metadata.name}/reject`;try{if(!(await r.fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewedBy:M.reviewedBy})})).ok)throw new Error(`failed to ${h.action} request`);j({open:!1,request:null,action:"approve",processing:!1}),m(e=>e.filter(e=>{var t,n;return e.metadata.name!==(null===(t=h.request)||void 0===t?void 0:t.metadata.name)||e.metadata.namespace!==(null===(n=h.request)||void 0===n?void 0:n.metadata.namespace)})),u(e=>e+1);const t="approve"===h.action?"approved":"rejected";l.post({message:`API key ${t}`,severity:"success",display:"transient"})}catch(e){console.error(`error ${h.action}ing request:`,e),j(e=>({...e,processing:!1})),l.post({message:`Failed to ${h.action} API key`,severity:"error",display:"transient"})}}}),(0,a.jsx)(ee,{open:y.open,requests:y.requests,action:y.action,processing:y.processing,onClose:()=>w({open:!1,requests:[],action:"approve",processing:!1}),onConfirm:async()=>{if(!M||0===y.requests.length)return;w(e=>({...e,processing:!0}));const e="approve"===y.action,t=e?`${c}/api/kuadrant/requests/bulk-approve`:`${c}/api/kuadrant/requests/bulk-reject`;try{if(!(await r.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requests:y.requests.map(e=>({namespace:e.metadata.namespace,name:e.metadata.name})),reviewedBy:M.reviewedBy})})).ok)throw new Error(`failed to bulk ${y.action} requests`);const n=y.requests.length,a=e?"approved":"rejected";w({open:!1,requests:[],action:"approve",processing:!1}),m([]),u(e=>e+1),l.post({message:`${n} API keys ${a}`,severity:"success",display:"transient"})}catch(e){console.error(`error bulk ${y.action}ing requests:`,e),w(e=>({...e,processing:!1})),l.post({message:`Failed to bulk ${y.action} API keys`,severity:"error",display:"transient"})}}})]})},ae=()=>{const[e,t]=(0,s.useState)(0),{allowed:n,loading:r}=(0,Y.l)(V.KV);return(0,a.jsxs)(c.Y,{themeId:"tool",children:[(0,a.jsx)(d.Y,{title:"API Keys",subtitle:"API keys management for Kubernetes",children:(0,a.jsx)(u.Y,{children:"Manage your API keys and access requests"})}),(0,a.jsxs)(p.U,{children:[(0,a.jsx)(i.A,{mb:2,children:(0,a.jsxs)(o.A,{value:e,onChange:(e,n)=>{t(n)},indicatorColor:"primary",textColor:"primary",children:[(0,a.jsx)(l.A,{label:"My API keys","data-testid":"my-api-keys-tab"}),!r&&n&&(0,a.jsx)(l.A,{label:"API keys approval","data-testid":"api-keys-approval-tab"})]})}),0===e&&(0,a.jsx)(U,{}),1===e&&n&&(0,a.jsx)(ne,{})]})]})},se=()=>(0,a.jsx)(m.B,{permission:V.DS,errorMessage:"you don't have permission to view the API Keys page",children:(0,a.jsx)(ae,{})})},23164:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");t.A=i},27799:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M21 5v6.59l-3-3.01-4 4.01-4-4-4 4-3-3.01V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42l3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l3 2.99 4-4 4 4 4-3.99z"}),"BrokenImage");t.A=i},38599:(e,t,n)=>{n.d(t,{B:()=>l});var a=n(31085),s=(n(95478),n(10394)),r=n(72501),i=n(86687),o=n(46205);const l=({children:e,permission:t,fallback:n,errorMessage:l})=>{const{allowed:c,loading:d,error:u}=(0,o.l)(t);return d?(0,a.jsx)(i.k,{}):u?(0,a.jsxs)(s.A,{p:4,children:[(0,a.jsxs)(r.A,{color:"error",children:["Unable to check permissions: ",u.message]}),(0,a.jsx)(r.A,{variant:"body2",color:"textSecondary",children:"Please try again or contact your administrator"})]}):c?(0,a.jsx)(a.Fragment,{children:e}):n?(0,a.jsx)(a.Fragment,{children:n}):(0,a.jsxs)(s.A,{p:4,children:[(0,a.jsx)(r.A,{color:"textSecondary",children:l||"You don't have permission to view this page"}),(0,a.jsx)(s.A,{mt:1,children:(0,a.jsxs)(r.A,{variant:"caption",color:"textSecondary",children:["Required permission: ",t.name]})})]})}},39590:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");t.A=i},45210:(e,t,n)=>{n.d(t,{Y:()=>I});var a=n(31085),s=n(22097),r=n(10394),i=n(64947),o=n(93453),l=n(29365),c=n(46423),d=n(5951),u=n(26343),p=n(28233),m=n(55197),h=n(37976),v=n(72501),g=n(5893),f=n(95478),A=(n(45250),n(49634),n(21006)),x=n(67550);const j=()=>{const{t:e}=(0,x.i)(A.O);return{url:"https://github.com/backstage/backstage/issues",items:[{title:e("supportConfig.default.title"),icon:"warning",links:[{title:e("supportConfig.default.linkTitle"),url:"https://github.com/backstage/backstage/blob/master/app-config.yaml"}]}]}};var y=n(27799);function b(e){const{id:t,Fallback:n=y.A,...r}=e,i=(0,s.useApp)().getSystemIcon(t)??n;return(0,a.jsx)(i,{...r})}function k(e){return(0,a.jsx)(b,{id:"help",...e})}var w=n(37725);const P=(0,h.makeStyles)({popoverList:{minWidth:260,maxWidth:400},menuItem:{whiteSpace:"normal"}},{name:"BackstageSupportButton"}),S=({icon:e})=>{const t=(0,s.useApp)(),n=e?t.getSystemIcon(e)??k:k;return(0,a.jsx)(n,{})},C=({link:e})=>(0,a.jsx)(w.N_,{to:e.url,children:e.title??e.url}),q=({item:e})=>(0,a.jsxs)(u.A,{button:!1,children:[(0,a.jsx)(c.A,{children:(0,a.jsx)(S,{icon:e.icon})}),(0,a.jsx)(d.A,{primary:e.title,secondary:e.links?.reduce((e,t,n)=>[...e,n>0&&(0,a.jsx)("br",{},n),(0,a.jsx)(C,{link:t},t.url)],[])})]});function I(e){const{t}=(0,x.i)(A.O),{title:n,items:c,children:d}=e,{items:h}=function(){const e=(0,s.useApiHolder)().get(s.configApiRef),t=e?.getOptionalConfig("app.support"),n=j();return t?{url:t.getString("url"),items:t.getConfigArray("items").flatMap(e=>({title:e.getString("title"),icon:e.getOptionalString("icon"),links:(e.getOptionalConfigArray("links")??[]).flatMap(e=>({url:e.getString("url"),title:e.getOptionalString("title")??""}))}))}:n}(),[y,b]=(0,f.useState)(!1),[w,S]=(0,f.useState)(null),C=P(),I=(0,s.useApi)(s.configApiRef).getOptionalConfig("app.support"),R=(0,g.A)(e=>e.breakpoints.down("sm")),$=e=>{S(e.currentTarget),b(!0)},z=()=>{b(!1)};return I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.A,{display:"flex",ml:1,children:R?(0,a.jsx)(l.A,{color:"primary",size:"small",onClick:$,"data-testid":"support-button","aria-label":"Support",children:(0,a.jsx)(k,{})}):(0,a.jsx)(i.A,{"data-testid":"support-button","aria-label":"Support",color:"primary",onClick:$,startIcon:(0,a.jsx)(k,{}),children:t("supportButton.title")})}),(0,a.jsxs)(m.Ay,{"data-testid":"support-button-popover",open:y,anchorEl:w,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},onClose:z,children:[(0,a.jsxs)(p.A,{className:C.popoverList,autoFocusItem:Boolean(w),children:[n&&(0,a.jsx)(u.A,{button:!1,alignItems:"flex-start",className:C.menuItem,children:(0,a.jsx)(v.A,{variant:"subtitle1",children:n})}),f.Children.map(d,(e,t)=>(0,a.jsx)(u.A,{button:!1,alignItems:"flex-start",className:C.menuItem,children:e},`child-${t}`)),(c??h).map((e,t)=>(0,a.jsx)(q,{item:e},`item-${t}`))]}),(0,a.jsx)(o.A,{children:(0,a.jsx)(i.A,{color:"primary",onClick:z,"aria-label":"Close",children:t("supportButton.close")})})]})]}):null}},46299:(e,t,n)=>{n.d(t,{S:()=>a});const a=e=>{const t={border:"none"};switch(e){case"Approved":return{...t,backgroundColor:"#4caf50",color:"#fff"};case"Rejected":return{...t,backgroundColor:"#f44336",color:"#fff"};default:return{...t,backgroundColor:"#ff9800",color:"#fff"}}}},55429:(e,t,n)=>{var a=n(4293),s=n(78920);t.A=void 0;var r=s(n(95478)),i=(0,a(n(74044)).default)(r.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckCircle");t.A=i},91638:(e,t,n)=>{var a=n(85608),s=n(95478),r=a.__importDefault(n(5030));t.A=function(e,t){void 0===t&&(t=[]);var n=r.default(e,t,{loading:!0}),a=n[0],i=n[1];return s.useEffect(function(){i()},[i]),a}}}]);
2
+ //# sourceMappingURL=4682.3c7098a8.chunk.js.map