From 22be8fd8981a6334d3fa361bf808f3716633512f Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Thu, 5 Aug 2021 23:32:17 +0100 Subject: [PATCH] chore: move proposal buttons to ActionBar --- .../components/buttons/proposalActionBar.tsx | 68 +++++++++++++++++++ .../src/views/proposal/proposalView.tsx | 51 ++------------ 2 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 packages/governance/src/views/proposal/components/buttons/proposalActionBar.tsx diff --git a/packages/governance/src/views/proposal/components/buttons/proposalActionBar.tsx b/packages/governance/src/views/proposal/components/buttons/proposalActionBar.tsx new file mode 100644 index 0000000..338dcbd --- /dev/null +++ b/packages/governance/src/views/proposal/components/buttons/proposalActionBar.tsx @@ -0,0 +1,68 @@ +import React from 'react'; +import { + Governance, + Proposal, + ProposalState, + TokenOwnerRecord, +} from '../../../../models/accounts'; +import CancelButton from './cancelButton'; +import { ParsedAccount } from '@oyster/common'; +import SignOffButton from './signOffButton'; +import { FinalizeVoteButton } from './finalizeVoteButton'; +import { RelinquishVoteButton } from './relinquishVoteButton'; +import { Vote } from '../../../../models/instructions'; +import { CastVoteButton } from './castVoteButton'; + +import { useWalletSignatoryRecord } from '../../../../hooks/apiHooks'; + +export function ProposalActionBar({ + governance, + tokenOwnerRecord, + proposal, +}: { + governance: ParsedAccount; + tokenOwnerRecord: ParsedAccount | undefined; + proposal: ParsedAccount; +}) { + let signatoryRecord = useWalletSignatoryRecord(proposal.pubkey); + + return ( +
+ + + {signatoryRecord && + (proposal.info.state === ProposalState.Draft || + proposal.info.state === ProposalState.SigningOff) && ( + + )} + + + {tokenOwnerRecord && ( + <> + + + + + )} +
+ ); +} diff --git a/packages/governance/src/views/proposal/proposalView.tsx b/packages/governance/src/views/proposal/proposalView.tsx index b9cced4..e4b9820 100644 --- a/packages/governance/src/views/proposal/proposalView.tsx +++ b/packages/governance/src/views/proposal/proposalView.tsx @@ -15,10 +15,7 @@ import { contexts } from '@oyster/common'; import { MintInfo } from '@solana/spl-token'; import { InstructionCard } from './components/instruction/instructionCard'; import { NewInstructionCard } from './components/instruction/newInstructionCard'; -import SignOffButton from './components/buttons/signOffButton'; -import { CastVoteButton } from './components/buttons/castVoteButton'; -import { RelinquishVoteButton } from './components/buttons/relinquishVoteButton'; import './style.less'; import { VoterBubbleGraph } from './components/vote/voterBubbleGraph'; @@ -32,16 +29,12 @@ import { VoteRecord, } from '../../models/accounts'; import { useKeyParam } from '../../hooks/useKeyParam'; -import { Vote } from '../../models/instructions'; -import CancelButton from './components/buttons/cancelButton'; -import { FinalizeVoteButton } from './components/buttons/finalizeVoteButton'; import { useGovernance, useProposal, useTokenOwnerRecords, useWalletTokenOwnerRecord, - useWalletSignatoryRecord, useInstructionsByProposal, useVoteRecordsByProposal, useSignatoriesByProposal, @@ -53,6 +46,7 @@ import { VoteScore } from './components/vote/voteScore'; import { VoteCountdown } from './components/header/voteCountdown'; import { useRealm } from '../../contexts/GovernanceContext'; import { getMintMaxVoteWeight } from '../../tools/units'; +import { ProposalActionBar } from './components/buttons/proposalActionBar'; const { TabPane } = Tabs; @@ -256,7 +250,6 @@ function InnerProposalView({ endpoint: string; hasVotes: boolean; }) { - let signatoryRecord = useWalletSignatoryRecord(proposal.pubkey); const tokenOwnerRecord = useWalletTokenOwnerRecord( governance.info.realm, proposal.info.governingTokenMint, @@ -306,43 +299,11 @@ function InnerProposalView({ -
- - - {signatoryRecord && - (proposal.info.state === ProposalState.Draft || - proposal.info.state === ProposalState.SigningOff) && ( - - )} - - - {tokenOwnerRecord && ( - <> - - - - - )} -
+