Skip to content

Commit

Permalink
Merge pull request #1457 from trilitech/web-add-dynamic-modal
Browse files Browse the repository at this point in the history
Web add dynamic modal
  • Loading branch information
serjonya-trili committed Jul 4, 2024
2 parents 26b1c74 + bf949e1 commit a8ab60b
Show file tree
Hide file tree
Showing 58 changed files with 342 additions and 119 deletions.
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"@types/react-dom": "18.3.0",
"@types/react-test-renderer": "^18.3.0",
"@tzkt/sdk-api": "^2.2.1",
"@umami/components": "workspace:^",
"@umami/core": "workspace:^",
"@umami/crypto": "workspace:^",
"@umami/data-polling": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* istanbul ignore file */
import { DynamicModalContext, useDynamicModal } from "@umami/components";
import { useDataPolling } from "@umami/data-polling";
import { WalletClient, useImplicitAccounts, useResetConnections } from "@umami/state";
import { noop } from "lodash";
import { useEffect } from "react";
import { HashRouter, Navigate, Route, Routes } from "react-router-dom";

import { AnnouncementBanner } from "./components/AnnouncementBanner";
import { DynamicModalContext, useDynamicModal } from "./components/DynamicModal";
import { BeaconProvider } from "./utils/beacon/BeaconProvider";
import { useDeeplinkHandler } from "./utils/useDeeplinkHandler";
import { AddressBookView } from "./views/addressBook/AddressBookView";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Center, Flex, Heading, IconButton, Text } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import {
type Account,
type FA12TokenBalance,
Expand All @@ -17,7 +18,6 @@ import { accountIconGradient } from "../AccountTile/AccountTile";
import { AccountTileIcon } from "../AccountTile/AccountTileIcon";
import { AddressPill } from "../AddressPill/AddressPill";
import { BuyTezForm } from "../BuyTez/BuyTezForm";
import { DynamicModalContext } from "../DynamicModal";
import { NoticeModal as DelegateNoticeModal } from "../SendFlow/Delegation/NoticeModal";
import { TezRecapDisplay } from "../TezRecapDisplay";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Button, Center, Flex, type FlexProps, Heading, Text } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account, type ImplicitAccount } from "@umami/core";
import {
useGetAccountDelegate,
Expand All @@ -13,7 +14,6 @@ import { PendingUnstakeRequests } from "./PendingUnstakeRequests/PendingUnstakeR
import { ExternalLinkIcon, PenIcon, XMarkIcon } from "../../../assets/icons";
import colors from "../../../style/colors";
import { AddressPill } from "../../AddressPill/AddressPill";
import { DynamicModalContext } from "../../DynamicModal";
import { ExternalLink } from "../../ExternalLink";
import { NoticeModal as DelegateNoticeModal } from "../../SendFlow/Delegation/NoticeModal";
import { NoticeModal as StakeNoticeModal } from "../../SendFlow/Stake/NoticeModal";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DynamicModalContext } from "@umami/components";
import {
type ImplicitAccount,
type MultisigAccount,
Expand All @@ -16,7 +17,6 @@ import colors from "../../../../style/colors";
import { AccountTileBase, LabelAndAddress } from "../../../AccountTile/AccountTile";
import { AddressTileIcon } from "../../../AddressTile/AddressTileIcon";
import { useAddressKind } from "../../../AddressTile/useAddressKind";
import { DynamicModalContext } from "../../../DynamicModal";
import { SignPage } from "../../../SendFlow/Multisig/SignPage";

export const MultisigSignerTile: React.FC<{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Button, Center, Flex, type FlexProps, Text } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type ImplicitAccount, estimate, makeAccountOperations } from "@umami/core";
import {
useAccountTotalFinalizableUnstakeAmount,
Expand All @@ -9,7 +10,6 @@ import { prettyTezAmount } from "@umami/tezos";
import { useContext } from "react";

import colors from "../../../../style/colors";
import { DynamicModalContext } from "../../../DynamicModal";
import { PrettyNumber } from "../../../PrettyNumber";
import { SignPage } from "../../../SendFlow/FinalizeUnstake/SignPage";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Button, type ButtonProps } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { useContext } from "react";

import { InfoModal } from "./InfoModal";
import { FolderInfoIcon } from "../../../assets/icons";
import { DynamicModalContext } from "../../DynamicModal";

/**
* Button to open a modal with the account's derivation info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
ModalContent,
ModalFooter,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { renameAccount, useAppDispatch, useValidateName } from "@umami/state";
import { type FC, useContext } from "react";
import { useForm } from "react-hook-form";

import { DynamicModalContext } from "../DynamicModal";
import { FormPageHeader } from "../SendFlow/FormPageHeader";

export const RenameAccountModal: FC<{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { useImplicitAccounts, useRemoveAccount } from "@umami/state";
import { useContext } from "react";
import { useNavigate } from "react-router-dom";

import { RenameAccountModal } from "./RenameAccountModal";
import { ConfirmationModal } from "../ConfirmationModal";
import { DynamicModalContext } from "../DynamicModal";
import { RenameRemoveMenu } from "../RenameRemoveMenu";

export const RenameRemoveMenuSwitch: React.FC<{ account: Account }> = ({ account }) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/AccountDrawer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DynamicModalContext } from "@umami/components";
import { useGetAccountAllTokens, useGetAccountNFTs, useGetOwnedAccount } from "@umami/state";
import { type RawPkh } from "@umami/tezos";
import { useContext } from "react";

import { AccountDrawerDisplay } from "./AccountDrawerDisplay";
import { sortedByLastUpdate } from "../../utils/token/utils";
import { DynamicModalContext } from "../DynamicModal";
import { ReceiveModal } from "../ReceiveModal";
import { FormPage as SendTezForm } from "../SendFlow/Tez/FormPage";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type IconProps } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { useAddressExistsInContacts } from "@umami/state";
import { useContext } from "react";

Expand All @@ -13,7 +14,6 @@ import {
KeyIcon,
XMarkIcon,
} from "../../assets/icons";
import { DynamicModalContext } from "../DynamicModal";
import { UpsertContactModal } from "../UpsertContactModal";

export const LeftIcon: React.FC<{ addressKind: AddressKind } & IconProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Text,
useToast,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Operation, makeAccountOperations } from "@umami/core";
import {
estimateAndUpdateBatch,
Expand All @@ -31,7 +32,6 @@ import { FormProvider, useForm } from "react-hook-form";
import { parseOperation } from "./utils";
import colors from "../../style/colors";
import { OwnedAccountsAutocomplete } from "../AddressAutocomplete";
import { DynamicModalContext } from "../DynamicModal";
import { FormErrorMessage } from "../FormErrorMessage";

type FormFields = {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/CSVFileUploader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Button, Text } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { useContext } from "react";

import { CSVFileUploadForm } from "./CSVFileUploadForm";
import { FileArrowDownIcon } from "../../assets/icons";
import { DynamicModalContext } from "../DynamicModal";

export const CSVFileUploader = () => {
const { openWith } = useContext(DynamicModalContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
ModalHeader,
useToast,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { changeMnemonicPassword, useAppDispatch, useAsyncActionHandler } from "@umami/state";
import { useContext } from "react";
import { FormProvider, useForm } from "react-hook-form";

import colors from "../../style/colors";
import { DynamicModalContext } from "../DynamicModal";
import { FormErrorMessage } from "../FormErrorMessage";
import { PasswordInput } from "../PasswordInput";

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { useContext } from "react";

import { DynamicModalContext } from "./DynamicModal";
import { WarningIcon } from "../assets/icons";
import colors from "../style/colors";

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/DeleteContactModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Contact } from "@umami/core";
import { contactsActions, useAppDispatch } from "@umami/state";
import { type FC, useContext } from "react";

import { CopyableAddress } from "./CopyableText";
import { DynamicModalContext } from "./DynamicModal";
import colors from "../style/colors";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
type OperationResponseInput,
} from "@airgap/beacon-wallet";
import { type TezosToolkit } from "@taquito/taquito";
import { DynamicModalContext } from "@umami/components";
import { type EstimatedAccountOperations, executeOperations, totalFee } from "@umami/core";
import { WalletClient, useAsyncActionHandler, useFindNetwork } from "@umami/state";
import { useContext } from "react";
import { useForm } from "react-hook-form";

import { DynamicModalContext } from "../../DynamicModal";
import { SuccessStep } from "../SuccessStep";

export const useSignWithBeacon = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { type TzktAlias } from "@umami/tzkt";
import { useContext } from "react";

import { FormPage } from "./FormPage";
import { WarningIcon } from "../../../assets/icons";
import colors from "../../../style/colors";
import { DynamicModalContext } from "../../DynamicModal";

export const ChangeDelegateNoticeModal = ({
account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { useContext } from "react";

import { FormPage } from "./FormPage";
import { NoticeIcon } from "../../../assets/icons";
import colors from "../../../style/colors";
import { DynamicModalContext } from "../../DynamicModal";
import { NoticeSteps } from "../NoticeSteps";

export const NewDelegateNoticeModal = ({ account }: { account: Account }) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/SendFlow/Multisig/SignPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ModalContent, ModalFooter } from "@chakra-ui/react";
import { type TezosToolkit } from "@taquito/taquito";
import { DynamicModalContext } from "@umami/components";
import {
type ApproveOrExecute,
type EstimatedAccountOperations,
Expand All @@ -13,7 +14,6 @@ import { useContext } from "react";
import { FormProvider, useForm } from "react-hook-form";

import { AdvancedSettingsAccordion } from "../../AdvancedSettingsAccordion";
import { DynamicModalContext } from "../../DynamicModal";
import { BatchModalBody } from "../BatchModalBody";
import { SignButton } from "../SignButton";
import { SuccessStep } from "../SuccessStep";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ModalContent,
ModalFooter,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import {
useGetMostFundedImplicitAccount,
useImplicitAccounts,
Expand All @@ -17,7 +18,6 @@ import { useContext } from "react";
import { FormProvider, useForm } from "react-hook-form";

import { SelectApproversFormPage } from "./SelectApproversFormPage";
import { DynamicModalContext } from "../../DynamicModal";
import { FormErrorMessage } from "../../FormErrorMessage";
import { FormPageHeader } from "../FormPageHeader";

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/SendFlow/Stake/NoticeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { useContext } from "react";
import { useForm } from "react-hook-form";

import { FormPage } from "./FormPage";
import { WarningIcon } from "../../../assets/icons";
import colors from "../../../style/colors";
import { DynamicModalContext } from "../../DynamicModal";

export const NoticeModal = ({ account }: { account: Account }) => {
const { openWith } = useContext(DynamicModalContext);
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/SendFlow/SuccessStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { useSelectedNetwork } from "@umami/state";
import type React from "react";
import { useContext } from "react";
import { Link, useNavigate } from "react-router-dom";

import { WindowLinkIcon } from "../../assets/icons/WindowLink";
import { DynamicModalContext } from "../DynamicModal";

export const SuccessStep: React.FC<{ hash: string }> = ({ hash }) => {
const network = useSelectedNetwork();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
ModalHeader,
Text,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Account } from "@umami/core";
import { useGetAccountStakedBalance } from "@umami/state";
import { useContext } from "react";

import { FormPage } from "./FormPage";
import { WarningIcon } from "../../../assets/icons";
import colors from "../../../style/colors";
import { DynamicModalContext } from "../../DynamicModal";
import { NoticeSteps } from "../NoticeSteps";
// TODO: test
export const NoticeModal = ({ account }: { account: Account }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useToast } from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Operation, estimate } from "@umami/core";
import {
estimateAndUpdateBatch,
Expand All @@ -14,7 +15,6 @@ import {
type SignPageProps,
useMakeFormOperations,
} from "./utils";
import { DynamicModalContext } from "../DynamicModal";

// This file defines hooks to create actions when form is submitted.

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/SendFlow/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Button } from "@chakra-ui/react";
import { type TezosToolkit } from "@taquito/taquito";
import { DynamicModalContext } from "@umami/components";
import {
type Account,
type AccountOperations,
Expand All @@ -24,7 +25,6 @@ import { useContext, useState } from "react";
import { useForm } from "react-hook-form";

import { SuccessStep } from "./SuccessStep";
import { DynamicModalContext } from "../DynamicModal";

// Convert given optional fields to required
// For example:
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
Text,
useMediaQuery,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { assetsActions, useAppDispatch, useIsLoading, useLastTimeUpdated } from "@umami/state";
import { differenceInMinutes, differenceInSeconds, formatDistance } from "date-fns";
import type React from "react";
import { useContext, useEffect, useState } from "react";

import { BuyTezForm } from "./BuyTez/BuyTezForm";
import { DynamicModalContext } from "./DynamicModal";
import { FormPage as SendTezForm } from "./SendFlow/Tez/FormPage";
import { FetchingIcon } from "../assets/icons";
import { CheckIcon } from "../assets/icons/CheckIcon";
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/UpsertContactModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ModalFooter,
ModalHeader,
} from "@chakra-ui/react";
import { DynamicModalContext } from "@umami/components";
import { type Contact } from "@umami/core";
import { getNetworksForContracts } from "@umami/multisig";
import {
Expand All @@ -24,7 +25,6 @@ import { isValidContractPkh } from "@umami/tezos";
import { type FC, useContext, useEffect, useRef } from "react";
import { useForm } from "react-hook-form";

import { DynamicModalContext } from "./DynamicModal";
import { FormErrorMessage } from "./FormErrorMessage";

/**
Expand Down
Loading

0 comments on commit a8ab60b

Please sign in to comment.