-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: edit network urls, closes #5795
- Loading branch information
1 parent
27f3b67
commit 7256379
Showing
13 changed files
with
214 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,12 @@ | ||
import { NetworkSelectors } from '@tests/selectors/network.selectors'; | ||
import { Form, Formik } from 'formik'; | ||
import { Stack, styled } from 'leather-styles/jsx'; | ||
import { NetworkForm } from './network-form'; | ||
import { NetworkFormLayout } from './network-form.layout'; | ||
|
||
import { Button, Link } from '@leather.io/ui'; | ||
|
||
import { ErrorLabel } from '@app/components/error-label'; | ||
import { Card, Content, Page } from '@app/components/layout'; | ||
import { PageHeader } from '@app/features/container/headers/page.header'; | ||
|
||
import { AddNetworkForm } from './add-network-form'; | ||
import { useAddNetwork } from './use-add-network'; | ||
const title = 'Add network'; | ||
|
||
export function AddNetwork() { | ||
const { error, initialFormValues, loading, onSubmit } = useAddNetwork(); | ||
|
||
return ( | ||
<> | ||
<PageHeader title="Add network" /> | ||
<Content> | ||
<Page> | ||
<Formik initialValues={initialFormValues} onSubmit={onSubmit}> | ||
{({ handleSubmit }) => ( | ||
<Card | ||
footerBorder | ||
footer={ | ||
<Button | ||
fullWidth | ||
aria-busy={loading} | ||
data-testid={NetworkSelectors.AddNetworkBtn} | ||
type="submit" | ||
onClick={() => handleSubmit()} | ||
> | ||
Add network | ||
</Button> | ||
} | ||
> | ||
<Form data-testid={NetworkSelectors.NetworkPageReady}> | ||
<Stack | ||
gap="space.05" | ||
maxWidth="pageWidth" | ||
px={{ base: 'space.00', sm: 'space.04', md: 'space.05' }} | ||
my="space.05" | ||
> | ||
<styled.span textStyle="body.02"> | ||
Use this form to add a new instance of the{' '} | ||
<Link | ||
href="https://github.com/blockstack/stacks-blockchain-api" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Stacks Blockchain API | ||
</Link>{' '} | ||
or{' '} | ||
<Link | ||
href="https://mempool.space/docs/api/rest" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Bitcoin Blockchain API | ||
</Link> | ||
. Make sure you review and trust the host before you add it. | ||
</styled.span> | ||
<AddNetworkForm /> | ||
{error ? ( | ||
<ErrorLabel data-testid={NetworkSelectors.ErrorText}>{error}</ErrorLabel> | ||
) : null} | ||
</Stack> | ||
</Form> | ||
</Card> | ||
)} | ||
</Formik> | ||
</Page> | ||
</Content> | ||
</> | ||
<NetworkFormLayout title={title}> | ||
<NetworkForm title={title} /> | ||
</NetworkFormLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { NetworkForm } from './network-form'; | ||
import { NetworkFormLayout } from './network-form.layout'; | ||
|
||
const title = 'Edit network'; | ||
|
||
export function EditNetwork() { | ||
return ( | ||
<NetworkFormLayout title={title}> | ||
<NetworkForm isEditNetworkMode title={title} /> | ||
</NetworkFormLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
import { Content, Page } from '@app/components/layout'; | ||
import { PageHeader } from '@app/features/container/headers/page.header'; | ||
|
||
interface NetworkFormLayoutProps { | ||
title: string; | ||
children: ReactNode; | ||
} | ||
|
||
export function NetworkFormLayout({ title, children }: NetworkFormLayoutProps) { | ||
return ( | ||
<> | ||
<PageHeader title={title} /> | ||
<Content> | ||
<Page>{children}</Page> | ||
</Content> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { NetworkSelectors } from '@tests/selectors/network.selectors'; | ||
import { Form, Formik } from 'formik'; | ||
import { Stack, styled } from 'leather-styles/jsx'; | ||
|
||
import { Button, Link } from '@leather.io/ui'; | ||
|
||
import { ErrorLabel } from '@app/components/error-label'; | ||
import { Card } from '@app/components/layout'; | ||
|
||
import { NetworkFormFields } from './network-form-fields'; | ||
import { useAddNetwork } from './use-add-network'; | ||
|
||
interface NetworkFormProps { | ||
title: string; | ||
isEditNetworkMode?: boolean; | ||
} | ||
|
||
export function NetworkForm({ isEditNetworkMode, title }: NetworkFormProps) { | ||
const { error, initialFormValues, loading, onSubmit } = useAddNetwork(); | ||
|
||
return ( | ||
<Formik initialValues={initialFormValues} onSubmit={onSubmit}> | ||
{({ handleSubmit }) => ( | ||
<Card | ||
footerBorder | ||
footer={ | ||
<Button | ||
fullWidth | ||
aria-busy={loading} | ||
data-testid={NetworkSelectors.AddNetworkBtn} | ||
type="submit" | ||
onClick={() => handleSubmit()} | ||
> | ||
{title} | ||
</Button> | ||
} | ||
> | ||
<Form data-testid={NetworkSelectors.NetworkPageReady}> | ||
<Stack | ||
gap="space.05" | ||
maxWidth="pageWidth" | ||
px={{ base: 'space.00', sm: 'space.04', md: 'space.05' }} | ||
my="space.05" | ||
> | ||
<styled.span textStyle="body.02"> | ||
Use this form to add a new instance of the{' '} | ||
<Link | ||
href="https://github.com/blockstack/stacks-blockchain-api" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Stacks Blockchain API | ||
</Link>{' '} | ||
or{' '} | ||
<Link href="https://mempool.space/docs/api/rest" target="_blank" rel="noreferrer"> | ||
Bitcoin Blockchain API | ||
</Link> | ||
. Make sure you review and trust the host before you add it. | ||
</styled.span> | ||
<NetworkFormFields isEditNetworkMode={isEditNetworkMode} /> | ||
{error ? ( | ||
<ErrorLabel data-testid={NetworkSelectors.ErrorText}>{error}</ErrorLabel> | ||
) : null} | ||
</Stack> | ||
</Form> | ||
</Card> | ||
)} | ||
</Formik> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.