Skip to content

Commit

Permalink
Show the current council budget
Browse files Browse the repository at this point in the history
  • Loading branch information
thesan committed Apr 2, 2024
1 parent bf2060b commit c4bda5c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ export const SpecificParametersDecreaseCouncilBudget: Story = {
const nextButton = getButtonByText(modal, 'Create proposal')
expect(nextButton).toBeDisabled()

const amountField = await modal.findByLabelText('Amount')
const amountField = await modal.findByLabelText('Decrease budget by')

// Invalid price set to 0
await userEvent.type(amountField, '0')
Expand Down
4 changes: 1 addition & 3 deletions packages/ui/src/mocks/data/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ const proposalDetails: Record<ProposalDetailsType, RecursivePartial<ProposalWith
UpdateWorkingGroupBudgetProposalDetails: { amount: joy(200), group: workingGroup },
VetoProposalDetails: { proposal: { __typename: 'Proposal', id: '0', title: random.words(4) } },
UpdateGlobalNftLimitProposalDetails: {},
DecreaseCouncilBudgetProposalDetails: {
amount: joy(1_000_000),
},
DecreaseCouncilBudgetProposalDetails: { amount: joy(100) },
}

export const proposalDetailsMap = mapValues(proposalDetails, (value, key) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const ProposalDetails = ({ proposalDetails, gracePeriod, exactExecutionBl
] as RenderNode[]
}

if (proposalDetails?.type === 'fundingRequest') {
if (proposalDetails?.type === 'fundingRequest' || proposalDetails?.type === 'decreaseCouncilBudget') {
return [
{
renderType: 'Amount',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ const amountMapper =
const overriddenLabelsBy: Partial<Record<ProposalType, string>> = {
decreaseWorkingGroupLeadStake: 'Decrease stake amount',
slashWorkingGroupLead: 'Slashing amount',
decreaseCouncilBudget: 'Decrease budget by',
}
return [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
import React from 'react'

import { useApi } from '@/api/hooks/useApi'
import { CurrencyName } from '@/app/constants/currency'
import { TokenInput, TokenInputComponent } from '@/common/components/forms'
import { Row } from '@/common/components/Modal'
import { RowGapBlock } from '@/common/components/page/PageContent'
import { TextMedium } from '@/common/components/typography'
import { TextMedium, TokenValue } from '@/common/components/typography'
import { useFirstObservableValue } from '@/common/hooks/useFirstObservableValue'

export const DecreaseCouncilBudget = () => {
const { api } = useApi()
const current = useFirstObservableValue(() => api?.query.council.budget(), [api?.isConnected])

return (
<RowGapBlock gap={24}>
<Row>
<RowGapBlock gap={8}>
<h4>Specific parameters</h4>
<TextMedium lighter>Decrease Council Budget</TextMedium>
<TextMedium lighter>
Decrease Council Budget.
{current && (
<>
{' '}
The current budget is <TokenValue value={current} />.
</>
)}
</TextMedium>
</RowGapBlock>
</Row>
<Row>
<RowGapBlock gap={20}>
<TokenInputComponent
label="Amount"
label="Decrease budget by"
tight
units={CurrencyName.integerValue}
required
Expand Down

0 comments on commit c4bda5c

Please sign in to comment.