Skip to content

Commit

Permalink
Add gateway routing (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
itexpert120 authored and Megha-Dev-19 committed May 14, 2024
1 parent 41d2b62 commit 286617f
Show file tree
Hide file tree
Showing 17 changed files with 292 additions and 171 deletions.
19 changes: 18 additions & 1 deletion apps/builddao/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@ const config = {
// customize your header
<Widget
src="${config_account}/widget/components.Navbar"
props={{ routes: config.router.routes, ...passProps, page: props.page }}
props={{
routes: config.router.routes,
...passProps,
page: props.page,
fromGateway: props.fromGateway,
}}
/>
),
Footer: () => <></>, // customize your footer
},
router: {
param: "page",
commonInit: {
fromGateway: props.fromGateway,
},
routes: {
home: {
path: "${config_account}/widget/page.home",
blockHeight: "final",
init: {
name: "Home",
...commonInit,
},
default: true,
},
Expand All @@ -44,13 +53,15 @@ const config = {
blockHeight: "final",
init: {
name: "Activity",
...commonInit,
},
},
projects: {
path: "${config_account}/widget/page.projects",
blockHeight: "final",
init: {
name: "Projects",
...commonInit,
},
hide: true,
},
Expand All @@ -59,6 +70,7 @@ const config = {
blockHeight: "final",
init: {
name: "Proposals",
...commonInit,
},
hide: true,
},
Expand All @@ -67,20 +79,23 @@ const config = {
blockHeight: "final",
init: {
name: "Resources",
...commonInit,
},
},
library: {
path: "${config_account}/widget/page.library",
blockHeight: "final",
init: {
name: "Library",
...commonInit,
},
},
profile: {
path: "${config_account}/widget/page.profile",
blockHeight: "final",
init: {
name: "Profile",
...commonInit,
},
hide: true,
},
Expand All @@ -89,6 +104,7 @@ const config = {
blockHeight: "final",
init: {
name: "Inspect",
...commonInit,
},
hide: true,
},
Expand All @@ -97,6 +113,7 @@ const config = {
blockHeight: "final",
init: {
name: "Project Page",
...commonInit,
},
hide: true,
},
Expand Down
2 changes: 0 additions & 2 deletions apps/builddao/widget/app/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ if (!config) {
}
}

console.log("config", config);

if (!config) {
return (
<p>
Expand Down
165 changes: 90 additions & 75 deletions apps/builddao/widget/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const unreadNotifications = getNotificationCount();
function Navbar(props) {
const { page, routes } = props;
const [dropdown, setDropdown] = useState(false);
const fromGateway = props.fromGateway ?? false;

const toggleDropdown = () => {
setDropdown((prev) => !prev);
Expand All @@ -263,12 +264,16 @@ function Navbar(props) {
<MainContent className="container-xl">
<Left>
<Link
to={href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "home",
},
})}
to={
!fromGateway
? href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "home",
},
})
: `/`
}
className="d-flex align-items-center"
>
<img
Expand All @@ -288,12 +293,18 @@ function Navbar(props) {
<Link
key={`desktop=${k}`}
style={{ textDecoration: "none" }}
to={href({
widgetSrc: "${config_account}/widget/app",
params: {
page: k,
},
})}
to={
!fromGateway
? href({
widgetSrc: "${config_account}/widget/app",
params: {
page: k,
},
})
: k === "home"
? "/"
: `/${k}`
}
>
<span key={k} className={page === k ? "active" : null}>
{route.init.icon && <i className={route.init.icon}></i>}
Expand All @@ -309,12 +320,16 @@ function Navbar(props) {
<Button
className="rounded-3 position-relative"
type="icon"
href={href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "notifications",
},
})}
href={
!fromGateway
? href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "notifications",
},
})
: "/notifications"
}
>
<i className="bi bi-bell"></i>
{unreadNotifications > 0 && (
Expand Down Expand Up @@ -345,56 +360,52 @@ function Navbar(props) {
gap: "0.5rem",
}}
>
<StyledDropdown className="dropdown ">
<div className="d-flex justify-content-end align-items-center gap-3">
<button
className="dropdown-toggle"
type="button"
id="dropdownMenu2222"
data-bs-toggle="dropdown"
aria-expanded="false"
>
<i
style={{ color: "white" }}
className="bi bi-three-dots"
></i>
</button>
<ul
className="dropdown-menu"
aria-labelledby="dropdownMenu2222"
>
<li>
<Link
style={{ textDecoration: "none" }}
href={href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "inspect",
widgetPath: routes[page].path,
},
})}
type="icon"
variant="outline"
className="d-flex align-tiems-center gap-2"
>
<i className="bi bi-code"></i>
<span>View source</span>
</Link>
</li>
<li>
<Link
style={{ textDecoration: "none" }}
href={`/edit/${routes[page].path}`}
type="icon"
variant="outline"
className="d-flex align-items-center gap-2"
>
<i className="bi bi-pencil"></i>
<span>Edit code</span>
</Link>
</li>
</ul>
</div>
<StyledDropdown className="dropdown">
<button
className="dropdown-toggle"
type="button"
id="dropdownMenu2222"
data-bs-toggle="dropdown"
aria-expanded="false"
>
<i style={{ color: "white" }} className="bi bi-three-dots"></i>
</button>
<ul className="dropdown-menu" aria-labelledby="dropdownMenu2222">
<li>
<Link
style={{ textDecoration: "none" }}
href={
!fromGateway
? href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "inspect",
widgetPath: routes[page].path,
},
})
: `/inspect/${routes[page].path}`
}
type="icon"
variant="outline"
className="d-flex align-tiems-center gap-2"
>
<i className="bi bi-code"></i>
<span>View source</span>
</Link>
</li>
<li>
<Link
style={{ textDecoration: "none" }}
href={`/edit/${routes[page].path}`}
type="icon"
variant="outline"
className="d-flex align-items-center gap-2"
>
<i className="bi bi-pencil"></i>
<span>Edit code</span>
</Link>
</li>
</ul>
</StyledDropdown>
{context.accountId ? (
<Widget
Expand Down Expand Up @@ -539,13 +550,17 @@ function Navbar(props) {
<Button
linkClassName="d-flex w-100"
className="w-100"
href={href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "inspect",
widgetPath: routes[page].path,
},
})}
href={
!fromGateway
? href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "inspect",
widgetPath: routes[page].path,
},
})
: `/inspect/${routes[page].path}`
}
>
<span>View source</span>
</Button>
Expand Down
20 changes: 12 additions & 8 deletions apps/builddao/widget/components/buttons/Connect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const { href: linkHref } = VM.require("${config_account}/widget/lib.url") || {
href: () => {},
};

const Component = () => {
const Component = (props) => {
if (!context.accountId) {
return (
<Button
Expand All @@ -148,12 +148,16 @@ const Component = () => {
</Bullet>
<Link
style={{ color: "#df9731", fontWeight: 600 }}
to={linkHref({
widgetSrc: "${config_account}/widget/app",
params: {
page: "feed",
},
})}
to={
!props.fromGateway
? linkHref({
widgetSrc: "${config_account}/widget/app",
params: {
page: "feed",
},
})
: "/feed"
}
>
View Activity{" "}
<svg
Expand Down Expand Up @@ -192,6 +196,6 @@ const Component = () => {

return (
<Container>
<Component />
<Component fromGateway={props.fromGateway} />
</Container>
);
18 changes: 11 additions & 7 deletions apps/builddao/widget/components/buttons/UserDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@ return (
<Link
className="dropdown-item"
type="button"
to={href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "profile",
accountId: context.accountId,
},
})}
to={
!props.fromGateway
? href({
widgetSrc: "${config_account}/widget/app",
params: {
page: "profile",
accountId: context.accountId,
},
})
: `/profile/${context.accountId}`
}
>
<User />
My Profile
Expand Down
1 change: 0 additions & 1 deletion apps/builddao/widget/components/modals/propose/Text.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ return (
proposalType: "Add Member",
}}
/>
{/* {console.log(notificationsData)} */}
<div className="w-100 d-flex">
<Button
className="ms-auto"
Expand Down
Loading

0 comments on commit 286617f

Please sign in to comment.