Skip to content
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

Merged
merged 17 commits into from
Feb 27, 2024
Merged

Landing page #199

merged 17 commits into from
Feb 27, 2024

Conversation

asutula
Copy link
Contributor

@asutula asutula commented Feb 23, 2024

No description provided.

Signed-off-by: Aaron Sutula <[email protected]>
@asutula asutula self-assigned this Feb 23, 2024
Copy link

railway-app bot commented Feb 23, 2024

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]>
Comment on lines +72 to +111
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 }));
},

Copy link
Contributor Author

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.

Comment on lines +206 to +213
<ChainSelector
onValueChange={(val) => {
if (typeof val === "number") {
setChainId(val);
}
}}
disabled={pendingDeploy}
/>
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Comment on lines +3 to +15
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 [];
}
}
Copy link
Contributor Author

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.

Copy link
Contributor Author

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";
Copy link
Contributor Author

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.

Comment on lines +53 to +54
"MinBlockDepth": 1,
"PersistEvents": true
Copy link
Contributor Author

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]>
@asutula asutula marked this pull request as ready for review February 26, 2024 22:28
@asutula asutula requested a review from joewagner February 26, 2024 22:29
Signed-off-by: Aaron Sutula <[email protected]>
Copy link
Contributor

@joewagner joewagner left a 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
Copy link
Contributor

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(() => {});
Copy link
Contributor

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) => {
Copy link
Contributor

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?

});
} catch {
// This is fine, we just don't have any teams if the user
// is unauthorized or some other error happens.
Copy link
Contributor

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));
Copy link
Contributor

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

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.

Copy link
Contributor

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]>
@asutula
Copy link
Contributor Author

asutula commented Feb 27, 2024

All really good feedback @joewagner. I fixed all the things you mentioned, take a look.

@joewagner
Copy link
Contributor

@asutula Nice work! The approval still looks good, merge away!

@asutula asutula merged commit b6a490e into staging Feb 27, 2024
4 checks passed
@asutula asutula deleted the landing-page branch February 27, 2024 15:58
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