Skip to content

Commit

Permalink
[Backport 4.4-2.4-wzd] Disable unmapped fields filter (#5012)
Browse files Browse the repository at this point in the history
* Disable unmapped fields filter button

* change disable prop to isDisabled

* change disable prop to isDisabled

* Change disable prop to isDisabled for euiButtonIcons

* Change disable prop to isDisabled for euiButtonIcons

Co-authored-by: Antonio <[email protected]>
  • Loading branch information
asteriscos and Desvelao authored Dec 22, 2022
1 parent 3e47f71 commit d194aeb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed pagination to SCA table [#4653](https://github.com/wazuh/wazuh-kibana-app/issues/4653) [#5010](https://github.com/wazuh/wazuh-kibana-app/pull/5010)
- Fixed WAZUH_PROTOCOL param suggestion [#4849](https://github.com/wazuh/wazuh-kibana-app/pull/4849)
- Raspbian OS, Ubuntu, Amazon Linux and Amazon Linux 2 commands in the wizard deploy agent now change when a different architecture is selected [#4876](https://github.com/wazuh/wazuh-kibana-app/pull/4876) [#4880](https://github.com/wazuh/wazuh-kibana-app/pull/4880)
- Fixed agent installation command for macOS in the deploy new agent section. [#4968](https://github.com/wazuh/wazuh-kibana-app/pull/4968)
- Disabled unmapped fields filter in Security Events alerts table [#4929](https://github.com/wazuh/wazuh-kibana-app/pull/4929)
- Deploy new agent section: Fixed the way macos versions and architectures were displayed, fixed the way agents were displayed, fixed the way ubuntu versions were displayed. [#4933](https://github.com/wazuh/wazuh-kibana-app/pull/4933)
- Fixed agent deployment instructions for HP-UX and Solaris. [#4943](https://github.com/wazuh/wazuh-kibana-app/pull/4943)
- Fixed Inventory checks table filters by stats [#4999](https://github.com/wazuh/wazuh-kibana-app/pull/4999)
- Fixed vulnerabilities default last scan date formatter [#4975](https://github.com/wazuh/wazuh-kibana-app/pull/4975)
- Fixed agent deployment instructions for HP-UX and Solaris. [#4943](https://github.com/wazuh/wazuh-kibana-app/pull/4943)
- Fixed a bug that caused the flyouts to close when clicking inside them [#4638](https://github.com/wazuh/wazuh-kibana-app/pull/4638)
- Fixed the manager option in the agent deployment section [#4981](https://github.com/wazuh/wazuh-kibana-app/pull/4981)
- Fixed Inventory checks table filters by stats [#4999](https://github.com/wazuh/wazuh-kibana-app/pull/4999)
Expand Down
16 changes: 1 addition & 15 deletions public/components/common/modules/discover/discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,6 @@ export const Discover = compose(
this.indexPattern = {
...(await this.PluginPlatformServices.indexPatterns.get(AppState.getCurrentPattern())),
};
const fields: IFieldType[] = [];
Object.keys(this.indexPattern.fields).forEach((item) => {
if (isNaN(item)) {
fields.push(this.indexPattern.fields[item]);
} else if (
this.props.includeFilters &&
this.indexPattern.fields[item].name.includes(this.props.includeFilters)
) {
fields.unshift(this.indexPattern.fields[item]);
} else {
fields.push(this.indexPattern.fields[item]);
}
});
this.indexPattern.fields = fields;
}

hideCreateCustomLabel = () => {
Expand Down Expand Up @@ -713,7 +699,7 @@ export const Discover = compose(
}

openIntelligence(e, redirectTo, itemID) {
AppNavigate.navigateToModule(e, 'overview', { "tab": 'mitre', "tabView": "intelligence", "tabRedirect": redirectTo, "idToRedirect": itemID});
AppNavigate.navigateToModule(e, 'overview', { "tab": 'mitre', "tabView": "intelligence", "tabRedirect": redirectTo, "idToRedirect": itemID });
}

render() {
Expand Down
19 changes: 11 additions & 8 deletions public/components/common/modules/discover/row-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class RowDetails extends Component {
} else {
return 0;
};
})
})
.reduce((product, [key, value]) => {
let fullPath = addDelimiter(head, key)
return isObject(value) ?
Expand Down Expand Up @@ -175,6 +175,7 @@ export class RowDetails extends Component {
const tmpRows = itemPaths.map((item) => {
const key = isString(field) ? item : fieldsToShow[i] + "." + item; // = agent + . + id = agent.id
const value = isString(field) ? field : this.getChildFromPath(this.props.item[fieldsToShow[i]], item);
const hasFieldMapping = this.props?.indexPattern?.fields?.getByName(key)?.filterable;// if the field is mapped the filter can be added and removed
const filter = {};
filter[key] = value;
const cells: any[] = [];
Expand All @@ -185,8 +186,9 @@ export class RowDetails extends Component {
{(this.state.hover === key &&
<EuiFlexGroup style={{ height: 35 }}>
<EuiFlexItem grow={false} style={{ marginRight: 0, marginTop: 8 }}>
<EuiToolTip position="top" content={`Filter for value`}>
<EuiToolTip position="top" content={hasFieldMapping ? 'Filter for value' : 'Unindexed fields can not be searched'}>
<EuiButtonIcon
isDisabled={!hasFieldMapping}
onClick={() => this.props.addFilter(filter)}
iconType="magnifyWithPlus"
aria-label="Filter"
Expand All @@ -195,8 +197,9 @@ export class RowDetails extends Component {
</EuiToolTip>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ marginRight: 0, marginLeft: 0, marginTop: 8 }}>
<EuiToolTip position="top" content={`Filter out value`}>
<EuiToolTip position="top" content={hasFieldMapping ? 'Filter for value' : 'Unindexed fields can not be searched'}>
<EuiButtonIcon
isDisabled={!hasFieldMapping}
onClick={() => this.props.addFilterOut(filter)}
iconType="magnifyWithMinus"
aria-label="Filter"
Expand Down Expand Up @@ -229,7 +232,7 @@ export class RowDetails extends Component {
cells.push(keyCell);

const formattedValue = Array.isArray(value) ? this.renderArrayValue(value) : value.toString();

// If the field is an array of objects, show the collapse button to show the nested fields
const showCollapseButton = Array.isArray(value) && arrayContainsObjects(value);

Expand All @@ -244,7 +247,7 @@ export class RowDetails extends Component {
className={valueClassName}
style={{ borderTop: 0, borderBottom: 0, padding: 0, margin: 0 }}
key={key + "2"}>
{ showCollapseButton && (
{showCollapseButton && (
<DocViewTableRowBtnCollapse onClick={this.onToggleCollapse} isCollapsed={this.state.isCollapsed} />
)}
<div
Expand All @@ -271,7 +274,7 @@ export class RowDetails extends Component {
}); //map
rows = [...rows, ...tmpRows]
}//if
} //for
} //for


return rows;
Expand Down Expand Up @@ -440,7 +443,7 @@ export class RowDetails extends Component {
</ul>
);
} else {

return value.toString();
}
}
Expand Down Expand Up @@ -542,7 +545,7 @@ export class RowDetails extends Component {
extraAction={
<a href={`#/manager/rules?tab=rules&redirectRule=${id}`} target="_blank" style={{ paddingTop: 5 }}>
<EuiIcon type="popout" color='primary' />&nbsp;
View in Rules
View in Rules
</a>
}
paddingSize="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function DocViewTableRowBtnFilterAdd({ onClick, disabled = false }: Props
})}
className="kbnDocViewer__actionButton"
data-test-subj="addInclusiveFilterButton"
disabled={disabled}
isDisabled={disabled}
onClick={onClick}
iconType={'magnifyWithPlus'}
iconSize={'s'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function DocViewTableRowBtnFilterExists({
onClick={onClick}
className="kbnDocViewer__actionButton"
data-test-subj="addExistsFilterButton"
disabled={disabled}
isDisabled={disabled}
iconType={'indexOpen'}
iconSize={'s'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function DocViewTableRowBtnFilterRemove({ onClick, disabled = false }: Pr
})}
className="kbnDocViewer__actionButton"
data-test-subj="removeInclusiveFilterButton"
disabled={disabled}
isDisabled={disabled}
onClick={onClick}
iconType={'magnifyWithMinus'}
iconSize={'s'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function DocViewTableRowBtnToggleColumn({ onClick, active, disabled = fal
})}
className="kbnDocViewer__actionButton"
data-test-subj="toggleColumnButton"
disabled
isDisabled={disabled}
iconType={'tableOfContents'}
iconSize={'s'}
/>
Expand Down

0 comments on commit d194aeb

Please sign in to comment.