Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This PR adds Project creation functionality #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# ABI files
/src/contracts

# dependencies
/node_modules
/.pnp
Expand All @@ -23,3 +26,5 @@ yarn-debug.log*
debug.log*
yarn-error.log*
package-lock.json


26 changes: 14 additions & 12 deletions contracts/truffle-config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
const path = require("path");
/* eslint-disable */
const path = require('path')

module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "../src/contracts"),
contracts_build_directory: path.join(__dirname, '../src/contracts'),
networks: {
development: {
host: '127.0.0.1',
port: 8545,
gas: 6721975, // <-- Use this high gas value
gasPrice: 1000000000,
network_id: '*' // Match any network id
}
network_id: '*', // Match any network id
},
},
// Configure your compilers
compilers: {
solc: {
version: "0.6.6", // Fetch exact version from solc-bin (default: truffle's version)
version: '0.6.6', // Fetch exact version from solc-bin (default: truffle's version)
docker: false, // Use "0.5.1" you've installed locally with docker (default: false)
settings: { // See the solidity docs for advice about optimization and evmVersion
settings: {
// See the solidity docs for advice about optimization and evmVersion
optimizer: {
enabled: true,
runs: 200
runs: 200,
},
evmVersion: 'constantinople'
}
}
}
};
evmVersion: 'constantinople',
},
},
},
}
20 changes: 20 additions & 0 deletions debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,23 @@
[0527/213826.031:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0528/151733.993:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0528/151734.019:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0529/140617.768:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0529/140617.771:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0601/221346.435:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0601/221346.456:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/164611.913:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/164611.915:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/190943.213:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/190943.215:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/192715.867:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/192715.870:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0603/212048.026:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0603/212048.028:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0604/185505.121:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0604/185505.138:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0605/101632.670:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0605/101632.672:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0605/105518.019:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0605/105518.043:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0605/114652.318:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0605/114652.321:ERROR:crash_report_database_win.cc(469)] failed to stat report
28 changes: 14 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import theme from './theme-court'
import MainView from './components/MainView'
import ErrorPage from './ErrorPage'

import Dashboard from './components/Dashboard/Dashboard'
import Dashboard from './components/Profile/Dashboard'
abhinav-anshul marked this conversation as resolved.
Show resolved Hide resolved
/* eslint-disable prettier/prettier */

import Tasks from './components/Tasks/Tasks'
import Sample from './components/Sample/Sample'
import Disputes from './components/Disputes/Disputes'
import Disputes from './components/Dashboard/Disputes'
abhinav-anshul marked this conversation as resolved.
Show resolved Hide resolved
import { WalletProvider } from './providers/Wallet'
import { ActivityProvider } from './components/Activity/ActivityProvider'

Expand All @@ -23,18 +23,18 @@ function App() {
<WalletProvider>
<BrowserRouter>
<ActivityProvider>
<Main layout={false} theme={theme}>
<MainView>
{/* <Redirect from='/' to='/dashboard' /> */}
<Switch>
<Route exact path='/profile' component={Dashboard} />
<Route exact path='/leaderboard' component={Tasks} />
<Route exact path='/dashboard' component={Disputes} />
<Route exact path='/sample' component={Sample} />
<Route component={ErrorPage} />
</Switch>
</MainView>
</Main>
<Main layout={false} theme={theme}>
<MainView>
{/* <Redirect from='/' to='/dashboard' /> */}
<Switch>
<Route exact path='/profile' component={Dashboard} />
<Route exact path='/leaderboard' component={Tasks} />
<Route exact path='/dashboard' component={Disputes} />
<Route exact path='/sample' component={Sample} />
<Route component={ErrorPage} />
</Switch>
</MainView>
</Main>
</ActivityProvider>
</BrowserRouter>
</WalletProvider>
Expand Down
8 changes: 8 additions & 0 deletions src/components/Activity/activity-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ const ACTIVITY_TYPES = new Map(
`,
}
},
newProject({ name, budget }) {
return {
icon: execute,
title: 'Added Project',
description: ` Created Project ${name} , ${budget}
`,
}
},
transaction({ transactionHash }) {
return {
title: 'Transaction',
Expand Down
132 changes: 132 additions & 0 deletions src/components/Dashboard/Import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* eslint-disable */
import React, { useState, useRef } from 'react'
import { SidePanel, Button, DropDown, TextInput, LoadingRing } from '@aragon/ui'
import { Octokit } from '@octokit/rest'
import { useWallet } from 'use-wallet'
import { useProjectCreationActions } from '../../hooks/useProjectCreation'

function Import() {
const wallet = useWallet()

const [USERNAME, SETUSERNAME] = useState(null)

const [opened, setOpened] = useState(false)

const [list, setList] = useState([])

// const [loading, setLoading] = useState(false)

const { create } = useProjectCreationActions()

const TOKEN = localStorage.getItem('ACCESS TOKEN')

const octokit = new Octokit({
auth: TOKEN,
})

const [publicRepos, setPublicRepos] = useState(0)
async function userInfo() {
const { data } = await octokit.request('/user')
let num = data.public_repos
setPublicRepos(num - 1)
return data
}

async function listUserRepos() {
setOpened(true)
let repoList = []
const user = await userInfo()
for (let page = 1; page <= Math.ceil(user.public_repos / 100); page++) {
const { data } = await octokit.repos.listForAuthenticatedUser({
per_page: 100,
page: page,
})
let repoIndex = 0
while (repoIndex < data.length) {
repoList.push({name: data[repoIndex].name, id: data[repoIndex].id})
repoIndex++
}
setList([...repoList])
}

return repoList
}

function handleClose() {
setOpened(false)
}

const [selected, setSelected] = useState(-1)

function handleOnChange(index, items) {
setSelected(index)
}

const inputBudget = useRef(null)
const inputName = useRef(null)
const inputDropdown = useRef(null)

async function handleProjectCreationn() {
let nameInput = inputName.current.value
let budgetInput = inputBudget.current.value
let dropdownInput = list[selected].id
await create(dropdownInput.toString(), nameInput, budgetInput)
}

return (
<>
{wallet.account !== null &&
localStorage.getItem('ACCESS TOKEN') !== null ? (
<Button mode='strong' onClick={listUserRepos}>
Import Project
</Button>
) : null}

<SidePanel onClose={handleClose} title='Repository' opened={opened}>
{list.length === 0 ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '4rem',
}}
>
<LoadingRing mode='half-circle' />
</div>
) : (
<>
<DropDown
selected={selected}
onChange={handleOnChange}
items={[...list.map(i=>i.name)]}
ref={inputDropdown}
style={{
marginTop: '4rem',
}}
/>
{console.log(selected)}
<TextInput
ref={inputName}
style={{ marginTop: '2rem' }}
placeholder='Provide a Name'
/>
<TextInput
ref={inputBudget}
style={{ marginTop: '2rem' }}
placeholder='Budget'
/>
<Button
onClick={handleProjectCreationn}
style={{ marginTop: '4rem' }}
mode='positive'
>
Import Project
</Button>
</>
)}
</SidePanel>
</>
)
}

export default Import
10 changes: 10 additions & 0 deletions src/components/Dashboard/ProjectCreation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
import { useProjectCreationActions } from '../../hooks/useProjectCreation'

export function handleProjectCreation() {
// useProjectCreationActions(id, name, budget)
}

/////

/////
96 changes: 0 additions & 96 deletions src/components/Disputes/Import.js

This file was deleted.

Loading