Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f45790e
Change tab to networking
charliepark Apr 3, 2024
3fcfd71
Merge branch 'main' into networking-tab-enhancements
charliepark Apr 3, 2024
693d025
Move Add Network Interface button above table
charliepark Apr 3, 2024
c9d1ebe
Merge branch 'main' into networking-tab-enhancements
charliepark Apr 3, 2024
c8bc25d
Move to using useReactTable directly for Network Interfaces
charliepark Apr 4, 2024
c44598d
Merge branch 'main' into networking-tab-enhancements
charliepark Apr 4, 2024
8985fd6
Table and modal to attach / detach working
charliepark Apr 6, 2024
556824b
Add tests
charliepark Apr 6, 2024
7b787dd
refactor button
charliepark Apr 6, 2024
b8e9238
fix test
charliepark Apr 6, 2024
54968b3
Merge main into networking-tab-enhancements
david-crespo Apr 8, 2024
1e25de9
roll TableTitle into UI table file
david-crespo Apr 8, 2024
b26adbc
change table title to text-sans-lg
david-crespo Apr 10, 2024
8e50065
tweak spacing
david-crespo Apr 11, 2024
8d60df4
put external IPs on top
david-crespo Apr 11, 2024
38cc08f
fix e2e tests
david-crespo Apr 11, 2024
7b68026
use non-hook version of addToast
david-crespo Apr 11, 2024
71bf1ad
simplify attach modal a bit
david-crespo Apr 11, 2024
aa95fca
casing
david-crespo Apr 11, 2024
05f769e
extract FloatingIpLabel
david-crespo Apr 11, 2024
fa03232
use watch instead of getValue and ListboxField instead of setValue
david-crespo Apr 11, 2024
082c209
fix mock floating IP update with empty description
david-crespo Apr 11, 2024
3122232
leave off dash when there's no description
david-crespo Apr 11, 2024
5418dc3
Table label tweaks
benjaminleonard Apr 11, 2024
418699d
tweak data fetches, get rid of question marks
david-crespo Apr 11, 2024
090fbfa
Merge branch 'networking-tab-enhancements' of https://github.com/oxid…
benjaminleonard Apr 12, 2024
fd643b0
change disk name column header on storage tab to "disk"
david-crespo Apr 12, 2024
d507f2d
move kind into its own column
david-crespo Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions app/pages/project/floating-ips/AttachFloatingIpModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/

import { useForm } from 'react-hook-form'

import { useApiMutation, useApiQueryClient, type FloatingIp, type Instance } from '~/api'
import { ListboxField } from '~/components/form/fields/ListboxField'
import { addToast } from '~/stores/toast'
import { Message } from '~/ui/lib/Message'
import { Modal } from '~/ui/lib/Modal'

function FloatingIpLabel({ fip }: { fip: FloatingIp }) {
return (
<div className="text-tertiary selected:text-accent-secondary">
<div>{fip.name}</div>
<div className="flex gap-0.5">
<div>{fip.ip}</div>
{fip.description && (
<>
<span className="mx-1 text-quinary selected:text-accent-disabled">/</span>
<div className="flex-grow overflow-hidden overflow-ellipsis whitespace-pre text-left">
{fip.description}
</div>
</>
)}
</div>
</div>
)
}

export const AttachFloatingIpModal = ({
floatingIps,
instance,
project,
onDismiss,
}: {
floatingIps: Array<FloatingIp>
instance: Instance
project: string
onDismiss: () => void
}) => {
const queryClient = useApiQueryClient()
const floatingIpAttach = useApiMutation('floatingIpAttach', {
onSuccess() {
queryClient.invalidateQueries('floatingIpList')
queryClient.invalidateQueries('instanceExternalIpList')
addToast({ content: 'Your floating IP has been attached' })
onDismiss()
},
onError: (err) => {
addToast({ title: 'Error', content: err.message, variant: 'error' })
},
})
const form = useForm({ defaultValues: { floatingIp: '' } })
const floatingIp = form.watch('floatingIp')

return (
<Modal isOpen title="Attach floating IP" onDismiss={onDismiss}>
<Modal.Body>
<Modal.Section>
<Message
variant="info"
content={`Instance ‘${instance.name}’ will be reachable at the selected IP address`}
/>
<form>
<ListboxField
control={form.control}
name="floatingIp"
label="Floating IP"
placeholder="Select floating IP"
items={floatingIps.map((ip) => ({
value: ip.id,
label: <FloatingIpLabel fip={ip} />,
labelString: ip.name,
}))}
required
/>
</form>
</Modal.Section>
</Modal.Body>
<Modal.Footer
actionText="Attach"
disabled={!floatingIp}
onAction={() =>
floatingIpAttach.mutate({
path: { floatingIp },
query: { project },
body: { kind: 'instance', parent: instance.id },
})
}
onDismiss={onDismiss}
></Modal.Footer>
</Modal>
)
}
2 changes: 1 addition & 1 deletion app/pages/project/floating-ips/FloatingIpsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const AttachFloatingIpModal = ({
const form = useForm({ defaultValues: { instanceId: '' } })

return (
<Modal isOpen title="Attach Floating IP" onDismiss={onDismiss}>
<Modal isOpen title="Attach floating IP" onDismiss={onDismiss}>
<Modal.Body>
<Modal.Section>
<Message
Expand Down
2 changes: 1 addition & 1 deletion app/pages/project/instances/instance/InstancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function InstancePage() {
<RouteTabs fullWidth>
<Tab to={pb.instanceStorage(instanceSelector)}>Storage</Tab>
<Tab to={pb.instanceMetrics(instanceSelector)}>Metrics</Tab>
<Tab to={pb.nics(instanceSelector)}>Network Interfaces</Tab>
<Tab to={pb.nics(instanceSelector)}>Networking</Tab>
<Tab to={pb.instanceConnect(instanceSelector)}>Connect</Tab>
</RouteTabs>
</>
Expand Down
Loading