Skip to content
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
7 changes: 5 additions & 2 deletions src/OptionsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { css, html } from './utils'

export function OptionsGroup({
name: groupName,
settingName,
options = [],
onOptionChange = () => null,
}) {
Expand Down Expand Up @@ -38,7 +39,7 @@ export function OptionsGroup({
>
${options.length > 0
? options.map(
([name, checked]) => html`
([name, checked, optionName]) => html`
<label
class=${css`
display: flex;
Expand All @@ -58,7 +59,9 @@ export function OptionsGroup({
<input
type="checkbox"
checked=${checked}
onClick=${() => onOptionChange(groupName, name, !checked)}
onClick=${() =>
onOptionChange(settingName || groupName, optionName || name, !checked)
}
/>
<span
class=${css`
Expand Down
61 changes: 48 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,53 @@ function App() {
}
}, [])

const options = useMemo(
() => {
const reviewerOptions = html`
<${OptionsGroup}
name="Reviewers"
onOptionChange=${changeOption}
options=${reviewers}
/>
`
// Get user / organization grouping of repos
const repoByOrgs = [...repos.reduce((orgMap, [name, checked]) => {
const [orgName, repoName] = name.split('/')
const repoSet = orgMap.get(orgName) || []
repoSet.push([repoName, checked, name])
orgMap.set(orgName, repoSet)

return orgMap
}, new Map())]
const repoOptions = html`
<div
class=${css`
font-size: 0.8rem;
`}
>
Repos:
<div
class=${css`
padding-left: 20px;
`}
>
${repoByOrgs.map(([orgName, orgRepos]) => html`
<${OptionsGroup}
name=${orgName}
settingName="Repos"
onOptionChange=${changeOption}
options=${orgRepos}
/>
`
)}
</div>
</div>
`

return [repoOptions, reviewerOptions]
}, [repos, reviewers]
)

const groups = useMemo(
() =>
GROUPS.reduce(
Expand Down Expand Up @@ -155,19 +202,7 @@ function App() {
<${Layout}
title="Aragon Pull Requests"
hasToken=${Boolean(GITHUB_TOKEN)}
options=${[
['Repos', repos],
['Reviewers', reviewers],
].map(
([name, options]) =>
html`
<${OptionsGroup}
name=${name}
onOptionChange=${changeOption}
options=${options}
/>
`
)}
options=${options}
columns=${groups.map(
([days, emoji, prs]) =>
html`
Expand Down