-
Notifications
You must be signed in to change notification settings - Fork 7
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
Changes from all commits
04e2058
024b621
291fbb9
bb7e8b5
3d2e9f7
809c1b3
8983e9d
782e288
4f5d0e8
869d041
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
newSubDao: RouteInfo; | ||
modifyGovernance: RouteInfo; | ||
hierarchy: RouteInfo; | ||
|
@@ -22,58 +21,54 @@ export interface DAORoutes extends RouteIndex { | |
} | ||
|
||
export const DAO_ROUTES: DAORoutes = { | ||
daos: { | ||
relative: () => '/daos', | ||
path: 'daos/:address/*', | ||
}, | ||
Comment on lines
-25
to
-28
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
dao: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}`, | ||
relative: (daoAddress: string) => `/home?dao=${daoAddress}`, | ||
path: '*', | ||
}, | ||
newSubDao: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/new`, | ||
relative: (daoAddress: string) => `/new?dao=${daoAddress}`, | ||
path: 'new', | ||
}, | ||
modifyGovernance: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/edit/governance`, | ||
relative: (daoAddress: string) => `/edit/governance?dao=${daoAddress}`, | ||
path: 'edit/governance', | ||
}, | ||
hierarchy: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/hierarchy`, | ||
relative: (daoAddress: string) => `/hierarchy?dao=${daoAddress}`, | ||
path: 'hierarchy', | ||
}, | ||
treasury: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/treasury`, | ||
relative: (daoAddress: string) => `/treasury?dao=${daoAddress}`, | ||
path: 'treasury', | ||
}, | ||
proposals: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/proposals`, | ||
relative: (daoAddress: string) => `/proposals?dao=${daoAddress}`, | ||
path: 'proposals', | ||
}, | ||
proposal: { | ||
relative: (daoAddress: string, proposalId: string) => | ||
`/daos/${daoAddress}/proposals/${proposalId}`, | ||
`/proposals/${proposalId}?dao=${daoAddress}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: 'proposals/:proposalId', | ||
}, | ||
proposalNew: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/proposals/new`, | ||
relative: (daoAddress: string) => `/proposals/new?dao=${daoAddress}`, | ||
path: 'proposals/new', | ||
}, | ||
settings: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/settings`, | ||
relative: (daoAddress: string) => `/settings?dao=${daoAddress}`, | ||
path: 'settings', | ||
}, | ||
proposalTemplates: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/proposal-templates`, | ||
relative: (daoAddress: string) => `/proposal-templates?dao=${daoAddress}`, | ||
path: 'proposal-templates', | ||
}, | ||
proposalTemplate: { | ||
relative: (daoAddress: string, proposalTemplateKey: string) => | ||
`/daos/${daoAddress}/proposal-templates/${proposalTemplateKey}`, | ||
`/proposal-templates/${proposalTemplateKey}?dao=${daoAddress}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with these "proposal template keys" |
||
path: 'proposal-templates/:proposalTemplateKey', | ||
}, | ||
proposalTemplateNew: { | ||
relative: (daoAddress: string) => `/daos/${daoAddress}/proposal-templates/new`, | ||
relative: (daoAddress: string) => `/proposal-templates/new?dao=${daoAddress}`, | ||
path: 'proposal-templates/new', | ||
}, | ||
}; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { useEffect } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { useFractal } from '../../providers/App/AppProvider'; | ||
import { useERC20Claim } from './loaders/governance/useERC20Claim'; | ||
import { useSnapshotProposals } from './loaders/snapshot/useSnapshotProposals'; | ||
|
@@ -11,7 +11,9 @@ import { useFractalTreasury } from './loaders/useFractalTreasury'; | |
import { useGovernanceContracts } from './loaders/useGovernanceContracts'; | ||
|
||
export default function useDAOController() { | ||
const { daoAddress } = useParams(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type of this |
||
const [searchParams] = useSearchParams(); | ||
const daoAddress = searchParams.get('dao'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type of this |
||
|
||
const { | ||
node: { | ||
nodeHierarchy: { parentAddress }, | ||
|
@@ -24,7 +26,7 @@ export default function useDAOController() { | |
} | ||
}, [action, daoAddress]); | ||
|
||
const { nodeLoading, errorLoading } = useFractalNode({ daoAddress }); | ||
const { nodeLoading, errorLoading } = useFractalNode({ daoAddress: daoAddress || undefined }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, to conform with |
||
useGovernanceContracts(); | ||
useFractalGuardContracts({}); | ||
useFractalFreeze({ parentSafeAddress: parentAddress }); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createBrowserRouter } from 'react-router-dom'; | ||
import { createBrowserRouter, redirect } from 'react-router-dom'; | ||
import { ModalProvider } from './components/ui/modals/ModalProvider'; | ||
import Layout from './components/ui/page/Layout'; | ||
import FourOhFourPage from './pages/404'; | ||
|
@@ -34,15 +34,15 @@ export const router = createBrowserRouter([ | |
element: <HomePage />, | ||
}, | ||
{ | ||
path: '/create', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need that slash |
||
path: 'create', | ||
element: <DaoCreatePage />, | ||
}, | ||
{ | ||
path: 'daos/:daoAddress', | ||
path: '/', | ||
element: <DAOController />, | ||
children: [ | ||
{ | ||
index: true, | ||
path: 'home', | ||
element: <DaoDashboardPage />, | ||
}, | ||
{ | ||
|
@@ -97,6 +97,12 @@ export const router = createBrowserRouter([ | |
}, | ||
], | ||
}, | ||
{ | ||
// this exists to keep old links working | ||
// /daos/0x0123/* will redirect to /home?dao=0x0123 | ||
path: 'daos/:daoAddress/*', | ||
loader: ({ params: { daoAddress } }) => redirect(`/home?dao=${daoAddress}`), | ||
}, | ||
{ | ||
path: '*', // 404 | ||
element: <FourOhFourPage />, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh this again! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk, I'm not super concerned about it at the moment. |
||
}); | ||
}; | ||
|
||
|
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.
Noticed that this wasn't being used anywhere in the codebase, so removed it.