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

Simplified issue filtering #1973

Open
wants to merge 2 commits into
base: decentralized-project-integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ jobs:
install: npm run bootstrap
after_success: npm run coveralls

- stage: test
script: travis_wait 60 npm run coverage -- --scope=@autarklabs/templates-open-enterprise
name: Template tests and coverage report
install: npm run bootstrap
after_success: npm run coveralls

- stage: deploy
before_install:
- mkdir $HOME/.aragon
Expand Down
2 changes: 2 additions & 0 deletions apps/dot-voting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"frontend": "npm run sync-assets && parcel app/index.html --port 4444",
"ganache-cli:test": "sh ../../node_modules/@aragon/test-helpers/ganache-cli.sh",
"lint": "solium --dir ./contracts",
"postcoverage": " sed -i 's+./IForwarder.sol+@aragon/os/contracts/common/IForwarder.sol+g' ../shared/test-helpers/contracts/common/ADynamicForwarder.sol",
"precommit": "lint-staged",
"precoverage": "sed -i 's+@aragon/os/contracts/common/IForwarder.sol+./IForwarder.sol+g' ../shared/test-helpers/contracts/common/ADynamicForwarder.sol",
"prepublishOnly": "truffle compile",
"publish:cd": "../../shared/deployments/check-publish.sh",
"publish:http": "npm run build:script && yes | aragon apm publish major --files dist --http localhost:4444 --http-served-from ./dist --propagate-content false --skip-confirmation true",
Expand Down
107 changes: 23 additions & 84 deletions apps/projects/app/components/Content/ProjectDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ import PropTypes from 'prop-types'
import React, { useState, useCallback } from 'react'
import styled from 'styled-components'
import { useQuery } from '@apollo/react-hooks'
import { gql } from 'apollo-boost'

import { Button, GU, Header, IconPlus, Text } from '@aragon/ui'
import { compareAsc, compareDesc } from 'date-fns'

import useShapedIssue from '../../hooks/useShapedIssue'
import { useBountyIssues } from '../../context/BountyIssues'
import { issueAttributes, SEARCH_ISSUES } from '../../utils/gql-queries.js'
import { SEARCH_ISSUES } from '../../utils/gql-queries.js'
import { Issue } from '../Card'
import { FilterBar, LoadingAnimation } from '../Shared'
import { usePanelManagement } from '../Panel'
Expand Down Expand Up @@ -59,11 +56,13 @@ class ProjectDetail extends React.PureComponent {
}

updateQuery = (filters, filtersData) => {
const queryFilters = {
labels: Object.keys(filters.labels).map(labelId => filtersData.labels[labelId].name),
search: '',
if (Object.keys(filters.labels).length > 0) {
this.props.setQuery({
labels: Object.keys(filters.labels).map(id => 'label:' + filtersData.labels[id].name).join(' ')
})
} else {
this.props.setQuery({ labels: '' })
}
this.props.setQuery(queryFilters)
}


Expand Down Expand Up @@ -200,14 +199,7 @@ class ProjectDetail extends React.PureComponent {

if (error) return this.queryError(error, refetch)

let dataSource
let pageInfo
if (data) {
pageInfo = data.repository ? data.repository.issues.pageInfo : data.search.pageInfo
dataSource = data.repository ? data.repository.issues.nodes : data.search.issues
}

const allIssues = dataSource ? dataSource.map(this.props.shapeIssue) : []
const allIssues = data ? data.search.issues.map(this.props.shapeIssue) : []
const filteredIssues = this.applyFilters(allIssues)

return (
Expand Down Expand Up @@ -240,31 +232,18 @@ class ProjectDetail extends React.PureComponent {
</Text>
<LoadingAnimation />
</div>
) : data && pageInfo.hasNextPage && (
) : data && data.search.pageInfo.hasNextPage && (
<Button
style={{ margin: '12px 0 30px 0' }}
mode="secondary"
onClick={() => {
fetchMore({
variables: { after: pageInfo.endCursor },
variables: { after: data.search.pageInfo.endCursor },
updateQuery: (prev, { fetchMoreResult }) => {

if (!fetchMoreResult) return prev

return data.repository ? {
...fetchMoreResult,
repository: {
...fetchMoreResult.repository,
issues: {
...fetchMoreResult.repository.issues,
nodes: [
...prev.repository.issues.nodes,
...fetchMoreResult.repository.issues.nodes,
]
},
}
} : {

return {
...fetchMoreResult,
search: {
...fetchMoreResult.search,
Expand Down Expand Up @@ -318,58 +297,18 @@ const ProjectDetailWrap = ({ repo, ...props }) => {
requestPath('/issues/' + id)
})

const SEARCH_ISSUES_2 = gql`
query SearchIssues($after: String, $owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
issues(
first: 25,
after: $after,
filterBy: {
${query.labels.length ? 'labels: [' + query.labels.map(l => `"${l}"`) + '],' : ''}
states: [OPEN]
},
orderBy: {
field: UPDATED_AT, direction: ${query.sort === 'updated-desc' ? 'DESC' : 'ASC'}
}) {
totalCount
pageInfo {
startCursor
hasNextPage
endCursor
}

nodes {
${ issueAttributes }
}
}
}
}
`

// text filter takes precedence
const graphqlQuery = query.search ?
useQuery(SEARCH_ISSUES, {
notifyOnNetworkStatusChange: true,
onError: console.error,
variables: {
after: query.after,
query: 'is:issue state:open ' +
`repo:${query.repo} ` +
`sort:${query.sort} ` +
`${query.search}`,
},
})
:
useQuery(SEARCH_ISSUES_2, {
notifyOnNetworkStatusChange: true,
onError: console.error,
variables: {
after: query.after,
owner: query.owner,
name: query.name,
labels: query.labels,
},
})
const graphqlQuery = useQuery(SEARCH_ISSUES, {
notifyOnNetworkStatusChange: true,
onError: console.error,
variables: {
after: query.after,
query: 'is:issue state:open ' +
`repo:${query.repo} ` +
`sort:${query.sort} ` +
`${query.search} ` +
`${query.labels}`,
},
})

const [ sortBy, setSortByRaw ] = useState(Object.keys(sortOptions)[0])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import "@aragon/os/contracts/lib/math/SafeMath.sol";
import "@aragon/os/contracts/lib/math/SafeMath64.sol";

// TODO: Use @aragon/os/contracts/ version when it gets merged
import "../evmscript/ScriptHelpers.sol";
import "../evmscript/DynamicScriptHelpers.sol";
// TODO: Research why using the @aragon/os version breaks coverage
import "./IForwarder.sol";
import "@aragon/os/contracts/common/IForwarder.sol";

/**
* @title ADynamicForwarder App
Expand All @@ -22,7 +22,7 @@ import "./IForwarder.sol";


contract ADynamicForwarder is IForwarder {
using ScriptHelpers for bytes;
using DynamicScriptHelpers for bytes;
using SafeMath for uint256;
using SafeMath64 for uint64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pragma solidity ^0.4.18;


library ScriptHelpers {
library DynamicScriptHelpers {
// To test with JS and compare with actual encoder. Maintaining for reference.
// t = function() { return IEVMScriptExecutor.at('0x4bcdd59d6c77774ee7317fc1095f69ec84421e49').contract.execScript.getData(...[].slice.call(arguments)).slice(10).match(/.{1,64}/g) }
// run = function() { return ScriptHelpers.new().then(sh => { sh.abiEncode.call(...[].slice.call(arguments)).then(a => console.log(a.slice(2).match(/.{1,64}/g)) ) }) }
Expand Down Expand Up @@ -135,4 +135,4 @@ library ScriptHelpers {
mstore(dest, or(destpart, srcpart))
}
}
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"clean:build": "npm run clean -- $npm_package_build_exclude_pattern",
"clean": "git clean -fXd",
"coverage": "lerna run coverage --no-bail",
"coveralls": "cat apps/*/coverage/lcov.info | coveralls",
"coveralls": "cat */*/coverage/lcov.info | coveralls",
"cypress:open": "cypress open",
"cypress:run": "wait-on http://localhost:3000/#/dev-dao-0 && cypress run --browser chrome",
"cypress": "CYPRESS=true apps/shared/test-helpers/ganache-cli.sh",
Expand All @@ -55,7 +55,7 @@
"frontend:rewards": "cd apps/rewards && npm run frontend",
"lint:address": "cd apps/address-book && npm run lint",
"lint:allocations": "cd apps/allocations && npm run lint",
"lint:contracts": "lerna run --scope='@tps/apps-*' lint --stream",
"lint:contracts": "lerna run --scope='@tps/apps-*' --scope='@autarklabs/*' lint --stream",
"lint:dot": "cd apps/dot-voting && npm run lint",
"lint:fix": "lerna exec --scope=@tps/apps-* --stream -- eslint app --fix",
"lint:projects": "cd apps/projects && npm run lint",
Expand Down Expand Up @@ -88,7 +88,7 @@
"test:projects": "cd apps/projects && npm test",
"test:rewards": "cd apps/rewards && npm test",
"test:tps": "lerna run --scope=@tps/kits-planning-suite --stream test",
"test": "lerna run test --no-bail --concurrency=1"
"test": "lerna run test --scope=@tps/apps-* --scope=@autarklabs/* --no-bail --concurrency=1"
},
"dependencies": {
"ipfs-http-client": "29.1.0",
Expand Down
3 changes: 2 additions & 1 deletion shared/integrations/StandardBounties/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"compile": "truffle compile",
"test": "truffle test",
"cvg": "./node_modules/.bin/solidity-coverage",
"migrate": "node_modules/.bin/truffle migrate | grep \"^0x[[:alnum:]]\\{40\\}\""
"migrate": "node_modules/.bin/truffle migrate | grep \"^0x[[:alnum:]]\\{40\\}\"",
"migrate:coverage": "node_modules/.bin/truffle migrate --network coverage | grep \"^0x[[:alnum:]]\\{40\\}\""
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion shared/integrations/StandardBounties/truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
host: 'localhost',
port: 8545,
network_id: '*',
gas: 8.2e6,
gas: 8e6,
gasPrice: 2000000000, // same as latest on Mainnet https://ethstats.net/
},
coverage: {
Expand Down
61 changes: 61 additions & 0 deletions templates/dev/contracts/BaseCache.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
pragma solidity 0.4.24;

import "@aragon/templates-shared/contracts/BaseTemplate.sol";


contract BaseCache is BaseTemplate {
// string constant private ERROR_MISSING_BASE_CACHE = "TEMPLATE_MISSING_BASE_CACHE";

struct InstalledBase {
ACL acl;
Kernel dao;
Finance finance;
TokenManager tokenManager;
Vault vault;
Voting voting;
}

mapping (address => InstalledBase) internal baseCache;

constructor(address[5] _deployedSetupContracts)
BaseTemplate(
DAOFactory(_deployedSetupContracts[0]),
ENS(_deployedSetupContracts[1]),
MiniMeTokenFactory(_deployedSetupContracts[2]),
IFIFSResolvingRegistrar(_deployedSetupContracts[3])
) {}

function _cacheBase(
ACL _acl,
Kernel _dao,
Finance _finance,
TokenManager _tokenManager,
Vault _vault,
Voting _voting,
address _owner
) internal
{
InstalledBase storage baseInstance = baseCache[_owner];
baseInstance.acl = _acl;
baseInstance.dao = _dao;
baseInstance.finance = _finance;
baseInstance.tokenManager = _tokenManager;
baseInstance.vault = _vault;
baseInstance.voting = _voting;
}

function _popBaseCache(address _owner) internal returns (ACL, Kernel, Finance, TokenManager, Vault, Voting) {
// require(baseCache[_owner] != address(0), ERROR_MISSING_BASE_CACHE);

InstalledBase storage baseInstance = baseCache[_owner];
ACL acl = baseInstance.acl;
Kernel dao = baseInstance.dao;
Finance finance = baseInstance.finance;
TokenManager tokenManager = baseInstance.tokenManager;
Vault vault = baseInstance.vault;
Voting voting = baseInstance.voting;

delete baseCache[_owner];
return (acl, dao, finance, tokenManager, vault, voting);
}
}
Loading