Skip to content

Commit

Permalink
fix(provider): Copy changes and refactor some components (#530)
Browse files Browse the repository at this point in the history
* chore: removed akt price data from dashboard

* chore: refactor and fix copy changes

* chore: changed actions to activity and other refactor changes

* chore: change control machine to label connected

* chore: refactor control machine sidebar

* chore: refactor sidebar control machine and provider status

* refactor(provider): change become provider process copy changes

* refactor(provider): fix sidebar ui

* refactor(provider): fix layout and added loading

* refactor(provider): fix wallet import mode and api calls

* fix: fixed type definations

* fix: removed console logs
  • Loading branch information
jigar-arc10 authored Jan 15, 2025
1 parent 7125f88 commit c5efbff
Show file tree
Hide file tree
Showing 21 changed files with 477 additions and 414 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
SelectContent,
SelectItem,
SelectTrigger,
Separator } from "@akashnetwork/ui/components";
Separator
} from "@akashnetwork/ui/components";
import { zodResolver } from "@hookform/resolvers/zod";
import { Plus, Trash } from "iconoir-react";
import { useAtom } from "jotai";
Expand Down Expand Up @@ -109,9 +110,8 @@ export const ProviderAttributes: React.FunctionComponent<ProviderAttributesProps
<div className="w-full max-w-2xl space-y-6">
<div>
<h3 className="text-xl font-bold">{existingAttributes ? "Edit Provider Attributes" : "Provider Attributes"}</h3>
<p className="text-muted-foreground text-sm">
{existingAttributes ? "Please update your provider attributes." : "Please enter your provider attributes."}
</p>
<p className="text-muted-foreground text-sm">Attributes choosen here will be displayed publicly to the Console.</p>
<p className="text-muted-foreground text-sm">It will be used for filtering and querying providers during bid process.</p>
</div>
<div>
<Separator />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const ProviderConfig: React.FC<ProviderConfigProps> = ({ onComplete }) =>
<div className="w-full max-w-2xl space-y-6">
<div>
<h3 className="text-xl font-bold">Provider Information</h3>
<p className="text-muted-foreground text-sm">Please enter your provider details.</p>
<p className="text-muted-foreground text-sm">Hostname will be displayed publicly to the Console.</p>
<p className="text-muted-foreground text-sm">Email may be used for notifications.</p>
</div>
<div>
<Separator />
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import React, { useCallback, useState } from "react";
import { Button, Input, Separator } from "@akashnetwork/ui/components";

import { ResetProviderForm } from "./ResetProviderProcess";
import { ServerForm } from "./ServerForm";

interface ServerAccessProps {
Expand Down Expand Up @@ -30,18 +29,26 @@ export const ServerAccess: React.FC<ServerAccessProps> = ({ onComplete }) => {
<div className="flex flex-col items-center pt-10">
{!activateServerForm ? (
<div className="space-y-6">
<div>
<h3 className="text-xl font-bold">Specify Number of Servers</h3>
<p className="text-muted-foreground text-sm">Tell us how many servers you'll be using in your setup.</p>
<div className="flex items-center space-x-4">
<h3 className="text-xl font-bold">Server Count</h3>
<Input
type="number"
placeholder="1"
value={numberOfServers}
onChange={handleNumberOfServersChange}
min={1}
className="w-20 rounded-md border-2 text-center"
/>
</div>
<Input type="number" placeholder="1" value={numberOfServers} onChange={handleNumberOfServersChange} min={1} />
<p className="text-sm">
How many servers will you be using to set up this provider? <br />
(Include all nodes - control nodes, etcd, worker nodes)
</p>
<div className="">
<Separator />
</div>
<div className="flex w-full justify-between">
<div className="flex justify-start">
<ResetProviderForm />
</div>
<div className="flex justify-start"></div>
<div className="flex justify-end">
<Button onClick={() => setActivateServerForm(true)}>Next</Button>
</div>
Expand Down
64 changes: 30 additions & 34 deletions apps/provider-console/src/components/become-provider/ServerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
if (currentServerNumber === 0 || !providerProcess?.storeInformation) {
return {
hostname: "",
authType: "password",
authType: "file",
username: "root",
port: 22
};
Expand All @@ -91,7 +91,7 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo

const form = useForm<AccountFormValues>({
resolver: zodResolver(accountFormSchema),
defaultValues: editMode ? controlMachine?.access : (getDefaultValues() as any)
defaultValues: editMode ? { ...controlMachine?.access, username: "root" } : (getDefaultValues() as any)
});

useEffect(() => {
Expand Down Expand Up @@ -278,9 +278,9 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
name="username"
render={({ field }) => (
<FormItem className="flex flex-col space-y-2">
<FormLabel>Username</FormLabel>
<FormLabel>SSH Username</FormLabel>
<FormControl>
<Input placeholder="Input your username" {...field} />
<Input placeholder="Input your SSH username" {...field} />
</FormControl>
<FormDescription>The username must be "root" for proper setup.</FormDescription>
<FormMessage />
Expand All @@ -300,12 +300,12 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
onValueChange={value => form.setValue("authType", value as "password" | "file")}
>
<TabsList className="ml-auto">
<TabsTrigger value="password" className="text-zinc-600 dark:text-zinc-200">
Password
</TabsTrigger>
<TabsTrigger value="file" className="text-zinc-600 dark:text-zinc-200">
File
</TabsTrigger>
<TabsTrigger value="password" className="text-zinc-600 dark:text-zinc-200">
Password
</TabsTrigger>
</TabsList>
<TabsContent value="password">
<FormField
Expand All @@ -328,7 +328,7 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
name="file"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Password File</FormLabel>
<FormLabel>SSH Private Key File</FormLabel>
<FormControl>
<Input id="file" type="file" onChange={e => fileChange(e, field)} />
</FormControl>
Expand Down Expand Up @@ -356,6 +356,27 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
</TabsContent>
</Tabs>
</div>
{currentServerNumber === 0 && !editMode && (
<div className="pt-2">
<FormField
control={form.control}
name="saveInformation"
render={({ field }) => (
<FormItem className="flex items-center space-x-2">
<FormControl>
<Checkbox id="saveInformation" checked={field.value} onCheckedChange={field.onChange} />
</FormControl>
<FormLabel htmlFor="saveInformation" className="text-sm font-medium leading-none">
Apply this config to all nodes?
</FormLabel>
</FormItem>
)}
/>
</div>
)}
</div>
<div className="">
<Separator />
</div>
<div className="flex justify-end">
<div className="flex w-full justify-between">
Expand All @@ -364,7 +385,7 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
<Button type="submit" disabled={isVerifying}>
{isVerifying ? (
<>
<Spinner size="small" className="mr-2"/>
<Spinner size="small" className="mr-2" />
Verifying...
</>
) : editMode ? (
Expand Down Expand Up @@ -393,31 +414,6 @@ export const ServerForm: React.FC<ServerFormProp> = ({ currentServerNumber, onCo
</Alert>
)}
</div>
{currentServerNumber === 0 && !editMode && (
<div className="rounded-md border">
<div className="space-y-2 p-4">
<h4 className="text-lg font-bold">Heads up!</h4>
<p className="text-sm">You can apply information from Control Plane 1 to all remaining nodes by checking the option below.</p>
<div>
<FormField
control={form.control}
name="saveInformation"
render={({ field }) => (
<FormItem className="flex items-center space-x-2">
<FormControl>
<Checkbox id="saveInformation" checked={field.value} onCheckedChange={field.onChange} />
</FormControl>
<FormLabel htmlFor="saveInformation" className="text-sm font-medium leading-none">
Yes
</FormLabel>
</FormItem>
)}
/>
<FormMessage />
</div>
</div>
</div>
)}
</form>
</Form>
</div>
Expand Down
Loading

0 comments on commit c5efbff

Please sign in to comment.