Skip to content

Commit 7de8b00

Browse files
authored
Fix cycle issue for off-chain proposals (#614)
Signed-off-by: Manank Patni <manank321@gmail.com>
1 parent 86ea3d9 commit 7de8b00

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/modules/explorer/components/ProposalActionsDialog.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { SupportedLambdaProposalKey } from "services/bakingBad/lambdas"
1515
import { ProposalAction, ProposalFormLambda } from "modules/explorer/components/ConfigProposalFormLambda"
1616
import { useDAO } from "services/services/dao/hooks/useDAO"
1717
import { ProposalCreatorModal } from "modules/lite/explorer/pages/CreateProposal/ProposalCreatorModal"
18+
import { useIsProposalButtonDisabled } from "services/contracts/baseDAO/hooks/useCycleInfo"
1819

1920
type RecursivePartial<T> = {
2021
[P in keyof T]?: RecursivePartial<T[P]>
@@ -123,6 +124,7 @@ export const ProposalActionsDialog: React.FC<Props> = ({ open, handleClose }) =>
123124
const [openProposalFormLambda, setOpenProposalFormLambda] = useState(false)
124125
const [openLiteProposal, setOpenLiteProposal] = useState(false)
125126
const liteDAOId = data?.liteDAOData?._id
127+
const shouldDisable = useIsProposalButtonDisabled(daoId)
126128

127129
const handleOpenCustomProposalModal = (key: ProposalAction) => {
128130
setProposalAction(key)
@@ -167,13 +169,21 @@ export const ProposalActionsDialog: React.FC<Props> = ({ open, handleClose }) =>
167169
onClick={() =>
168170
elem.id === "off-chain"
169171
? handleLiteProposal()
170-
: elem.isLambda
171-
? handleOpenCustomProposalModal(elem.id)
172-
: handleOpenSupportedExecuteProposalModal(elem.id)
172+
: !shouldDisable
173+
? elem.isLambda
174+
? handleOpenCustomProposalModal(elem.id)
175+
: handleOpenSupportedExecuteProposalModal(elem.id)
176+
: null
173177
}
174178
>
175-
<ActionText color="textPrimary">{elem.name}</ActionText>
176-
<ActionDescriptionText color="textPrimary"> {elem.description} </ActionDescriptionText>
179+
<ActionText color={shouldDisable && elem.id !== "off-chain" ? "textSecondary" : "textPrimary"}>
180+
{elem.name}
181+
</ActionText>
182+
<ActionDescriptionText
183+
color={shouldDisable && elem.id !== "off-chain" ? "textSecondary" : "textPrimary"}
184+
>
185+
{elem.description}{" "}
186+
</ActionDescriptionText>
177187
</OptionContainer>
178188
</Grid>
179189
)

src/modules/explorer/pages/Proposals/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,7 @@ export const Proposals: React.FC = () => {
241241
direction={isMobileSmall ? "column" : "row"}
242242
xs={isMobileSmall ? undefined : true}
243243
>
244-
<SmallButton
245-
variant="contained"
246-
disabled={shouldDisable}
247-
color="secondary"
248-
onClick={() => setOpenDialog(true)}
249-
>
244+
<SmallButton variant="contained" color="secondary" onClick={() => setOpenDialog(true)}>
250245
New Proposal
251246
</SmallButton>
252247
<Grid>

0 commit comments

Comments
 (0)