Skip to content

Commit

Permalink
added voting config item to creation UI to change only_members_execute
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed May 28, 2024
1 parent 2ddd135 commit 9daceba
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@
"proposalAllAbstainClarification": "When all voters abstain, a proposal will fail.",
"proposalDepositTooltip": "The deposit required to create a proposal.",
"proposalDepositWillBeRefunded": "Proposal deposit will be refunded once closed.",
"proposalExecutionPolicyDescription": "Who is allowed to execute passed proposals?",
"proposalModuleInfoCardsTooltip": "Different proposal types are configured separately. This is the configuration for the {{type}} proposal type.",
"proposalModuleInfoCardsTooltip_approval": "Different proposal types are configured separately. This is the configuration for proposals that approve proposals in the DAO shown.",
"proposalQuorumTooltip": "This proportion of voting power must vote on a proposal for it to pass.",
Expand Down Expand Up @@ -1739,6 +1740,7 @@
"proposal": "Proposal",
"proposalAllAbstain": "All abstain clarification",
"proposalCreationInfo": "Proposal creation info",
"proposalExecutionPolicy": "Proposal execution policy",
"proposalId": "Proposal {{id}}",
"proposalNotFound": "Proposal Not Found",
"proposalTieClarification": "Tie clarification",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useTranslation } from 'react-i18next'

import { LockWithKeyEmoji, SegmentedControls } from '@dao-dao/stateless'
import {
DaoCreationVotingConfigItem,
DaoCreationVotingConfigItemInputProps,
DaoCreationVotingConfigItemReviewProps,
DaoCreationVotingConfigWithProposalExecutionPolicy,
} from '@dao-dao/types'

const ProposalExecutionPolicyVotingConfigItemInput = ({
data: { onlyMembersExecute },
setValue,
}: DaoCreationVotingConfigItemInputProps<DaoCreationVotingConfigWithProposalExecutionPolicy>) => {
const { t } = useTranslation()

return (
<SegmentedControls
onSelect={(value) => setValue('onlyMembersExecute', value)}
selected={onlyMembersExecute}
tabs={[
{
label: t('info.onlyMembers'),
value: true,
},
{
label: t('info.anyone'),
value: false,
},
]}
/>
)
}

const ProposalExecutionPolicyVotingConfigItemReview = ({
data: { onlyMembersExecute },
}: DaoCreationVotingConfigItemReviewProps<DaoCreationVotingConfigWithProposalExecutionPolicy>) => {
const { t } = useTranslation()
return <>{onlyMembersExecute ? t('info.onlyMembers') : t('info.anyone')}</>
}

export const makeProposalExecutionPolicyVotingConfigItem =
(): DaoCreationVotingConfigItem<DaoCreationVotingConfigWithProposalExecutionPolicy> => ({
Icon: LockWithKeyEmoji,
nameI18nKey: 'title.proposalExecutionPolicy',
descriptionI18nKey: 'info.proposalExecutionPolicyDescription',
tooltipI18nKey: 'info.proposalExecutionPolicyDescription',
Input: ProposalExecutionPolicyVotingConfigItemInput,
getInputError: ({ onlyMembersExecute } = {}) => onlyMembersExecute,
Review: ProposalExecutionPolicyVotingConfigItemReview,
})
2 changes: 2 additions & 0 deletions packages/stateful/components/dao/commonVotingConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { makeAllowRevotingVotingConfigItem } from './AllowRevotingVotingConfigIt
import { makeApproverVotingConfigItem } from './ApproverVotingConfigItem'
import { makeMultipleChoiceVotingConfigItem } from './MultipleChoiceVotingConfigItem'
import { makeProposalDepositVotingConfigItem } from './ProposalDepositVotingConfigItem'
import { makeProposalExecutionPolicyVotingConfigItem } from './ProposalExecutionPolicyVotingConfigItem'
import { makeProposalSubmissionPolicyVotingConfigItem } from './ProposalSubmissionPolicyVotingConfigItem'
import { makeQuorumVotingConfigItem } from './QuorumVotingConfigItem'
import { makeVetoVotingConfigItem } from './VetoVotingConfigItem'
Expand All @@ -20,6 +21,7 @@ export const loadCommonVotingConfigItems =
makeQuorumVotingConfigItem(),
makeAllowRevotingVotingConfigItem(),
makeProposalSubmissionPolicyVotingConfigItem(),
makeProposalExecutionPolicyVotingConfigItem(),
makeApproverVotingConfigItem(),
makeVetoVotingConfigItem(),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo<
votingDuration,
proposalDeposit,
anyoneCanPropose,
onlyMembersExecute,
allowRevoting,
veto,
},
Expand Down Expand Up @@ -89,7 +90,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo<
close_proposal_on_execution_failure: true,
max_voting_period: convertDurationWithUnitsToDuration(votingDuration),
min_voting_period: null,
only_members_execute: true,
only_members_execute: !!onlyMembersExecute,
pre_propose_info: {
module_may_propose: {
info: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo<
votingDuration,
proposalDeposit,
anyoneCanPropose,
onlyMembersExecute,
allowRevoting,
approver,
veto,
Expand Down Expand Up @@ -99,7 +100,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo<
close_proposal_on_execution_failure: true,
max_voting_period: convertDurationWithUnitsToDuration(votingDuration),
min_voting_period: null,
only_members_execute: true,
only_members_execute: !!onlyMembersExecute,
pre_propose_info: {
module_may_propose: {
info: {
Expand Down
1 change: 1 addition & 0 deletions packages/stateful/recoil/atoms/newDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const makeDefaultNewDao = (chainId: string): NewDao => ({
refundPolicy: DepositRefundPolicy.OnlyPassed,
},
anyoneCanPropose: false,
onlyMembersExecute: true,
allowRevoting: false,
enableMultipleChoice: true,
approver: {
Expand Down
7 changes: 6 additions & 1 deletion packages/types/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,19 @@ export type DaoCreationVotingConfigWithVeto = {
veto: ProposalVetoConfig
}

export type DaoCreationVotingConfigWithProposalExecutionPolicy = {
onlyMembersExecute: boolean
}

export type DaoCreationVotingConfig = DaoCreationVotingConfigWithAllowRevoting &
DaoCreationVotingConfigWithProposalDeposit &
DaoCreationVotingConfigWithProposalSubmissionPolicy &
DaoCreationVotingConfigWithQuorum &
DaoCreationVotingConfigWithVotingDuration &
DaoCreationVotingConfigWithEnableMultipleChoice &
DaoCreationVotingConfigWithApprover &
DaoCreationVotingConfigWithVeto
DaoCreationVotingConfigWithVeto &
DaoCreationVotingConfigWithProposalExecutionPolicy

//! Other

Expand Down

0 comments on commit 9daceba

Please sign in to comment.