if (this.mounted) {
this.setState({ loading: false });
}
- return Promise.reject();
+ return [];
}
);
}
};
fetchFacet = (facet /*: string */) => {
- return this.fetchIssues({ ps: 1, facets: mapFacet(facet) }).then(({ facets, ...other }) => {
- if (this.mounted) {
- this.setState(state => ({
- facets: { ...state.facets, ...parseFacets(facets) },
- referencedComponents: {
- ...state.referencedComponents,
- ...keyBy(other.components, 'uuid')
- },
- referencedLanguages: {
- ...state.referencedLanguages,
- ...keyBy(other.languages, 'key')
- },
- referencedRules: {
- ...state.referencedRules,
- ...keyBy(other.rules, 'key')
- },
- referencedUsers: {
- ...state.referencedUsers,
- ...keyBy(other.users, 'login')
- }
- }));
- }
- });
+ return this.fetchIssues({ ps: 1, facets: mapFacet(facet) }).then(
+ ({ facets, ...other }) => {
+ if (this.mounted) {
+ this.setState(state => ({
+ facets: { ...state.facets, ...parseFacets(facets) },
+ referencedComponents: {
+ ...state.referencedComponents,
+ ...keyBy(other.components, 'uuid')
+ },
+ referencedLanguages: {
+ ...state.referencedLanguages,
+ ...keyBy(other.languages, 'key')
+ },
+ referencedRules: {
+ ...state.referencedRules,
+ ...keyBy(other.rules, 'key')
+ },
+ referencedUsers: {
+ ...state.referencedUsers,
+ ...keyBy(other.users, 'login')
+ }
+ }));
+ }
+ },
+ () => {}
+ );
};
isFiltered = () => {
<DateInput
className="search-navigator-date-facet-selection-dropdown-left"
inputClassName="search-navigator-date-facet-selection-input"
+ maxDate={createdBefore ? toShortNotSoISOString(createdBefore) : '+0'}
onChange={this.handlePeriodChangeAfter}
placeholder={translate('from')}
value={createdAfter ? toShortNotSoISOString(createdAfter) : undefined}
<DateInput
className="search-navigator-date-facet-selection-dropdown-right"
inputClassName="search-navigator-date-facet-selection-input"
+ minDate={createdAfter ? toShortNotSoISOString(createdAfter) : undefined}
onChange={this.handlePeriodChangeBefore}
placeholder={translate('to')}
value={createdBefore ? toShortNotSoISOString(createdBefore) : undefined}
<div>
<DateInput
className="little-spacer-right"
+ maxDate={this.formatDate(this.props.to) || '+0'}
name="from"
- value={this.formatDate(this.props.from)}
- placeholder={translate('from')}
onChange={this.handleFromDateChange}
+ placeholder={translate('from')}
+ value={this.formatDate(this.props.from)}
/>
{'—'}
<DateInput
className="little-spacer-left"
+ minDate={this.formatDate(this.props.from)}
name="to"
- value={this.formatDate(this.props.to)}
- placeholder={translate('to')}
onChange={this.handleToDateChange}
+ placeholder={translate('to')}
+ value={this.formatDate(this.props.to)}
/>
<button
className="spacer-left"
<DateInput
className="little-spacer-right"
format="yy-mm-dd"
- maxDate="+0"
+ maxDate="2016-12-27"
name="from"
onChange={[Function]}
placeholder="from"
className="little-spacer-left"
format="yy-mm-dd"
maxDate="+0"
+ minDate="2016-10-27"
name="to"
onChange={[Function]}
placeholder="to"
}
export default class ChangelogSearch extends React.PureComponent<Props> {
- handleResetClick(event: React.SyntheticEvent<HTMLElement>) {
+ handleResetClick = (event: React.SyntheticEvent<HTMLElement>) => {
event.preventDefault();
event.currentTarget.blur();
this.props.onReset();
- }
+ };
formatDate = (date?: string) => (date ? toShortNotSoISOString(date) : undefined);
return (
<div className="display-inline-block" id="quality-profile-changelog-form">
<DateInput
+ maxDate={this.formatDate(this.props.toDate) || '+0'}
name="since"
- value={this.formatDate(this.props.fromDate)}
- placeholder={translate('from')}
onChange={this.props.onFromDateChange}
+ placeholder={translate('from')}
+ value={this.formatDate(this.props.fromDate)}
/>
{' — '}
<DateInput
+ minDate={this.formatDate(this.props.fromDate)}
name="to"
- value={this.formatDate(this.props.toDate)}
- placeholder={translate('to')}
onChange={this.props.onToDateChange}
+ placeholder={translate('to')}
+ value={this.formatDate(this.props.toDate)}
/>
- <button className="spacer-left" onClick={this.handleResetClick.bind(this)}>
+ <button className="spacer-left" onClick={this.handleResetClick}>
{translate('reset_verb')}
</button>
</div>
inputClassName?: string;
// see http://api.jqueryui.com/datepicker/#option-maxDate for details
maxDate?: Date | string | number;
+ minDate?: Date | string | number;
name: string;
onChange: (value?: string) => void;
placeholder: string;
this.attachDatePicker();
}
+ componentDidUpdate(prevProps: Props) {
+ if ($.fn && ($.fn as any).datepicker && this.input) {
+ if (prevProps.maxDate !== this.props.maxDate) {
+ ($(this.input) as any).datepicker('option', { maxDate: this.props.maxDate });
+ }
+ if (prevProps.minDate !== this.props.minDate) {
+ ($(this.input) as any).datepicker('option', { minDate: this.props.minDate });
+ }
+ }
+ }
+
handleChange = () => {
const { value } = this.input;
this.props.onChange(value);
changeMonth: true,
changeYear: true,
maxDate: this.props.maxDate,
+ minDate: this.props.minDate,
onSelect: this.handleChange
};