-
Notifications
You must be signed in to change notification settings - Fork 49
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
Feature/dao-action-page DAO-283 #478
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
60f82a4
added basic daoSideCard
Fabricevladimir a6cf312
modified sidecard, added actionlinks
Fabricevladimir 0cd86d6
Action Header added
sepehr2github a865227
searchbox and dropdown menu added to action page
sepehr2github 4e64366
Action card added
sepehr2github 30efa8f
Added basic calls for actions
Fabricevladimir fac256d
added help component on for settings page
Fabricevladimir 118b22d
add load more button
sepehr2github 1220c39
fix conflict
sepehr2github cbe3112
actions list logic added & actions filter added
sepehr2github 56e3f54
search login implemented
sepehr2github a4abc9a
Human readable date format added & load more button logic added
sepehr2github 5236b9a
fix action cards title overlaping
sepehr2github 9486d57
fix single action card bugs & add no action available message
sepehr2github 59012c5
Merge branch 'refactoring_finance' into feature/dao-action-page
sepehr2github ada0537
fix prettier error for setting route
sepehr2github 525668d
change filter function & add no-available function & change limit to 100
sepehr2github dc80e25
add rejected status to dropdown menu and use same array for selected …
sepehr2github 8d260e3
fix conflicts
sepehr2github dfb90f4
Merge branch 'refactoring_finance' into feature/dao-action-page
sepehr2github File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 100, | ||
"tabWidth": 2 | ||
"tabWidth": 2, | ||
"endOfLine":"auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
packages/govern-console/src/containers/DAO/DaoActionPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
import React, { useState } from 'react'; | ||
import { DropDown, Button, GU, SearchInput, IconDown, Grid, GridItem, useLayout } from '@aragon/ui'; | ||
import styled from 'styled-components'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
import DaoActionCard from './components/DaoActionCard/DaoActionCard'; | ||
import NoActionAvailable from './components/NoActionAvailable/NoActionAvailable'; | ||
|
||
type actionsType = { | ||
__typename?: string; | ||
id: string; | ||
state: string; | ||
createdAt: string; | ||
payload: { | ||
__typename?: string; | ||
id: string; | ||
executionTime: string; | ||
title: string; | ||
}; | ||
}[]; | ||
|
||
type props = { | ||
fetchMore: () => Promise<void>; | ||
actions: actionsType; | ||
isMore: boolean; | ||
identifier: string; | ||
}; | ||
|
||
const Container = styled.div` | ||
margin-top: ${3 * GU}px; | ||
`; | ||
|
||
const HeaderContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
margin-bottom: ${3 * GU}px; | ||
`; | ||
|
||
const Title = styled.div` | ||
font-weight: 600; | ||
font-size: 28px; | ||
line-height: 125%; | ||
`; | ||
|
||
const SearchContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
margin-bottom: ${3 * GU}px; | ||
`; | ||
|
||
const CustomActionButton = styled(Button)` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 12px 24px; | ||
width: 134px; | ||
height: 44px; | ||
border-radius: 12px; | ||
box-shadow: none; | ||
`; | ||
|
||
const LoadMoreButton = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 12px 24px; | ||
width: 154px; | ||
height: 44px; | ||
border-radius: 12px; | ||
color: #7483ab; | ||
background: #ffffff; | ||
box-shadow: none; | ||
cursor: pointer; | ||
& > svg { | ||
padding-left: 2px; | ||
} | ||
`; | ||
|
||
const ActionListContainer = styled.div` | ||
width: 100%; | ||
margin-bottom: ${3 * GU}px; | ||
`; | ||
|
||
const DaoActionsPage: React.FC<props> = ({ fetchMore, actions, isMore, identifier }) => { | ||
const history = useHistory(); | ||
const [selected, setSelected] = useState<number>(0); | ||
const [value, setValue] = useState<string>(''); | ||
const actionStates = [ | ||
'All Actions', | ||
'Executable', | ||
'Scheduled', | ||
'Challenged', | ||
'Executed', | ||
'Rejected', | ||
'Ruled Negatively', | ||
]; | ||
|
||
const FilterState = (data: actionsType[0]) => { | ||
return selected > 0 ? actionStates[selected] === data.state : true; | ||
}; | ||
|
||
const SearchAction = (data: actionsType[0]) => { | ||
const re = new RegExp(value, 'i'); | ||
if (data.payload.title?.match(re) || value === '') return data; | ||
}; | ||
|
||
const RenderActions = (actions: actionsType) => { | ||
const { layoutName } = useLayout(); | ||
const temp: React.ReactElement[] = []; | ||
if (actions) { | ||
actions | ||
.filter((data) => FilterState(data)) // Filter Based on status | ||
.filter((data) => SearchAction(data)) // search among vidible Actions | ||
.map((data, index: number) => { | ||
temp.push( | ||
<GridItem | ||
gridColumn={layoutName === 'medium' ? '1/-1' : index % 2 === 0 ? '1/3' : '3/5'} | ||
> | ||
<DaoActionCard | ||
key={index} | ||
date={data.createdAt} | ||
state={data.state} | ||
title={data.payload.title} | ||
/> | ||
</GridItem>, | ||
); | ||
}); | ||
if (temp.length === 0) return <NoActionAvailable />; | ||
return temp; | ||
} else return <div>Loading...</div>; | ||
}; | ||
|
||
const goToNewExecution = () => { | ||
history.push(`/daos/${identifier}/actions/new-execution`); | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<HeaderContainer> | ||
<Title>Actions</Title> | ||
<CustomActionButton label="New action" onClick={goToNewExecution} /> | ||
</HeaderContainer> | ||
<SearchContainer> | ||
<DropDown | ||
items={actionStates} | ||
css={` | ||
border: none; | ||
`} | ||
selected={selected} | ||
onChange={setSelected} | ||
/> | ||
<SearchInput | ||
css={` | ||
width: 100%; | ||
margin-left: ${3 * GU}px; | ||
border-radius: 12px; | ||
`} | ||
onChange={(text: string) => setValue(text)} | ||
placeholder="Type to search..." | ||
wide={true} | ||
/> | ||
</SearchContainer> | ||
<ActionListContainer> | ||
<Grid column={'4'}>{RenderActions(actions)}</Grid> | ||
</ActionListContainer> | ||
{isMore && ( | ||
<LoadMoreButton onClick={fetchMore}> | ||
<span>Load more</span> | ||
<IconDown /> | ||
</LoadMoreButton> | ||
)} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default DaoActionsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,13 @@ import { Grid, GridItem, GU, useLayout } from '@aragon/ui'; | |
import { lazy, Suspense, useEffect, useMemo, useState } from 'react'; | ||
import { Redirect, Switch, useHistory, useLocation, useParams, useRouteMatch } from 'react-router'; | ||
|
||
import NoDaoFound from './NoDaoFound'; | ||
import DaoSideCard from './components/DaoSideCard/DaoSideCard'; | ||
import NewExecution from 'containers/NewExecution/NewExecution'; | ||
import HelpComponent from 'components/HelpComponent/HelpComponent'; | ||
import ProposalDetails from 'containers/ProposalDetails/ProposalDetails'; | ||
import { useDaoQuery, useLazyProposalListQuery } from 'hooks/query-hooks'; | ||
|
||
import DaoActionsPage from './DaoActionPage'; | ||
const DaoSettings = lazy(() => import('containers/DAOSettings/DAOSettings')); | ||
|
||
const StyledGridItem = styled(GridItem)<{ paddingTop: string }>` | ||
|
@@ -32,13 +33,16 @@ const DaoHomePage: React.FC = () => { | |
* State | ||
*/ | ||
const [daoExists, setDaoExists] = useState<boolean>(true); | ||
const [IsMoreActions, setIsMoreActions] = useState<boolean>(false); | ||
const [daoDetails, setDaoDetails] = useState<any>(); | ||
const [queueNonce, setQueueNonce] = useState<number>(); | ||
const [visibleActions, setVisibleActions] = useState<any>([]); | ||
|
||
/** | ||
* Effects | ||
*/ | ||
const { data: dao, loading: daoIsLoading } = useDaoQuery(daoName); | ||
const { getQueueData, data: queueData } = useLazyProposalListQuery(); | ||
const { getQueueData, data: queueData, fetchMore } = useLazyProposalListQuery(); | ||
|
||
/** | ||
* Update state and get queue data | ||
|
@@ -63,6 +67,19 @@ const DaoHomePage: React.FC = () => { | |
} | ||
}, [daoIsLoading, dao, getQueueData]); | ||
|
||
/** | ||
* Functions | ||
*/ | ||
const fetchMoreData = async () => { | ||
if (fetchMore) { | ||
fetchMore({ | ||
variables: { | ||
offset: visibleActions.length, | ||
}, | ||
}); | ||
} | ||
}; | ||
|
||
/** | ||
* Update visible proposals | ||
*/ | ||
|
@@ -72,6 +89,12 @@ const DaoHomePage: React.FC = () => { | |
} | ||
}, [queueData]); | ||
|
||
useEffect(() => { | ||
if (queueNonce && visibleActions.length) { | ||
setIsMoreActions(queueNonce !== visibleActions.length); | ||
} else setIsMoreActions(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how queueNonce is related to |
||
}, [queueNonce, visibleActions]); | ||
|
||
/** | ||
* Render | ||
*/ | ||
|
@@ -100,7 +123,14 @@ const DaoHomePage: React.FC = () => { | |
<ApmRoute | ||
exact | ||
path={`${path}actions`} | ||
render={() => <div>Actions Component goes here...</div>} | ||
render={() => ( | ||
<DaoActionsPage | ||
fetchMore={fetchMoreData} | ||
actions={visibleActions} | ||
isMore={IsMoreActions} | ||
identifier={daoName} | ||
/> | ||
)} | ||
/> | ||
<ApmRoute | ||
exact | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified by creating a functional Component for
NoAvailableAction