Skip to content

Commit

Permalink
Fix cycle issue for off-chain proposals (#614)
Browse files Browse the repository at this point in the history
Signed-off-by: Manank Patni <[email protected]>
  • Loading branch information
Man-Jain authored Jul 23, 2023
1 parent 86ea3d9 commit 7de8b00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
20 changes: 15 additions & 5 deletions src/modules/explorer/components/ProposalActionsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { SupportedLambdaProposalKey } from "services/bakingBad/lambdas"
import { ProposalAction, ProposalFormLambda } from "modules/explorer/components/ConfigProposalFormLambda"
import { useDAO } from "services/services/dao/hooks/useDAO"
import { ProposalCreatorModal } from "modules/lite/explorer/pages/CreateProposal/ProposalCreatorModal"
import { useIsProposalButtonDisabled } from "services/contracts/baseDAO/hooks/useCycleInfo"

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

const handleOpenCustomProposalModal = (key: ProposalAction) => {
setProposalAction(key)
Expand Down Expand Up @@ -167,13 +169,21 @@ export const ProposalActionsDialog: React.FC<Props> = ({ open, handleClose }) =>
onClick={() =>
elem.id === "off-chain"
? handleLiteProposal()
: elem.isLambda
? handleOpenCustomProposalModal(elem.id)
: handleOpenSupportedExecuteProposalModal(elem.id)
: !shouldDisable
? elem.isLambda
? handleOpenCustomProposalModal(elem.id)
: handleOpenSupportedExecuteProposalModal(elem.id)
: null
}
>
<ActionText color="textPrimary">{elem.name}</ActionText>
<ActionDescriptionText color="textPrimary"> {elem.description} </ActionDescriptionText>
<ActionText color={shouldDisable && elem.id !== "off-chain" ? "textSecondary" : "textPrimary"}>
{elem.name}
</ActionText>
<ActionDescriptionText
color={shouldDisable && elem.id !== "off-chain" ? "textSecondary" : "textPrimary"}
>
{elem.description}{" "}
</ActionDescriptionText>
</OptionContainer>
</Grid>
)
Expand Down
7 changes: 1 addition & 6 deletions src/modules/explorer/pages/Proposals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,7 @@ export const Proposals: React.FC = () => {
direction={isMobileSmall ? "column" : "row"}
xs={isMobileSmall ? undefined : true}
>
<SmallButton
variant="contained"
disabled={shouldDisable}
color="secondary"
onClick={() => setOpenDialog(true)}
>
<SmallButton variant="contained" color="secondary" onClick={() => setOpenDialog(true)}>
New Proposal
</SmallButton>
<Grid>
Expand Down

0 comments on commit 7de8b00

Please sign in to comment.