Skip to content

Commit

Permalink
Merge branch 'main' into release/v1.0.5v2
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpeach committed May 19, 2023
2 parents e1db5be + daf3e57 commit ea75940
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 33 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## v1.0.5

### Features

- [#346](https://github.com/alleslabs/celatone-frontend/pull/346) Apply initial condition to my stored codes upload button
- [#327](https://github.com/alleslabs/celatone-frontend/pull/327) Update logic to enable upload wasm code
- [#317](https://github.com/alleslabs/celatone-frontend/pull/317) Add amplitude for proposal list page and pagination

Expand Down Expand Up @@ -93,7 +96,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#298](https://github.com/alleslabs/celatone-frontend/pull/298) Show deposit/voting period from gov params and add minimum required alert
- [#309](https://github.com/alleslabs/celatone-frontend/pull/309) Add public account name and description in account detail page
- [#289](https://github.com/alleslabs/celatone-frontend/pull/289) Add public accounts to public projects
- [#308](https://github.com/alleslabs/celatone-frontend/pull/308) Adjust view more button to full width and fix empty state layout in contract history
Expand Down
10 changes: 5 additions & 5 deletions src/lib/layout/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const Navbar = observer(({ isExpand, setIsExpand }: NavbarProps) => {
slug: "/past-txs",
icon: "history",
},
{
name: "Proposals",
slug: "/proposals",
icon: "proposal",
},
// {
// name: "Proposals",
// slug: "/proposals",
// icon: "proposal",
// },
// {
// name: "Osmosis Pools",
// slug: "/pools",
Expand Down
51 changes: 32 additions & 19 deletions src/lib/pages/codes/components/MyStoredCodesSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Box, Heading, HStack } from "@chakra-ui/react";
import { useWallet } from "@cosmos-kit/react";

import { MyStoredCodesTable } from "lib/components/table";
import type { CodeInfo } from "lib/types";
import { useUploadAccessParams } from "lib/services/proposalService";
import type { Addr, CodeInfo } from "lib/types";
import { AccessConfigPermission } from "lib/types";

import { UploadButton } from "./UploadButton";

Expand All @@ -19,21 +22,31 @@ export const MyStoredCodesSection = ({
onRowSelect,
disconnectedMessage,
isSearching,
}: MyStoredCodesSectionProps) => (
<Box mb={8}>
<HStack alignItems="center" justifyContent="space-between" mb="18px">
<Heading as="h6" variant="h6">
My Stored Codes
</Heading>
<UploadButton />
</HStack>
<MyStoredCodesTable
codes={codes}
isLoading={isLoading}
onRowSelect={onRowSelect}
emptyMessage="Your uploaded Wasm files will display as My Stored Codes."
disconnectedMessage={disconnectedMessage}
isSearching={isSearching}
/>
</Box>
);
}: MyStoredCodesSectionProps) => {
const { data } = useUploadAccessParams();
const { address } = useWallet();
const isAllowed = Boolean(data?.addresses?.includes(address as Addr));

const isPermissionedNetwork =
data?.permission !== AccessConfigPermission.EVERYBODY;

return (
<Box mb={8}>
<HStack alignItems="center" justifyContent="space-between" mb="18px">
<Heading as="h6" variant="h6">
My Stored Codes
</Heading>
{/* TODO: overwrite this logic when merging proposal feature */}
<UploadButton isAllowed={!isPermissionedNetwork || isAllowed} />
</HStack>
<MyStoredCodesTable
codes={codes}
isLoading={isLoading}
onRowSelect={onRowSelect}
emptyMessage="Your uploaded Wasm files will display as My Stored Codes."
disconnectedMessage={disconnectedMessage}
isSearching={isSearching}
/>
</Box>
);
};
23 changes: 17 additions & 6 deletions src/lib/pages/codes/components/UploadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ import { Button } from "@chakra-ui/react";

import { useInternalNavigate } from "lib/app-provider";
import { CustomIcon } from "lib/components/icon";
import { Tooltip } from "lib/components/Tooltip";

export const UploadButton = () => {
interface UploadButtonProps {
isAllowed: boolean;
}
export const UploadButton = ({ isAllowed }: UploadButtonProps) => {
const navigate = useInternalNavigate();

return (
<Button
onClick={() => navigate({ pathname: "/upload" })}
leftIcon={<CustomIcon name="plus" boxSize="12px" />}
<Tooltip
label="Only allowed address can upload Wasm file without opening proposal"
isDisabled={isAllowed}
>
Upload New Code
</Button>
<Button
disabled={!isAllowed}
onClick={() => navigate({ pathname: "/upload" })}
rightIcon={<CustomIcon name="upload" boxSize="12px" />}
>
Upload New Code
</Button>
</Tooltip>
);
};
7 changes: 7 additions & 0 deletions src/lib/pages/proposal/whitelist/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getAlert } from "../utils";
import {
useCurrentNetwork,
useFabricateFee,
useInternalNavigate,
useSimulateFeeQuery,
useSubmitProposalTx,
} from "lib/app-provider";
Expand Down Expand Up @@ -88,6 +89,7 @@ const ProposalToWhitelist = () => {
name: "addresses",
});
const { isTestnet } = useCurrentNetwork();
const navigate = useInternalNavigate();

const addressesArray = addresses.map((addressObj) => addressObj.address);
const formErrorsKey = Object.keys(formErrors);
Expand Down Expand Up @@ -189,6 +191,11 @@ const ProposalToWhitelist = () => {
submitProposalTx,
]);

useEffect(() => {
// remark: disable proposal whitelist and redirect to home page
navigate({ pathname: "/" });
}, [navigate]);

useEffect(() => {
if (minDeposit)
reset({
Expand Down
9 changes: 7 additions & 2 deletions src/lib/pages/proposals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRouter } from "next/router";
import type { ChangeEvent } from "react";
import { useState, useEffect } from "react";

import { useChainId } from "lib/app-provider";
import { useChainId, useInternalNavigate } from "lib/app-provider";
import { NewProposalButton } from "lib/components/button/NewProposalButton";
import InputWithIcon from "lib/components/InputWithIcon";
import PageContainer from "lib/components/PageContainer";
Expand Down Expand Up @@ -63,9 +63,14 @@ const Proposals = () => {
proposer
);

const navigate = useInternalNavigate();

useEffect(() => {
// remark: disable proposal and redirect to home page
navigate({ pathname: "/" });

if (router.isReady) AmpTrack(AmpEvent.TO_PROPOSAL_LIST);
}, [router.isReady]);
}, [navigate, router.isReady]);

useEffect(() => {
setPageSize(10);
Expand Down

0 comments on commit ea75940

Please sign in to comment.