Skip to content

Commit

Permalink
Merge pull request #1026 from alleslabs/fix/nav-menu-on-mobile
Browse files Browse the repository at this point in the history
fix: add missing menu items  for sequencer tier
  • Loading branch information
evilpeach authored Jul 17, 2024
2 parents 952d199 + 3bbfcc9 commit 5d986fe
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#1026](https://github.com/alleslabs/celatone-frontend/pull/1026) Add missing menu items for sequencer tier
- [#1025](https://github.com/alleslabs/celatone-frontend/pull/1025) Handle new tx query params for contract txs

## v1.7.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "celatone",
"version": "1.6.0",
"version": "1.7.1",
"author": "Alles Labs",
"contributors": [
{
Expand Down
95 changes: 63 additions & 32 deletions src/lib/layout/mobile/NavDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Text,
useDisclosure,
} from "@chakra-ui/react";
import { useMemo } from "react";

import { NetworkMenu } from "../NetworkMenu";
import { AmpEvent, track } from "lib/amplitude";
Expand All @@ -29,10 +30,14 @@ import { CustomIcon } from "lib/components/icon";
import { useIsCurrentPage } from "lib/hooks";
import { usePublicProjectStore } from "lib/providers/store";

import { getNavDrawerFull, getNavDrawerLite } from "./utils";
import {
getNavDrawerFull,
getNavDrawerLite,
getNavDrawerSequencer,
} from "./utils";

export const NavDrawer = () => {
const { isFullTier } = useTierConfig();
const { tier } = useTierConfig();
const govConfig = useGovConfig({ shouldRedirect: false });
const wasmConfig = useWasmConfig({ shouldRedirect: false });
const moveConfig = useMoveConfig({ shouldRedirect: false });
Expand All @@ -43,37 +48,63 @@ export const NavDrawer = () => {
const { getSavedPublicProjects } = usePublicProjectStore();
const { isOpen, onOpen, onClose } = useDisclosure();

const navMenu = isFullTier
? getNavDrawerFull(
govConfig.enabled,
wasmConfig.enabled,
moveConfig.enabled,
nftConfig.enabled
)
: getNavDrawerLite(
govConfig.enabled,
wasmConfig.enabled,
moveConfig.enabled
);
const navMenu = useMemo(() => {
let navMenuTmp = [];
switch (tier) {
case "full":
navMenuTmp = getNavDrawerFull(
govConfig.enabled,
wasmConfig.enabled,
moveConfig.enabled,
nftConfig.enabled
);
break;
case "sequencer":
navMenuTmp = getNavDrawerSequencer(
govConfig.enabled,
wasmConfig.enabled,
moveConfig.enabled
);
break;
case "lite":
navMenuTmp = getNavDrawerLite(
govConfig.enabled,
wasmConfig.enabled,
moveConfig.enabled
);
break;
default:
throw new Error(`Invalid tier: ${tier}`);
}

if (publicProject.enabled)
navMenuTmp.push({
category: "Public Projects",
slug: "public-projects",
submenu: [
...getSavedPublicProjects().map((list) => ({
name: list.name,
slug: `/projects/${list.slug}`,
logo: list.logo,
})),
{
name: "View All Projects",
slug: "/projects",
icon: "public-project" as IconKeys,
},
],
});

if (publicProject.enabled) {
navMenu.push({
category: "Public Projects",
slug: "public-projects",
submenu: [
...getSavedPublicProjects().map((list) => ({
name: list.name,
slug: `/projects/${list.slug}`,
logo: list.logo,
})),
{
name: "View All Projects",
slug: "/projects",
icon: "public-project" as IconKeys,
},
],
});
}
return navMenuTmp;
}, [
getSavedPublicProjects,
govConfig.enabled,
moveConfig.enabled,
nftConfig.enabled,
publicProject.enabled,
tier,
wasmConfig.enabled,
]);

return (
<>
Expand Down
71 changes: 69 additions & 2 deletions src/lib/layout/mobile/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import type { MenuInfo } from "../navbar/types";
import type { IconKeys } from "lib/components/icon";

Expand Down Expand Up @@ -43,7 +44,7 @@ export const getNavDrawerLite = (
? [
{
name: "0x1 Page",
slug: "/account/0x1",
slug: "/accounts/0x1",
icon: "hex" as IconKeys,
},
]
Expand All @@ -52,6 +53,72 @@ export const getNavDrawerLite = (
},
];

export const getNavDrawerSequencer = (
isGov: boolean,
isWasm: boolean,
isMove: boolean
): MenuInfo[] => [
{
category: "Overview",
slug: "overview",
submenu: [
{ name: "Overview", slug: "/", icon: "home" as IconKeys },
{
name: "Transactions",
slug: "/txs",
icon: "file" as IconKeys,
},
{
name: "Blocks",
slug: "/blocks",
icon: "block" as IconKeys,
},
...(isGov
? [
{
name: "Validators",
slug: "/validators",
icon: "validator" as IconKeys,
},
{
name: "Proposals",
slug: "/proposals",
icon: "proposal" as IconKeys,
},
]
: []),
...(isWasm
? [
{
name: "Codes",
slug: "/codes",
icon: "code" as IconKeys,
},
{
name: "Query",
slug: "/interact-contract",
icon: "query" as IconKeys,
},
]
: []),
...(isMove
? [
{
name: "0x1 Page",
slug: "/accounts/0x1",
icon: "hex" as IconKeys,
},
{
name: "View Module",
slug: "/interact",
icon: "query" as IconKeys,
},
]
: []),
],
},
];

export const getNavDrawerFull = (
isGov: boolean,
isWasm: boolean,
Expand Down Expand Up @@ -115,7 +182,7 @@ export const getNavDrawerFull = (
},
{
name: "0x1 Page",
slug: "/account/0x1",
slug: "/accounts/0x1",
icon: "hex" as IconKeys,
},
{
Expand Down
6 changes: 1 addition & 5 deletions src/lib/layout/subheader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ const SubHeader = () => {
);
case "sequencer":
case "mesa":
return getSubHeaderSequencer(
govConfig.enabled,
wasmConfig.enabled,
nftConfig.enabled
);
return getSubHeaderSequencer(govConfig.enabled, wasmConfig.enabled);
case "lite":
default:
return getSubHeaderLite(govConfig.enabled, wasmConfig.enabled);
Expand Down
22 changes: 2 additions & 20 deletions src/lib/layout/subheader/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ export const getSubHeaderLite = (isGov: boolean, isWasm: boolean) => {
return base;
};

export const getSubHeaderSequencer = (
isGov: boolean,
isWasm: boolean,
isNft: boolean
) => {
export const getSubHeaderSequencer = (isGov: boolean, isWasm: boolean) => {
const base: SubHeaderMenuInfo[] = [
{ name: "Overview", slug: "/", icon: "home" },
{ name: "Transactions", slug: "/txs", icon: "file" },
Expand All @@ -56,21 +52,7 @@ export const getSubHeaderSequencer = (
);

if (isWasm)
base.push(
{ name: "Codes", slug: "/codes", icon: "code" as IconKeys }
// {
// name: "Contracts",
// slug: "/contracts",
// icon: "contract-address" as IconKeys,
// }
);

if (isNft)
base.push({
name: "NFTs",
slug: "/nft-collections",
icon: "group" as IconKeys,
});
base.push({ name: "Codes", slug: "/codes", icon: "code" as IconKeys });

return base;
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pages/home/components/QuickMenuMobileLite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const QuickMenuMobileLite = ({ prettyName }: { prettyName: string }) => {
if (move.enabled)
base.push({
title: "0x1 Page",
slug: "/account/0x1",
slug: "/accounts/0x1",
icon: "hex" as IconKeys,
isDocument: false,
});
Expand Down

0 comments on commit 5d986fe

Please sign in to comment.