@kyro-cms/admin 0.1.5 → 0.1.7
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.
- package/README.md +149 -51
- package/package.json +52 -5
- package/src/collections/auth/index.ts +2 -2
- package/src/collections/portfolio/index.ts +343 -0
- package/src/components/ActionBar.tsx +153 -16
- package/src/components/Admin.tsx +136 -27
- package/src/components/ApiExplorer.tsx +325 -0
- package/src/components/ApiKeysManager.tsx +563 -0
- package/src/components/AuditLogsPage.tsx +664 -0
- package/src/components/AutoForm.tsx +1417 -661
- package/src/components/BrandingHub.tsx +267 -0
- package/src/components/BulkActionsBar.tsx +3 -3
- package/src/components/CreateView.tsx +3 -3
- package/src/components/Dashboard.tsx +393 -0
- package/src/components/DetailView.tsx +199 -57
- package/src/components/DeveloperCenter.tsx +403 -0
- package/src/components/EnhancedListView.tsx +786 -0
- package/src/components/GraphQLExplorer.tsx +675 -0
- package/src/components/GraphQLPlayground.tsx +627 -0
- package/src/components/ListView.tsx +191 -53
- package/src/components/MediaGallery.tsx +1569 -0
- package/src/components/Modal.tsx +149 -0
- package/src/components/RestPlayground.tsx +951 -0
- package/src/components/Sidebar.astro +237 -0
- package/src/components/UserManagement.tsx +204 -0
- package/src/components/VersionHistoryPanel.tsx +3 -3
- package/src/components/WebhookManager.tsx +608 -0
- package/src/components/blocks/AccordionBlock.tsx +97 -0
- package/src/components/blocks/ArrayBlock.tsx +75 -0
- package/src/components/blocks/BlockEditModal.MARKER +12 -0
- package/src/components/blocks/BlockEditModal.tsx +774 -0
- package/src/components/blocks/ButtonBlock.tsx +165 -0
- package/src/components/blocks/ChildBlocksTree.tsx +551 -0
- package/src/components/blocks/CodeBlock.tsx +66 -0
- package/src/components/blocks/ColumnsBlock.tsx +151 -0
- package/src/components/blocks/DividerBlock.tsx +43 -0
- package/src/components/blocks/FileBlock.tsx +64 -0
- package/src/components/blocks/HeadingBlock.tsx +81 -0
- package/src/components/blocks/HeroBlock.tsx +157 -0
- package/src/components/blocks/ImageBlock.tsx +83 -0
- package/src/components/blocks/LinkBlock.tsx +71 -0
- package/src/components/blocks/ListBlock.tsx +39 -0
- package/src/components/blocks/ParagraphBlock.tsx +61 -0
- package/src/components/blocks/RelationshipBlock.tsx +279 -0
- package/src/components/blocks/VStackBlock.tsx +75 -0
- package/src/components/blocks/VideoBlock.tsx +45 -0
- package/src/components/blocks/index.ts +10 -0
- package/src/components/fields/BlocksField.tsx +323 -0
- package/src/components/fields/CheckboxField.tsx +15 -9
- package/src/components/fields/CodeField.tsx +234 -0
- package/src/components/fields/DateField.tsx +38 -11
- package/src/components/fields/EditorClient.tsx +271 -0
- package/src/components/fields/FileField.tsx +390 -0
- package/src/components/fields/HybridContentField.tsx +109 -0
- package/src/components/fields/ImageField.tsx +429 -0
- package/src/components/fields/JSONField.tsx +361 -0
- package/src/components/fields/MarkdownField.tsx +282 -0
- package/src/components/fields/NumberField.tsx +42 -12
- package/src/components/fields/PortableTextField.tsx +143 -0
- package/src/components/fields/PortableTextRenderer.tsx +68 -0
- package/src/components/fields/RelationshipField.tsx +231 -59
- package/src/components/fields/SelectField.tsx +25 -15
- package/src/components/fields/TextField.tsx +45 -14
- package/src/components/fields/extensions/blockComponents.tsx +237 -0
- package/src/components/fields/extensions/blocksStore.ts +273 -0
- package/src/components/fields/index.ts +13 -0
- package/src/components/index.ts +1 -2
- package/src/components/layout/Header.tsx +2 -2
- package/src/components/layout/Layout.tsx +2 -2
- package/src/components/ui/Badge.tsx +9 -4
- package/src/components/ui/BlockDrawer.tsx +79 -0
- package/src/components/ui/Button.tsx +1 -1
- package/src/components/ui/CommandPalette.tsx +362 -0
- package/src/components/ui/CommandPaletteWrapper.tsx +97 -0
- package/src/components/ui/Dropdown.tsx +1 -1
- package/src/components/ui/Modal.tsx +37 -12
- package/src/components/ui/PromptModal.tsx +94 -0
- package/src/components/ui/SlidePanel.tsx +43 -16
- package/src/components/ui/Toast.tsx +80 -14
- package/src/env.d.ts +16 -0
- package/src/env.ts +20 -0
- package/src/index.ts +0 -1
- package/src/layouts/AdminLayout.astro +164 -170
- package/src/layouts/AuthLayout.astro +50 -0
- package/src/lib/MediaService.ts +541 -0
- package/src/lib/auth/sqlite-adapter.ts +319 -0
- package/src/lib/config.ts +22 -6
- package/src/lib/dataStore.ts +132 -74
- package/src/lib/db/adapter.ts +54 -0
- package/src/lib/db/drizzle-mysql-adapter.ts +194 -0
- package/src/lib/db/drizzle-mysql-auth-adapter.ts +327 -0
- package/src/lib/db/drizzle-postgres-adapter.ts +202 -0
- package/src/lib/db/drizzle-postgres-auth-adapter.ts +304 -0
- package/src/lib/db/drizzle-sqlite-adapter.ts +227 -0
- package/src/lib/db/drizzle-sqlite-auth-adapter.ts +548 -0
- package/src/lib/db/index.ts +449 -0
- package/src/lib/db/mongodb-adapter.ts +207 -0
- package/src/lib/db/mongodb-auth-adapter.ts +305 -0
- package/src/lib/db/schema/mysql-auth.ts +113 -0
- package/src/lib/db/schema/mysql-content.ts +20 -0
- package/src/lib/db/schema/postgres-auth.ts +116 -0
- package/src/lib/db/schema/postgres-content.ts +35 -0
- package/src/lib/db/schema/postgres-media.ts +52 -0
- package/src/lib/db/schema/postgres-settings.ts +11 -0
- package/src/lib/db/schema/sqlite-auth.ts +112 -0
- package/src/lib/db/schema/sqlite-content.ts +20 -0
- package/src/lib/graphql/index.ts +1 -0
- package/src/lib/graphql/schema.ts +443 -0
- package/src/lib/rate-limit.ts +267 -0
- package/src/lib/storage.ts +374 -0
- package/src/lib/store.ts +85 -0
- package/src/middleware.ts +116 -28
- package/src/pages/[collection]/[id].astro +178 -122
- package/src/pages/[collection]/index.astro +24 -156
- package/src/pages/admin/api-explorer.astro +98 -0
- package/src/pages/admin/graphql-explorer.astro +40 -0
- package/src/pages/admin/graphql.astro +97 -0
- package/src/pages/admin/index.astro +286 -0
- package/src/pages/admin/keys.astro +8 -0
- package/src/pages/admin/rest-playground.astro +44 -0
- package/src/pages/admin/webhooks.astro +8 -0
- package/src/pages/api/[collection]/[id]/publish.ts +44 -0
- package/src/pages/api/[collection]/[id]/unpublish.ts +42 -0
- package/src/pages/api/[collection]/[id]/versions.ts +36 -0
- package/src/pages/api/[collection]/[id].ts +102 -159
- package/src/pages/api/[collection]/index.ts +151 -230
- package/src/pages/api/auth/[id].ts +48 -69
- package/src/pages/api/auth/audit-logs.ts +20 -43
- package/src/pages/api/auth/login.ts +159 -45
- package/src/pages/api/auth/logout.ts +50 -20
- package/src/pages/api/auth/refresh.ts +119 -0
- package/src/pages/api/auth/register.ts +110 -40
- package/src/pages/api/auth/users.ts +22 -97
- package/src/pages/api/collections.ts +59 -0
- package/src/pages/api/globals/[slug]/test.ts +172 -0
- package/src/pages/api/globals/[slug].ts +42 -0
- package/src/pages/api/graphql.ts +90 -0
- package/src/pages/api/health.ts +417 -40
- package/src/pages/api/keys/[id].ts +26 -0
- package/src/pages/api/keys/index.ts +75 -0
- package/src/pages/api/media/[id].ts +309 -0
- package/src/pages/api/media/folders.ts +609 -0
- package/src/pages/api/media/index.ts +146 -0
- package/src/pages/api/media/resize.ts +267 -0
- package/src/pages/api/search.ts +82 -0
- package/src/pages/api/slug-availability.ts +70 -0
- package/src/pages/api/storage-config.ts +20 -0
- package/src/pages/api/storage-status.ts +206 -0
- package/src/pages/api/upload.ts +334 -0
- package/src/pages/api/webhooks/index.ts +71 -0
- package/src/pages/audit/index.astro +2 -104
- package/src/pages/login.astro +82 -0
- package/src/pages/media.astro +10 -0
- package/src/pages/preview/[collection]/[id].astro +178 -0
- package/src/pages/register.astro +102 -0
- package/src/pages/roles/index.astro +21 -21
- package/src/pages/settings/[slug].astro +162 -0
- package/src/pages/settings/index.astro +9 -0
- package/src/pages/users/[id].astro +29 -21
- package/src/pages/users/index.astro +22 -17
- package/src/pages/users/new.astro +18 -17
- package/src/styles/main.css +553 -128
- package/src/components/layout/Sidebar.tsx +0 -497
- package/src/pages/index.astro +0 -225
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
interface Collection {
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
fields: number;
|
|
7
|
+
endpoints: {
|
|
8
|
+
list: string;
|
|
9
|
+
create: string;
|
|
10
|
+
read: string;
|
|
11
|
+
update: string;
|
|
12
|
+
delete: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ApiExplorerProps {
|
|
17
|
+
collections: Collection[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function ApiExplorer({ collections }: ApiExplorerProps) {
|
|
21
|
+
const [selectedEndpoint, setSelectedEndpoint] = useState<{
|
|
22
|
+
collection: string;
|
|
23
|
+
method: string;
|
|
24
|
+
url: string;
|
|
25
|
+
description: string;
|
|
26
|
+
} | null>(null);
|
|
27
|
+
const [response, setResponse] = useState<string>("");
|
|
28
|
+
const [loading, setLoading] = useState(false);
|
|
29
|
+
const [method, setMethod] = useState<"GET" | "POST" | "PATCH" | "DELETE">(
|
|
30
|
+
"GET",
|
|
31
|
+
);
|
|
32
|
+
const [url, setUrl] = useState("");
|
|
33
|
+
const [requestBody, setRequestBody] = useState("");
|
|
34
|
+
const [status, setStatus] = useState<number | null>(null);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (collections.length > 0) {
|
|
38
|
+
const first = collections[0];
|
|
39
|
+
setSelectedEndpoint({
|
|
40
|
+
collection: first.slug,
|
|
41
|
+
method: "GET",
|
|
42
|
+
url: `/api/${first.slug}`,
|
|
43
|
+
description: `List all ${first.name}`,
|
|
44
|
+
});
|
|
45
|
+
setUrl(`/api/${first.slug}`);
|
|
46
|
+
}
|
|
47
|
+
}, [collections]);
|
|
48
|
+
|
|
49
|
+
const handleEndpointClick = useCallback(
|
|
50
|
+
(endpoint: typeof selectedEndpoint) => {
|
|
51
|
+
if (!endpoint) return;
|
|
52
|
+
setSelectedEndpoint(endpoint);
|
|
53
|
+
setUrl(endpoint.url);
|
|
54
|
+
setMethod(endpoint.method as "GET" | "POST" | "PATCH" | "DELETE");
|
|
55
|
+
setRequestBody("");
|
|
56
|
+
setResponse("");
|
|
57
|
+
setStatus(null);
|
|
58
|
+
},
|
|
59
|
+
[],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const executeRequest = async () => {
|
|
63
|
+
if (!url) return;
|
|
64
|
+
|
|
65
|
+
setLoading(true);
|
|
66
|
+
setResponse("");
|
|
67
|
+
setStatus(null);
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const options: RequestInit = {
|
|
71
|
+
method,
|
|
72
|
+
headers: {
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (["POST", "PATCH"].includes(method) && requestBody) {
|
|
78
|
+
options.body = requestBody;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const res = await fetch(url, options);
|
|
82
|
+
setStatus(res.status);
|
|
83
|
+
|
|
84
|
+
const contentType = res.headers.get("content-type");
|
|
85
|
+
if (contentType?.includes("application/json")) {
|
|
86
|
+
const data = await res.json();
|
|
87
|
+
setResponse(JSON.stringify(data, null, 2));
|
|
88
|
+
} else {
|
|
89
|
+
const text = await res.text();
|
|
90
|
+
setResponse(text);
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
setResponse(
|
|
94
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
95
|
+
);
|
|
96
|
+
setStatus(500);
|
|
97
|
+
} finally {
|
|
98
|
+
setLoading(false);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const getMethodColor = (m: string) => {
|
|
103
|
+
switch (m) {
|
|
104
|
+
case "GET":
|
|
105
|
+
return "bg-green-500/10 text-green-600 border-green-500/20";
|
|
106
|
+
case "POST":
|
|
107
|
+
return "bg-blue-500/10 text-blue-600 border-blue-500/20";
|
|
108
|
+
case "PATCH":
|
|
109
|
+
return "bg-yellow-500/10 text-yellow-600 border-yellow-500/20";
|
|
110
|
+
case "DELETE":
|
|
111
|
+
return "bg-red-500/10 text-red-600 border-red-500/20";
|
|
112
|
+
default:
|
|
113
|
+
return "bg-gray-500/10 text-gray-600 border-gray-500/20";
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const getStatusColor = (s: number) => {
|
|
118
|
+
if (s >= 200 && s < 300) return "text-green-600 bg-green-500/10";
|
|
119
|
+
if (s >= 400 && s < 500) return "text-yellow-600 bg-yellow-500/10";
|
|
120
|
+
if (s >= 500) return "text-red-600 bg-red-500/10";
|
|
121
|
+
return "text-gray-600 bg-gray-500/10";
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className="h-[calc(100vh-200px)] min-h-[600px] flex gap-6">
|
|
126
|
+
{/* Sidebar - Collections */}
|
|
127
|
+
<div className="w-80 flex-shrink-0 overflow-y-auto">
|
|
128
|
+
<div className="space-y-4">
|
|
129
|
+
{collections.map((collection) => (
|
|
130
|
+
<div key={collection.slug} className="space-y-2">
|
|
131
|
+
<h3 className="font-bold text-[var(--kyro-text-primary)] px-3 py-2 bg-[var(--kyro-surface-accent)] rounded-lg">
|
|
132
|
+
{collection.name}
|
|
133
|
+
</h3>
|
|
134
|
+
<div className="space-y-1 pl-2">
|
|
135
|
+
<button type="button"
|
|
136
|
+
onClick={() =>
|
|
137
|
+
handleEndpointClick({
|
|
138
|
+
collection: collection.slug,
|
|
139
|
+
method: "GET",
|
|
140
|
+
url: `/api/${collection.slug}`,
|
|
141
|
+
description: `List all ${collection.name}`,
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
className={`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${
|
|
145
|
+
selectedEndpoint?.url === `/api/${collection.slug}` &&
|
|
146
|
+
method === "GET"
|
|
147
|
+
? "bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"
|
|
148
|
+
: "hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)]"
|
|
149
|
+
}`}
|
|
150
|
+
>
|
|
151
|
+
<span
|
|
152
|
+
className={`inline-block px-1.5 py-0.5 rounded text-[10px] font-bold mr-2 ${getMethodColor("GET")}`}
|
|
153
|
+
>
|
|
154
|
+
GET
|
|
155
|
+
</span>
|
|
156
|
+
List
|
|
157
|
+
</button>
|
|
158
|
+
<button type="button"
|
|
159
|
+
onClick={() =>
|
|
160
|
+
handleEndpointClick({
|
|
161
|
+
collection: collection.slug,
|
|
162
|
+
method: "POST",
|
|
163
|
+
url: `/api/${collection.slug}`,
|
|
164
|
+
description: `Create new ${collection.name}`,
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
className={`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${
|
|
168
|
+
selectedEndpoint?.url === `/api/${collection.slug}` &&
|
|
169
|
+
method === "POST"
|
|
170
|
+
? "bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"
|
|
171
|
+
: "hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)]"
|
|
172
|
+
}`}
|
|
173
|
+
>
|
|
174
|
+
<span
|
|
175
|
+
className={`inline-block px-1.5 py-0.5 rounded text-[10px] font-bold mr-2 ${getMethodColor("POST")}`}
|
|
176
|
+
>
|
|
177
|
+
POST
|
|
178
|
+
</span>
|
|
179
|
+
Create
|
|
180
|
+
</button>
|
|
181
|
+
<button type="button"
|
|
182
|
+
onClick={() =>
|
|
183
|
+
handleEndpointClick({
|
|
184
|
+
collection: collection.slug,
|
|
185
|
+
method: "GET",
|
|
186
|
+
url: `/api/${collection.slug}/:id`,
|
|
187
|
+
description: `Get ${collection.name} by ID`,
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
className={`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${
|
|
191
|
+
selectedEndpoint?.url === `/api/${collection.slug}/:id` &&
|
|
192
|
+
method === "GET"
|
|
193
|
+
? "bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"
|
|
194
|
+
: "hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)]"
|
|
195
|
+
}`}
|
|
196
|
+
>
|
|
197
|
+
<span
|
|
198
|
+
className={`inline-block px-1.5 py-0.5 rounded text-[10px] font-bold mr-2 ${getMethodColor("GET")}`}
|
|
199
|
+
>
|
|
200
|
+
GET
|
|
201
|
+
</span>
|
|
202
|
+
Get by ID
|
|
203
|
+
</button>
|
|
204
|
+
<button type="button"
|
|
205
|
+
onClick={() =>
|
|
206
|
+
handleEndpointClick({
|
|
207
|
+
collection: collection.slug,
|
|
208
|
+
method: "PATCH",
|
|
209
|
+
url: `/api/${collection.slug}/:id`,
|
|
210
|
+
description: `Update ${collection.name}`,
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
className={`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${
|
|
214
|
+
selectedEndpoint?.url === `/api/${collection.slug}/:id` &&
|
|
215
|
+
method === "PATCH"
|
|
216
|
+
? "bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"
|
|
217
|
+
: "hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)]"
|
|
218
|
+
}`}
|
|
219
|
+
>
|
|
220
|
+
<span
|
|
221
|
+
className={`inline-block px-1.5 py-0.5 rounded text-[10px] font-bold mr-2 ${getMethodColor("PATCH")}`}
|
|
222
|
+
>
|
|
223
|
+
PATCH
|
|
224
|
+
</span>
|
|
225
|
+
Update
|
|
226
|
+
</button>
|
|
227
|
+
<button type="button"
|
|
228
|
+
onClick={() =>
|
|
229
|
+
handleEndpointClick({
|
|
230
|
+
collection: collection.slug,
|
|
231
|
+
method: "DELETE",
|
|
232
|
+
url: `/api/${collection.slug}/:id`,
|
|
233
|
+
description: `Delete ${collection.name}`,
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
className={`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${
|
|
237
|
+
selectedEndpoint?.url === `/api/${collection.slug}/:id` &&
|
|
238
|
+
method === "DELETE"
|
|
239
|
+
? "bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"
|
|
240
|
+
: "hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)]"
|
|
241
|
+
}`}
|
|
242
|
+
>
|
|
243
|
+
<span
|
|
244
|
+
className={`inline-block px-1.5 py-0.5 rounded text-[10px] font-bold mr-2 ${getMethodColor("DELETE")}`}
|
|
245
|
+
>
|
|
246
|
+
DEL
|
|
247
|
+
</span>
|
|
248
|
+
Delete
|
|
249
|
+
</button>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
))}
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
{/* Main Content */}
|
|
257
|
+
<div className="flex-1 flex flex-col min-w-0">
|
|
258
|
+
{/* URL Bar */}
|
|
259
|
+
<div className="flex gap-3 mb-4">
|
|
260
|
+
<select
|
|
261
|
+
value={method}
|
|
262
|
+
onChange={(e) =>
|
|
263
|
+
setMethod(e.target.value as "GET" | "POST" | "PATCH" | "DELETE")
|
|
264
|
+
}
|
|
265
|
+
className={`px-4 py-2 rounded-lg font-bold text-sm border ${getMethodColor(method)}`}
|
|
266
|
+
>
|
|
267
|
+
<option value="GET">GET</option>
|
|
268
|
+
<option value="POST">POST</option>
|
|
269
|
+
<option value="PATCH">PATCH</option>
|
|
270
|
+
<option value="DELETE">DELETE</option>
|
|
271
|
+
</select>
|
|
272
|
+
<input
|
|
273
|
+
type="text"
|
|
274
|
+
value={url}
|
|
275
|
+
onChange={(e) => setUrl(e.target.value)}
|
|
276
|
+
placeholder="/api/collection"
|
|
277
|
+
className="flex-1 px-4 py-2 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-sm font-mono focus:outline-none focus:border-[var(--kyro-sidebar-active)]"
|
|
278
|
+
/>
|
|
279
|
+
<button type="button"
|
|
280
|
+
onClick={executeRequest}
|
|
281
|
+
disabled={loading || !url}
|
|
282
|
+
className="px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-lg font-bold text-sm hover:opacity-90 transition-opacity disabled:opacity-50"
|
|
283
|
+
>
|
|
284
|
+
{loading ? "Sending..." : "Send"}
|
|
285
|
+
</button>
|
|
286
|
+
</div>
|
|
287
|
+
|
|
288
|
+
{/* Request Body (for POST/PATCH) */}
|
|
289
|
+
{["POST", "PATCH"].includes(method) && (
|
|
290
|
+
<div className="mb-4">
|
|
291
|
+
<label className="block text-sm font-bold text-[var(--kyro-text-secondary)] mb-2">
|
|
292
|
+
Request Body (JSON)
|
|
293
|
+
</label>
|
|
294
|
+
<textarea
|
|
295
|
+
value={requestBody}
|
|
296
|
+
onChange={(e) => setRequestBody(e.target.value)}
|
|
297
|
+
placeholder='{"field": "value"}'
|
|
298
|
+
rows={6}
|
|
299
|
+
className="w-full px-4 py-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg text-sm font-mono focus:outline-none focus:border-[var(--kyro-sidebar-active)] resize-y"
|
|
300
|
+
/>
|
|
301
|
+
</div>
|
|
302
|
+
)}
|
|
303
|
+
|
|
304
|
+
{/* Response */}
|
|
305
|
+
<div className="flex-1 flex flex-col min-h-0">
|
|
306
|
+
<div className="flex items-center justify-between mb-2">
|
|
307
|
+
<label className="text-sm font-bold text-[var(--kyro-text-secondary)]">
|
|
308
|
+
Response
|
|
309
|
+
</label>
|
|
310
|
+
{status && (
|
|
311
|
+
<span
|
|
312
|
+
className={`px-3 py-1 rounded-lg text-sm font-bold ${getStatusColor(status)}`}
|
|
313
|
+
>
|
|
314
|
+
{status}
|
|
315
|
+
</span>
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
|
+
<pre className="flex-1 p-4 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg text-xs font-mono overflow-auto whitespace-pre-wrap">
|
|
319
|
+
{response || "Send a request to see the response"}
|
|
320
|
+
</pre>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
}
|