Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #16 from meemproject/feature/ethdenver-updates
Browse files Browse the repository at this point in the history
Show magic wallet; fix bundle actions not disabled for non-creators
  • Loading branch information
kengoldfarb authored Mar 4, 2023
2 parents aba1301 + abd7853 commit c96c23f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 23 deletions.
7 changes: 5 additions & 2 deletions src/components/Atoms/FacetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface IProps {
contracts?: Contracts[]
isLoading?: boolean
isEnabled?: boolean
isDisabled?: boolean
}

export const FacetList: React.FC<IProps> = ({
Expand All @@ -44,6 +45,7 @@ export const FacetList: React.FC<IProps> = ({
contractInstances,
contracts,
isEnabled,
isDisabled,
proxyContract
}) => {
const { classes } = useStyles()
Expand Down Expand Up @@ -227,7 +229,8 @@ export const FacetList: React.FC<IProps> = ({
<Switch
key={`${contract?.id}-${selector}`}
disabled={
!isEnabled
!isEnabled ||
isDisabled
}
checked={
isInUse
Expand Down Expand Up @@ -255,7 +258,7 @@ export const FacetList: React.FC<IProps> = ({
)}
</div>
</ContractCard>
{isEnabled && (
{isEnabled && !isDisabled && (
<div>
<IconButton
tooltip="Remove Facet"
Expand Down
26 changes: 16 additions & 10 deletions src/components/Bundles/BundleContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const BundleContainer: React.FC = () => {
const { anonClient } = useMeemApollo()
const { classes } = useStyles()
const bundleId = router.query.bundleId as string
const { chainId } = useWallet()
const { chainId, accounts } = useWallet()

const form = useForm({
initialValues: {
Expand Down Expand Up @@ -253,17 +253,23 @@ export const BundleContainer: React.FC = () => {
form={form}
isLoading={isLoading}
contracts={contracts}
isDisabled={
data?.Bundles[0].Creator?.address !==
accounts[0]
}
/>
<Space h={24} />
<Center>
<Button
type="submit"
loading={isSaving}
disabled={isLoading || isSaving}
>
Save
</Button>
</Center>
{data?.Bundles[0].Creator?.address === accounts[0] && (
<Center>
<Button
type="submit"
loading={isSaving}
disabled={isLoading || isSaving}
>
Save
</Button>
</Center>
)}
</>
)}
</form>
Expand Down
21 changes: 13 additions & 8 deletions src/components/Bundles/BundleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export interface IProps {
form: UseFormReturnType<any>
contracts: Contracts[]
isLoading?: boolean
isDisabled?: boolean
}

export const BundleForm: React.FC<IProps> = ({
form,
isLoading: isParentLoading
isLoading: isParentLoading,
isDisabled
}) => {
const { anonClient } = useMeemApollo()
const { classes } = useStyles()
Expand Down Expand Up @@ -125,20 +127,23 @@ export const BundleForm: React.FC<IProps> = ({
<div className={classes.section_wrapper}>
<Text size="xl">Facets</Text>
<Space w={12} />
<Button
disabled={isLoading}
onClick={() => setIsOpen(true)}
leftIcon={<CirclePlus />}
>
Add Facet
</Button>
{!isDisabled && (
<Button
disabled={isLoading}
onClick={() => setIsOpen(true)}
leftIcon={<CirclePlus />}
>
Add Facet
</Button>
)}
</div>
<Space h={12} />
<FacetList
form={form}
contracts={data?.Contracts as Contracts[]}
isLoading={isLoading}
isEnabled
isDisabled={isDisabled}
/>
<Modal
opened={isOpen}
Expand Down
22 changes: 19 additions & 3 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
Avatar,
Divider
} from '@mantine/core'
import { useWallet } from '@meemproject/react'
import { useAuth } from '@meemproject/react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import React, { useState } from 'react'
import { Logout, ChevronDown, Dots } from 'tabler-icons-react'
import { Logout, ChevronDown, Dots, Wallet } from 'tabler-icons-react'
import { quickTruncate } from '../../utils/truncated_wallet'
import { ChainSelect } from '../Atoms/ChainSelect'
import { Logo } from '../Atoms/Logo'
Expand Down Expand Up @@ -162,7 +162,7 @@ export const HeaderMenu: React.FC = () => {
const [isUserMenuOpened, setUserMenuOpened] = useState(false)
const { classes, cx } = useStyles()
const router = useRouter()
const wallet = useWallet()
const wallet = useAuth()

const navigateHome = () => {
router.push({ pathname: '/' })
Expand Down Expand Up @@ -222,6 +222,22 @@ export const HeaderMenu: React.FC = () => {
</UnstyledButton>
}
>
{wallet.walletType === 'magic' && (
<Menu.Item
className={classes.menuItem}
onClick={async () => {
try {
wallet.magic?.wallet.showUI()
} catch (e) {
// eslint-disable-next-line no-console
console.log(e)
}
}}
icon={<Wallet size={14} />}
>
Wallet
</Menu.Item>
)}
<Menu.Item
className={classes.menuItem}
onClick={async () => {
Expand Down

0 comments on commit c96c23f

Please sign in to comment.