Skip to content

Commit

Permalink
Feature/671 delegation (#840)
Browse files Browse the repository at this point in the history
* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* develop to master (#482)

* UI/layout cleanup (#438)

* run generator

* import connect, theme libs. Add eindow.global. Ensure main.tsx uses React 17 API.

* deletes app test

* updates favicon and title

* remove nx defaults

* rough in layout box, target DH connect nav with class

* remove even more css. World's dubest layout component

* switches to connect class padding for mobile

* extract base layout component to storybook

* hook export chain, change name to outerlayout

* extract formSegment from summon-app; replace in all instances in summon

* extract split-column, replace all instances in summon

* document future changes in comments

* fix exports

* switch core-app to nx default project

* fix spacing

* Fix/split column bug (#444)

- fix bug

* Layouts/subnav (#447)

* clear out extra app.t.tsx

* build sub-nav

* style sub-nav

* test subnav

* extract subNavLink into component

* subnavlink story

* build subnavlink story

* fix broken as prop

* add mobile view, icon button trigger

* add tsc command to core-app

* adds human-format, removes profanity

* Fix summon (#446)

* Fix summon

* clear out extra app.t.tsx

* build sub-nav

* style sub-nav

* test subnav

* extract subNavLink into component

* subnavlink story

* build subnavlink story

* fix broken as prop

* Fix summon

* add mobile view, icon button trigger

* add tsc command to core-app

* adds human-format, removes profanity

* add human-format to dao-data

* move dts file

Co-authored-by: jordan <[email protected]>
Co-authored-by: Jord <[email protected]>

* Haus layout (#451)

* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* build formLayout Component

* type correction

* build formLayout story

* rough in bicolumn layout

* handle bicolumn mobile switch, finish bicolumn

* fix mainlayout naming

* build story for bi-column layout

* build dh layout one shot?

* yes, one shot

* fix import

* change prop name

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* bumping packages that were published pre revert last week - causing fialures with package publishing (#460)

* removing period from info content which casues confusing tooltip (#453)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub profile menu fix (#480)

* fixes profile link and layout

* dao list style

* adds toast to share link

* Readme tables preferred (#483)

* adjusting breakdown of apps and libs to tables

* adding additoonal app references and libs

* adding timestamp and address fields to many events (#468)

* adding timestamps and address fields to many events

* addressing code review

* shortening naming convention on proposals, top level txHash defined as txHash going forward

* update version

* deploy subgraph and generate query types

Co-authored-by: skuhlmann <[email protected]>

Co-authored-by: Jord <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: jordan <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>

* Revert "develop to master (#482)" (#492)

This reverts commit 5f7d121.

Co-authored-by: Sam Kuhlmann <[email protected]>

* Develop into master (#577)

* Feature/form builder (#553)

* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* build formLayout Component

* type correction

* build formLayout story

* rough in bicolumn layout

* handle bicolumn mobile switch, finish bicolumn

* fix mainlayout naming

* build story for bi-column layout

* scaffold formBuilder library

* rough in formBuilder

* restructure types

* refactor component structure

* test render inputs

* add core fields to builder enum

* add row layout to builder

* built logger, fix logger bug

* add disable all functionality

* handle asynchronous callback as props to form builder

* remove some comments

* put submit button in form footer

* fix code based on review

* build validation pipeline

* clean form and field types

* revise types again, simplify rules API

* commit after refactor carnage

* roll back to react-hook-form v6, finally get some traction

* found source of bug, trying new rhf version

* ...and the bug was slain, returned to that cold, miserable shit heap from whence it came.

* reintroduce devtool and logger

* build metadata form, form segment subForm component

* clean, add custom submit btn text

* clean

* build string validations

* derive validation type from function obj

* wrestled types into validation system

* rebuild form builder as context

* build formBuilder hook, use it in the factory

* create sample test

* update form placement

* more post merge corrections

* write validation updaters and add to pipeline, test required updaters, test validation, test pipeline

* try jest testing

* ensure field state updates on formState change

* more cleaning

* reorg files

* build metadata form

* tweak button styles, add defaultValues to formBuilder

* good place to stop

* remove comments

* fix Jest errors

* fix field wrapper stories, update lock

* may have fixed jest errors

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Fix build (#563)

* Fix build

* Almost

* More changes

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Revert "Develop into master (#577)"

This reverts commit b8644d3.

* gets member profile menu setup

* gets delegation form working

* gets other delegate links working in member list

* adds some better tooltip text

* addresses feedback and does some cleanup

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: jordan <[email protected]>
  • Loading branch information
8 people authored Sep 16, 2022
1 parent 2900253 commit 3742664
Show file tree
Hide file tree
Showing 18 changed files with 350 additions and 12 deletions.
44 changes: 44 additions & 0 deletions apps/core-app/src/components/ManageDelegate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useMemo } from 'react';
import { FormBuilder } from '@daohaus/haus-form-builder';
import { useConnectedMembership, useDao } from '@daohaus/dao-context';

import { CustomFields } from '../legos/config';
import { COMMON_FORMS } from '../legos/form';

type ManageDelegateProps = {
defaultMember?: string;
};

export const ManageDelegate = ({ defaultMember }: ManageDelegateProps) => {
const { connectedMembership } = useConnectedMembership();
const { refreshAll } = useDao();

const defaultValues = useMemo(() => {
if (defaultMember) {
return { delegatingTo: defaultMember };
}
if (
connectedMembership &&
connectedMembership.delegatingTo !== connectedMembership.memberAddress
) {
return connectedMembership;
}
}, [connectedMembership, defaultMember]);

const onFormComplete = () => {
refreshAll?.();
};

if (!connectedMembership) return null;

return (
<FormBuilder
defaultValues={defaultValues}
form={COMMON_FORMS.MANAGE_DELEGATE}
customFields={CustomFields}
onSuccess={onFormComplete}
/>
);
};

export default ManageDelegate;
144 changes: 144 additions & 0 deletions apps/core-app/src/components/MemberProfileMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { useMemo } from 'react';
import { RiMore2Fill } from 'react-icons/ri';
import { useParams } from 'react-router-dom';
import styled from 'styled-components';
import { useConnectedMembership } from '@daohaus/dao-context';
import {
Dropdown,
DropdownMenuItem,
DropdownButton,
font,
Theme,
Dialog,
DialogTrigger,
DialogContent,
DropdownLink,
DropdownText,
} from '@daohaus/ui';

import ManageDelegate from './ManageDelegate';

export const ProfileMenuTrigger = styled(DropdownButton)`
padding: 0 4px 0 4px;
&[data-state='open'] {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
svg.icon-right {
color: ${({ theme }: { theme: Theme }) => theme.primary};
}
svg.icon-left {
margin-right: 0;
}
`;

export const ProfileMenuLink = styled(DropdownLink)`
font-weight: ${font.weight.bold};
`;

const ProfileMenuText = styled(DropdownText)`
border-radius: 2px;
color: ${(props) => props.theme.dropdown.text};
font-weight: ${font.weight.bold};
cursor: pointer;
display: flex;
padding: 1rem;
transition: 0.2s all;
width: 100%;
font-size: ${font.size.md};
svg {
margin-left: 0.3rem;
}
:hover {
background-color: ${(props) => props.theme.navTabs.hoverNavLinkDropdownBg};
border-color: ${(props) => props.theme.navTabs.hoverNavLinkDropdownBorder};
text-decoration: none;
}
&.disabled {
color: ${(props) => props.theme.dropdown.textDisabled};
}
`;

type MemberProfileMenuProps = {
memberAddress: string;
};

export const MemberProfileMenu = ({
memberAddress,
}: MemberProfileMenuProps) => {
const { daoid, daochain } = useParams();
const { connectedMembership } = useConnectedMembership();

const enableActions = useMemo(() => {
return (
connectedMembership &&
connectedMembership?.memberAddress !== memberAddress &&
Number(connectedMembership.shares) > 0
);
}, [connectedMembership, memberAddress]);

const isMenuForConnectedMember = useMemo(() => {
return connectedMembership?.memberAddress === memberAddress;
}, [connectedMembership, memberAddress]);

return (
<Dropdown
menuMinWidth="17.8rem"
trigger={<ProfileMenuTrigger IconLeft={RiMore2Fill} sm />}
side="left"
>
{isMenuForConnectedMember && (
<>
<DropdownMenuItem key="delegate" asChild>
<Dialog>
<DialogTrigger asChild>
<ProfileMenuText>Delegate</ProfileMenuText>
</DialogTrigger>
<DialogContent title="Manage Delegate">
<ManageDelegate />
</DialogContent>
</Dialog>
</DropdownMenuItem>
<DropdownMenuItem key="ragequit" asChild>
<ProfileMenuText className="disabled">Rage Quit</ProfileMenuText>
</DropdownMenuItem>
</>
)}

{!isMenuForConnectedMember && (
<>
<DropdownMenuItem key="delegateTo" asChild>
<Dialog>
<DialogTrigger asChild>
<ProfileMenuText className={enableActions ? '' : 'disabled'}>
Delegate To
</ProfileMenuText>
</DialogTrigger>
<DialogContent title="Manage Delegate">
<ManageDelegate defaultMember={memberAddress} />
</DialogContent>
</Dialog>
</DropdownMenuItem>
<DropdownMenuItem key="guildkick" asChild>
<ProfileMenuLink
className={enableActions ? '' : 'disabled'}
href={`/molochv3/${daochain}/${daoid}/new-proposal?formLego=GUILDKICK&defaultValues=${JSON.stringify(
{
memberAddress: memberAddress,
}
)}`}
>
Guild Kick
</ProfileMenuLink>
</DropdownMenuItem>
</>
)}
</Dropdown>
);
};
4 changes: 4 additions & 0 deletions apps/core-app/src/components/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@daohaus/common-utilities';

import { TMembership, useDao } from '@daohaus/dao-context';
import { MemberProfileMenu } from './MemberProfileMenu';

const AvatarLarge = styled(Avatar)`
height: 12rem;
Expand Down Expand Up @@ -134,6 +135,9 @@ export const Profile = ({ profile, membership }: ProfileProps) => {
)}
</Container>
</ProfileMetadataContainer>
{membership && (
<MemberProfileMenu memberAddress={membership.memberAddress} />
)}
</PSubContainer>
{membership && dao && (
<DataGrid>
Expand Down
4 changes: 3 additions & 1 deletion apps/core-app/src/components/ProfileLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ type ProfileLinkProps = {
sm?: boolean;
lg?: boolean;
buttonText?: string;
secondary?: boolean;
};

export const ProfileLink = ({
memberAddress,
sm = false,
lg = false,
buttonText = 'Profile',
secondary = false,
}: ProfileLinkProps) => {
const { daoid, daochain } = useParams();

return (
<Link href={`/molochv3/${daochain}/${daoid}/members/${memberAddress}`}>
<Button sm={sm} lg={lg}>
<Button sm={sm} lg={lg} secondary={secondary}>
{buttonText}
</Button>
</Link>
Expand Down
6 changes: 3 additions & 3 deletions apps/core-app/src/components/customFields/SelectApplicant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SelectApplicant = ({
daoMemberOnly,
...props
}: SelectApplicantProps) => {
const [textMode, toggleTextMode] = useState(false);
const [textMode, toggleTextMode] = useState(true);
const [memberList, setMemberList] = useState<Array<OptionType>>([]);
const [memberLoading, setMemberLoading] = useState(false);
const [valError, setValError] = useState<ErrorMessage | undefined>();
Expand Down Expand Up @@ -62,7 +62,7 @@ export const SelectApplicant = ({
[daochain, daoid, setValue]
);

const ToggeButton = () => {
const ToggleButton = () => {
return (
<Button
sm
Expand Down Expand Up @@ -103,7 +103,7 @@ export const SelectApplicant = ({
loading={memberLoading}
options={!textMode ? memberList : []}
placeholder={!textMode ? `Choose a Member` : `0x`}
rightAddon={<ToggeButton />}
rightAddon={<ToggleButton />}
/>
);
};
64 changes: 64 additions & 0 deletions apps/core-app/src/components/customFields/delegateInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react';

import {
Buildable,
WrappedInput,
Field,
ParMd,
DataMd,
ParSm,
Theme,
Tooltip,
} from '@daohaus/ui';
import { useConnectedMembership, useDao } from '@daohaus/dao-context';
import {
formatValueTo,
fromWei,
votingPowerPercentage,
} from '@daohaus/common-utilities';
import styled from 'styled-components';
import { useFormContext } from 'react-hook-form';

const RemoveDelegate = styled(ParSm)`
margin-top: 3rem;
:hover {
cursor: pointer;
color: ${({ theme }: { theme: Theme }) => theme.link.color};
}
`;

export const DelegateInput = (props: Buildable<Field>) => {
const { connectedMembership } = useConnectedMembership();
const { dao } = useDao();
const { setValue } = useFormContext();

const hasCurrentDelegate =
connectedMembership?.delegatingTo !== connectedMembership?.memberAddress;

const handleRemoveDelegate = () => {
setValue(props.id, connectedMembership?.memberAddress);
};

const votingPowerMessage = `${dao?.shareTokenName} (${formatValueTo({
value: fromWei(connectedMembership?.shares || '0'),
decimals: 2,
format: 'number',
})} - ${votingPowerPercentage(
dao?.totalShares || '0',
connectedMembership?.shares || '0'
)}% voting power) `;

return (
<>
<WrappedInput {...props} />
<ParMd>Voting token to delegate</ParMd>
<DataMd>{votingPowerMessage}</DataMd>
{hasCurrentDelegate && (
<RemoveDelegate onClick={handleRemoveDelegate}>
Remove Existing Delegate
<Tooltip content="Will reset the delegate address to your own. Then you can submit the transaction to update." />
</RemoveDelegate>
)}
</>
);
};
2 changes: 2 additions & 0 deletions apps/core-app/src/legos/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ShamanDeluxe } from '../components/customFields/ShamanDeluxe';
import { TagsInput } from '../components/customFields/tagsInput';
import { FakeMarkdown } from '../components/FakeMarkdown';
import { ProposalOffering } from '../components/customFields/ProposalOffering';
import { DelegateInput } from '../components/customFields/delegateInput';

export const CustomFields = {
...CoreFieldLookup,
Expand All @@ -21,6 +22,7 @@ export const CustomFields = {
tagsInput: TagsInput,
fakeMarkdown: FakeMarkdown,
proposalOffering: ProposalOffering,
delegateInput: DelegateInput,
};

export type CustomFieldLego = FieldLegoBase<typeof CustomFields>;
Expand Down
12 changes: 12 additions & 0 deletions apps/core-app/src/legos/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@ export const CONTRACT: Record<string, ContractLego> = {
abi: LOCAL_ABI.TRIBUTE_MINION,
targetAddress: CONTRACTS.TRIBUTE_MINION,
},
SHARES_ERC20: {
type: 'static',
contractName: 'SHARES_ERC20',
abi: LOCAL_ABI.SHARES,
targetAddress: '.dao.sharesAddress',
},
LOOT_ERC20: {
type: 'static',
contractName: 'LOOT_ERC20',
abi: LOCAL_ABI.LOOT,
targetAddress: '.dao.sharesAddress',
},
};
6 changes: 6 additions & 0 deletions apps/core-app/src/legos/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export const FIELD: Record<string, CustomFieldLego> = {
label: 'Tags (separated by commas)',
placeholder: 'DAO Name',
},
DELEGATE: {
id: 'delegatingTo',
type: 'delegateInput',
label: 'Delgate to',
placeholder: '0x0...',
},
PROPOSAL_EXPIRY: {
id: 'checkRender',
type: 'checkRender',
Expand Down
9 changes: 9 additions & 0 deletions apps/core-app/src/legos/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,4 +534,13 @@ export const COMMON_FORMS: Record<string, CustomFormLego> = {
...PROPOSAL_SETTINGS_FIELDS,
],
},
MANAGE_DELEGATE: {
id: 'MANAGE_DELEGATE',
fields: [FIELD.DELEGATE],
requiredFields: {
delegatingTo: true,
},
submitButtonText: 'Update Delegate',
tx: TX.MANAGE_DELEGATE,
},
};
6 changes: 6 additions & 0 deletions apps/core-app/src/legos/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ export const TX: Record<string, TXLego> = {
},
],
}),
MANAGE_DELEGATE: {
id: 'MANAGE_DELEGATE',
contract: CONTRACT.SHARES_ERC20,
method: 'delegate',
args: ['.formValues.delegatingTo'],
},
};

export const TABULA_TX: Record<string, TXLego> = {
Expand Down
Loading

0 comments on commit 3742664

Please sign in to comment.