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

Filters for analysis table #990

Merged
merged 4 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Neuroscout tests

on: [push, pull_request]

on:
push:
branches:
- master
pull_request:
jobs:
tests:
name: neuroscout tests
Expand Down
25 changes: 22 additions & 3 deletions neuroscout/frontend/src/AnalysisList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,26 @@ export class AnalysisListTable extends React.Component<
ownersWidth: number
}
> {
state = { redirectId: '', owners: [], searchText: '', ownersWidth: 10 }
constructor(props) {
super(props)
let owners: string[] = []
let ownersWidth = 10

if (props.analyses !== null && props.analyses.length > 0) {
owners = [
...new Set(
props.analyses.filter(x => x.user_name).map(x => x.user_name),
),
].sort() as string[]
ownersWidth = Math.max(...owners.map(x => (x ? x.length : 0))) + 4
}
this.state = {
redirectId: '',
owners: owners,
searchText: '',
ownersWidth: ownersWidth,
}
}

componentDidUpdate(prevProps) {
const length = prevProps.analyses ? prevProps.analyses.length : 0
Expand All @@ -48,9 +67,9 @@ export class AnalysisListTable extends React.Component<
) {
const owners = [
...new Set(
this.props.analyses.map(x => (x.user_name ? x.user_name : ' ')),
this.props.analyses.filter(x => x.user_name).map(x => x.user_name),
),
]
].sort() as string[]

/* no science behind adding 4, just a bit of buffer */
const ownersWidth = Math.max(...owners.map(x => (x ? x.length : 0))) + 4
Expand Down