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

Enhancement/1492 dao identifier query param #1494

Merged
merged 10 commits into from
Mar 27, 2024

Conversation

adamgall
Copy link
Member

@adamgall adamgall commented Mar 26, 2024

Closes #1492

I decided to split the work from #1483 into two PRs, this being the first. To that effect, I created a new issue (#1492), which this PR closes.

This PR:

  • Removes the /daos path prefix from all DAO-specific routes.
  • Moves the DAO address identifier from within the URL's path, to in a new queryParam (called "dao").
  • Introduces a new path for the DAO's Dashboard (which used to be just the address of the DAO), called "/home".
  • Maintains the URL path matching for existing links that are out there on the internet.

For example, a DAO's URL used to be

  1. home: https://app.fractalframework.xyz/daos/0x36bD3044ab68f600f6d3e081056F34f2a58432c4
  2. treasury: https://app.fractalframework.xyz/daos/0x36bD3044ab68f600f6d3e081056F34f2a58432c4/treasury
  3. proposals: https://app.fractalframework.xyz/daos/0x36bD3044ab68f600f6d3e081056F34f2a58432c4/proposals

But as per this PR, it will be

  1. home: https://app.fractalframework.xyz/home?dao=0x36bD3044ab68f600f6d3e081056F34f2a58432c4
  2. treasury: https://app.fractalframework.xyz/treasury?dao=0x36bD3044ab68f600f6d3e081056F34f2a58432c4
  3. proposals: https://app.fractalframework.xyz/proposals?dao=0x36bD3044ab68f600f6d3e081056F34f2a58432c4

Additionally, we make sure to preserve existing URLs that are out there on the internet. To do that, we still match the /daos/:address/* path, and automatically redirect to /home?dao=:address.

A side effect that reviewers of this PR should be aware of, is that if someone had bookmarked or previously linked to any page within a DAO (like the treasury or proposals page), the redirect will take a user to the home page in the new URL structure.

@adamgall adamgall self-assigned this Mar 26, 2024
Copy link

netlify bot commented Mar 26, 2024

Deploy Preview for fractal-dev ready!

Name Link
🔨 Latest commit 869d041
🔍 Latest deploy log https://app.netlify.com/sites/fractal-dev/deploys/660392a9b074f200089fd99b
😎 Deploy Preview https://deploy-preview-1494.app.dev.fractalframework.xyz
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -7,7 +7,6 @@ type RouteInfo = { relative: (...args: any) => string; path: string };
type RouteIndex = { [key: string]: RouteInfo };
export interface DAORoutes extends RouteIndex {
dao: RouteInfo;
daos: RouteInfo;
Copy link
Member Author

Choose a reason for hiding this comment

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

Noticed that this wasn't being used anywhere in the codebase, so removed it.

Comment on lines -25 to -28
daos: {
relative: () => '/daos',
path: 'daos/:address/*',
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Noticed that this wasn't being used anywhere in the codebase, so removed it.

path: 'proposals',
},
proposal: {
relative: (daoAddress: string, proposalId: string) =>
`/daos/${daoAddress}/proposals/${proposalId}`,
`/proposals/${proposalId}?dao=${daoAddress}`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Proposal IDs are still living within the path structure, but that's gonna have to be ok for now.

path: 'proposal-templates',
},
proposalTemplate: {
relative: (daoAddress: string, proposalTemplateKey: string) =>
`/daos/${daoAddress}/proposal-templates/${proposalTemplateKey}`,
`/proposal-templates/${proposalTemplateKey}?dao=${daoAddress}`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Same with these "proposal template keys"

@@ -11,7 +11,9 @@ import { useFractalTreasury } from './loaders/useFractalTreasury';
import { useGovernanceContracts } from './loaders/useGovernanceContracts';

export default function useDAOController() {
const { daoAddress } = useParams();
Copy link
Member Author

Choose a reason for hiding this comment

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

The type of this daoAddress is string | undefined.

@@ -24,7 +26,7 @@ export default function useDAOController() {
}
}, [action, daoAddress]);

const { nodeLoading, errorLoading } = useFractalNode({ daoAddress });
const { nodeLoading, errorLoading } = useFractalNode({ daoAddress: daoAddress || undefined });
Copy link
Member Author

Choose a reason for hiding this comment

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

So, to conform with useFractalNode expecting string | undefined, just did this to coerce the null to undefined.

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is the entry point to it all -- it's where we used to grab the DAO address from the path, but now grab the DAO address from a query param.

src/pages/DAOController.tsx Outdated Show resolved Hide resolved
@@ -34,69 +36,69 @@ export const router = createBrowserRouter([
element: <HomePage />,
},
{
path: '/create',
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't need that slash

@@ -103,7 +103,7 @@ export const getProposalVotes = async (
...rest,
voter,
choice: VOTE_CHOICES[voteType],
} as ProposalVote; // This bypasses the type check, but it's fine
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh this again!

Copy link
Contributor

Choose a reason for hiding this comment

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

Such a annoying p3 issue. Like worth investigating? idk plenty of other things to do...

Copy link
Member Author

Choose a reason for hiding this comment

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

idk, I'm not super concerned about it at the moment.

Copy link
Contributor

@Da-Colon Da-Colon left a comment

Choose a reason for hiding this comment

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

Code Review - Approval pending some live testing.

@adamgall
Copy link
Member Author

adamgall commented Mar 26, 2024

I'm seeing an issue with this code.

If you attempt to load an invalid DAO, the "Invalid DAO" page is rendering without the context of the <Layout>, which is a bug.

edit: ah, but I think I know how to fix it. Will push more code in a bit

edit2: fixed, with a realization that I didn't need to remove the <Outlet>s from DAOController anyway yay

Copy link

@tomstuart123 tomstuart123 left a comment

Choose a reason for hiding this comment

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

@adamgall - approval given

I did lots of testing of this PR with Decent, shutter, and myosin by pasting old URLs into this deploy link
Good news is they were all handled successfully 🙂

I can also confirm your point above that linking to an old link to the treasury page, will now link back to the core homepage (note - this is absolutely fine)

Copy link
Contributor

@Da-Colon Da-Colon left a comment

Choose a reason for hiding this comment

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

Ship it

@adamgall adamgall merged commit 0eca025 into develop Mar 27, 2024
7 checks passed
@adamgall adamgall deleted the enhancement/1492-dao-identifier-query-param branch March 27, 2024 13:42
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.

Moving DAO identifier to query params
3 participants