-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Landing page #199
Landing page #199
Conversation
Signed-off-by: Aaron Sutula <[email protected]>
This PR is being deployed to Railway 🚅 web: ◻️ REMOVED |
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
firstNProjectSlugs: async function (n: number) { | ||
const res = await db | ||
.select({ team: teams.slug, project: projects.slug }) | ||
.from(projects) | ||
.innerJoin(teamProjects, eq(projects.id, teamProjects.projectId)) | ||
.innerJoin(teams, eq(teamProjects.teamId, teams.id)) | ||
.orderBy(projects.name) | ||
.limit(n) | ||
.all(); | ||
return res; | ||
}, | ||
|
||
projectByTeamAndProjectSlugs: async function ( | ||
teamSlug: string, | ||
projectSlug: string, | ||
) { | ||
const res = await db | ||
.select({ team: teams, project: projects }) | ||
.from(projects) | ||
.innerJoin(teamProjects, eq(projects.id, teamProjects.projectId)) | ||
.innerJoin(teams, eq(teamProjects.teamId, teams.id)) | ||
.where(and(eq(teams.slug, teamSlug), eq(projects.slug, projectSlug))) | ||
.get(); | ||
return res; | ||
}, | ||
|
||
latestProjects: async function (offset: number, count: number) { | ||
const res = await db | ||
.select({ projects, teams }) | ||
.from(projects) | ||
.innerJoin(teamProjects, eq(projects.id, teamProjects.projectId)) | ||
.innerJoin(teams, eq(teamProjects.teamId, teams.id)) | ||
.where(isNotNull(projects.createdAt)) | ||
.orderBy(desc(projects.createdAt)) | ||
.offset(offset) | ||
.limit(count) | ||
.all(); | ||
return res.map((r) => ({ team: r.teams, project: r.projects })); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some new sore functions for populating the landing page.
<ChainSelector | ||
onValueChange={(val) => { | ||
if (typeof val === "number") { | ||
setChainId(val); | ||
} | ||
}} | ||
disabled={pendingDeploy} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the ChainSelector
component to optionally support selecting "all testnets" and "all mainnets", so uses of this component need to be updated to handle those new values in the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component to display latest projects on the landing page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component to display latest tables on the landing page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reusable component to move forwards and backwards through paginated data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to update to the latest shadcn component version here to be compatible with a radix ui update that was introduced by installing the Alert component.
export async function featuredProjectSlugs() { | ||
if (process.env.NODE_ENV === "development") { | ||
return await store.projects.firstNProjectSlugs(5); | ||
} else if (process.env.SITE_DOMAIN?.includes("staging")) { | ||
return [ | ||
{ team: "aaron", project: "four-project" }, | ||
{ team: "joe", project: "students" }, | ||
{ team: "aaron", project: "with-timestamp" }, | ||
]; | ||
} else { | ||
return []; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we configure featured projects. cc @dtbuchholz.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are a couple functions that wrap the validator /query
endpoint to get data for the landing page.
@@ -1,5 +1,5 @@ | |||
import { Wallet, getDefaultProvider } from "ethers"; | |||
import { NonceManager } from "@tableland/nonce"; | |||
import { NonceManager } from "@ethersproject/experimental"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary change until we're ready for redis nonce manager.
"MinBlockDepth": 1, | ||
"PersistEvents": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated our local tableland validator config to persist event data so we can use it during development.
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asutula Great work! I have a few suggestions, and comments. In case you want to get this out as is for EthDen I'll approve, if not, I'm happy to jump in voice tomorrow to discuss.
@@ -1,4 +1,3 @@ | |||
API_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting, we probably want this to be STORE_PRIVATE_KEY
right?
setLoading(false); | ||
}); | ||
} | ||
fetchLatestTables().catch(() => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do something with this error. Maybe notify the user that we couldn't load the latest tables, or log to the console? Also, inside the catch function we should probably do setLoading(false)
since the loading is finished and the body of the above then
function won't be called.
useEffect(() => { | ||
async function fetchLatestTables() { | ||
setLoading(true); | ||
await getLatestTables(selectedChain).then((tables) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do const tables = await getLatestTables(selectedChain);
instead of mixing await
and then
?
packages/web/app/page.tsx
Outdated
}); | ||
} catch { | ||
// This is fine, we just don't have any teams if the user | ||
// is unauthorized or some other error happens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log the error to the console?
if (val === "mainnets" || val === "testnets") { | ||
onValueChange(val); | ||
} else { | ||
onValueChange(parseInt(val, 10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what possible values of val
could be called here, but if ""
or undefined
make it here this will be NaN
. Is that ok?
</div> | ||
<div className="ml-auto flex items-center gap-2"> | ||
<Label>Chain:</Label> | ||
<ChainSelector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticing that when I change chains, the pagination isn't reseting. This means if I'm looking at page 2 of "all testnets" and I switch to "all mainnets", it's a blank list. If I notice that the pagination says "2", i'd be able to figure out how to get back to the list of popular mainnet tables, but if not, it looks like there aren't any tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes for the Latest Tableland tables pagination.
Signed-off-by: Aaron Sutula <[email protected]>
All really good feedback @joewagner. I fixed all the things you mentioned, take a look. |
@asutula Nice work! The approval still looks good, merge away! |
No description provided.