Skip to content

Conversation

charliepark
Copy link
Contributor

This PR finishes the QueryTable move from ~/table/QueryTable to ~/table/QueryTable2 (though — not to be confusing — it also renames the file ~/table/QueryTable2 back to ~/table/QueryTable.

All tests are passing and I clicked through to check that the tables are still rendering their data correctly. Will look for a few more optimizations / refactors in this, but I it's ready for review.

Copy link

vercel bot commented Apr 1, 2024

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

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Apr 2, 2024 9:51pm

@charliepark
Copy link
Contributor Author

Oh, capitalization; fun times.

@david-crespo
Copy link
Collaborator

Looks great pending the casing fixes. You should also be able to delete DefaultCell and linkCell. I think.

cell: (info) => <DateCell value={info.getValue()} />,
}),
]

Copy link
Collaborator

Choose a reason for hiding this comment

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

This one, on the other hand, has a column that can't be defined outside of render because it relies on project. In this case, we need to memoize.

const columns = useMemo(() => [
  colHelper.accessor('name', { cell: makeLinkCell((vpc) => pb.vpc({ project, vpc }))}),
  colHelper.accessor('dnsName', { header: 'DNS name' }),
  colHelper.accessor('description', {}),
  colHelper.accessor('timeCreated', {
    header: 'created',
    cell: (info) => <DateCell value={info.getValue()} />,
  }),
  getActionsCol(makeActions)
], [project, makeActions])

There's no point using useColsWithActions here — all it really does is wrap that useMemo. We may find we're using useColsWithActions in so few places after this change that we should just get rid of it.

In theory we could move the four statically definable columns out of here and spread them in with ...staticCols, but I don't think the misdirection is worth it. Because of the useMemo they are only ever defined once anyway.

}

const colHelper = createColumnHelper<Project>()
const projectsPageStaticCols = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick, but for future reference I think the long name is overkill in files where there's only one, which is nearly all of them. It's actually kind of nice for them all to have the same name; it's like export const loader in a remix app.

@david-crespo
Copy link
Collaborator

We did it.

@david-crespo david-crespo merged commit b63c81e into main Apr 2, 2024
@david-crespo david-crespo deleted the more-table-conversions branch April 2, 2024 22:36
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.

2 participants