+ {popup}
+
{fullApiKey && (
+ Name
API Key
Regenerate
Delete
@@ -177,6 +180,24 @@ function Main() {
{apiKeys.map((apiKey) => (
+
+ handleEdit(apiKey)}
+ >
+
+ {apiKey.api_key_name || null}
+
+
{apiKey.api_key_display}
@@ -194,12 +215,7 @@ function Main() {
text-sm`}
onClick={async () => {
setKeyIsGenerating(true);
- const response = await fetch(
- `/api/admin/api-key/${apiKey.api_key_id}`,
- {
- method: "PATCH",
- }
- );
+ const response = await regenerateApiKey(apiKey);
setKeyIsGenerating(false);
if (!response.ok) {
const errorMsg = await response.text();
@@ -221,12 +237,7 @@ function Main() {
{
- const response = await fetch(
- `/api/admin/api-key/${apiKey.api_key_id}`,
- {
- method: "DELETE",
- }
- );
+ const response = await deleteApiKey(apiKey.api_key_id);
if (!response.ok) {
const errorMsg = await response.text();
setPopup({
@@ -243,6 +254,21 @@ function Main() {
))}
+
+ {showCreateUpdateForm && (
+ {
+ setFullApiKey(apiKey.api_key);
+ }}
+ onClose={() => {
+ setShowCreateUpdateForm(false);
+ setSelectedApiKey(undefined);
+ mutate("/api/admin/api-key");
+ }}
+ setPopup={setPopup}
+ apiKey={selectedApiKey}
+ />
+ )}
);
}
diff --git a/web/src/app/ee/admin/api-key/types.ts b/web/src/app/ee/admin/api-key/types.ts
new file mode 100644
index 000000000..01984c776
--- /dev/null
+++ b/web/src/app/ee/admin/api-key/types.ts
@@ -0,0 +1,11 @@
+interface APIKey {
+ api_key_id: number;
+ api_key_display: string;
+ api_key: string | null;
+ api_key_name: string | null;
+ user_id: string;
+}
+
+interface APIKeyArgs {
+ name?: string;
+}