myIssues: boolean,
openFacets: { [string]: boolean },
openIssue: ?Issue,
+ openPopup: ?{
+ issue: string,
+ name: string
+ },
paging?: Paging,
query: Query,
referencedComponents: { [string]: ReferencedComponent },
myIssues: areMyIssuesSelected(props.location.query),
openFacets: { resolutions: true, types: true },
openIssue: null,
+ openPopup: null,
query: parseQuery(props.location.query),
referencedComponents: {},
referencedLanguages: {},
});
};
+ handlePopupToggle = (issue /*: string */, popupName /*: string */, open /*: ?boolean */) => {
+ this.setState((state /*: State */) => {
+ const samePopup =
+ state.openPopup && state.openPopup.name === popupName && state.openPopup.issue === issue;
+ if (open !== false && !samePopup) {
+ return { openPopup: { issue, name: popupName } };
+ } else if (open !== true && samePopup) {
+ return { openPopup: null };
+ }
+ return state;
+ });
+ };
+
handleIssueCheck = (issue /*: string */) => {
this.setState(state => ({
checked: state.checked.includes(issue)
onIssueChange={this.handleIssueChange}
onIssueCheck={currentUser.isLoggedIn ? this.handleIssueCheck : undefined}
onIssueClick={this.openIssue}
+ onPopupToggle={this.handlePopupToggle}
+ openPopup={this.state.openPopup}
organization={organization}
selectedIssue={selectedIssue}
/>}
onIssueChange: Issue => void,
onIssueCheck?: string => void,
onIssueClick: string => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?{ issue: string, name: string},
organization?: { key: string },
selectedIssue: ?Issue
|};
/*:: props: Props; */
render() {
- const { checked, component, issues, selectedIssue } = this.props;
+ const { checked, component, issues, openPopup, selectedIssue } = this.props;
return (
<div>
onCheck={this.props.onIssueCheck}
onClick={this.props.onIssueClick}
onFilterChange={this.props.onFilterChange}
+ onPopupToggle={this.props.onPopupToggle}
+ openPopup={openPopup && openPopup.issue === issue.key ? openPopup.name : null}
organization={this.props.organization}
previousIssue={index > 0 ? issues[index - 1] : null}
selected={selectedIssue != null && selectedIssue.key === issue.key}
onCheck?: string => void,
onClick: string => void,
onFilterChange: (changes: {}) => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?string,
organization?: { key: string },
previousIssue: ?Object,
selected: boolean
onCheck={this.props.onCheck}
onClick={this.props.onClick}
onFilter={this.handleFilter}
+ onPopupToggle={this.props.onPopupToggle}
+ openPopup={this.props.openPopup}
selected={this.props.selected}
/>
</div>
notAccessible: boolean,
notExist: boolean,
openIssuesByLine: { [number]: boolean },
+ openPopup: ?{
+ issue: string,
+ name: string
+ },
selectedIssue?: string,
sources?: Array<SourceLine>,
sourceRemoved: boolean,
notAccessible: false,
notExist: false,
openIssuesByLine: {},
+ openPopup: null,
selectedIssue: props.selectedIssue,
selectedIssueLocation: null,
sourceRemoved: false,
}
};
+ handlePopupToggle = (issue /*: string */, popupName /*: string */, open /*: ?boolean */) => {
+ this.setState((state /*: State */) => {
+ const samePopup =
+ state.openPopup && state.openPopup.name === popupName && state.openPopup.issue === issue;
+ if (open !== false && !samePopup) {
+ return { openPopup: { issue, name: popupName } };
+ } else if (open !== true && samePopup) {
+ return { openPopup: null };
+ }
+ return state;
+ });
+ };
+
displayLinePopup(line /*: number */, element /*: HTMLElement */) {
const popup = new LineActionsPopupView({
line,
onIssuesClose={this.handleCloseIssues}
onLineClick={this.handleLineClick}
onLocationSelect={this.props.onLocationSelect}
+ onPopupToggle={this.handlePopupToggle}
+ openPopup={this.state.openPopup}
onSCMClick={this.handleSCMClick}
onSymbolClick={this.handleSymbolClick}
openIssuesByLine={this.state.openIssuesByLine}
onSCMClick: (SourceLine, HTMLElement) => void,
onSymbolClick: (Array<string>) => void,
openIssuesByLine: { [number]: boolean },
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?{ issue: string, name: string},
scroll?: HTMLElement => void,
selectedIssue: string | null,
sources: Array<SourceLine>,
onSCMClick={this.props.onSCMClick}
onSymbolClick={this.props.onSymbolClick}
openIssues={this.props.openIssuesByLine[line.line] || false}
+ onPopupToggle={this.props.onPopupToggle}
+ openPopup={this.props.openPopup}
previousLine={index > 0 ? sources[index - 1] : undefined}
scroll={this.props.scroll}
secondaryIssueLocations={optimizedSecondaryIssueLocations}
onSCMClick: (SourceLine, HTMLElement) => void,
onSymbolClick: (Array<string>) => void,
openIssues: boolean,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?{ issue: string, name: string},
previousLine?: SourceLine,
scroll?: HTMLElement => void,
secondaryIssueLocations: Array<{
onIssueSelect={this.props.onIssueSelect}
onLocationSelect={this.props.onLocationSelect}
onSymbolClick={this.props.onSymbolClick}
+ onPopupToggle={this.props.onPopupToggle}
+ openPopup={this.props.openPopup}
scroll={this.props.scroll}
secondaryIssueLocations={this.props.secondaryIssueLocations}
selectedIssue={this.props.selectedIssue}
onIssueSelect: (issueKey: string) => void,
onLocationSelect?: number => void,
onSymbolClick: (Array<string>) => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?{ issue: string, name: string},
scroll?: HTMLElement => void,
secondaryIssueLocations: Array<{
from: number,
issues={issues}
onIssueChange={this.props.onIssueChange}
onIssueClick={onIssueSelect}
+ onPopupToggle={this.props.onPopupToggle}
+ openPopup={this.props.openPopup}
selectedIssue={selectedIssue}
/>}
</td>
issues: Array<IssueType>,
onIssueChange: IssueType => void,
onIssueClick: (issueKey: string) => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?{ issue: string, name: string},
selectedIssue: string | null
};
*/
/*:: props: Props; */
render() {
- const { issues, onIssueClick, selectedIssue } = this.props;
+ const { issues, onIssueClick, openPopup, selectedIssue } = this.props;
return (
<div className="issue-list">
key={issue.key}
onChange={this.props.onIssueChange}
onClick={onIssueClick}
+ onPopupToggle={this.props.onPopupToggle}
+ openPopup={openPopup && openPopup.issue === issue.key ? openPopup.name : null}
selected={selectedIssue === issue.key}
/>
)}
onIssueSelect={jest.fn()}
onSelectLocation={jest.fn()}
onSymbolClick={jest.fn()}
+ onPopupToggle={jest.fn()}
+ openPopup={null}
selectedIssue="issue-1"
showIssues={true}
/>
const issues = [{ key: 'foo' }, { key: 'bar' }];
const onIssueClick = jest.fn();
const wrapper = shallow(
- <LineIssuesList issues={issues} line={line} onIssueClick={onIssueClick} selectedIssue="foo" />
+ <LineIssuesList
+ issues={issues}
+ line={line}
+ onIssueClick={onIssueClick}
+ onPopupToggle={jest.fn()}
+ openPopup={null}
+ selectedIssue="foo"
+ />
);
expect(wrapper).toMatchSnapshot();
});
]
}
onIssueClick={[Function]}
+ onPopupToggle={[Function]}
+ openPopup={null}
selectedIssue="issue-1"
/>
</td>
}
}
onClick={[Function]}
+ onPopupToggle={[Function]}
+ openPopup={null}
selected={true}
/>
<BaseIssue
}
}
onClick={[Function]}
+ onPopupToggle={[Function]}
+ openPopup={null}
selected={false}
/>
</div>
onCheck?: string => void,
onClick: string => void,
onFilter?: (property: string, issue: Issue) => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ openPopup: ?string,
selected: boolean
|};
*/
-/*::
-type State = {
- currentPopup: string
-};
-*/
-
export default class BaseIssue extends React.PureComponent {
- /*:: mounted: boolean; */
/*:: props: Props; */
- /*:: state: State; */
static contextTypes = {
store: PropTypes.object
selected: false
};
- constructor(props /*: Props */) {
- super(props);
- this.state = {
- currentPopup: ''
- };
- }
-
componentDidMount() {
- this.mounted = true;
if (this.props.selected) {
this.bindShortcuts();
}
}
componentWillUnmount() {
- this.mounted = false;
if (this.props.selected) {
this.unbindShortcuts();
}
}
togglePopup = (popupName /*: string */, open /*: ?boolean */) => {
- if (this.mounted) {
- this.setState((prevState /*: State */) => {
- if (prevState.currentPopup !== popupName && open !== false) {
- return { currentPopup: popupName };
- } else if (prevState.currentPopup === popupName && open !== true) {
- return { currentPopup: '' };
- }
- return prevState;
- });
- }
+ this.props.onPopupToggle(this.props.issue.key, popupName, open);
};
handleAssignement = (login /*: string */) => {
onFilter={this.props.onFilter}
onChange={this.props.onChange}
togglePopup={this.togglePopup}
- currentPopup={this.state.currentPopup}
+ currentPopup={this.props.openPopup}
selected={this.props.selected}
/>
);
/*::
type Props = {|
checked?: boolean,
- currentPopup: string,
+ currentPopup: ?string,
issue: Issue,
onAssign: string => void,
onChange: Issue => void,
/*::
type Props = {
issue: Issue,
- currentPopup: string,
+ currentPopup: ?string,
onAssign: string => void,
onChange: Issue => void,
onFail: Error => void,
/*::
type Props = {|
commentPlaceholder: string,
- currentPopup: string,
+ currentPopup: ?string,
issueKey: string,
onChange: Issue => void,
onFail: Error => void,
/*::
type Props = {|
issue: Issue,
- currentPopup: string,
+ currentPopup: ?string,
onFail: Error => void,
onFilter?: (property: string, issue: Issue) => void,
togglePopup: (string, boolean | void) => void
const element = shallow(
<IssueCommentAction
issueKey="issue-key"
- currentPopup=""
+ currentPopup={null}
onFail={jest.fn()}
onIssueChange={jest.fn()}
toggleComment={jest.fn()}
const element = shallow(
<IssueCommentAction
issueKey="issue-key"
- currentPopup=""
+ currentPopup={null}
onFail={jest.fn()}
onIssueChange={jest.fn()}
toggleComment={toggle}
it('should render the titlebar correctly', () => {
const element = shallow(
- <IssueTitleBar issue={issue} currentPopup="" onFail={jest.fn()} togglePopup={jest.fn()} />
+ <IssueTitleBar issue={issue} currentPopup={null} onFail={jest.fn()} togglePopup={jest.fn()} />
);
expect(element).toMatchSnapshot();
});
const element = shallow(
<IssueTitleBar
issue={issue}
- currentPopup=""
+ currentPopup={null}
onFail={jest.fn()}
onFilter={jest.fn()}
togglePopup={jest.fn()}