Skip to content

Conversation

@david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Oct 31, 2022

  • Network interface create/edit on the instance networking tab
  • NetworkInterfaceField
  • ImageSelectField
  • Delete Formik entirely
  • Instance create works, e2e tests pass!
  • Fix RadioField typing
  • Rename RadioField2, think about reworking it to be less repetitive

Main app.js size goes down 100 KB.

image

@vercel
Copy link

vercel bot commented Oct 31, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
console-ui-storybook ✅ Ready (Inspect) Visit Preview Nov 1, 2022 at 3:23PM (UTC)

// API accepts undefined but it's easier if we don't
SetRequired<InstanceCreate, 'networkInterfaces'>,
{
networkInterfaceType: InstanceNetworkInterfaceAttachment['type']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I've done here is take the None/Default/Custom radio state out of the top-level form state and used networkInterfaces.type as the value of the field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, definitely like that better.

>

const values: InstanceCreateInput = {
const baseDefaultValues: InstanceCreateInput = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"base" because we add in the default value for the selected image at render time because it comes from the API.

}: CreateFormProps<InstanceCreateInput, Instance>) {
CreateInstanceForm.loader = async () => {
await apiQueryClient.prefetchQuery('systemImageList', {})
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we always have the images on hand in render.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that's just the default pagination size? We really have to rework the images API... or figure out how images are even supposed to exist in the product.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, default of 1000

* then in the calling code, the field would not infer `TFieldValues` and
* constrain the `name` prop to paths in the values object.
*/
children: (form: UseFormReturn<TFieldValues>) => ReactNode
Copy link
Collaborator Author

@david-crespo david-crespo Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that passing the whole form instead of only the control is obviously the thing to do here. In most calling code, all we change is (control) => to ({ control }) =>, so that's easy. I didn't change the SideModalForm to work this way yet because of noise. I'll do that in a followup when I move everything back into app/components/form.

Initially I made this change because I thought I needed it for instance create — I was going to do something funky with watch — but even though I didn't end up using it, it seems to me clearly the correct way to do it.

</NavLinkItem>
<NavLinkItem to={pb.hotkeys()}>
<Profile16Icon /> Hotkeys
</NavLinkItem>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took these out because they're fake and it seemed easier than changing them, but I can put them back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine. Can just re-add them as we implement them.

{
id: 'a2ea1d7a-cc5a-4fda-a400-e2d2b18f53c5',
name: 'ubuntu-20.04',
name: 'ubuntu-20-04',
Copy link
Collaborator Author

@david-crespo david-crespo Nov 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were invalid names and they were breaking the instance create POST! This is a bug on main actually.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validators ftw

Copy link
Contributor

@just-be-dev just-be-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a big change, good work. Only minor feedback, excited to see formik removed.

...props,
}))
)
export const Form = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This nested declaration likely makes the babel plugin not work for these components.

const [currentDistro, setCurrentDistro] = useState<string | undefined>(id)
control: Control<InstanceCreateInput>
}) {
const distros = images.map((image) => ({ ...image, ...distroDisplay(image) }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice, yeah. Cleaner.

@@ -1,39 +0,0 @@
import { Settings24Icon } from '@oxide/ui'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to re-add this page soon, but nbd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants