Skip to content
Closed
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
968d7f6
Merge pull request #1468 from daostack/dev
jellegerbrandy Mar 2, 2020
c2af3da
Merge branch 'master' into release_20200303
dkent600 Mar 3, 2020
3019382
Merge pull request #1475 from daostack/release_20200303
dkent600 Mar 5, 2020
2a8580d
migrating latest signal features commits
mrrobot16 Feb 3, 2020
e44df7e
Added DAO Header component in this branch
mrrobot16 Mar 4, 2020
8436d1f
Getting signal data and displaying it in the UI
mrrobot16 Mar 5, 2020
ee3ac8a
add action to save ipfs data
shekhar-shubhendu Mar 10, 2020
774ed7c
update signal scheme url
shekhar-shubhendu Mar 10, 2020
12c1b58
update Signals.json
shekhar-shubhendu Mar 10, 2020
867e99e
update logic to save/update/delete signals data
shekhar-shubhendu Mar 10, 2020
f67a8c8
linting and small fixes. remove hardcoded address
shekhar-shubhendu Mar 10, 2020
25a18c5
in history, open proposal in new tab on ctrl-click (#1474)
dkent600 Mar 5, 2020
243108e
show DAO total rep in sidebar (#1473)
dkent600 Mar 5, 2020
59cef63
In create proposal form tab directly from title to description
tibetsprague Mar 4, 2020
8984873
Lint fix
tibetsprague Mar 4, 2020
805a2b3
Require NETWORK env var on Heroku and default to rinkeby
tibetsprague Mar 6, 2020
67bed9a
Close modals by pressing ESC
tibetsprague Feb 26, 2020
dd12533
Fix styling of submit button on profile page when submitting
tibetsprague Feb 26, 2020
ad3e324
Make sure tooltip on redemptions button doesn't cover the button
tibetsprague Feb 26, 2020
dc8e759
Create ModalPopup component to bundle common modal stuff
tibetsprague Mar 3, 2020
e57fb22
Fix paths
tibetsprague Mar 4, 2020
09c5527
Enforce required permissions when adding/editing known Schemes
tibetsprague Mar 6, 2020
9d7afae
migrating latest signal features commits
mrrobot16 Feb 3, 2020
10c3f3c
Added DAO Header component in this branch
mrrobot16 Mar 4, 2020
49ec178
Getting signal data and displaying it in the UI
mrrobot16 Mar 5, 2020
a3c0ba7
add action to save ipfs data
shekhar-shubhendu Mar 10, 2020
77cf7df
update signal scheme url
shekhar-shubhendu Mar 10, 2020
26617c9
update Signals.json
shekhar-shubhendu Mar 10, 2020
23a99a7
update logic to save/update/delete signals data
shekhar-shubhendu Mar 10, 2020
1c955f3
linting and small fixes. remove hardcoded address
shekhar-shubhendu Mar 10, 2020
5249869
fix css
shekhar-shubhendu Mar 11, 2020
50476e0
update css, use var in tsx instead
shekhar-shubhendu Mar 11, 2020
400590b
Merge branch 'dev' into feat/signal-scheme
mrrobot16 Mar 12, 2020
6e9a3e9
eslint fixes
mrrobot16 Mar 17, 2020
8b511b7
Added responsive to this branch
mrrobot16 Apr 12, 2020
6f618ac
Latest responsive code
mrrobot16 Apr 29, 2020
f13ca00
Added dynamic holdings
mrrobot16 May 3, 2020
a65f320
deleted unneeded css code
mrrobot16 May 16, 2020
33bb933
Background image fix -back in history
mrrobot16 May 17, 2020
0f73aaf
Background image fix -back in history
mrrobot16 May 17, 2020
33869a8
Merge branch 'feat/signal-scheme' of https://github.com/apeunit/alche…
mrrobot16 May 19, 2020
6727857
Revert "Background image fix -back in history"
mrrobot16 May 19, 2020
8763f66
eslint fixes
mrrobot16 May 19, 2020
88645d8
Added subgraph endpoints json
mrrobot16 May 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/actions/arcActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Address, DAO, IProposalCreateOptions, IProposalOutcome, ITransactionState, ITransactionUpdate, ReputationFromTokenScheme, Scheme } from "@daostack/client";
import { Address, DAO, IProposalCreateOptions, IProposalOutcome, ITransactionState,
ITransactionUpdate, ReputationFromTokenScheme, Scheme } from "@daostack/client";
import { IAsyncAction } from "actions/async";
import { getArc } from "arc";
import { toWei } from "lib/util";
Expand Down Expand Up @@ -38,11 +39,28 @@ export const operationNotifierObserver = (dispatch: Redux.Dispatch<any, any>, tx
];
};

export function saveSignalDescription(signalDescription: any): ThunkAction<any, IRootState, null> {
return async (_getState: () => IRootState) => {
const arc = getArc();
let ipfsDataToSave: object = {};
if (signalDescription.key && signalDescription.value !== undefined) {
if (!arc.ipfsProvider) {
throw Error("No ipfsProvider set on Arc instance - cannot save data on IPFS");
}
ipfsDataToSave = {
key: signalDescription.key,
value: signalDescription.value,
};
}
return await arc.ipfs.addAndPinString(Buffer.from(JSON.stringify(ipfsDataToSave)));
};
}

export function createProposal(proposalOptions: IProposalCreateOptions): ThunkAction<any, IRootState, null> {
return async (dispatch: Redux.Dispatch<any, any>, _getState: () => IRootState) => {
try {
const arc = getArc();

const dao = new DAO(proposalOptions.dao, arc);

const observer = operationNotifierObserver(dispatch, "Create proposal");
Expand Down
5 changes: 3 additions & 2 deletions src/components/Account/AccountImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ interface IProps {
accountAddress: string;
profile?: IProfileState;
width: number;
style?: any;
}

export default class AccountImage extends React.Component<IProps, null> {

public render(): RenderOutput {
const { accountAddress, profile, width } = this.props;
const { accountAddress, profile, width, style } = this.props;

let url;
if (profile && profile.image && profile.image[0] && profile.image[0].contentUrl) {
Expand All @@ -25,6 +26,6 @@ export default class AccountImage extends React.Component<IProps, null> {
});
}

return (<img src={url} className={css.accountImage} width={width} />);
return (<img src={url} className={css.accountImage} width={width} style={ style ? style : {}}/>);
}
}
71 changes: 71 additions & 0 deletions src/components/Dao/DaoHeader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.headerWrap {
background: white;
margin: 8rem 2.5% 40px 0;
padding: 25px;
position: relative;
border-radius: 20px 20px 0 0;
}

.reputationHolders {
display: block;
position: absolute;
font-size: 10px;
font-weight: normal;
color: $gray-1;
white-space: nowrap;
}

.daoName {
font-size: 24px;
color: #689bd6;
}

.daoInfo {
margin-left: 15%;
top: 15px;
position: absolute;
}

.daoDescription {
font-family: $body-font;
color: $black;
font-weight: 500;
font-size: 13px;
width: 75%;
}

.circularSquare {
border-radius: 50%;
border-color: white;
border-style: solid
}

.daoImg {
// margin-left: 15%
top: -40px;
position: absolute
}

.holdings {
margin-left: 85%;
padding: 15px;
border: 1px solid #dbd7d7;
border-radius: 7px;
margin-bottom: 15px
}

.holdings .holdingsAmount {
margin-top: 5px;
color: #565a5d;
font-size: 12px
}

.holdings .holdingsAmount .holdingsName {
float: right;
margin-right: 25px
}

.daoHeader {
position: absolute;
top: 50px;
}
101 changes: 101 additions & 0 deletions src/components/Dao/DaoHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import * as React from "react";
import { IDAOState, Scheme } from "@daostack/client";

import withSubscription, { ISubscriptionProps } from "components/Shared/withSubscription";
import AccountImage from "components/Account/AccountImage";
import * as css from "./DaoHeader.scss";

const styles = {
circularSquare: {
borderRadius: "50%",
borderColor: "white",
borderStyle: "solid",
},
};

interface Signal {
id: string;
data: any | string;
}

interface IExternalProps {
daoState: IDAOState;
signal?: Signal | any;
}

type IProps = IExternalProps & ISubscriptionProps<[Scheme[], Signal | any]>;

class DaoHeaderComponent extends React.Component<IProps, any> {
render() {
const { daoState, signal } = this.props;
const { name, memberCount, address } = daoState;
const data = {
daoImg: "/assets/images/generic-user-avatar.png",
reputationHolders: memberCount,
holdings: [
{ name: "GEN", amount: 0.24653 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are these numbers coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry super late response. I had to take time off due to personal issues. I am back now.

What I am currently working on is on making it responsive and render "dao members count" and "dao holdings".

Another todo is when we have a signal scheme proposal we want to be able to show in the proposal summary what off chain data are we modifying so that users know what to expect to change if a signal scheme proposal is passed.

{ name: "ETH", amount: 16.01 },
{ name: "DAI", amount: 148.19 },
],
description: `
${name} is an independent, global community of people working together to build and promote Decentralized Autonomous Organizations (DAOs).
It’s the perfect place to get involved with DAOstack and get your feet wet in a real-life DAO.
`,
};

return (
<div className={css.headerWrap}>
<div className={css.daoImg}>
{/* Logo will go here instead of AccountImage this is just a placeholder */}
<AccountImage
accountAddress={address}
width={106}
style={styles.circularSquare}
/>
</div>
<div className={css.daoInfo}>
<b className={css.daoName}>
{ signal.name ? signal.name : name }
</b>
<b className={css.reputationHolders}>
{ data.reputationHolders } Reputation Holders
</b>
</div>

<div className={css.holdings}>
Holdings
{
data.holdings.map((holding, index) => {
return (
<div key={index} className={css.holdingsAmount}>
{ holding.amount }
<div className={css.holdingsName}>
{ holding.name }
</div>
</div>
);
})
}
</div>

<h2 className={css.daoHeader}>
This is the { name } Header
<div className={css.daoDescription}>
{ data.description }
</div>
</h2>
</div>
);
}
}

const DaoHeader = withSubscription({
wrappedComponent: DaoHeaderComponent,
checkForUpdate: [],
createObservable: (props: IExternalProps) => {
const dao = props.daoState.dao;
return dao.schemes({}, { fetchAllData: true, subscribe: true });
},
});

export default DaoHeader;
10 changes: 10 additions & 0 deletions src/components/Dao/DaoSchemesPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
padding-top: 30px;
}

.daoHeaderBackground {
// @TODO Image is repeating, check this later when using real image
// background-image: url(/assets/images/bg-test.jpeg);
width: 115%;
position: absolute;
display: flex;
height: 30%;
top:0;
right: 0;
}

@media only screen and (max-width: 425px) {
.wrapper h1 {
Expand Down
43 changes: 39 additions & 4 deletions src/components/Dao/DaoSchemesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { CSSTransition, TransitionGroup } from "react-transition-group";
import * as css from "./DaoSchemesPage.scss";
import ProposalSchemeCard from "./ProposalSchemeCard";
import SimpleSchemeCard from "./SimpleSchemeCard";
import DAOHeader from "./DaoHeader";
import gql from "graphql-tag";
import { getArc } from "arc";
import { combineLatest } from "rxjs";

const Fade = ({ children, ...props }: any) => (
<CSSTransition
Expand All @@ -29,11 +33,23 @@ const Fade = ({ children, ...props }: any) => (
</CSSTransition>
);

const DAOHeaderBackground = (props: any) => (
<div
className={css.daoHeaderBackground}
style={{ backgroundImage: `url(${props.backgroundImage})` }}
></div>
);

type IExternalProps = {
daoState: IDAOState;
} & RouteComponentProps<any>;

type IProps = IExternalProps & ISubscriptionProps<Scheme[]>;
interface Signal {
id: string;
data: any | string;
};

type IProps = IExternalProps & ISubscriptionProps<[Scheme[], Signal[] | any]>;

class DaoSchemesPage extends React.Component<IProps, null> {

Expand All @@ -48,7 +64,11 @@ class DaoSchemesPage extends React.Component<IProps, null> {
public render() {
const { data } = this.props;
const dao = this.props.daoState;
const allSchemes = data;
const [allSchemes, signalsData] = data;
const { signals } = signalsData.data;
const signal = signals.length > 0 ? signals[0] : null;
const daoHeaderBackground = signal ? JSON.parse(signal.data).Header : null;
const backgroundImage = daoHeaderBackground ? daoHeaderBackground : null;

const contributionReward = allSchemes.filter((scheme: Scheme) => scheme.staticState.name === "ContributionReward");
const knownSchemes = allSchemes.filter((scheme: Scheme) => scheme.staticState.name !== "ContributionReward" && KNOWN_SCHEME_NAMES.indexOf(scheme.staticState.name) >= 0);
Expand Down Expand Up @@ -78,8 +98,9 @@ class DaoSchemesPage extends React.Component<IProps, null> {

return (
<div className={css.wrapper}>
{ backgroundImage && <DAOHeaderBackground backgroundImage={backgroundImage} /> }
<BreadcrumbsItem to={"/dao/" + dao.address}>{dao.name}</BreadcrumbsItem>

{ signal && <DAOHeader {...this.props} signal={signal} /> }
<Sticky enabled top={50} innerZ={10000}>
<h1>All Plugins</h1>
</Sticky>
Expand All @@ -104,7 +125,21 @@ export default withSubscription({
errorComponent: (props) => <span>{props.error.message}</span>,
checkForUpdate: [],
createObservable: (props: IExternalProps) => {
const arc = getArc();
const dao = props.daoState.dao;
return dao.schemes({}, { fetchAllData: true, subscribe: true });
const schemes = dao.schemes({}, { fetchAllData: true, subscribe: true });
// const DAOAddress = props.daoState.address;
// Currently only one dao has signal data
const DAOAddress = dao.id;
const signalQuery = gql`
{
signals(where: { id: "${DAOAddress}" } ) {
id
data
}
}
`;
const signalSchemeData = arc.getObservable(signalQuery);
return combineLatest(schemes, signalSchemeData);
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ const mapStateToProps = (state: IRootState, ownProps: IStateProps) => {

interface IDispatchProps {
createProposal: typeof arcActions.createProposal;
saveSignalData: typeof arcActions.saveSignalDescription;
showNotification: typeof showNotification;
}

const mapDispatchToProps = {
createProposal: arcActions.createProposal,
saveSignalData: arcActions.saveSignalDescription,
showNotification,
};

Expand Down Expand Up @@ -98,7 +100,6 @@ class CreateKnownSchemeProposal extends React.Component<IProps, IState> {
private handleSubmit = async (values: IFormValues, { setSubmitting }: any ): Promise<void> => {

if (!await enableWalletProvider({ showNotification: this.props.showNotification })) { return; }

const currentAction = this.state.currentAction;
const callValues = [];

Expand All @@ -107,24 +108,35 @@ class CreateKnownSchemeProposal extends React.Component<IProps, IState> {
values[field.name] = callValue;
callValues.push(callValue);
}

let callData = "";
try {
callData = this.props.genericSchemeInfo.encodeABI(currentAction, callValues);

if(values.key) {
const ipfsValue = {
key: values.key,
value: "",
};
if(currentAction.id !== "deleteSignalType") {
ipfsValue.value = values.value;
currentAction.abi.inputs.pop();
}
const ipfsData = await this.props.saveSignalData(ipfsValue);
callData = this.props.genericSchemeInfo.encodeABI(currentAction, [ipfsData]);
} else {
callData = this.props.genericSchemeInfo.encodeABI(currentAction, callValues);
}
} catch (err) {
showNotification(NotificationStatus.Failure, err.message);
setSubmitting(false);
return;
}
setSubmitting(false);

let ethValue = new BN(0);

if (this.props.genericSchemeInfo.specs.name === "Standard Bounties") {
const calcBountEth = await this.getBountyEth(values);
ethValue = ethValue.add(calcBountEth);
}

const proposalValues = {
...values,
callData,
Expand Down
Loading