From de71f3e27ae95def738a94f9bd81e2c498bf2fc6 Mon Sep 17 00:00:00 2001 From: roienatan <34843014+roienatan@users.noreply.github.com> Date: Sun, 6 Sep 2020 11:42:16 +0300 Subject: [PATCH] Support for Join and FundingRequest proposals (read only) (#2099) --- src/assets/locales/en/translation.json | 8 +- src/components/Plugin/Plugin.scss | 1 + src/components/Plugin/PluginContainer.tsx | 4 +- .../ProposalSummary/ProposalSummary.tsx | 20 ++++- .../ProposalSummaryFundingRequest.tsx | 73 ++++++++++++++++++ .../ProposalSummary/ProposalSummaryJoin.tsx | 74 +++++++++++++++++++ src/lib/pluginUtils.ts | 4 + 7 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 src/components/Proposal/ProposalSummary/ProposalSummaryFundingRequest.tsx create mode 100644 src/components/Proposal/ProposalSummary/ProposalSummaryJoin.tsx diff --git a/src/assets/locales/en/translation.json b/src/assets/locales/en/translation.json index 221563426..21d53cfc0 100644 --- a/src/assets/locales/en/translation.json +++ b/src/assets/locales/en/translation.json @@ -38,5 +38,11 @@ "3BoxProfileSuccess": "Profile data saved to 3Box", "Following": "Now following", "UnFollowing": "No longer following", - "Raw call data": "Raw call data" + "Raw call data": "Raw call data", + "Address": "Address:", + "Funding": "Funding:", + "Reputation Minted": "Reputation Minted:", + "Minimum DAO bounty": "Minimum DAO bounty:", + "Amount": "Amount:", + "Amount Redeemed": "Amount Redeemed:" } diff --git a/src/components/Plugin/Plugin.scss b/src/components/Plugin/Plugin.scss index 210010c8e..8679a82ac 100644 --- a/src/components/Plugin/Plugin.scss +++ b/src/components/Plugin/Plugin.scss @@ -85,6 +85,7 @@ background-color: $disabled-button-color; border: $disabled-button-border; cursor: not-allowed; + pointer-events: none; } .activationTime { font-size: $caption; diff --git a/src/components/Plugin/PluginContainer.tsx b/src/components/Plugin/PluginContainer.tsx index 2ceca7cc0..166a161d0 100644 --- a/src/components/Plugin/PluginContainer.tsx +++ b/src/components/Plugin/PluginContainer.tsx @@ -140,6 +140,8 @@ class PluginContainer extends React.Component { } const isActive = getPluginIsActive(pluginState); + // The next line is temporary until creation of Join and FundingRequest proposals will be available. + const disabled = pluginState.name === "Join" || pluginState.name === "FundingRequest"; const isProposalPlugin = Object.keys(PLUGIN_NAMES).includes(pluginState.name); const isBountyPlugin = pluginName(pluginState, pluginState.address) === "Standard Bounties"; // checking the special case here where the information tab is the default @@ -229,7 +231,7 @@ class PluginContainer extends React.Component { { } else { return ; } + } else if (proposal.coreState.name === "Join"){ + const state = proposal.coreState as IJoinProposalState; + return ; + } else if (proposal.coreState.name === "FundingRequest") { + const state = proposal.coreState as IFundingRequestProposalState; + return ; } else { return
Unknown proposal type
; } diff --git a/src/components/Proposal/ProposalSummary/ProposalSummaryFundingRequest.tsx b/src/components/Proposal/ProposalSummary/ProposalSummaryFundingRequest.tsx new file mode 100644 index 000000000..9ca001144 --- /dev/null +++ b/src/components/Proposal/ProposalSummary/ProposalSummaryFundingRequest.tsx @@ -0,0 +1,73 @@ +import { IDAOState, IFundingRequestProposalState } from "@daostack/arc.js"; +import classNames from "classnames"; +import { getNetworkName, linkToEtherScan, fromWei } from "lib/util"; +import * as React from "react"; +import { IProfileState } from "reducers/profilesReducer"; +import i18next from "i18next"; +import * as css from "./ProposalSummary.scss"; + +interface IExternalProps { + beneficiaryProfile?: IProfileState; + detailView?: boolean; + daoState: IDAOState; + proposalState: IFundingRequestProposalState; + transactionModal?: boolean; +} + +interface IState { + network: string; +} + +type IProps = IExternalProps; + +export default class ProposalSummary extends React.Component { + + constructor(props: IProps) { + super(props); + this.state = { + network: "", + }; + + } + + public async componentDidMount(): Promise { + this.setState({ network: (await getNetworkName()).toLowerCase() }); + } + + public render(): RenderOutput { + const { proposalState, detailView, transactionModal } = this.props; + const proposalSummaryClass = classNames({ + [css.detailView]: detailView, + [css.transactionModal]: transactionModal, + [css.proposalSummary]: true, + [css.withDetails]: true, + }); + + return ( +
+
+ + {proposalState.name} + + {detailView && +
+ + + + + + + +
+ {i18next.t("Address")} + + + + {proposalState.beneficiary}
{i18next.t("Amount")}{fromWei(proposalState.amount)}
{i18next.t("Amount Redeemed")}:{fromWei(proposalState.amountRedeemed)}
+
+ } +
+
+ ); + } +} diff --git a/src/components/Proposal/ProposalSummary/ProposalSummaryJoin.tsx b/src/components/Proposal/ProposalSummary/ProposalSummaryJoin.tsx new file mode 100644 index 000000000..8480c1b78 --- /dev/null +++ b/src/components/Proposal/ProposalSummary/ProposalSummaryJoin.tsx @@ -0,0 +1,74 @@ +import { IDAOState, IJoinProposalState } from "@daostack/arc.js"; +import classNames from "classnames"; +import { getNetworkName, linkToEtherScan, fromWei } from "lib/util"; +import * as React from "react"; +import { IProfileState } from "reducers/profilesReducer"; +import i18next from "i18next"; +import * as css from "./ProposalSummary.scss"; + +interface IExternalProps { + beneficiaryProfile?: IProfileState; + detailView?: boolean; + daoState: IDAOState; + proposalState: IJoinProposalState; + transactionModal?: boolean; +} + +interface IState { + network: string; +} + +type IProps = IExternalProps; + +export default class ProposalSummary extends React.Component { + + constructor(props: IProps) { + super(props); + this.state = { + network: "", + }; + + } + + public async componentDidMount(): Promise { + this.setState({ network: (await getNetworkName()).toLowerCase() }); + } + + public render(): RenderOutput { + const { proposalState, detailView, transactionModal } = this.props; + const proposalSummaryClass = classNames({ + [css.detailView]: detailView, + [css.transactionModal]: transactionModal, + [css.proposalSummary]: true, + [css.withDetails]: true, + }); + + return ( +
+
+ + {proposalState.name} + + {detailView && +
+ + + + + + + + +
+ {i18next.t("Address")} + + + + {proposalState.proposedMember}
{i18next.t("Funding")}{fromWei(proposalState.funding)}
{i18next.t("Reputation Minted")}{fromWei(proposalState.reputationMinted)}
{i18next.t("Minimum DAO bounty")}{fromWei(proposalState.genesisProtocolParams.minimumDaoBounty)}
+
+ } +
+
+ ); + } +} diff --git a/src/lib/pluginUtils.ts b/src/lib/pluginUtils.ts index 17812e738..d94ce2856 100644 --- a/src/lib/pluginUtils.ts +++ b/src/lib/pluginUtils.ts @@ -42,6 +42,8 @@ export const REQUIRED_PLUGIN_PERMISSIONS: any = { "UpgradeScheme": PluginPermissions.IsRegistered | PluginPermissions.CanRegisterPlugins | PluginPermissions.CanUpgradeController, "VestingScheme": PluginPermissions.IsRegistered, "VoteInOrganizationScheme": PluginPermissions.IsRegistered | PluginPermissions.CanCallDelegateCall, + "Join": PluginPermissions.IsRegistered, + "FundingRequest": PluginPermissions.IsRegistered, }; /** plugins that we know how to interpret */ @@ -53,6 +55,8 @@ export const PLUGIN_NAMES = { SchemeFactory: "Plugin Manager", Competition: "Competition", ContributionRewardExt: "Contribution Reward Ext", + Join: "Join", + FundingRequest: "Funding Request", }; /**