Skip to content

Commit b59c148

Browse files
authored
feat(tangle-cloud): List operators in the Operators page (#3005)
1 parent 4fb6891 commit b59c148

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1279
-615
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ libs/tangle-shared-ui/src/graphql/
103103
vitest.config.*.timestamp*
104104

105105
# React Scan reports
106-
reports/
106+
reports/
107+
.cursor/rules/nx-rules.mdc
108+
.github/instructions/nx.instructions.md

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"files.associations": {
1414
"*.css": "tailwindcss"
1515
},
16-
"eslint.useFlatConfig": true
16+
"eslint.useFlatConfig": true,
17+
"nxConsole.generateAiAgentRules": true
1718
}

apps/tangle-cloud/src/app/app.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { PagePath } from '../types';
1010
import RegistrationReview from '../pages/registrationReview/page';
1111
import RegistrationLayout from '../pages/registrationReview/layout';
1212
import DeployPage from '../pages/blueprints/[id]/deploy/page';
13+
import OperatorsPage from '../pages/operators/page';
14+
import OperatorsLayout from '../pages/operators/layout';
1315
import NotFoundPage from '../pages/notFound';
1416
import { FC } from 'react';
1517

@@ -72,11 +74,11 @@ const App: FC = () => {
7274
/>
7375

7476
<Route
75-
path={PagePath.BLUEPRINTS_REGISTRATION_REVIEW}
77+
path={PagePath.OPERATORS}
7678
element={
77-
<RegistrationLayout>
78-
<RegistrationReview />
79-
</RegistrationLayout>
79+
<OperatorsLayout>
80+
<OperatorsPage />
81+
</OperatorsLayout>
8082
}
8183
/>
8284

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// TODO: Update this link after the pricing page is ready
2-
export const OPERATOR_PRICING_URL = 'https://docs.tangle.tools';
1+
// TODO: Update this link after the operator RPC page is ready
2+
export const OPERATOR_RPC_URL = 'https://docs.tangle.tools';
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { zodResolver } from '@hookform/resolvers/zod';
2+
import { Blueprint } from '@tangle-network/tangle-shared-ui/types/blueprint';
3+
import { Form } from '@tangle-network/ui-components/components/form';
4+
import {
5+
FormControl,
6+
FormField,
7+
FormItem,
8+
FormLabel,
9+
FormMessage,
10+
} from '@tangle-network/ui-components/components/form';
11+
import { Input } from '@tangle-network/ui-components';
12+
import {
13+
ModalBody,
14+
ModalContent,
15+
ModalHeader,
16+
} from '@tangle-network/ui-components/components/Modal';
17+
import { FC, useCallback } from 'react';
18+
import { useForm } from 'react-hook-form';
19+
import {
20+
blueprintFormSchema,
21+
BlueprintFormSchema,
22+
BlueprintFormResult,
23+
} from './types';
24+
import FormActions from './FormActions';
25+
26+
type Props = {
27+
onOpenChange: (isOpen: boolean) => void;
28+
blueprints: Blueprint[];
29+
onSubmit: (result: BlueprintFormResult) => void;
30+
};
31+
32+
const ConfigureBlueprintModal: FC<Props> = ({
33+
onOpenChange,
34+
blueprints,
35+
onSubmit,
36+
}) => {
37+
const form = useForm<BlueprintFormSchema>({
38+
resolver: zodResolver(blueprintFormSchema),
39+
defaultValues: {
40+
rpcUrl: '',
41+
},
42+
});
43+
44+
const handleClose = useCallback(() => {
45+
onOpenChange(false);
46+
form.reset();
47+
}, [form, onOpenChange]);
48+
49+
const handleSubmit = useCallback(
50+
(values: BlueprintFormSchema) => {
51+
handleClose();
52+
onSubmit({
53+
values,
54+
});
55+
},
56+
[handleClose, onSubmit],
57+
);
58+
59+
return (
60+
<ModalContent
61+
size="md"
62+
onInteractOutside={(event) => event.preventDefault()}
63+
title="Configure Blueprint"
64+
description={`Configure the RPC URL for ${blueprints.length} selected blueprint${blueprints.length > 1 ? 's' : ''}`}
65+
>
66+
<ModalHeader onClose={handleClose} className="pb-4">
67+
Configure Blueprint{blueprints.length > 1 ? 's' : ''}
68+
</ModalHeader>
69+
70+
<ModalBody className="p-6">
71+
<Form {...form}>
72+
<form
73+
onSubmit={form.handleSubmit(handleSubmit)}
74+
className="space-y-6"
75+
>
76+
{blueprints.length > 1 ? (
77+
<div className="space-y-4">
78+
<p className="text-mono-120 dark:text-mono-100">
79+
The following blueprints will be configured with the same RPC
80+
URL:
81+
</p>
82+
<ul className="list-disc pl-5 space-y-2">
83+
{blueprints.map((blueprint) => (
84+
<li
85+
key={blueprint.id}
86+
className="text-mono-120 dark:text-mono-100"
87+
>
88+
{blueprint.name}
89+
</li>
90+
))}
91+
</ul>
92+
</div>
93+
) : null}
94+
95+
<FormField
96+
control={form.control}
97+
name="rpcUrl"
98+
render={({ field }) => (
99+
<FormItem>
100+
<FormLabel>Enter RPC URL</FormLabel>
101+
<FormControl>
102+
<Input
103+
id="rpc-url-input"
104+
placeholder="https://rpc.example.com"
105+
{...field}
106+
/>
107+
</FormControl>
108+
<FormMessage />
109+
</FormItem>
110+
)}
111+
/>
112+
113+
<FormActions />
114+
</form>
115+
</Form>
116+
</ModalBody>
117+
</ModalContent>
118+
);
119+
};
120+
121+
export default ConfigureBlueprintModal;

apps/tangle-cloud/src/pages/blueprints/ConfigurePricingModal/FormActions.tsx renamed to apps/tangle-cloud/src/pages/blueprints/ConfigureBlueprintModal/FormActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Button from '@tangle-network/ui-components/components/buttons/Button';
22
import { ModalFooter } from '@tangle-network/ui-components/components/Modal';
3-
import { OPERATOR_PRICING_URL } from '../../../constants/links';
3+
import { OPERATOR_RPC_URL } from '../../../constants/links';
44

55
const FormActions = () => {
66
return (
77
<ModalFooter className="px-0">
88
<Button
9-
href={OPERATOR_PRICING_URL}
9+
href={OPERATOR_RPC_URL}
1010
target="_blank"
1111
className="flex-1 max-w-none"
1212
variant="secondary"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ConfigureBlueprintModal from './ConfigureBlueprintModal';
2+
3+
export default ConfigureBlueprintModal;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { z } from 'zod';
2+
3+
export const blueprintFormSchema = z.object({
4+
rpcUrl: z.string().url({ message: 'Please enter a valid URL' }).optional(),
5+
});
6+
7+
export type BlueprintFormSchema = z.infer<typeof blueprintFormSchema>;
8+
9+
export type BlueprintFormResult = {
10+
values: BlueprintFormSchema;
11+
};

apps/tangle-cloud/src/pages/blueprints/ConfigurePricingModal/ConfigurePricingModal.tsx

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)