Skip to content

Commit

Permalink
fix: only show proposal voting actions to editors (#980)
Browse files Browse the repository at this point in the history
* fix: only show proposal voting actions to editors

* fix: janky placeholder for button height in proposal header
  • Loading branch information
baiirun authored Jan 10, 2025
1 parent 14fae51 commit be32032
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/web/partials/active-proposal/accept-or-reject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as React from 'react';
import { useState } from 'react';

import { useAccessControl } from '~/core/hooks/use-access-control';
import { useSmartAccount } from '~/core/hooks/use-smart-account';
import { useVote } from '~/core/hooks/use-vote';
import { Proposal } from '~/core/io/dto/proposals';
Expand All @@ -14,6 +15,7 @@ import { Pending } from '~/design-system/pending';
import { Execute } from './execute';

interface Props {
spaceId: string;
isProposalEnded: boolean;
// If the proposal is executable that means it's done and the
// acceptance threshold has passed.
Expand All @@ -26,13 +28,15 @@ interface Props {
}

export function AcceptOrReject({
spaceId,
isProposalEnded,
isProposalExecutable,
status,
userVote,
onchainProposalId,
votingContractAddress,
}: Props) {
const { isEditor } = useAccessControl(spaceId);
const { vote, status: voteStatus } = useVote({
address: votingContractAddress,
onchainProposalId,
Expand Down Expand Up @@ -81,7 +85,7 @@ export function AcceptOrReject({
return <div className="rounded bg-errorTertiary px-3 py-2 text-button text-red-01">Rejected</div>;
}

if (!isProposalEnded && smartAccount) {
if (!isProposalEnded && smartAccount && isEditor) {
return (
<div className="relative">
<div className="inline-flex items-center gap-4">
Expand All @@ -97,5 +101,6 @@ export function AcceptOrReject({
);
}

return null;
// Janky placeholder for button height
return <div className="h-9 w-1" />;
}
1 change: 1 addition & 0 deletions apps/web/partials/active-proposal/active-proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ async function ReviewProposal({ proposalId, spaceId, connectedAddress }: Props)
</div>

<AcceptOrReject
spaceId={spaceId}
onchainProposalId={proposal.onchainProposalId}
isProposalEnded={isProposalEnded}
isProposalExecutable={isProposalExecutable}
Expand Down

0 comments on commit be32032

Please sign in to comment.