-
Notifications
You must be signed in to change notification settings - Fork 21
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
15 changed files
with
520 additions
and
16 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
67 changes: 67 additions & 0 deletions
67
packages/stateful/actions/core/actions/EnableApprover/Component.tsx
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,67 @@ | ||
import { ComponentType } from 'react' | ||
import { useFormContext } from 'react-hook-form' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { | ||
InputErrorMessage, | ||
InputLabel, | ||
useActionOptions, | ||
} from '@dao-dao/stateless' | ||
import { AddressInputProps } from '@dao-dao/types' | ||
import { ActionComponent, ActionContextType } from '@dao-dao/types/actions' | ||
import { makeValidateAddress, validateRequired } from '@dao-dao/utils' | ||
|
||
import { | ||
MultipleChoiceProposalModule, | ||
SecretMultipleChoiceProposalModule, | ||
} from '../../../../clients' | ||
|
||
export type EnableApproverData = { | ||
approver: string | ||
} | ||
|
||
export type EnableApproverOptions = { | ||
AddressInput: ComponentType<AddressInputProps<EnableApproverData>> | ||
} | ||
|
||
export const EnableApproverComponent: ActionComponent< | ||
EnableApproverOptions | ||
> = ({ isCreating, fieldNamePrefix, errors, options: { AddressInput } }) => { | ||
const { t } = useTranslation() | ||
const { | ||
context, | ||
chain: { bech32_prefix: bech32Prefix }, | ||
} = useActionOptions() | ||
const { register } = useFormContext<EnableApproverData>() | ||
|
||
return ( | ||
<> | ||
{context.type === ActionContextType.Dao && | ||
context.dao.proposalModules.some( | ||
(m) => | ||
m instanceof MultipleChoiceProposalModule || | ||
m instanceof SecretMultipleChoiceProposalModule | ||
) && ( | ||
<p className="body-text text-text-interactive-error max-w-prose"> | ||
{t('error.multipleChoiceApprovalNotYetSupported')} | ||
</p> | ||
)} | ||
|
||
<p className="body-text max-w-prose"> | ||
{t('info.enableApproverExplanation')} | ||
</p> | ||
|
||
<div className="flex flex-col gap-1 max-w-prose"> | ||
<InputLabel name={t('title.approver')} /> | ||
<AddressInput | ||
disabled={!isCreating} | ||
error={errors?.approver} | ||
fieldName={(fieldNamePrefix + 'approver') as 'approver'} | ||
register={register} | ||
validation={[validateRequired, makeValidateAddress(bech32Prefix)]} | ||
/> | ||
<InputErrorMessage error={errors?.approver} /> | ||
</div> | ||
</> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/stateful/actions/core/actions/EnableApprover/README.md
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,20 @@ | ||
# EnableApprover | ||
|
||
Enable an approver for an existing proposal module. | ||
|
||
## Bulk import format | ||
|
||
This is relevant when bulk importing actions, as described in [this | ||
guide](https://github.com/DA0-DA0/dao-dao-ui/wiki/Bulk-importing-actions). | ||
|
||
### Key | ||
|
||
`enableApprover` | ||
|
||
### Data format | ||
|
||
```json | ||
{ | ||
"approver": "<ADDRESS>" | ||
} | ||
``` |
Oops, something went wrong.