-
Notifications
You must be signed in to change notification settings - Fork 303
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
add search filter criteria for authorized and unauthorized studies #4825
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,7 @@ export class QueryStore { | |
|
||
@computed | ||
get queryParser() { | ||
return new QueryParser(this.referenceGenomes); | ||
return new QueryParser(this.referenceGenomes, this.readPermissions); | ||
} | ||
|
||
initialize(urlWithInitialParams?: string) { | ||
|
@@ -1511,6 +1511,16 @@ export class QueryStore { | |
return new Set(referenceGenomes); | ||
} | ||
|
||
@computed get readPermissions(): Set<string> { | ||
const studies = Array.from(this.treeData.map_node_meta.keys()).filter( | ||
s => typeof (s as CancerStudy).readPermission !== 'undefined' | ||
); | ||
const readPermissions = studies.map(n => | ||
(n as CancerStudy).readPermission.toString() | ||
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.
|
||
); | ||
return new Set(readPermissions); | ||
} | ||
|
||
@computed get selectableSelectedStudies() { | ||
return this.selectableSelectedStudyIds | ||
.map( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,7 @@ export class ListPhrase implements Phrase { | |
for (const fieldName of this.fields) { | ||
let anyPhraseMatch = false; | ||
const fieldValue = study[fieldName]; | ||
if (fieldValue) { | ||
if (typeof fieldValue !== 'undefined') { | ||
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. fieldValue===undefined |
||
for (const phrase of this._phraseList) { | ||
anyPhraseMatch = | ||
anyPhraseMatch || | ||
|
@@ -165,7 +165,8 @@ function matchPhrase(phrase: string, fullText: string) { | |
|
||
/** | ||
* Full match using lowercase | ||
* Need to convert boolean to string before applying lowercase | ||
*/ | ||
function matchPhraseFull(phrase: string, fullText: string) { | ||
return fullText.toLowerCase() === phrase.toLowerCase(); | ||
function matchPhraseFull(phrase: string, toMatch: boolean | string | number) { | ||
return _.toString(toMatch).toLowerCase() === phrase.toLowerCase(); | ||
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. probably don'tneed to use _ (lodash here). just toMatch.toString().toLowerCase() |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export type FilterFieldOption = { | ||
value: string; | ||
displayValue: string; | ||
}; | ||
|
||
export function toFilterFieldOption(option: string) { | ||
return { value: option, displayValue: option }; | ||
} | ||
|
||
export function toFilterFieldValue(option: FilterFieldOption) { | ||
return option.value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,70 @@ | ||
import * as React from 'react'; | ||
import { observer } from 'mobx-react'; | ||
import { Collapse } from 'react-collapse'; | ||
import classnames from 'classnames'; | ||
|
||
@observer | ||
export default class UnknownStudiesWarning extends React.Component< | ||
{ ids: String[] }, | ||
{ studiesCollapsed: boolean }, | ||
{} | ||
> { | ||
constructor(props: { ids: String[] }) { | ||
super(props); | ||
this.state = { | ||
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. we try to use mobx state instead of react state. for consistency. just put it as an observable property on the component |
||
studiesCollapsed: true | ||
}; | ||
} | ||
|
||
toggleStudiesCollapse = () => { | ||
this.setState(prevState => ({ | ||
studiesCollapsed: !prevState.studiesCollapsed | ||
})); | ||
} | ||
|
||
render() { | ||
const { studiesCollapsed } = this.state; | ||
if (this.props.ids.length > 0) { | ||
return ( | ||
<div | ||
className="alert alert-danger" | ||
data-test="unkown-study-warning" | ||
style={{ marginBottom: 0 }} | ||
> | ||
<i className="fa fa-exclamation-triangle"></i> The following | ||
studies do not exist or you do not have access to them: | ||
<ul style={{ margin: '10px 0' }}> | ||
{this.props.ids.map(id => ( | ||
<li>{id}</li> | ||
))} | ||
</ul> | ||
|
||
<div | ||
style={{ | ||
width: '100%', | ||
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. probably don't need width:100% |
||
display: 'flex', | ||
alignItems: 'center', | ||
}} | ||
onClick={() => this.toggleStudiesCollapse()} | ||
> | ||
<i className="fa fa-exclamation-triangle"></i> The following | ||
studies do not exist or you do not have access to them. | ||
<span style={{ float: 'right' }}> | ||
{studiesCollapsed ? ( | ||
<i | ||
className={classnames( | ||
'fa fa-chevron-down' | ||
)} | ||
/> | ||
) : ( | ||
<i | ||
className={classnames( | ||
'fa fa-chevron-up' | ||
)} | ||
/> | ||
)} | ||
</span> | ||
</div> | ||
<Collapse isOpened={!studiesCollapsed}> | ||
<ul style={{ margin: '10px 0' }}> | ||
{this.props.ids.map(id => ( | ||
<li>{id}</li> | ||
))} | ||
</ul> | ||
</Collapse> | ||
Please resubmit your query below. | ||
</div> | ||
); | ||
|
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.
(s:CancerStudy)=>s.readPermission===undefined
should work. You don't need typeof anymore. Possible that you will need to cast with as, but not sure.