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

Filterbar context #1693

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
184d239
Overflow Button restored
rkzel Nov 6, 2019
404873a
Merge branch 'filterbar-overflow' of github.com:AutarkLabs/open-enter…
rkzel Nov 6, 2019
9d1a22a
Cleanup of Filter components
rkzel Nov 7, 2019
cf5ffbc
Merge branch 'filterbar-overflow' of github.com:AutarkLabs/open-enter…
rkzel Nov 8, 2019
c20684d
Merge branch 'dev' of github.com:AutarkLabs/open-enterprise into filt…
rkzel Nov 8, 2019
39faada
added filtering context, converted Issues to func component, added Fi…
rkzel Nov 12, 2019
5cf1e2a
Merge branch 'filterbar-overflow' of github.com:AutarkLabs/open-enter…
rkzel Nov 12, 2019
05eeb70
Moved FilterBar-related files from components to Shared/FilterBar
rkzel Nov 15, 2019
757f02f
Filters context provider, plus various associated functions
rkzel Nov 15, 2019
98a9160
Standardized names displayed in ActiveFilters
rkzel Nov 15, 2019
16c42bb
applyFilters has many parameters, and now they are named
rkzel Nov 15, 2019
0932960
Within context this panel has direct access to all filtering data
rkzel Nov 15, 2019
b051215
Merge branch 'dev' of github.com:AutarkLabs/open-enterprise into filt…
rkzel Nov 18, 2019
2dd0a32
Exported component from FilterBar, so it can be reused in App
rkzel Nov 19, 2019
f86e95a
Preserving GH prop structure shape
rkzel Nov 19, 2019
5597d8c
Filtering Context Provider and helpers
rkzel Nov 19, 2019
84f4544
Connected App to filtering context. Added secondary buttons in Header
rkzel Nov 19, 2019
ca1c998
fixed location of the file
rkzel Nov 19, 2019
eefb476
Connected to filtering context, so the card can set correct project t…
rkzel Nov 19, 2019
d1980bf
Connected to filtering context
rkzel Nov 19, 2019
8cecb42
redesigned component
rkzel Nov 19, 2019
9675e85
Issues, FilterBar and improved Filter Panel
rkzel Nov 19, 2019
00da2b4
fixed resetFilters
rkzel Nov 20, 2019
d130d5c
Projects: revert to passing graphqlQuery to Issues
Nov 20, 2019
595b189
preserving Issues component by passing graphqlQuery in props
rkzel Nov 20, 2019
1118d9b
Merge branch 'dev' into filterbar-context
Nov 26, 2019
17d199e
Projects/MiniFilterBar: display at 514px width
Nov 26, 2019
7e001fc
Projects/Issues: resetFilters when component unmounts
Nov 26, 2019
58a51eb
Projects/MiniFilterBar: only show on issues list
Nov 26, 2019
5d8d8ce
DropDowns in Filters Panel should not close automatically
rkzel Nov 26, 2019
5b05b35
Projects/TextFilter: rm all props
Dec 3, 2019
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
134 changes: 74 additions & 60 deletions apps/projects/app/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { useEffect, useState } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import { ApolloProvider } from 'react-apollo'

import styled from 'styled-components'
import { useAragonApi } from './api-react'
import {
Bar,
Button,
BackButton,
GU,
Header,
IconFilter,
IconPlus,
Main,
Tabs,
Expand All @@ -30,12 +32,12 @@ import { LoadingAnimation } from './components/Shared'
import { EmptyWrapper } from './components/Shared'
import { Error } from './components/Card'
import { DecoratedReposProvider } from './context/DecoratedRepos'
import { IssueFiltersProvider } from './context/IssueFilters'
import { TextFilter } from './components/Shared/FilterBar/TextFilter'

const App = () => {
const { api, appState } = useAragonApi()
const [ activeIndex, setActiveIndex ] = useState(
{ tabIndex: 0, tabData: {} }
)
const [ activeIndex, setActiveIndex ] = useState(0)
const [ selectedIssueId, setSelectedIssue ] = useState(null)
const [ githubLoading, setGithubLoading ] = useState(false)
const [ panel, setPanel ] = useState(null)
Expand Down Expand Up @@ -88,9 +90,7 @@ const App = () => {
}
}

const changeActiveIndex = data => {
setActiveIndex(data)
}
const changeActiveIndex = index => setActiveIndex(index)

const closePanel = () => {
setPanel(null)
Expand All @@ -112,10 +112,6 @@ const App = () => {
window.addEventListener('message', handlePopupMessage)
}

const handleSelect = index => {
changeActiveIndex({ tabIndex: index, tabData: {} })
}

const handleResolveLocalIdentity = address => {
return api.resolveAddressIdentity(address).toPromise()
}
Expand Down Expand Up @@ -154,16 +150,24 @@ const App = () => {
tabs.push({ name: 'Settings', body: Settings })

// Determine current tab details
const TabComponent = tabs[activeIndex.tabIndex].body
const TabComponent = tabs[activeIndex].body
const TabAction = () => {
const { setupNewIssue, setupNewProject } = usePanelManagement()
const { setupNewIssue, setupNewProject, filters: filtersPanel } = usePanelManagement()

switch (tabs[activeIndex.tabIndex].name) {
switch (tabs[activeIndex].name) {
case 'Overview': return (
<Button mode="strong" icon={<IconPlus />} onClick={setupNewProject} label="New project" />
)
case 'Issues': return (
<Button mode="strong" icon={<IconPlus />} onClick={setupNewIssue} label="New issue" />
<>
{!selectedIssueId && (
<MiniFilterBar>
<Button icon={<IconFilter />} onClick={filtersPanel} label="Filters Panel" />
<TextFilter />
</MiniFilterBar>
)}
<Button mode="strong" icon={<IconPlus />} onClick={setupNewIssue} label="New issue" />
</>
)
default: return null
}
Expand All @@ -178,56 +182,66 @@ const App = () => {
onShowLocalIdentityModal={handleShowLocalIdentityModal}
>
<DecoratedReposProvider>
<Header
primary="Projects"
secondary={
<TabAction />
}
/>
<ErrorBoundary>

{selectedIssueId
? (
<React.Fragment>
<Bar>
<BackButton onClick={() => setSelectedIssue(null)} />
</Bar>
<IssueDetail issueId={selectedIssueId} />
</React.Fragment>
)
: (
<React.Fragment>
<Tabs
items={tabs.map(t => t.name)}
onChange={handleSelect}
selected={activeIndex.tabIndex}
/>
<TabComponent
status={github.status}
app={api}
bountyIssues={issues}
bountySettings={bountySettings}
tokens={tokens}
activeIndex={activeIndex}
changeActiveIndex={changeActiveIndex}
setSelectedIssue={setSelectedIssue}
onLogin={handleGithubSignIn}
/>
</React.Fragment>
)
}
</ErrorBoundary>
<PanelManager
activePanel={panel}
onClose={closePanel}
{...panelProps}
/>
<IssueFiltersProvider>
<Header
primary="Projects"
secondary={
<TabAction />
}
/>
<ErrorBoundary>
{selectedIssueId
? (
<React.Fragment>
<Bar>
<BackButton onClick={() => setSelectedIssue(null)} />
</Bar>
<IssueDetail issueId={selectedIssueId} />
</React.Fragment>
)
: (
<React.Fragment>
<Tabs
items={tabs.map(t => t.name)}
onChange={changeActiveIndex}
selected={activeIndex}
/>
<TabComponent
status={github.status}
app={api}
bountyIssues={issues}
bountySettings={bountySettings}
tokens={tokens}
activeIndex={activeIndex}
changeActiveIndex={changeActiveIndex}
setSelectedIssue={setSelectedIssue}
onLogin={handleGithubSignIn}
/>
</React.Fragment>
)
}
</ErrorBoundary>
<PanelManager
activePanel={panel}
onClose={closePanel}
{...panelProps}
/>
</IssueFiltersProvider>
</DecoratedReposProvider>
</IdentityProvider>
</PanelContext.Provider>
</ApolloProvider>
</Main>
)
}
const MiniFilterBar = styled.span`
> * {
margin-right: ${GU}px;
}

@media only screen and (min-width: 515px) {
display: none;
}
`

export default App
12 changes: 0 additions & 12 deletions apps/projects/app/assets/IconCoins.js

This file was deleted.

17 changes: 0 additions & 17 deletions apps/projects/app/assets/IconFilter.js

This file was deleted.

4 changes: 1 addition & 3 deletions apps/projects/app/assets/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import IconMore from './IconMore'
import IconSort from './IconSort'
import IconGrid from './IconGrid'
import IconCoins from './IconCoins'
import IconFilter from './IconFilter'
import IconBarbell from './IconBarbell'
import IconOpen from './IconOpen'
import IconCollapse from './IconCollapse'
import IconDropArrow from './IconDropArrow'

export { IconMore, IconSort, IconGrid, IconCoins, IconFilter, IconBarbell, IconOpen, IconCollapse, IconDropArrow }
export { IconMore, IconSort, IconGrid, IconBarbell, IconOpen, IconCollapse, IconDropArrow }
19 changes: 15 additions & 4 deletions apps/projects/app/components/Card/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '../../utils/responsive'
import { useAragonApi } from '../../api-react'
import { toHex } from 'web3-utils'
import { useIssueFilters } from '../../context/IssueFilters'

const Project = ({
repoId,
Expand All @@ -34,6 +35,14 @@ const Project = ({

const theme = useTheme()
const { width } = useLayout()
const {
activeFilters,
availableFilters,
setAvailableFilters,
setActiveFilters,
activeFiltersCount,
setActiveFiltersCount,
} = useIssueFilters()

const removeProject = () => {
removeRepo(toHex(repoId)).toPromise()
Expand All @@ -44,10 +53,12 @@ const Project = ({

const clickContext = e => {
e.stopPropagation()
changeActiveIndex({
tabIndex: 1,
tabData: { filterIssuesByRepoId: repoId },
})
const newActiveFilters = { ...activeFilters, projects: { [repoId]: true } }
setActiveFilters(newActiveFilters)
const newAvailableFilters = { ...availableFilters, projects: { [repoId]: { name: label } } }
setAvailableFilters(newAvailableFilters)
setActiveFiltersCount(activeFiltersCount + 1)
changeActiveIndex(1)
}

return (
Expand Down
Loading