@@ -355,14 +355,11 @@ export default class App extends React.PureComponent { | |||
s: 'FILE_LINE', | |||
...serializeQuery(query), | |||
ps: 100, | |||
organization: organization && organization.key, | |||
facets, | |||
...additional | |||
}; | |||
if (organization) { | |||
parameters.organization = organization.key; | |||
} | |||
// only sorting by CREATION_DATE is allowed, so let's sort DESC | |||
if (query.sort) { | |||
Object.assign(parameters, { asc: 'false' }); | |||
@@ -696,6 +693,7 @@ export default class App extends React.PureComponent { | |||
onFacetToggle={this.handleFacetToggle} | |||
onFilterChange={this.handleFilterChange} | |||
openFacets={this.state.openFacets} | |||
organization={this.props.organization} | |||
query={query} | |||
referencedComponents={this.state.referencedComponents} | |||
referencedLanguages={this.state.referencedLanguages} |
@@ -20,15 +20,15 @@ | |||
// @flow | |||
import React from 'react'; | |||
import { sortBy, uniq, without } from 'lodash'; | |||
import Avatar from '../../../components/ui/Avatar'; | |||
import FacetBox from './components/FacetBox'; | |||
import FacetHeader from './components/FacetHeader'; | |||
import FacetItem from './components/FacetItem'; | |||
import FacetItemsList from './components/FacetItemsList'; | |||
import FacetFooter from './components/FacetFooter'; | |||
import { searchAssignees } from '../utils'; | |||
import type { ReferencedUser, Component } from '../utils'; | |||
import Avatar from '../../../components/ui/Avatar'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import type { ReferencedUser, Component } from '../utils'; | |||
type Props = {| | |||
assigned: boolean, | |||
@@ -38,6 +38,7 @@ type Props = {| | |||
onChange: (changes: {}) => void, | |||
onToggle: (property: string) => void, | |||
open: boolean, | |||
organization?: { key: string }, | |||
stats?: { [string]: number }, | |||
referencedUsers: { [string]: ReferencedUser } | |||
|}; | |||
@@ -73,7 +74,13 @@ export default class AssigneeFacet extends React.PureComponent { | |||
this.props.onChange({ assigned: true, assignees: [] }); | |||
}; | |||
handleSearch = (query: string) => searchAssignees(query, this.props.component); | |||
handleSearch = (query: string) => { | |||
let organization = this.props.component && this.props.component.organization; | |||
if (this.props.organization && !organization) { | |||
organization = this.props.organization.key; | |||
} | |||
return searchAssignees(query, organization); | |||
}; | |||
handleSelect = (assignee: string) => { | |||
const { assignees } = this.props; |
@@ -37,6 +37,7 @@ type Props = {| | |||
onChange: (changes: { [string]: Array<string> }) => void, | |||
onToggle: (property: string) => void, | |||
open: boolean, | |||
organization?: { key: string }, | |||
stats?: { [string]: number }, | |||
referencedComponents: { [string]: ReferencedComponent }, | |||
projects: Array<string> | |||
@@ -68,26 +69,28 @@ export default class ProjectFacet extends React.PureComponent { | |||
}; | |||
handleSearch = (query: string) => { | |||
const { component } = this.props; | |||
return component != null && ['VW', 'SVW'].includes(component.qualifier) | |||
? getTree(component.key, { ps: 50, q: query, qualifiers: 'TRK' }).then(response => | |||
response.components.map(component => ({ | |||
label: component.name, | |||
organization: component.organization, | |||
value: component.refId | |||
})) | |||
) | |||
: searchProjects({ | |||
ps: 50, | |||
filter: query ? `query = "${query}"` : '' | |||
}).then(response => | |||
response.components.map(component => ({ | |||
label: component.name, | |||
organization: component.organization, | |||
value: component.id | |||
})) | |||
); | |||
const { component, organization } = this.props; | |||
if (component != null && ['VW', 'SVW'].includes(component.qualifier)) { | |||
return getTree(component.key, { ps: 50, q: query, qualifiers: 'TRK' }).then(response => | |||
response.components.map(component => ({ | |||
label: component.name, | |||
organization: component.organization, | |||
value: component.refId | |||
})) | |||
); | |||
} | |||
return searchProjects({ | |||
ps: 50, | |||
filter: query ? `query = "${query}"` : '', | |||
organization: organization && organization.key | |||
}).then(response => | |||
response.components.map(component => ({ | |||
label: component.name, | |||
organization: component.organization, | |||
value: component.id | |||
})) | |||
); | |||
}; | |||
handleSelect = (rule: string) => { |
@@ -50,6 +50,7 @@ type Props = {| | |||
onFacetToggle: (property: string) => void, | |||
onFilterChange: (changes: { [string]: Array<string> }) => void, | |||
openFacets: { [string]: boolean }, | |||
organization?: { key: string }, | |||
query: Query, | |||
referencedComponents: { [string]: ReferencedComponent }, | |||
referencedLanguages: { [string]: ReferencedLanguage }, | |||
@@ -130,10 +131,12 @@ export default class Sidebar extends React.PureComponent { | |||
rules={query.rules} | |||
/> | |||
<TagFacet | |||
component={component} | |||
facetMode={query.facetMode} | |||
onChange={this.props.onFilterChange} | |||
onToggle={this.props.onFacetToggle} | |||
open={!!openFacets.tags} | |||
organization={this.props.organization} | |||
stats={facets.tags} | |||
tags={query.tags} | |||
/> | |||
@@ -144,6 +147,7 @@ export default class Sidebar extends React.PureComponent { | |||
onChange={this.props.onFilterChange} | |||
onToggle={this.props.onFacetToggle} | |||
open={!!openFacets.projects} | |||
organization={this.props.organization} | |||
projects={query.projects} | |||
referencedComponents={this.props.referencedComponents} | |||
stats={facets.projects} | |||
@@ -185,6 +189,7 @@ export default class Sidebar extends React.PureComponent { | |||
onChange={this.props.onFilterChange} | |||
onToggle={this.props.onFacetToggle} | |||
open={!!openFacets.assignees} | |||
organization={this.props.organization} | |||
assigned={query.assigned} | |||
assignees={query.assignees} | |||
referencedUsers={this.props.referencedUsers} |
@@ -27,12 +27,15 @@ import FacetItemsList from './components/FacetItemsList'; | |||
import FacetFooter from './components/FacetFooter'; | |||
import { searchIssueTags } from '../../../api/issues'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import type { Component } from '../utils'; | |||
type Props = {| | |||
component?: Component, | |||
facetMode: string, | |||
onChange: (changes: { [string]: Array<string> }) => void, | |||
onToggle: (property: string) => void, | |||
open: boolean, | |||
organization?: { key: string }, | |||
stats?: { [string]: number }, | |||
tags: Array<string> | |||
|}; | |||
@@ -63,7 +66,11 @@ export default class TagFacet extends React.PureComponent { | |||
}; | |||
handleSearch = (query: string) => { | |||
return searchIssueTags({ ps: 50, q: query }).then(tags => | |||
let organization = this.props.component && this.props.component.organization; | |||
if (this.props.organization && !organization) { | |||
organization = this.props.organization.key; | |||
} | |||
return searchIssueTags({ organization, ps: 50, q: query }).then(tags => | |||
tags.map(tag => ({ label: tag, value: tag })) | |||
); | |||
}; |
@@ -192,9 +192,9 @@ export type CurrentUser = | |||
| { isLoggedIn: false } | |||
| { isLoggedIn: true, email?: string, login: string, name: string }; | |||
export const searchAssignees = (query: string, component?: Component) => { | |||
return component | |||
? searchMembers({ organization: component.organization, ps: 50, q: query }).then(response => | |||
export const searchAssignees = (query: string, organization?: string) => { | |||
return organization | |||
? searchMembers({ organization, ps: 50, q: query }).then(response => | |||
response.users.map(user => ({ | |||
avatar: user.avatar, | |||
label: user.name, |