Skip to content

More table conversions - #2115

Merged
david-crespo merged 38 commits into
mainfrom
more-table-conversions
Apr 2, 2024
Merged

david-crespo merged 38 commits into
mainfrom
more-table-conversions

Conversation

@charliepark

Copy link
Copy Markdown
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.

@vercel

vercel Bot commented Apr 1, 2024 •

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

Oh, capitalization; fun times.

@david-crespo

Copy link
Copy Markdown
Collaborator

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

Comment thread app/pages/system/SiloImagesPage.tsx Resolved
Comment thread app/pages/project/vpcs/VpcsPage.tsx Outdated
cell: (info) => <DateCell value={info.getValue()} />,
}),
]

Copy link
Copy Markdown
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.

Comment thread app/pages/ProjectsPage.tsx Outdated
}

const colHelper = createColumnHelper<Project>()
const projectsPageStaticCols = [

Copy link
Copy Markdown
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
Copy Markdown
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

This branch was successfully deployed

1 active deployment
Preview — 3b06ac0f Deployed Apr 2, 2024 by vercel[bot]
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