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

Commit

Permalink
bundle permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
kengoldfarb committed Mar 4, 2023
1 parent 8e19ec8 commit abd7853
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 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

0 comments on commit abd7853

Please sign in to comment.