From e9d4560e40a19260e17030d07754140783320b3b Mon Sep 17 00:00:00 2001 From: Jennie Alles Date: Thu, 4 Jan 2024 17:37:53 +0700 Subject: [PATCH 1/4] fix(components): adjust search state consistency --- CHANGELOG.md | 1 + .../select-code/CodeSelectDrawerButton.tsx | 6 +- .../select-contract/AllContractLists.tsx | 11 ++-- .../select-contract/ContractListCard.tsx | 2 +- .../select-contract/ContractListDetail.tsx | 1 + src/lib/components/state/ZeroState.tsx | 50 ++++++++------ .../table/codes/MySavedCodesTable.tsx | 49 ++++++++------ .../table/codes/MyStoredCodesTable.tsx | 8 +-- src/lib/pages/contract-list/index.tsx | 1 + .../public-project/components/AllProject.tsx | 66 ++++++++++++++----- .../components/tables/accounts/index.tsx | 4 +- .../components/tables/codes/index.tsx | 5 +- .../components/tables/contracts/index.tsx | 5 +- src/lib/pages/saved-accounts/index.tsx | 22 +++---- .../components/MySavedCodesSection.tsx | 23 ------- src/lib/pages/saved-codes/index.tsx | 21 ++---- .../components/MyStoredCodesSection.tsx | 29 -------- src/lib/pages/stored-codes/index.tsx | 9 ++- 18 files changed, 150 insertions(+), 163 deletions(-) delete mode 100644 src/lib/pages/saved-codes/components/MySavedCodesSection.tsx delete mode 100644 src/lib/pages/stored-codes/components/MyStoredCodesSection.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ea6a0d6f..9f4b4c66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#712](https://github.com/alleslabs/celatone-frontend/pull/712) Adjust search state consistency - [#702](https://github.com/alleslabs/celatone-frontend/pull/702) api v1 - contract info - [#703](https://github.com/alleslabs/celatone-frontend/pull/703) api v1 - contract's query msgs - [#697](https://github.com/alleslabs/celatone-frontend/pull/697) api v1 - contract tables (migrations and related proposals) diff --git a/src/lib/components/select-code/CodeSelectDrawerButton.tsx b/src/lib/components/select-code/CodeSelectDrawerButton.tsx index 2addcd532..96f677d79 100644 --- a/src/lib/components/select-code/CodeSelectDrawerButton.tsx +++ b/src/lib/components/select-code/CodeSelectDrawerButton.tsx @@ -69,8 +69,6 @@ export const CodeSelectDrawerButton = ({ onClose(); }; - const isSearching = !!keyword || permissionValue !== "all"; - return ( <> - + + + Gathering Public Projects... + + + We are currently gathering public projects to feature here. +
To share yours with the community, please submit your + request. +
+ track(AmpEvent.USE_SUBMIT_PROJECT)} + > + + + ); @@ -77,8 +105,10 @@ export const AllProject = observer(() => { /> {!filteredPublicProjects.length ? ( ) : ( )} diff --git a/src/lib/pages/public-project/components/tables/codes/index.tsx b/src/lib/pages/public-project/components/tables/codes/index.tsx index 7c0a1cb50..b8d8c8e70 100644 --- a/src/lib/pages/public-project/components/tables/codes/index.tsx +++ b/src/lib/pages/public-project/components/tables/codes/index.tsx @@ -122,13 +122,12 @@ export const PublicProjectCodeTable = observer( ) : ( )} diff --git a/src/lib/pages/public-project/components/tables/contracts/index.tsx b/src/lib/pages/public-project/components/tables/contracts/index.tsx index ba5d16da8..1632f996a 100644 --- a/src/lib/pages/public-project/components/tables/contracts/index.tsx +++ b/src/lib/pages/public-project/components/tables/contracts/index.tsx @@ -113,13 +113,12 @@ export const PublicProjectContractTable = observer( ) : ( )} diff --git a/src/lib/pages/saved-accounts/index.tsx b/src/lib/pages/saved-accounts/index.tsx index 28edbb72f..2c9b1e56b 100644 --- a/src/lib/pages/saved-accounts/index.tsx +++ b/src/lib/pages/saved-accounts/index.tsx @@ -25,8 +25,6 @@ const SavedAccounts = observer(() => { const [keyword, setKeyword] = useState(""); - const isSearching = !!keyword; - const filteredsavedAccounts = useMemo(() => { if (!keyword) return savedAccounts; return savedAccounts.filter( @@ -78,21 +76,21 @@ const SavedAccounts = observer(() => { size="lg" amptrackSection="saved-account-search" /> - - ) : ( - } /> - ) - } - /> + } + /> + ) : ( + } /> + )} ); }); diff --git a/src/lib/pages/saved-codes/components/MySavedCodesSection.tsx b/src/lib/pages/saved-codes/components/MySavedCodesSection.tsx deleted file mode 100644 index 149e3dd2f..000000000 --- a/src/lib/pages/saved-codes/components/MySavedCodesSection.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { MySavedCodesTable } from "lib/components/table"; -import type { CodeInfo } from "lib/types"; - -interface MySavedCodesSectionProps { - codes: CodeInfo[]; - isLoading: boolean; - onRowSelect: (codeId: number) => void; - isSearching: boolean; -} - -export const MySavedCodesSection = ({ - codes, - isLoading, - onRowSelect, - isSearching, -}: MySavedCodesSectionProps) => ( - -); diff --git a/src/lib/pages/saved-codes/index.tsx b/src/lib/pages/saved-codes/index.tsx index b9f659786..2ffee05f3 100644 --- a/src/lib/pages/saved-codes/index.tsx +++ b/src/lib/pages/saved-codes/index.tsx @@ -10,11 +10,10 @@ import { useInternalNavigate } from "lib/app-provider"; import { FilterByPermission } from "lib/components/forms"; import InputWithIcon from "lib/components/InputWithIcon"; import PageContainer from "lib/components/PageContainer"; -import { SavedCodeZeroState } from "lib/components/state"; +import { MySavedCodesTable } from "lib/components/table"; import type { PermissionFilterValue } from "lib/hooks"; import { useMyCodesData } from "lib/model/code"; -import { MySavedCodesSection } from "./components/MySavedCodesSection"; import { SaveCodeButton } from "./components/SaveCodeButton"; interface CodeFilterState { @@ -45,8 +44,6 @@ const SavedCodes = observer(() => { isSavedCodesLoading, } = useMyCodesData(keyword, permissionValue); - const isSearching = !!keyword || permissionValue !== "all"; - useEffect(() => { if (router.isReady && isSavedCodesLoading) { track(AmpEvent.TO_MY_SAVED_CODES, { savedCodesCount }); @@ -96,16 +93,12 @@ const SavedCodes = observer(() => { }} /> - {!savedCodesCount ? ( - } /> - ) : ( - - )} + ); }); diff --git a/src/lib/pages/stored-codes/components/MyStoredCodesSection.tsx b/src/lib/pages/stored-codes/components/MyStoredCodesSection.tsx deleted file mode 100644 index da7401527..000000000 --- a/src/lib/pages/stored-codes/components/MyStoredCodesSection.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { MyStoredCodesTable } from "lib/components/table"; -import type { CodeInfo } from "lib/types"; - -interface MyStoredCodesSectionProps { - codes: CodeInfo[]; - isLoading: boolean; - onRowSelect: (codeId: number) => void; - disconnectedMessage: string; - isSearching: boolean; -} - -export const MyStoredCodesSection = ({ - codes, - isLoading, - onRowSelect, - disconnectedMessage, - isSearching, -}: MyStoredCodesSectionProps) => { - return ( - - ); -}; diff --git a/src/lib/pages/stored-codes/index.tsx b/src/lib/pages/stored-codes/index.tsx index e96beb653..bcab8dd60 100644 --- a/src/lib/pages/stored-codes/index.tsx +++ b/src/lib/pages/stored-codes/index.tsx @@ -14,13 +14,13 @@ import { import { FilterByPermission } from "lib/components/forms"; import InputWithIcon from "lib/components/InputWithIcon"; import PageContainer from "lib/components/PageContainer"; +import { MyStoredCodesTable } from "lib/components/table"; import type { PermissionFilterValue } from "lib/hooks"; import { useMyCodesData } from "lib/model/code"; import { useUploadAccessParams } from "lib/services/proposalService"; import type { Addr } from "lib/types"; import { AccessConfigPermission } from "lib/types"; -import { MyStoredCodesSection } from "./components/MyStoredCodesSection"; import { ProposalButton } from "./components/ProposalButton"; import { UploadButton } from "./components/UploadButton"; @@ -53,8 +53,6 @@ const StoredCodes = observer(() => { isStoredCodesLoading, } = useMyCodesData(keyword, permissionValue); - const isSearching = !!keyword || permissionValue !== "all"; - useEffect(() => { if (router.isReady) track(AmpEvent.TO_MY_STORED_CODES); }, [router.isReady]); @@ -121,12 +119,13 @@ const StoredCodes = observer(() => { /> - ); From 2fb737aabe48bf97580e887aa257f083611b1dc5 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:22:53 +0700 Subject: [PATCH 2/4] fix: comment --- CHANGELOG.md | 2 +- .../select-code/CodeSelectDrawerButton.tsx | 2 +- .../select-contract/ContractListCard.tsx | 7 +- .../select-contract/ContractListDetail.tsx | 4 +- .../table/codes/MyStoredCodesTable.tsx | 6 +- .../public-project/components/AllProject.tsx | 67 +++++++++---------- .../components/tables/accounts/index.tsx | 2 +- .../components/tables/codes/index.tsx | 2 +- .../components/tables/contracts/index.tsx | 2 +- src/lib/pages/stored-codes/index.tsx | 25 +++---- 10 files changed, 61 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ecde257f..8a82adb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,7 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements -- [#712](https://github.com/alleslabs/celatone-frontend/pull/712) Adjust search state consistency +- [#713](https://github.com/alleslabs/celatone-frontend/pull/713) Adjust search state consistency - [#702](https://github.com/alleslabs/celatone-frontend/pull/702) api v1 - contract info - [#703](https://github.com/alleslabs/celatone-frontend/pull/703) api v1 - contract's query msgs - [#697](https://github.com/alleslabs/celatone-frontend/pull/697) api v1 - contract tables (migrations and related proposals) diff --git a/src/lib/components/select-code/CodeSelectDrawerButton.tsx b/src/lib/components/select-code/CodeSelectDrawerButton.tsx index 96f677d79..b43455a82 100644 --- a/src/lib/components/select-code/CodeSelectDrawerButton.tsx +++ b/src/lib/components/select-code/CodeSelectDrawerButton.tsx @@ -117,7 +117,7 @@ export const CodeSelectDrawerButton = ({ My Stored Codes - My Saved Codes + My Saved Codes diff --git a/src/lib/components/select-contract/ContractListCard.tsx b/src/lib/components/select-contract/ContractListCard.tsx index a94a7e146..6f56d0cb6 100644 --- a/src/lib/components/select-contract/ContractListCard.tsx +++ b/src/lib/components/select-contract/ContractListCard.tsx @@ -26,8 +26,9 @@ export const ContractListCard = ({ isReadOnly, }: ContractListCardProps) => { const isInstantiatedByMe = - item.slug !== formatSlugName(INSTANTIATED_LIST_NAME); - const isDisabled = isReadOnly && isInstantiatedByMe && !item.contracts.length; + item.slug === formatSlugName(INSTANTIATED_LIST_NAME); + const isDisabled = + isReadOnly && !isInstantiatedByMe && !item.contracts.length; return ( {item.contracts.length} - {isInstantiatedByMe && ( + {!isInstantiatedByMe && ( ) : ( ) } diff --git a/src/lib/components/table/codes/MyStoredCodesTable.tsx b/src/lib/components/table/codes/MyStoredCodesTable.tsx index b1eaef30b..286655930 100644 --- a/src/lib/components/table/codes/MyStoredCodesTable.tsx +++ b/src/lib/components/table/codes/MyStoredCodesTable.tsx @@ -29,7 +29,11 @@ export const MyStoredCodesTable = ({ } diff --git a/src/lib/pages/public-project/components/AllProject.tsx b/src/lib/pages/public-project/components/AllProject.tsx index 3fe7cdd6c..c6d8dfce8 100644 --- a/src/lib/pages/public-project/components/AllProject.tsx +++ b/src/lib/pages/public-project/components/AllProject.tsx @@ -54,42 +54,39 @@ export const AllProject = observer(() => { if (isLoading) return ; if (!publicProjectInfo) return ( - - + + + Gathering Public Projects... + + - - - Gathering Public Projects... - - - We are currently gathering public projects to feature here. -
To share yours with the community, please submit your - request. -
- track(AmpEvent.USE_SUBMIT_PROJECT)} - > - - -
+ We are currently gathering public projects to feature here. +
To share yours with the community, please submit your request. +
+ track(AmpEvent.USE_SUBMIT_PROJECT)} + > + + ); diff --git a/src/lib/pages/public-project/components/tables/accounts/index.tsx b/src/lib/pages/public-project/components/tables/accounts/index.tsx index fa73433d7..7146798f8 100644 --- a/src/lib/pages/public-project/components/tables/accounts/index.tsx +++ b/src/lib/pages/public-project/components/tables/accounts/index.tsx @@ -102,7 +102,7 @@ export const PublicProjectAccountTable = ({ ? "No matching accounts found for this project. Make sure you are searching with Account Address or Account Name" : "There are currently no accounts related to this project." } - imageVariant={onViewMore ? "empty" : "not-found"} + imageVariant={accounts.length ? "not-found" : "empty"} withBorder /> )} diff --git a/src/lib/pages/public-project/components/tables/codes/index.tsx b/src/lib/pages/public-project/components/tables/codes/index.tsx index b8d8c8e70..6e079d81f 100644 --- a/src/lib/pages/public-project/components/tables/codes/index.tsx +++ b/src/lib/pages/public-project/components/tables/codes/index.tsx @@ -127,7 +127,7 @@ export const PublicProjectCodeTable = observer( ? "No matching codes found for this project. Make sure you are searching with Code ID or Code Name" : "There are currently no codes related to this project." } - imageVariant={onViewMore ? "empty" : "not-found"} + imageVariant={codes.length ? "not-found" : "empty"} withBorder /> )} diff --git a/src/lib/pages/public-project/components/tables/contracts/index.tsx b/src/lib/pages/public-project/components/tables/contracts/index.tsx index 4ccc0a970..7f02e0da0 100644 --- a/src/lib/pages/public-project/components/tables/contracts/index.tsx +++ b/src/lib/pages/public-project/components/tables/contracts/index.tsx @@ -118,7 +118,7 @@ export const PublicProjectContractTable = observer( ? "No matching contracts found for this project. Make sure you are searching with Contract Address or Contract Name" : "There are currently no contracts related to this project." } - imageVariant={onViewMore ? "empty" : "not-found"} + imageVariant={contracts.length ? "not-found" : "empty"} withBorder /> )} diff --git a/src/lib/pages/stored-codes/index.tsx b/src/lib/pages/stored-codes/index.tsx index 4b1e06197..cce11240d 100644 --- a/src/lib/pages/stored-codes/index.tsx +++ b/src/lib/pages/stored-codes/index.tsx @@ -30,13 +30,10 @@ interface CodeFilterState { const StoredCodes = observer(() => { const router = useRouter(); - const govConfig = useGovConfig({ shouldRedirect: false }); const navigate = useInternalNavigate(); - const onRowSelect = (codeId: number) => - navigate({ - pathname: "/codes/[codeId]", - query: { codeId }, - }); + const { address } = useCurrentChain(); + const govConfig = useGovConfig({ shouldRedirect: false }); + // TODO refactor to useState const { watch, setValue } = useForm({ defaultValues: { @@ -51,16 +48,21 @@ const StoredCodes = observer(() => { storedCodes: stored, isStoredCodesLoading, } = useMyCodesData(keyword, permissionValue); + const { data, isFetching: isUploadAccessFetching } = useUploadAccessParams(); + + const isPermissionedNetwork = + data?.permission !== AccessConfigPermission.EVERYBODY; + const isAllowed = Boolean(address && data?.addresses?.includes(address)); useEffect(() => { if (router.isReady) track(AmpEvent.TO_MY_STORED_CODES); }, [router.isReady]); - const { data, isFetching: isUploadAccessFetching } = useUploadAccessParams(); - const { address } = useCurrentChain(); - const isAllowed = Boolean(address && data?.addresses?.includes(address)); - const isPermissionedNetwork = - data?.permission !== AccessConfigPermission.EVERYBODY; + const onRowSelect = (codeId: number) => + navigate({ + pathname: "/codes/[codeId]", + query: { codeId }, + }); return ( @@ -117,7 +119,6 @@ const StoredCodes = observer(() => { }} /> - Date: Tue, 9 Jan 2024 17:41:41 +0700 Subject: [PATCH 3/4] fix: update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a82adb9e..12da6a617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#713](https://github.com/alleslabs/celatone-frontend/pull/713) Adjust search state consistency - [#711](https://github.com/alleslabs/celatone-frontend/pull/711) Refactor assetInfos and add movePoolInfos to tx details ### Improvements @@ -57,7 +58,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements -- [#713](https://github.com/alleslabs/celatone-frontend/pull/713) Adjust search state consistency - [#702](https://github.com/alleslabs/celatone-frontend/pull/702) api v1 - contract info - [#703](https://github.com/alleslabs/celatone-frontend/pull/703) api v1 - contract's query msgs - [#697](https://github.com/alleslabs/celatone-frontend/pull/697) api v1 - contract tables (migrations and related proposals) From 2f28e9ceb2efdde141b64c5e50d5f9390ef4ebd0 Mon Sep 17 00:00:00 2001 From: Songwong Tasneeyapant <16089160+songwongtp@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:55:32 +0700 Subject: [PATCH 4/4] fix: update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12da6a617..22d9cc101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,11 +39,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features -- [#713](https://github.com/alleslabs/celatone-frontend/pull/713) Adjust search state consistency - [#711](https://github.com/alleslabs/celatone-frontend/pull/711) Refactor assetInfos and add movePoolInfos to tx details ### Improvements +- [#713](https://github.com/alleslabs/celatone-frontend/pull/713) Adjust search state consistency - [#710](https://github.com/alleslabs/celatone-frontend/pull/710) Refactor all address types ### Bug fixes