Skip to content

Commit

Permalink
Clean events
Browse files Browse the repository at this point in the history
  • Loading branch information
dlabrecq committed Jun 5, 2023
1 parent faa59da commit 79dd5d3
Show file tree
Hide file tree
Showing 61 changed files with 192 additions and 218 deletions.
4 changes: 2 additions & 2 deletions src/components/drawers/exports/exportActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ExportsActionsBase extends React.Component<ExportsActionsProps, ExportsAct
});
};

public handleOnToggle = (event: React.MouseEvent<HTMLButtonElement>, isDropdownOpen: boolean) => {
public handleOnToggle = (isDropdownOpen: boolean) => {
this.setState({ isDropdownOpen });
};

Expand All @@ -61,7 +61,7 @@ class ExportsActionsBase extends React.Component<ExportsActionsProps, ExportsAct
<>
<Dropdown
onSelect={this.handleOnSelect}
toggle={<KebabToggle onToggle={this.handleOnToggle} />}
toggle={<KebabToggle onToggle={(_evt, isOpen) => this.handleOnToggle(isOpen)} />}
isOpen={isDropdownOpen}
isPlain
position="right"
Expand Down
6 changes: 3 additions & 3 deletions src/routes/components/dataTable/dataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class DataTable extends React.Component<DataTableProps, any> {
};
};

private handleOnSelect = (event, isSelected, rowId) => {
private handleOnSelect = (isSelected, rowId) => {
const { onSelected, rows } = this.props;

let newRows;
Expand All @@ -113,7 +113,7 @@ class DataTable extends React.Component<DataTableProps, any> {
});
};

private handleOnSort = (event, index, direction) => {
private handleOnSort = (index, direction) => {
const { columns, onSort } = this.props;

if (onSort) {
Expand Down Expand Up @@ -171,7 +171,7 @@ class DataTable extends React.Component<DataTableProps, any> {
select={{
isDisabled: row.selectionDisabled, // Disable select for "no-project"
isSelected: row.selected,
onSelect: (_event, isSelected) => this.handleOnSelect(_event, isSelected, rowIndex),
onSelect: (_evt, isSelected) => this.handleOnSelect(isSelected, rowIndex),
rowIndex,
}}
style={item.style}
Expand Down
10 changes: 5 additions & 5 deletions src/routes/components/dataTable/selectableTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface SelectableTableOwnProps {
filterBy: any;
isLoading?: boolean;
onSort(value: string, isSortAscending: boolean);
onRowClick(event: React.KeyboardEvent | React.MouseEvent, rowIndex: number);
onRowClick(rowIndex: number);
orderBy: any;
rows?: any[];
}
Expand Down Expand Up @@ -90,7 +90,7 @@ class SelectableTable extends React.Component<SelectableTableProps, any> {
};
};

private handleOnSort = (event, index, direction) => {
private handleOnSort = (index, direction) => {
const { columns, onSort } = this.props;

if (onSort) {
Expand All @@ -100,15 +100,15 @@ class SelectableTable extends React.Component<SelectableTableProps, any> {
}
};

private handleOnRowClick = (event, rowIndex) => {
private handleOnRowClick = (rowIndex: number) => {
const { onRowClick, rows } = this.props;

rows.map(row => (row.selected = false));
rows[rowIndex].selected = true;

this.setState({ rows }, () => {
if (onRowClick) {
onRowClick(event, rowIndex);
onRowClick(rowIndex);
}
});
};
Expand Down Expand Up @@ -155,7 +155,7 @@ class SelectableTable extends React.Component<SelectableTableProps, any> {
isSelectable
isClickable
isRowSelected={row.selected}
onRowClick={_event => this.handleOnRowClick(_event, rowIndex)}
onRowClick={_evt => this.handleOnRowClick(rowIndex)}
key={`row-${rowIndex}`}
>
{row.cells.map((item, cellIndex) =>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/components/dataToolbar/basicToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class BasicToolbarBase extends React.Component<BasicToolbarProps, BasicTo
});
}

private handleOnCategorySelect = (event, selection: CategoryOption) => {
private handleOnCategorySelect = (selection: CategoryOption) => {
this.setState({
categoryInput: '',
currentCategory: selection.value,
Expand Down Expand Up @@ -213,7 +213,7 @@ export class BasicToolbarBase extends React.Component<BasicToolbarProps, BasicTo
});
};

private handleOnCategoryInputChange = (event: React.FormEvent<HTMLInputElement>, value: string) => {
private handleOnCategoryInputChange = (value: string) => {
const val = cleanInput(value);
this.setState({ categoryInput: val });
};
Expand Down
4 changes: 2 additions & 2 deletions src/routes/components/dataToolbar/costCategoryValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CostCategoryValueBase extends React.Component<CostCategoryValueProps, Cost
return options;
}

private onCostCategoryValueChange = (event: React.FormEvent<HTMLInputElement>, value: string) => {
private onCostCategoryValueChange = (value: string) => {
const { onCostCategoryValueInputChange } = this.props;

this.setState({ costCategoryKeyValueInput: value }, () => {
Expand Down Expand Up @@ -154,7 +154,7 @@ class CostCategoryValueBase extends React.Component<CostCategoryValueProps, Cost
id="tag-key-value-input"
type="search"
aria-label={intl.formatMessage(messages.filterByCostCategoryValueAriaLabel)}
onChange={this.onCostCategoryValueChange}
onChange={(_evt, value) => this.onCostCategoryValueChange(value)}
value={costCategoryKeyValue}
placeholder={intl.formatMessage(messages.filterByValuePlaceholder)}
onKeyDown={evt => onCostCategoryValueInput(evt)}
Expand Down
12 changes: 6 additions & 6 deletions src/routes/components/dataToolbar/dataToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class DataToolbarBase extends React.Component<DataToolbarProps, DataToolb
});
}

private handleOnCategorySelect = (event, selection: CategoryOption) => {
private handleOnCategorySelect = (selection: CategoryOption) => {
this.setState({
categoryInput: '',
currentCategory: selection.value,
Expand Down Expand Up @@ -272,7 +272,7 @@ export class DataToolbarBase extends React.Component<DataToolbarProps, DataToolb
});
};

private handleOnCategoryInputChange = (event: React.FormEvent<HTMLInputElement>, value: string) => {
private handleOnCategoryInputChange = (value: string) => {
const val = cleanInput(value);
this.setState({ categoryInput: val });
};
Expand Down Expand Up @@ -382,7 +382,7 @@ export class DataToolbarBase extends React.Component<DataToolbarProps, DataToolb
});
};

private handleOnCostCategoryKeySelect = (event, selection) => {
private handleOnCostCategoryKeySelect = selection => {
this.setState({
currentCostCategoryKey: selection,
isCostCategoryKeySelectExpanded: !this.state.isCostCategoryKeySelectExpanded,
Expand Down Expand Up @@ -491,7 +491,7 @@ export class DataToolbarBase extends React.Component<DataToolbarProps, DataToolb
});
}

private handleOnExcludeSelect = (event, selection: ExcludeOption) => {
private handleOnExcludeSelect = (selection: ExcludeOption) => {
this.setState({
currentExclude: selection.value,
isExcludeSelectOpen: !this.state.isExcludeSelectOpen,
Expand Down Expand Up @@ -582,7 +582,7 @@ export class DataToolbarBase extends React.Component<DataToolbarProps, DataToolb
});
};

private handleOnTagKeySelect = (event, selection) => {
private handleOnTagKeySelect = selection => {
this.setState({
currentTagKey: selection,
isTagKeySelectExpanded: !this.state.isTagKeySelectExpanded,
Expand Down Expand Up @@ -725,7 +725,7 @@ export class DataToolbarBase extends React.Component<DataToolbarProps, DataToolb
});
};

private handlePlatformCostsChanged = (event: React.FormEvent<HTMLInputElement>, checked: boolean) => {
private handlePlatformCostsChanged = (checked: boolean) => {
const { onPlatformCostsChanged } = this.props;
const { isPlatformCostsChecked } = this.state;
this.setState({ isPlatformCostsChecked: !isPlatformCostsChecked }, () => {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/components/dataToolbar/tagValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TagValueBase extends React.Component<TagValueProps, TagValueState> {
return options;
}

private onTagValueChange = (event: React.FormEvent<HTMLInputElement>, value: string) => {
private onTagValueChange = (value: string) => {
const { onTagValueInputChange } = this.props;

this.setState({ tagKeyValueInput: value }, () => {
Expand Down Expand Up @@ -153,7 +153,7 @@ class TagValueBase extends React.Component<TagValueProps, TagValueState> {
id="tag-key-value-input"
type="search"
aria-label={intl.formatMessage(messages.filterByTagValueAriaLabel)}
onChange={this.onTagValueChange}
onChange={(_evt, value) => this.onTagValueChange(value)}
value={tagKeyValue}
placeholder={intl.formatMessage(messages.filterByValuePlaceholder)}
onKeyDown={evt => onTagValueInput(evt)}
Expand Down
8 changes: 4 additions & 4 deletions src/routes/components/dataToolbar/utils/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const getPlatformCosts = ({
isDisabled,
isPlatformCostsChecked,
}: {
handlePlatformCostsChanged?: (event: React.FormEvent<HTMLInputElement>, checked: boolean) => void;
handlePlatformCostsChanged?: (checked: boolean) => void;
isDisabled?: boolean;
isPlatformCostsChecked?: boolean;
}) => {
Expand All @@ -70,7 +70,7 @@ export const getPlatformCosts = ({
label={intl.formatMessage(messages.sumPlatformCosts)}
isChecked={isPlatformCostsChecked}
isDisabled={isDisabled}
onChange={handlePlatformCostsChanged}
onChange={(_evt, checked) => handlePlatformCostsChanged(checked)}
/>
</ToolbarItem>
);
Expand All @@ -86,7 +86,7 @@ export const getKebab = ({
showPlatformCosts,
}: {
handleColumnManagementClicked?: () => void;
handlePlatformCostsChanged?: (event: React.FormEvent<HTMLInputElement>, checked: boolean) => void;
handlePlatformCostsChanged?: (checked: boolean) => void;
isPlatformCostsChecked?: boolean;
showColumnManagement?: boolean;
showPlatformCosts?: boolean;
Expand All @@ -101,7 +101,7 @@ export const getKebab = ({
if (showPlatformCosts) {
options.push({
label: messages.sumPlatformCosts,
onClick: (event: React.FormEvent<HTMLInputElement>) => handlePlatformCostsChanged(event, !isPlatformCostsChecked),
onClick: (_evt, _checked) => handlePlatformCostsChanged(!isPlatformCostsChecked),
});
}
return (
Expand Down
4 changes: 2 additions & 2 deletions src/routes/components/dataToolbar/utils/bulkSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getBulkSelect = ({
}: {
handleOnBulkSelect?: () => void;
handleOnBulkSelectClicked?: (action: string) => void;
handleOnBulkSelectToggle?: (event: React.MouseEvent<HTMLButtonElement>, isOpen: boolean) => void;
handleOnBulkSelectToggle?: (isOpen: boolean) => void;
isAllSelected?: boolean;
isBulkSelectDisabled?: boolean;
isBulkSelectOpen?: boolean;
Expand Down Expand Up @@ -72,7 +72,7 @@ export const getBulkSelect = ({
}}
/>,
]}
onToggle={handleOnBulkSelectToggle}
onToggle={(_evt, isOpen) => handleOnBulkSelectToggle(isOpen)}
>
{numSelected !== 0 && (
<React.Fragment>{intl.formatMessage(messages.selected, { value: numSelected })}</React.Fragment>
Expand Down
12 changes: 6 additions & 6 deletions src/routes/components/dataToolbar/utils/category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const getCategoryInput = ({
currentCategory?: string;
filters?: Filters;
handleOnCategoryInput?: (event, key: string) => void;
handleOnCategoryInputChange?: (event: React.FormEvent<HTMLInputElement>, value: string) => void;
handleOnCategoryInputChange?: (value: string) => void;
handleOnCategoryInputSelect?: (value: string, key: string) => void;
handleOnDelete?: (type: any, chip: any) => void;
handleOnWorkloadTypeSelect?: (event, selection: string) => void;
Expand Down Expand Up @@ -96,7 +96,7 @@ export const getCategoryInput = ({
id={`category-input-${categoryOption.key}`}
type="search"
aria-label={intl.formatMessage(messages.filterByInputAriaLabel, { value: categoryOption.key })}
onChange={handleOnCategoryInputChange}
onChange={(_evt, value) => handleOnCategoryInputChange(value)}
value={categoryInput}
placeholder={intl.formatMessage(messages.filterByPlaceholder, { value: categoryOption.key })}
onKeyDown={evt => handleOnCategoryInput(evt, categoryOption.key)}
Expand Down Expand Up @@ -239,8 +239,8 @@ export const getCategorySelect = ({
currentCategory?: string;
isDisabled?: boolean;
filters?: Filters;
handleOnCategorySelect?: (event: React.MouseEvent, selection: CategoryOption) => void;
handleOnCategoryToggle?: (event: React.MouseEvent, isOpen: boolean) => void;
handleOnCategorySelect?: (selection: CategoryOption) => void;
handleOnCategoryToggle?: (isOpen: boolean) => void;
isCategorySelectOpen?: boolean;
}) => {
if (!categoryOptions) {
Expand All @@ -256,8 +256,8 @@ export const getCategorySelect = ({
id="category-select"
isDisabled={isDisabled && !hasFilters(filters)}
isOpen={isCategorySelectOpen}
onSelect={handleOnCategorySelect}
onToggle={handleOnCategoryToggle}
onSelect={(_evt, value) => handleOnCategorySelect(value)}
onToggle={(_evt, isExpanded) => handleOnCategoryToggle(isExpanded)}
selections={selection}
toggleIcon={<FilterIcon />}
variant={SelectVariant.single}
Expand Down
9 changes: 5 additions & 4 deletions src/routes/components/dataToolbar/utils/costCategory.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ToolbarChipGroup } from '@patternfly/react-core';
import { ToolbarFilter, ToolbarItem } from '@patternfly/react-core';
import type { SelectOptionObject } from '@patternfly/react-core/deprecated';
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core/deprecated';
import type { Resource } from 'api/resources/resource';
import type { ResourcePathsType } from 'api/resources/resource';
Expand Down Expand Up @@ -31,8 +32,8 @@ export const getCostCategoryKeySelect = ({
currentCostCategoryKey?: string;
filters?: Filters;
handleOnCostCategoryKeyClear?: () => void;
handleOnCostCategoryKeySelect?: (event: React.MouseEvent, selection) => void;
handleOnCostCategoryKeyToggle?: (event: React.MouseEvent, isOpen: boolean) => void;
handleOnCostCategoryKeySelect?: (selection: SelectOptionObject) => void;
handleOnCostCategoryKeyToggle?: (isOpen: boolean) => void;
isCostCategoryKeySelectExpanded?: boolean;
isDisabled?: boolean;
resourceReport?: Resource;
Expand All @@ -52,8 +53,8 @@ export const getCostCategoryKeySelect = ({
variant={SelectVariant.typeahead}
typeAheadAriaLabel={intl.formatMessage(messages.filterByCostCategoryKeyAriaLabel)}
onClear={handleOnCostCategoryKeyClear}
onToggle={handleOnCostCategoryKeyToggle}
onSelect={handleOnCostCategoryKeySelect}
onToggle={(_evt, isExpanded) => handleOnCostCategoryKeyToggle(isExpanded)}
onSelect={(_evt, value) => handleOnCostCategoryKeySelect(value)}
isOpen={isCostCategoryKeySelectExpanded}
placeholderText={intl.formatMessage(messages.chooseKeyPlaceholder)}
selections={currentCostCategoryKey}
Expand Down
8 changes: 4 additions & 4 deletions src/routes/components/dataToolbar/utils/exclude.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const getExcludeSelect = ({
}: {
currentExclude?: string;
filters?: Filters;
handleOnExcludeSelect: (event: React.MouseEvent, selection: ExcludeOption) => void;
handleOnExcludeToggle: (event: React.MouseEvent, isOpen: boolean) => void;
handleOnExcludeSelect: (selection: ExcludeOption) => void;
handleOnExcludeToggle: (isOpen: boolean) => void;
isDisabled?: boolean;
isExcludeSelectOpen?: boolean;
}) => {
Expand All @@ -45,8 +45,8 @@ export const getExcludeSelect = ({
id="exclude-select"
isDisabled={isDisabled && !hasFilters(filters)}
isOpen={isExcludeSelectOpen}
onSelect={handleOnExcludeSelect}
onToggle={handleOnExcludeToggle}
onSelect={(_evt, value) => handleOnExcludeSelect(value)}
onToggle={(_evt, isExpanded) => handleOnExcludeToggle(isExpanded)}
selections={selection}
variant={SelectVariant.single}
>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/components/dataToolbar/utils/orgUntits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getOrgUnitSelect = ({
filters?: Filters;
handleOnDelete?: (type: any, chip: any) => void;
handleOnOrgUnitSelect?: (event: React.MouseEvent, selection: string) => void;
handleOnOrgUnitToggle?: (event: React.MouseEvent, isOpen: boolean) => void;
handleOnOrgUnitToggle?: (isOpen: boolean) => void;
isDisabled?: boolean;
isOrgUnitSelectExpanded?: boolean;
orgReport: Org;
Expand Down Expand Up @@ -80,7 +80,7 @@ export const getOrgUnitSelect = ({
className="selectOverride"
variant={SelectVariant.checkbox}
aria-label={intl.formatMessage(messages.filterByOrgUnitAriaLabel)}
onToggle={handleOnOrgUnitToggle}
onToggle={(_evt, isExpanded) => handleOnOrgUnitToggle(isExpanded)}
onSelect={handleOnOrgUnitSelect}
selections={selections}
isOpen={isOrgUnitSelectExpanded}
Expand Down
9 changes: 5 additions & 4 deletions src/routes/components/dataToolbar/utils/tags.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ToolbarChipGroup } from '@patternfly/react-core';
import { ToolbarFilter, ToolbarItem } from '@patternfly/react-core';
import type { SelectOptionObject } from '@patternfly/react-core/deprecated';
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core/deprecated';
import type { Tag } from 'api/tags/tag';
import type { TagPathsType } from 'api/tags/tag';
Expand Down Expand Up @@ -29,8 +30,8 @@ export const getTagKeySelect = ({
currentTagKey?: string;
filters?: Filters;
handleOnTagKeyClear?: () => void;
handleOnTagKeySelect?: (event: React.MouseEvent, selection) => void;
handleOnTagKeyToggle?: (event: React.MouseEvent, isOpen: boolean) => void;
handleOnTagKeySelect?: (value: SelectOptionObject) => void;
handleOnTagKeyToggle?: (isOpen: boolean) => void;
isDisabled?: boolean;
isTagKeySelectExpanded?: boolean;
tagReport?: Tag;
Expand All @@ -50,8 +51,8 @@ export const getTagKeySelect = ({
variant={SelectVariant.typeahead}
typeAheadAriaLabel={intl.formatMessage(messages.filterByTagKeyAriaLabel)}
onClear={handleOnTagKeyClear}
onToggle={handleOnTagKeyToggle}
onSelect={handleOnTagKeySelect}
onToggle={(_evt, isExpanded) => handleOnTagKeyToggle(isExpanded)}
onSelect={(_evt, value) => handleOnTagKeySelect(value)}
isOpen={isTagKeySelectExpanded}
placeholderText={intl.formatMessage(messages.chooseKeyPlaceholder)}
selections={currentTagKey}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/components/optimizations/optimizationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class OptimizationsTableBase extends React.Component<OptimizationsTableProps, Op
});
};

private handleOnRowClick = (event: React.KeyboardEvent | React.MouseEvent, rowIndex: number) => {
private handleOnRowClick = (rowIndex: number) => {
const { closeOptimizationsDrawer, isOpen, openOptimizationsDrawer } = this.props;
const { currentRow, rows } = this.state;

Expand Down
Loading

0 comments on commit 79dd5d3

Please sign in to comment.