-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
228 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Text, useToast } from "@chakra-ui/react"; | ||
import type { ReactNode } from "react"; | ||
|
||
import { useInternalNavigate } from "lib/app-provider"; | ||
import { CustomIcon } from "lib/components/icon"; | ||
import { useChainConfigStore } from "lib/providers/store"; | ||
|
||
import { ActionModal } from "./ActionModal"; | ||
|
||
interface RemoveChainConfigModalProps { | ||
chainId: string; | ||
trigger: ReactNode; | ||
} | ||
|
||
export function RemoveChainConfigModal({ | ||
chainId, | ||
trigger, | ||
}: RemoveChainConfigModalProps) { | ||
const { removeChainConfig, getChainConfig } = useChainConfigStore(); | ||
const navigate = useInternalNavigate(); | ||
|
||
const chainConfig = getChainConfig(chainId); | ||
|
||
const toast = useToast(); | ||
const handleRemove = () => { | ||
removeChainConfig(chainId); | ||
navigate({ pathname: "/", replace: true }); | ||
|
||
setTimeout(() => { | ||
toast({ | ||
title: `Removed '${chainConfig?.prettyName}'`, | ||
status: "success", | ||
duration: 5000, | ||
isClosable: false, | ||
position: "bottom-right", | ||
icon: <CustomIcon name="check-circle-solid" color="success.main" />, | ||
}); | ||
}, 1000); | ||
}; | ||
|
||
return ( | ||
<ActionModal | ||
title={`Removed '${chainConfig?.prettyName}'?`} | ||
icon="delete-solid" | ||
iconColor="error.light" | ||
trigger={trigger} | ||
mainBtnTitle="Yes, Remove it" | ||
mainVariant="error" | ||
mainAction={handleRemove} | ||
otherBtnTitle="No, Keep It" | ||
> | ||
<Text> | ||
All information about your Minitia will be lost and can‘t be | ||
recovered. You can save this address again later, but you will need to | ||
add its new address name. | ||
</Text> | ||
</ActionModal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,171 @@ | ||
import { | ||
Button, | ||
chakra, | ||
Flex, | ||
Grid, | ||
TabList, | ||
TabPanel, | ||
TabPanels, | ||
Tabs, | ||
Tag, | ||
} from "@chakra-ui/react"; | ||
import { Button, Grid, Heading, Stack } from "@chakra-ui/react"; | ||
import { isUndefined } from "lodash"; | ||
import { useRouter } from "next/router"; | ||
import { z } from "zod"; | ||
|
||
import { useAllowCustomNetworks } from "lib/app-provider"; | ||
import ActionPageContainer from "lib/components/ActionPageContainer"; | ||
import { | ||
CustomNetworkFooterCta, | ||
CustomNetworkPageHeader, | ||
} from "lib/components/custom-network"; | ||
import { CustomTab } from "lib/components/CustomTab"; | ||
import { CustomNetworkPageHeader } from "lib/components/custom-network"; | ||
// import { CustomTab } from "lib/components/CustomTab"; | ||
import { CustomIcon } from "lib/components/icon"; | ||
import JsonReadOnly from "lib/components/json/JsonReadOnly"; | ||
import { RemoveChainConfigModal } from "lib/components/modal/RemoveChainConfigModal"; | ||
import { InvalidState } from "lib/components/state"; | ||
import { useChainConfigStore } from "lib/providers/store"; | ||
import { jsonPrettify } from "lib/utils"; | ||
|
||
import { ExportNetworkConfig } from "./components/ExportNetworkConfig"; | ||
import { UpdateGasFeeDetails } from "./components/UpdateGasFeeDetails"; | ||
import { UpdateNetworkDetails } from "./components/UpdateNetworkDetails"; | ||
import { UpdateSupportedFeatures } from "./components/UpdateSupportedFeatures"; | ||
import { UpdateWalletRegistry } from "./components/UpdateWalletRegistry"; | ||
|
||
const StyledCustomTab = chakra(CustomTab, { | ||
baseStyle: { | ||
border: "unset", | ||
borderRadius: "4px", | ||
_selected: { bgColor: "gray.800" }, | ||
_hover: { bgColor: "gray.700" }, | ||
}, | ||
}); | ||
|
||
const StyledTabPanel = chakra(TabPanel, { | ||
baseStyle: { | ||
p: 0, | ||
width: "550px", | ||
minWidth: "550px", | ||
}, | ||
}); | ||
|
||
const TabMenu = [ | ||
{ name: "Network Details", key: "network-details" }, | ||
{ name: "Supported Features", key: "supported-features" }, | ||
{ name: "Gas & Fee Details", key: "gas-fee-details" }, | ||
{ name: "Wallet Registry", key: "wallet-registry" }, | ||
]; | ||
// import { ExportNetworkConfig } from "./components/ExportNetworkConfig"; | ||
// import { UpdateGasFeeDetails } from "./components/UpdateGasFeeDetails"; | ||
// import { UpdateNetworkDetails } from "./components/UpdateNetworkDetails"; | ||
// import { UpdateSupportedFeatures } from "./components/UpdateSupportedFeatures"; | ||
// import { UpdateWalletRegistry } from "./components/UpdateWalletRegistry"; | ||
|
||
export const NetworkConfig = () => { | ||
useAllowCustomNetworks({ shouldRedirect: true }); | ||
// const StyledCustomTab = chakra(CustomTab, { | ||
// baseStyle: { | ||
// border: "unset", | ||
// borderRadius: "4px", | ||
// _selected: { bgColor: "gray.800" }, | ||
// _hover: { bgColor: "gray.700" }, | ||
// }, | ||
// }); | ||
|
||
// const StyledTabPanel = chakra(TabPanel, { | ||
// baseStyle: { | ||
// p: 0, | ||
// width: "550px", | ||
// minWidth: "550px", | ||
// }, | ||
// }); | ||
|
||
// const TabMenu = [ | ||
// { name: "Network Details", key: "network-details" }, | ||
// { name: "Supported Features", key: "supported-features" }, | ||
// { name: "Gas & Fee Details", key: "gas-fee-details" }, | ||
// { name: "Wallet Registry", key: "wallet-registry" }, | ||
// ]; | ||
|
||
const InvalidChainId = () => <InvalidState title="Invalid Chain ID" />; | ||
|
||
interface NetworkConfigBodyProps { | ||
chainId: string; | ||
} | ||
|
||
const NetworkConfigBody = ({ chainId }: NetworkConfigBodyProps) => { | ||
const { getChainConfig } = useChainConfigStore(); | ||
const chainConfig = getChainConfig(chainId); | ||
|
||
// const leftButtonProps = { | ||
// label: "Cancel", | ||
// action: () => {}, | ||
// variant: "outline-secondary", | ||
// }; | ||
|
||
// const rightButtonProps = { | ||
// label: "Update", | ||
// action: () => {}, | ||
// variant: "primary", | ||
// }; | ||
|
||
const forms = [ | ||
<UpdateNetworkDetails />, | ||
<UpdateSupportedFeatures />, | ||
<UpdateGasFeeDetails />, | ||
<UpdateWalletRegistry />, | ||
]; | ||
|
||
const leftButtonProps = { | ||
label: "Cancel", | ||
action: () => {}, | ||
variant: "outline-secondary", | ||
}; | ||
|
||
const rightButtonProps = { | ||
label: "Update", | ||
action: () => {}, | ||
variant: "primary", | ||
}; | ||
if (isUndefined(chainConfig)) return <InvalidChainId />; | ||
|
||
return ( | ||
<> | ||
<ActionPageContainer width={900}> | ||
<CustomNetworkPageHeader | ||
title="CHAIN_NAME" | ||
subtitle="Your Custom Minitia" | ||
hasAlert={false} | ||
/> | ||
<Tabs variant="unstyled" orientation="vertical" mt={6}> | ||
<Grid templateColumns="2fr 5fr" gap={6} w="full" my={8}> | ||
<TabList w="full"> | ||
{TabMenu.map((item) => ( | ||
<StyledCustomTab key={item.key}>{item.name}</StyledCustomTab> | ||
))} | ||
<StyledCustomTab pointerEvents="none" isDisabled> | ||
<Flex gap={2} align="center"> | ||
Export JSON <Tag size="xs">Soon</Tag> | ||
</Flex> | ||
</StyledCustomTab> | ||
<Button | ||
variant="outline-gray" | ||
mt={10} | ||
size="sm" | ||
leftIcon={<CustomIcon name="delete" />} | ||
> | ||
Remove Network | ||
</Button> | ||
</TabList> | ||
<TabPanels px={8} w="full"> | ||
{forms.map((item) => ( | ||
<StyledTabPanel>{item}</StyledTabPanel> | ||
))} | ||
<StyledTabPanel> | ||
<ExportNetworkConfig /> | ||
</StyledTabPanel> | ||
</TabPanels> | ||
</Grid> | ||
</Tabs> | ||
</ActionPageContainer> | ||
<CustomNetworkFooterCta | ||
leftButtonProps={leftButtonProps} | ||
rightButtonProps={rightButtonProps} | ||
isCenterAlign={false} | ||
<ActionPageContainer width={900}> | ||
<CustomNetworkPageHeader | ||
title={chainConfig.prettyName} | ||
subtitle="Your Custom Minitia" | ||
hasAlert={false} | ||
/> | ||
</> | ||
<Grid templateColumns="2fr 5fr" gap={6} w="full" my={8}> | ||
<RemoveChainConfigModal | ||
chainId={chainId} | ||
trigger={ | ||
<Button | ||
variant="outline-gray" | ||
mt={10} | ||
size="md" | ||
leftIcon={<CustomIcon name="delete" />} | ||
> | ||
Remove Network | ||
</Button> | ||
} | ||
/> | ||
<Stack> | ||
<Heading as="h6" variant="h6"> | ||
Current Configuration in JSON | ||
</Heading> | ||
<JsonReadOnly | ||
text={jsonPrettify(JSON.stringify(chainConfig))} | ||
canCopy | ||
fullWidth | ||
/> | ||
</Stack> | ||
</Grid> | ||
</ActionPageContainer> | ||
); | ||
|
||
// return ( | ||
// <> | ||
// <ActionPageContainer width={900}> | ||
// <CustomNetworkPageHeader | ||
// title={chainConfig.prettyName} | ||
// subtitle="Your Custom Minitia" | ||
// hasAlert={false} | ||
// /> | ||
// <Tabs variant="unstyled" orientation="vertical" mt={6}> | ||
// <Grid templateColumns="2fr 5fr" gap={6} w="full" my={8}> | ||
// <TabList w="full"> | ||
// {TabMenu.map((item) => ( | ||
// <StyledCustomTab key={item.key}>{item.name}</StyledCustomTab> | ||
// ))} | ||
// <StyledCustomTab pointerEvents="none" isDisabled> | ||
// <Flex gap={2} align="center"> | ||
// Export JSON <Tag size="xs">Soon</Tag> | ||
// </Flex> | ||
// </StyledCustomTab> | ||
// <Button | ||
// variant="outline-gray" | ||
// mt={10} | ||
// size="sm" | ||
// leftIcon={<CustomIcon name="delete" />} | ||
// > | ||
// Remove Network | ||
// </Button> | ||
// </TabList> | ||
// <TabPanels px={8} w="full"> | ||
// <StyledTabPanel> | ||
// <UpdateNetworkDetails /> | ||
// </StyledTabPanel> | ||
// <StyledTabPanel> | ||
// <UpdateSupportedFeatures /> | ||
// </StyledTabPanel> | ||
// <StyledTabPanel> | ||
// " <UpdateGasFeeDetails /> | ||
// </StyledTabPanel> | ||
// <StyledTabPanel> | ||
// <UpdateWalletRegistry /> | ||
// </StyledTabPanel> | ||
// <StyledTabPanel> | ||
// <ExportNetworkConfig /> | ||
// </StyledTabPanel> | ||
// </TabPanels> | ||
// </Grid> | ||
// </Tabs> | ||
// </ActionPageContainer> | ||
// <CustomNetworkFooterCta | ||
// leftButtonProps={leftButtonProps} | ||
// rightButtonProps={rightButtonProps} | ||
// isCenterAlign={false} | ||
// /> | ||
// </> | ||
// ); | ||
}; | ||
|
||
export const NetworkConfig = () => { | ||
useAllowCustomNetworks({ shouldRedirect: true }); | ||
const router = useRouter(); | ||
const validated = z.string().safeParse(router.query.chainId); | ||
|
||
if (!validated.success) return <InvalidChainId />; | ||
|
||
return <NetworkConfigBody chainId={validated.data} />; | ||
}; |
File renamed without changes.
File renamed without changes.