@kyro-cms/admin 0.10.18 → 0.10.19
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/package.json
CHANGED
|
@@ -393,11 +393,19 @@ export function GraphQLPlayground({
|
|
|
393
393
|
const [token, setToken] = useState<string>("");
|
|
394
394
|
const [showToken, setShowToken] = useState(false);
|
|
395
395
|
const [isConnected, setIsConnected] = useState(false);
|
|
396
|
-
const [tab, setTab] = useState<QueryTab>({
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
const [tab, setTab] = useState<QueryTab>(() => {
|
|
397
|
+
if (typeof window !== "undefined") {
|
|
398
|
+
try {
|
|
399
|
+
const saved = localStorage.getItem("kyro_graphql_tab");
|
|
400
|
+
if (saved) return JSON.parse(saved);
|
|
401
|
+
} catch {}
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
id: "default",
|
|
405
|
+
query: initialQuery || DEFAULT_QUERY,
|
|
406
|
+
variables: initialVariables || "{}",
|
|
407
|
+
headers: "",
|
|
408
|
+
};
|
|
401
409
|
});
|
|
402
410
|
const [response, setResponse] = useState<string>("");
|
|
403
411
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -411,7 +419,15 @@ export function GraphQLPlayground({
|
|
|
411
419
|
const [rightTab, setRightTab] = useState<"response" | "docs" | "history">(
|
|
412
420
|
initialShowDocs ? "docs" : "response",
|
|
413
421
|
);
|
|
414
|
-
const [history, setHistory] = useState<HistoryEntry[]>(
|
|
422
|
+
const [history, setHistory] = useState<HistoryEntry[]>(() => {
|
|
423
|
+
if (typeof window !== "undefined") {
|
|
424
|
+
try {
|
|
425
|
+
const saved = localStorage.getItem("kyro_graphql_history");
|
|
426
|
+
if (saved) return JSON.parse(saved);
|
|
427
|
+
} catch {}
|
|
428
|
+
}
|
|
429
|
+
return [];
|
|
430
|
+
});
|
|
415
431
|
const [lastDuration, setLastDuration] = useState<number>(0);
|
|
416
432
|
const [lastStatus, setLastStatus] = useState<number>(0);
|
|
417
433
|
const [copied, setCopied] = useState(false);
|
|
@@ -426,6 +442,18 @@ export function GraphQLPlayground({
|
|
|
426
442
|
setIsMounted(true);
|
|
427
443
|
}, []);
|
|
428
444
|
|
|
445
|
+
useEffect(() => {
|
|
446
|
+
if (isMounted) {
|
|
447
|
+
localStorage.setItem("kyro_graphql_tab", JSON.stringify(tab));
|
|
448
|
+
}
|
|
449
|
+
}, [tab, isMounted]);
|
|
450
|
+
|
|
451
|
+
useEffect(() => {
|
|
452
|
+
if (isMounted) {
|
|
453
|
+
localStorage.setItem("kyro_graphql_history", JSON.stringify(history));
|
|
454
|
+
}
|
|
455
|
+
}, [history, isMounted]);
|
|
456
|
+
|
|
429
457
|
useEffect(() => {
|
|
430
458
|
const check = () => setIsDesktop(window.innerWidth >= 768);
|
|
431
459
|
check();
|
|
@@ -83,13 +83,21 @@ export function RestPlayground({ collections = [] }: RestPlaygroundProps) {
|
|
|
83
83
|
const [history, setHistory] = useState<HistoryItem[]>([]);
|
|
84
84
|
const [envVars, setEnvVars] = useState<EnvVariable[]>([]);
|
|
85
85
|
const [selectedRequest, setSelectedRequest] = useState<SavedRequest | null>(null);
|
|
86
|
-
const [currentRequest, setCurrentRequest] = useState<SavedRequest>({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
const [currentRequest, setCurrentRequest] = useState<SavedRequest>(() => {
|
|
87
|
+
if (typeof window !== "undefined") {
|
|
88
|
+
try {
|
|
89
|
+
const saved = localStorage.getItem("kyro_rest_current");
|
|
90
|
+
if (saved) return JSON.parse(saved);
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
id: "new",
|
|
95
|
+
name: "Untitled Request",
|
|
96
|
+
method: "GET",
|
|
97
|
+
url: "",
|
|
98
|
+
headers: {},
|
|
99
|
+
body: "",
|
|
100
|
+
};
|
|
93
101
|
});
|
|
94
102
|
const [response, setResponse] = useState<{ status: number; duration: number; size: number; data: any } | null>(null);
|
|
95
103
|
const [loading, setLoading] = useState(false);
|
|
@@ -136,6 +144,10 @@ export function RestPlayground({ collections = [] }: RestPlaygroundProps) {
|
|
|
136
144
|
if (isMounted) localStorage.setItem(STORAGE_KEYS.env, JSON.stringify(envVars));
|
|
137
145
|
}, [envVars, isMounted]);
|
|
138
146
|
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (isMounted) localStorage.setItem("kyro_rest_current", JSON.stringify(currentRequest));
|
|
149
|
+
}, [currentRequest, isMounted]);
|
|
150
|
+
|
|
139
151
|
const resolveUrl = (url: string) => {
|
|
140
152
|
let resolved = url;
|
|
141
153
|
envVars.forEach((v) => {
|