Skip to content

Commit

Permalink
feat(frontend): admin ui changes (#2716)
Browse files Browse the repository at this point in the history
* feat(frontend): admin ui changes

* refactor: standardize default a link styling (#2719)

---------

Co-authored-by: Blair Currey <[email protected]>
  • Loading branch information
njlie and BlairCurrey authored May 14, 2024
1 parent d9b2442 commit 604af14
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 20 deletions.
12 changes: 6 additions & 6 deletions packages/frontend/app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ const navigation = [
name: 'Home',
href: '/'
},
{
name: 'Peers',
href: '/peers'
},
{
name: 'Assets',
href: '/assets'
},
{
name: 'Peers',
href: '/peers'
},
{
name: 'Wallet Addresses',
href: '/wallet-addresses'
},
{
name: 'Webhooks',
href: '/webhooks'
name: 'Webhook Events',
href: '/webhook-events'
},
{
name: 'Payments',
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/app/components/ui/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ type InputProps = Omit<ComponentPropsWithoutRef<'input'>, 'className'> & {
label?: string
error?: string | string[]
addOn?: ReactNode
description?: ReactNode
}

export const Input = forwardRef<HTMLInputElement, InputProps>(
({ addOn, label, type, error, id, ...props }, ref) => {
({ description, addOn, label, type, error, id, ...props }, ref) => {
const internalId = id ?? useId()

return (
Expand All @@ -38,6 +39,9 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
{...props}
/>
</div>
{description ? (
<div className='font-medium text-sm'>{description}</div>
) : null}
<FieldError error={error} />
</div>
)
Expand Down
8 changes: 6 additions & 2 deletions packages/frontend/app/components/ui/PasswordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentPropsWithoutRef } from 'react'
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
import { forwardRef, useId, useState } from 'react'
import { Eye, EyeSlash } from '../icons'
import { FieldError } from './FieldError'
Expand All @@ -10,10 +10,11 @@ type InputProps = Omit<
> & {
label?: string
error?: string | string[]
description?: ReactNode
}

export const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
({ label, error, ...props }, ref) => {
({ label, error, description, ...props }, ref) => {
const id = useId()
const [isVisible, setIsVisible] = useState(false)

Expand Down Expand Up @@ -45,6 +46,9 @@ export const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
)}
</button>
</div>
{description ? (
<div className='font-medium text-sm'>{description}</div>
) : null}
<FieldError error={error} />
</div>
)
Expand Down
8 changes: 7 additions & 1 deletion packages/frontend/app/components/ui/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ReactNode } from 'react'
import { Fragment, useId, useState } from 'react'
import { Combobox, Transition } from '@headlessui/react'
import { Input } from './Input'
Expand All @@ -19,6 +20,7 @@ type SelectProps = {
required?: boolean
error?: string | string[]
defaultValue?: SelectOption
description?: ReactNode
}

export const Select = ({
Expand All @@ -32,7 +34,8 @@ export const Select = ({
defaultValue = {
label: '',
value: ''
}
},
description
}: SelectProps) => {
const id = useId()
const [internalValue, setInternalValue] = useState<SelectOption>(defaultValue)
Expand Down Expand Up @@ -82,6 +85,9 @@ export const Select = ({
)}
</Combobox.Button>
</div>
{description ? (
<div className='font-medium text-sm'>{description}</div>
) : null}
{error ? <FieldError error={error} /> : null}
<Transition
as={Fragment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function ViewIncomingPaymentPage() {
<p className='font-medium'>Wallet Address ID </p>
<Link
to={`/wallet-addresses/${incomingPayment.walletAddressId}`}
className='mt-1 underline text-blue-600 hover:text-blue-800 visited:text-purple-600'
className='default-link'
>
{incomingPayment.walletAddressId}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function ViewOutgoingPaymentPage() {
<p className='font-medium'>Wallet Address ID </p>
<Link
to={`/wallet-addresses/${outgoingPayment.walletAddressId}`}
className='mt-1 underline text-blue-600 hover:text-blue-800 visited:text-purple-600'
className='default-link'
>
{outgoingPayment.walletAddressId}
</Link>
Expand All @@ -99,10 +99,7 @@ export default function ViewOutgoingPaymentPage() {
</div>
<div>
<p className='font-medium'>Receiver</p>
<Link
className='underline text-blue-600 hover:text-blue-800 visited:text-purple-600'
to={outgoingPayment.receiver}
>
<Link className='default-link' to={outgoingPayment.receiver}>
{outgoingPayment.receiver}
</Link>
</div>
Expand Down
69 changes: 69 additions & 0 deletions packages/frontend/app/routes/peers.$peerId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ export default function ViewPeerPage() {
defaultValue={peer.name ?? ''}
placeholder='Peer name'
error={response?.errors.general.fieldErrors.name}
description={
<>
The name of the{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/peering/'
>
peer
</a>
.
</>
}
/>
<Input
name='staticIlpAddress'
Expand All @@ -131,6 +143,17 @@ export default function ViewPeerPage() {
error={
response?.errors.general.fieldErrors.staticIlpAddress
}
description={
<>
{"The peer's "}
<a
className='default-link'
href='https://interledger.org/developers/rfcs/ilp-addresses/'
>
address on the Interledger network.
</a>
</>
}
/>
<Input
type='number'
Expand All @@ -141,6 +164,18 @@ export default function ViewPeerPage() {
label='Max Packet Amount'
placeholder='Max Packet Amount'
error={response?.errors.general.fieldErrors.maxPacketAmount}
description={
<>
The maximum amount of value that can be sent in a single{' '}
<a
className='default-link'
href='https://interledger.org/developers/rfcs/stream-protocol/#35-packets-and-frames'
>
Interledger STREAM Packet
</a>
.
</>
}
/>
</div>
<div className='flex justify-end p-4'>
Expand Down Expand Up @@ -174,6 +209,17 @@ export default function ViewPeerPage() {
label='Incoming Auth Tokens'
placeholder='Accepts a comma separated list of tokens'
error={response?.errors.http.fieldErrors.incomingAuthTokens}
description={
<>
List of valid tokens to accept when receiving{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/connector/#incoming-http'
>
incoming ILP packets from the peer.
</a>
</>
}
/>
<PasswordInput
name='outgoingAuthToken'
Expand All @@ -182,6 +228,17 @@ export default function ViewPeerPage() {
required
defaultValue={peer.http.outgoing.authToken}
error={response?.errors.http.fieldErrors.outgoingAuthToken}
description={
<>
List of valid tokens to present when sending{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/connector/#outgoing-http'
>
outgoing ILP packets to the peer.
</a>
</>
}
/>
<Input
name='outgoingEndpoint'
Expand All @@ -190,6 +247,18 @@ export default function ViewPeerPage() {
required
defaultValue={peer.http.outgoing.endpoint}
error={response?.errors.http.fieldErrors.outgoingEndpoint}
description={
<>
Endpoint on the peer to which{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/connector/#outgoing-http'
>
outgoing ILP packets
</a>{' '}
will be sent.
</>
}
/>
</div>
<div className='flex justify-end p-4'>
Expand Down
81 changes: 81 additions & 0 deletions packages/frontend/app/routes/peers.create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,54 @@ export default function CreatePeerPage() {
label='Name'
placeholder='Peer name'
error={response?.errors?.fieldErrors.name}
description={
<>
The name of the{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/peering/'
>
peer
</a>{' '}
to be added.
</>
}
/>
<Input
name='staticIlpAddress'
label='Static ILP Address'
placeholder='ILP Address'
required
error={response?.errors?.fieldErrors?.staticIlpAddress}
description={
<>
{"The peer's "}
<a
className='default-link'
href='https://interledger.org/developers/rfcs/ilp-addresses/'
>
address on the Interledger network.
</a>
</>
}
/>
<Input
name='maxPacketAmount'
label='Max Packet Amount'
placeholder='Max Packet Amount'
error={response?.errors?.fieldErrors?.maxPacketAmount}
description={
<>
The maximum amount of value that can be sent in a single{' '}
<a
className='default-link'
href='https://interledger.org/developers/rfcs/stream-protocol/#35-packets-and-frames'
>
Interledger STREAM Packet
</a>
.
</>
}
/>
</div>
</div>
Expand All @@ -89,20 +124,54 @@ export default function CreatePeerPage() {
label='Incoming Auth Tokens'
placeholder='Accepts a comma separated list of tokens'
error={response?.errors?.fieldErrors?.incomingAuthTokens}
description={
<>
List of valid tokens to accept when receiving{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/connector/#incoming-http'
>
incoming ILP packets from the peer.
</a>
</>
}
/>
<Input
name='outgoingAuthToken'
label='Outgoing Auth Token'
placeholder='Outgoing HTTP Auth Token'
required
error={response?.errors?.fieldErrors?.outgoingAuthToken}
description={
<>
List of valid tokens to present when sending{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/connector/#outgoing-http'
>
outgoing ILP packets to the peer.
</a>
</>
}
/>
<Input
name='outgoingEndpoint'
label='Outgoing Endpoint'
placeholder='Outgoing HTTP Endpoint'
required
error={response?.errors?.fieldErrors?.outgoingEndpoint}
description={
<>
Endpoint on the peer to which{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/interledger-protocol/connector/#outgoing-http'
>
outgoing ILP packets
</a>{' '}
will be sent.
</>
}
/>
</div>
</div>
Expand All @@ -124,6 +193,18 @@ export default function CreatePeerPage() {
name='asset'
placeholder='Select asset...'
label='Asset'
description={
<>
The type of{' '}
<a
className='default-link'
href='https://rafiki.dev/concepts/asset/'
>
asset
</a>{' '}
that is sent to & received from the peer.
</>
}
required
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function WebhookEventData() {
const [searchParams] = useSearchParams()
const state = location.state as { data: string }
const dismiss = () =>
navigate(`/webhooks${searchParams ? `?${searchParams}` : null}`, {
navigate(`/webhook-events${searchParams ? `?${searchParams}` : null}`, {
preventScrollReset: true
})

Expand Down
Loading

0 comments on commit 604af14

Please sign in to comment.