Skip to content

Commit

Permalink
Fixed some module's no-lambda and other tslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
khangaridb committed Oct 16, 2018
1 parent 1332bc5 commit 8c82cb2
Show file tree
Hide file tree
Showing 66 changed files with 1,594 additions and 1,541 deletions.
1 change: 1 addition & 0 deletions src/locales/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable
const en = require('./en.json');
const mn = require('./mn.json');

Expand Down
52 changes: 21 additions & 31 deletions src/modules/auth/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,29 @@ import { Route } from 'react-router-dom';
import { AuthLayout } from '../layout/components';
import { ForgotPassword, ResetPassword, SignIn } from './containers';

const routes = () => (
<React.Fragment>
<Route
path="/"
component={() => {
return <AuthLayout content={<SignIn />} />;
}}
/>
const routes = () => {
const home = () => <AuthLayout content={<SignIn />} />;
const signIn = () => <AuthLayout content={<SignIn />} />;
const forgotPassword = () => <AuthLayout content={<ForgotPassword />} />;

<Route
path="/sign-in"
component={() => {
return <AuthLayout content={<SignIn />} />;
}}
/>
const resetPassword = ({ location }) => {
const parsed = queryString.parse(location.search);
return (
<AuthLayout content={<ResetPassword token={parsed.token || ''} />} />
);
};

<Route
path="/forgot-password"
component={() => {
return <AuthLayout content={<ForgotPassword />} />;
}}
/>
return (
<React.Fragment>
<Route path="/" component={home} />

<Route
path="/reset-password"
component={({ location }) => {
const parsed = queryString.parse(location.search);
return (
<AuthLayout content={<ResetPassword token={parsed.token || ''} />} />
);
}}
/>
</React.Fragment>
);
<Route path="/sign-in" component={signIn} />

<Route path="/forgot-password" component={forgotPassword} />

<Route path="/reset-password" component={resetPassword} />
</React.Fragment>
);
};

export default routes;
13 changes: 4 additions & 9 deletions src/modules/common/components/Chooser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CommonChooser extends React.Component<Props, State> {
};

this.onSelect = this.onSelect.bind(this);
this.handleChange = this.handleChange.bind(this);
this.search = this.search.bind(this);
this.loadMore = this.loadMore.bind(this);
}
Expand Down Expand Up @@ -105,7 +104,7 @@ class CommonChooser extends React.Component<Props, State> {
}

return (
<li key={data._id} onClick={() => this.handleChange(icon, data)}>
<li key={data._id} onClick={this.handleChange.bind(this, icon, data)}>
{this.props.renderName(data)}
<Icon icon={icon} />
</li>
Expand All @@ -125,7 +124,7 @@ class CommonChooser extends React.Component<Props, State> {
}

render() {
const { renderForm, datas, title, data } = this.props;
const { renderForm, datas, title, data, closeModal } = this.props;
const selectedDatas = this.state.datas;

const addTrigger = (
Expand All @@ -141,7 +140,7 @@ class CommonChooser extends React.Component<Props, State> {
<Column>
<FormControl
placeholder={__('Type to search')}
onChange={e => this.search(e)}
onChange={this.search}
/>
<ul>
{datas.map(dataItem => this.renderRow(dataItem, 'add'))}
Expand Down Expand Up @@ -177,11 +176,7 @@ class CommonChooser extends React.Component<Props, State> {
content={renderForm}
/>
<div>
<Button
btnStyle="simple"
onClick={() => this.props.closeModal()}
icon="cancel-1"
>
<Button btnStyle="simple" onClick={closeModal} icon="cancel-1">
Cancel
</Button>
<Button
Expand Down
11 changes: 5 additions & 6 deletions src/modules/common/components/CountsByTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ interface IProps extends IRouterProps {
function CountsByTag({ history, tags, counts, manageUrl, loading }: IProps) {
const { Section } = Wrapper.Sidebar;

const onClick = () => {
router.setParams(history, { tag: null });
};

return (
<Section collapsible={tags.length > 5}>
<Section.Title>{__('Filter by tags')}</Section.Title>
Expand All @@ -27,12 +31,7 @@ function CountsByTag({ history, tags, counts, manageUrl, loading }: IProps) {
</Link>

{router.getParam(history, 'tag') ? (
<a
tabIndex={0}
onClick={() => {
router.setParams(history, { tag: null });
}}
>
<a tabIndex={0} onClick={onClick}>
<Icon icon="cancel-1" />
</a>
) : null}
Expand Down
21 changes: 7 additions & 14 deletions src/modules/common/components/DateFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class DateFilter extends React.Component<Props & ApolloClientProps, State> {
this.renderPopover = this.renderPopover.bind(this);
this.refetchCountQuery = this.refetchCountQuery.bind(this);
this.renderCount = this.renderCount.bind(this);
this.onDateChange = this.onDateChange.bind(this);
this.filterByDate = this.filterByDate.bind(this);
}

Expand All @@ -135,8 +134,10 @@ class DateFilter extends React.Component<Props & ApolloClientProps, State> {
}
}

onDateChange<T extends keyof State>(type: T, date: State[T]) {
this.setState({ [type]: date } as Pick<State, keyof State>);
onDateChange<T extends keyof State>({ date }: { date: State[T] }, type: T) {
if (typeof date !== 'string') {
this.setState({ [type]: date } as Pick<State, keyof State>);
}
}

refetchCountQuery() {
Expand Down Expand Up @@ -209,31 +210,23 @@ class DateFilter extends React.Component<Props & ApolloClientProps, State> {
<Datetime
{...props}
value={this.state.startDate}
onChange={date => {
if (typeof date !== 'string') {
this.onDateChange('startDate', date.toDate());
}
}}
onChange={this.onDateChange.bind(this, 'startDate')}
/>
</FlexItem>

<FlexItem>
<Datetime
{...props}
value={this.state.endDate}
onChange={date => {
if (typeof date !== 'string') {
this.onDateChange('endDate', date.toDate());
}
}}
onChange={this.onDateChange.bind(this, 'endDate')}
/>
</FlexItem>
</FlexRow>

{this.renderCount()}

<FlexRow>
<Button btnStyle="simple" onClick={() => this.filterByDate()}>
<Button btnStyle="simple" onClick={this.filterByDate}>
Filter
</Button>
</FlexRow>
Expand Down
10 changes: 7 additions & 3 deletions src/modules/common/components/FilterByParams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class FilterByParams extends React.Component<IProps, State> {
}
}

onClick(paramKey: string, fieldId: string) {
const { history } = this.props;

router.setParams(history, { [paramKey]: fieldId });
}

renderItems() {
const { history, fields, counts, paramKey, icon, searchable } = this.props;
const { key } = this.state;
Expand Down Expand Up @@ -75,9 +81,7 @@ class FilterByParams extends React.Component<IProps, State> {
? 'active'
: ''
}
onClick={() => {
router.setParams(history, { [paramKey]: field._id });
}}
onClick={this.onClick.bind(this, paramKey, field._id)}
>
{icon ? (
<Icon icon={icon} style={{ color: field.colorCode }} />
Expand Down
20 changes: 10 additions & 10 deletions src/modules/common/components/ModifiableSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { __, Alert } from '../utils';

type OptionProps = {
option: any;
onSelect: (option: any[], e: any) => void;
onSelect: (option: any[]) => void;
};

class Option extends React.Component<OptionProps> {
Expand All @@ -19,11 +19,11 @@ class Option extends React.Component<OptionProps> {
};

return (
<div style={style} onClick={e => onSelect(option, e)}>
<div style={style} onClick={onSelect.bind(null, option)}>
<span style={{ float: 'left' }}>{option.label}</span>
<Icon
style={{ float: 'right' }}
onClick={() => onRemove(option.value)}
onClick={onRemove(option.value)}
icon="cancel-1"
/>
</div>
Expand Down Expand Up @@ -80,7 +80,11 @@ class ModifiableSelect extends React.Component<Props, State> {
return <span>{selectedOption}</span>;
}

handleSave() {
handleSave(e) {
if (e.key !== 'Enter') {
return;
}

const { options, selectedOption } = this.state;
const { onChange } = this.props;
const value = (document.getElementById(
Expand Down Expand Up @@ -157,11 +161,7 @@ class ModifiableSelect extends React.Component<Props, State> {
<FormControl
id="removableSelect-value"
autoFocus={true}
onKeyPress={e => {
if (e.key === 'Enter') {
this.handleSave();
}
}}
onKeyPress={this.handleSave}
/>
</FormGroup>
<Button
Expand Down Expand Up @@ -205,7 +205,7 @@ class ModifiableSelect extends React.Component<Props, State> {
searchable={false}
value={selectedOption}
valueComponent={this.renderValue}
onChange={obj => this.setItem(obj)}
onChange={this.setItem}
options={this.generateOptions()}
optionComponent={Option}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/common/components/SortHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class SortHandler extends React.Component<IProps> {
icon="uparrow-2"
size={7}
isActive={this.checkSortActive(sortField, -1)}
onClick={() => this.sortHandler(sortField, -1)}
onClick={this.sortHandler.bind(this, sortField, -1)}
/>
<Icon
icon="downarrow"
size={7}
isActive={this.checkSortActive(sortField, 1)}
onClick={() => this.sortHandler(sortField, 1)}
onClick={this.sortHandler.bind(this, sortField, 1)}
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/common/components/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Uploader extends React.Component<Props, State> {
alt="attachment"
src="/images/attach.svg"
style={attachmentPreviewStyle}
onClick={e => this.removeAttachment(e)}
onClick={this.removeAttachment}
/>
))}
{loading && <Spinner />}
Expand Down
4 changes: 3 additions & 1 deletion src/modules/common/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ export class ErxesEditor extends React.Component<ErxesEditorProps> {
this.toggleInlineStyle = this.toggleInlineStyle.bind(this);
}

focus() {}
focus() {
return;
}

onTab(e) {
const { onChange, editorState } = this.props;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/common/components/filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Filter({ queryParams = {}, history }: IProps) {
}

return (
<Chip onClickClose={() => onClickClose([paramKey])}>
<Chip onClickClose={onClickClose.bind(null, [paramKey])}>
{bool ? paramKey : queryParams[paramKey]}
</Chip>
);
Expand All @@ -53,7 +53,7 @@ function Filter({ queryParams = {}, history }: IProps) {
const ChipText = createChipText(graphqlQuery, id);

return (
<Chip normal={true} onClickClose={() => onClickClose([paramKey])}>
<Chip normal={true} onClickClose={onClickClose.bind(null, [paramKey])}>
<ChipText />
</Chip>
);
Expand All @@ -67,7 +67,7 @@ function Filter({ queryParams = {}, history }: IProps) {
return (
<Chip
normal={true}
onClickClose={() => onClickClose(['startDate', 'endDate'])}
onClickClose={onClickClose.bind(null, ['startDate', 'endDate'])}
>
{queryParams.startDate} - {queryParams.endDate}
</Chip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ class FilterableList extends React.Component<Props, State> {
<li
key={item._id}
className={showCheckmark ? item.selectedBy : ''}
onClick={() => {
this.toggleItem(item._id);
}}
onClick={this.toggleItem.bind(this, item._id)}
>
{item.iconClass ? (
<i
Expand Down
8 changes: 5 additions & 3 deletions src/modules/common/components/form/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ class Textarea extends React.Component<Props> {
}
}

setArea({ area }) {
this.area = area;
}

render() {
const { maxHeight, ...props } = this.props;

return (
<TextArea
{...props}
innerRef={area => {
this.area = area;
}}
innerRef={this.setArea}
maxHeight={maxHeight}
onChange={this.onChange}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const PerPageChooser = ({ history }: IRouterProps) => {
const renderOption = n => {
return (
<Option>
<a onClick={() => onClick(n)}>{n}</a>
<a onClick={onClick.bind(null, n)}>{n}</a>
</Option>
);
};
Expand Down
Loading

0 comments on commit 8c82cb2

Please sign in to comment.