Skip to content

Commit d936d4e

Browse files
committed
Remove permissions form field in ecosystem partners page + UI adjusments (#4747)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR removes unused code related to partner permissions and updates UI components in the dashboard ecosystem section. ### Detailed summary - Removed unused `PartnerPermission` type and related code - Updated UI components in the dashboard ecosystem section for better user experience > The following files were skipped due to too many changes: `apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/add-partner-form.client.tsx` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent bc72883 commit d936d4e

File tree

12 files changed

+126
-218
lines changed

12 files changed

+126
-218
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import {
5+
Dialog,
6+
DialogContent,
7+
DialogHeader,
8+
DialogTitle,
9+
DialogTrigger,
10+
} from "@/components/ui/dialog";
11+
import { PlusIcon } from "lucide-react";
12+
import { useState } from "react";
13+
import type { Ecosystem } from "../../../../types";
14+
import { AddPartnerForm } from "./add-partner-form.client";
15+
16+
export function AddPartnerDialogButton(props: {
17+
ecosystem: Ecosystem;
18+
}) {
19+
const [open, setOpen] = useState(false);
20+
return (
21+
<Dialog open={open} onOpenChange={setOpen}>
22+
<DialogTrigger asChild>
23+
<Button className="gap-2 max-sm:w-full">
24+
<PlusIcon className="size-4" />
25+
Add Partner
26+
</Button>
27+
</DialogTrigger>
28+
<DialogContent>
29+
<DialogHeader className="mb-2">
30+
<DialogTitle className="text-2xl font-semibold tracking-tight">
31+
Add Partner
32+
</DialogTitle>
33+
</DialogHeader>
34+
<AddPartnerForm
35+
ecosystem={props.ecosystem}
36+
onPartnerAdded={() => setOpen(false)}
37+
/>
38+
</DialogContent>
39+
</Dialog>
40+
);
41+
}

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/client/add-partner-form.client.tsx

Lines changed: 30 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
"use client";
2+
import { Spinner } from "@/components/ui/Spinner/Spinner";
23
import { Button } from "@/components/ui/button";
34
import {
45
Form,
56
FormControl,
67
FormDescription,
78
FormField,
89
FormItem,
10+
FormLabel,
911
FormMessage,
1012
} from "@/components/ui/form";
1113
import { Input } from "@/components/ui/input";
12-
import {
13-
Select,
14-
SelectContent,
15-
SelectItem,
16-
SelectTrigger,
17-
SelectValue,
18-
} from "@/components/ui/select";
19-
import { ToolTipLabel } from "@/components/ui/tooltip";
2014
import { cn } from "@/lib/utils";
2115
import { zodResolver } from "@hookform/resolvers/zod";
2216
import { useForm } from "react-hook-form";
@@ -26,14 +20,17 @@ import type { Ecosystem } from "../../../../types";
2620
import { partnerFormSchema } from "../../constants";
2721
import { useAddPartner } from "../../hooks/use-add-partner";
2822

29-
export function AddPartnerForm({ ecosystem }: { ecosystem: Ecosystem }) {
23+
export function AddPartnerForm({
24+
ecosystem,
25+
onPartnerAdded,
26+
}: { ecosystem: Ecosystem; onPartnerAdded: () => void }) {
3027
const form = useForm<z.input<typeof partnerFormSchema>>({
3128
resolver: zodResolver(partnerFormSchema),
3229
});
3330

3431
const { mutateAsync: addPartner, isPending } = useAddPartner({
3532
onSuccess: () => {
36-
form.reset();
33+
onPartnerAdded();
3734
},
3835
onError: (error) => {
3936
const message =
@@ -57,18 +54,18 @@ export function AddPartnerForm({ ecosystem }: { ecosystem: Ecosystem }) {
5754
allowlistedBundleIds: values.bundleIds
5855
.split(/,| /)
5956
.filter((d) => d.length > 0),
60-
permissions: [values.permissions],
6157
});
6258
})}
63-
className="flex flex-col gap-2 lg:flex-row"
59+
className="flex flex-col gap-6"
6460
>
65-
<div className="grid gap-2 lg:grid-cols-12 grow">
61+
<div className="flex flex-col gap-4">
6662
<FormField
6763
control={form.control}
6864
name="name"
6965
defaultValue="" // Note: you *must* provide a default value here or the field won't reset
7066
render={({ field }) => (
71-
<FormItem className="col-span-4 lg:col-span-3">
67+
<FormItem>
68+
<FormLabel> App Name </FormLabel>
7269
<FormControl>
7370
<Input
7471
placeholder="App name"
@@ -94,22 +91,16 @@ export function AddPartnerForm({ ecosystem }: { ecosystem: Ecosystem }) {
9491
name="domains"
9592
defaultValue="" // Note: you *must* provide a default value here or the field won't reset
9693
render={({ field }) => (
97-
<FormItem className="col-span-4 lg:col-span-4">
94+
<FormItem>
95+
<FormLabel> Domains </FormLabel>
9896
<FormControl>
99-
<>
100-
<Input placeholder="Domains" className="peer" {...field} />
101-
<FormDescription
102-
className={cn(
103-
"hidden text-xs transition-all lg:block lg:-translate-y-4 lg:opacity-0 peer-focus-visible:opacity-100 peer-focus-visible:translate-y-0",
104-
form.formState.errors.domains?.message &&
105-
"text-destructive lg:translate-y-0 lg:opacity-100 block", // If there are errors show them rather than the tip
106-
)}
107-
>
108-
{form.formState.errors.domains?.message ??
109-
"Space or comma-separated list of regex domains (e.g. *.example.com)"}
110-
</FormDescription>
111-
</>
97+
<Input placeholder="Domains" className="peer" {...field} />
11298
</FormControl>
99+
100+
<FormDescription>
101+
Space or comma-separated list of regex domains (e.g.
102+
*.example.com)
103+
</FormDescription>
113104
</FormItem>
114105
)}
115106
/>
@@ -118,75 +109,24 @@ export function AddPartnerForm({ ecosystem }: { ecosystem: Ecosystem }) {
118109
name="bundleIds"
119110
defaultValue="" // Note: you *must* provide a default value here or the field won't reset
120111
render={({ field }) => (
121-
<FormItem className="col-span-4 lg:col-span-3">
112+
<FormItem>
113+
<FormLabel> Bundle ID </FormLabel>
122114
<FormControl>
123-
<>
124-
<Input
125-
placeholder="Bundle ID"
126-
className="peer"
127-
{...field}
128-
/>
129-
<FormDescription
130-
className={cn(
131-
"hidden text-xs transition-all lg:block lg:-translate-y-4 lg:opacity-0 peer-focus-visible:opacity-100 peer-focus-visible:translate-y-0",
132-
form.formState.errors.bundleIds?.message &&
133-
"text-destructive translate-y-0 opacity-100 block",
134-
)}
135-
>
136-
{form.formState.errors.bundleIds?.message ??
137-
"Space or comma-separated list of bundle IDs"}
138-
</FormDescription>
139-
</>
115+
<Input placeholder="Bundle ID" className="peer" {...field} />
140116
</FormControl>
141-
<FormMessage />
142-
</FormItem>
143-
)}
144-
/>
145-
<FormField
146-
control={form.control}
147-
name="permissions"
148-
defaultValue="PROMPT_USER_V1" // Note: you *must* provide a default value here or the field won't reset
149-
render={({ field }) => (
150-
<FormItem className="col-span-4 lg:col-span-2">
151-
<Select
152-
onValueChange={field.onChange}
153-
defaultValue={field.value}
154-
>
155-
<ToolTipLabel label="Should wallet actions prompt the user for approval?">
156-
<FormControl>
157-
<SelectTrigger className="w-full">
158-
<SelectValue placeholder="Wallet prompts" />
159-
</SelectTrigger>
160-
</FormControl>
161-
</ToolTipLabel>
162-
<SelectContent>
163-
<SelectItem value="FULL_CONTROL_V1">
164-
Never prompt
165-
</SelectItem>
166-
<SelectItem value="PROMPT_USER_V1">Prompt user</SelectItem>
167-
</SelectContent>
168117

169-
<FormDescription
170-
className={cn(
171-
"hidden text-xs transition-all lg:block lg:-translate-y-4 lg:opacity-0 peer-focus-visible:opacity-100 peer-focus-visible:translate-y-0",
172-
form.formState.errors.permissions?.message &&
173-
"text-destructive lg:translate-y-0 lg:opacity-100 block", // If there are errors show them rather than the tip
174-
)}
175-
>
176-
{form.formState.errors.permissions?.message ??
177-
"Wallet signing"}
178-
</FormDescription>
179-
</Select>
118+
<FormDescription>
119+
Space or comma-separated list of bundle IDs
120+
</FormDescription>
121+
122+
<FormMessage />
180123
</FormItem>
181124
)}
182125
/>
183126
</div>
184-
<Button
185-
disabled={isPending}
186-
type="submit"
187-
variant="outline"
188-
className="w-full lg:w-auto"
189-
>
127+
128+
<Button disabled={isPending} type="submit" className="w-full gap-2">
129+
{isPending && <Spinner className="size-4" />}
190130
Add
191131
</Button>
192132
</form>

0 commit comments

Comments
 (0)