zudoku 0.3.0-dev.81 → 0.3.0-dev.83

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.
@@ -34,6 +34,17 @@ export const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {
34
34
  },
35
35
  });
36
36
 
37
+ const rollKeyMutation = useMutation({
38
+ mutationFn: (id: string) => {
39
+ if (!service.rollKey) {
40
+ throw new Error("rollKey not implemented");
41
+ }
42
+
43
+ return service.rollKey(id, context);
44
+ },
45
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: ["api-keys"] }),
46
+ });
47
+
37
48
  return (
38
49
  <div className="max-w-screen-lg h-full pt-[--padding-content-top] pb-[--padding-content-bottom]">
39
50
  <Slotlet name="api-keys-list-page" />
@@ -50,14 +61,14 @@ export const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {
50
61
  <Slotlet name="api-keys-list-page-before-keys" />
51
62
 
52
63
  {data.length === 0 ? (
53
- <div className="flex flex-col justify-center gap-4 items-center h-1/2 my-8">
54
- <div className="text-center">
64
+ <div className="flex flex-col justify-center gap-4 items-center p-8 border rounded bg-muted/30 text-muted-foreground">
65
+ <p className="text-center">
55
66
  No API keys created yet.
56
67
  <br />
57
- Get started and create the first one now
58
- </div>
68
+ Get started and create your first key.
69
+ </p>
59
70
  {service.createKey && (
60
- <Button asChild>
71
+ <Button asChild variant="outline">
61
72
  <Link to="/settings/api-keys/new">Create API Key</Link>
62
73
  </Button>
63
74
  )}
@@ -94,7 +105,18 @@ export const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {
94
105
  </div>
95
106
  <div className="flex gap-2">
96
107
  {service.rollKey && (
97
- <Button size="icon">
108
+ <Button
109
+ size="icon"
110
+ title="Roll this key"
111
+ variant="ghost"
112
+ onClick={() => {
113
+ if (!confirm("Do you want to roll this key?")) {
114
+ return;
115
+ }
116
+
117
+ rollKeyMutation.mutate(key.id);
118
+ }}
119
+ >
98
120
  <RotateCwIcon size={16} />
99
121
  </Button>
100
122
  )}
@@ -128,10 +150,9 @@ const RevealApiKey = ({ apiKey }: { apiKey: string }) => {
128
150
 
129
151
  return (
130
152
  <div className="flex gap-2 items-center text-sm w-full">
131
- <input
132
- className="border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono max-w-min"
133
- value={revealed ? apiKey : "•".repeat(apiKey.length)}
134
- />
153
+ <div className="border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono w-fit overflow-x-scroll h-9 items-center flex px-2">
154
+ {revealed ? apiKey : "•".repeat(apiKey.length)}
155
+ </div>
135
156
  <Button
136
157
  variant="outline"
137
158
  onClick={() => setRevealed((prev) => !prev)}
@@ -54,6 +54,16 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
54
54
  const response = await fetch(request);
55
55
  invariant(response.ok, "Failed to delete API key");
56
56
  },
57
+ rollKey: async (id, context) => {
58
+ const response = await fetch(
59
+ await context.signRequest(
60
+ new Request(endpoint + `/v1/developer/api-keys/${id}/key`, {
61
+ method: "DELETE",
62
+ }),
63
+ ),
64
+ );
65
+ invariant(response.ok, "Failed to delete API key");
66
+ },
57
67
  createKey: async (apiKey, context) => {
58
68
  const request = new Request(endpoint + `/v1/developer/api-keys`, {
59
69
  method: "POST",
@@ -234,7 +234,7 @@ export const Playground = ({
234
234
  >
235
235
  <div className="flex justify-between">
236
236
  <TabsList>
237
- {pathParams.length > 0 && (
237
+ {queryParams.length + pathParams.length > 0 && (
238
238
  <TabsTrigger value="parameters">Parameters</TabsTrigger>
239
239
  )}
240
240
  <TabsTrigger value="headers">