Skip to content

Commit

Permalink
Fleet UI: Host filter styling/click bug fixes (#22147)
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelElysia committed Sep 17, 2024
1 parent 7e389d1 commit 0fe6b6c
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 85 deletions.
22 changes: 10 additions & 12 deletions frontend/components/forms/fields/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class Dropdown extends Component {
parseTarget: PropTypes.bool,
tooltip: PropTypes.string,
autoFocus: PropTypes.bool,
/** Includes styled filter icon */
tableFilterDropdown: PropTypes.bool,
/** Includes styled icon */
iconName: PropTypes.string,
helpText: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
Expand All @@ -71,7 +71,7 @@ class Dropdown extends Component {
parseTarget: false,
tooltip: "",
autoFocus: false,
tableFilterDropdown: false,
iconName: "",
};

onMenuOpen = () => {
Expand Down Expand Up @@ -155,16 +155,16 @@ class Dropdown extends Component {
);
};

// Adds styled filter icon to dropdown
renderCustomTableFilter = () => {
const { options, value } = this.props;
// Adds styled icon to dropdown
renderWithIcon = () => {
const { options, value, iconName } = this.props;
const customLabel = options
.filter((option) => option.value === value)
.map((option) => option.label);

return (
<div className={`${baseClass}__custom-value`}>
<Icon name="filter" className={`${baseClass}__icon`} />
<Icon name={iconName} className={`${baseClass}__icon`} />
<div className={`${baseClass}__custom-value-label`}>{customLabel}</div>
</div>
);
Expand All @@ -177,7 +177,7 @@ class Dropdown extends Component {
onMenuOpen,
onMenuClose,
renderCustomDropdownArrow,
renderCustomTableFilter,
renderWithIcon,
} = this;
const {
error,
Expand All @@ -192,7 +192,7 @@ class Dropdown extends Component {
wrapperClassName,
searchable,
autoFocus,
tableFilterDropdown,
iconName,
} = this.props;

const formFieldProps = pick(this.props, [
Expand Down Expand Up @@ -230,9 +230,7 @@ class Dropdown extends Component {
onClose={onMenuClose}
autoFocus={autoFocus}
arrowRenderer={renderCustomDropdownArrow}
valueComponent={
tableFilterDropdown ? renderCustomTableFilter : undefined
}
valueComponent={iconName ? renderWithIcon : undefined}
/>
</FormField>
);
Expand Down
1 change: 0 additions & 1 deletion frontend/components/forms/fields/Dropdown/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
}

&-label {
width: 105px;
line-height: 38px;
font-size: $small;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const SoftwareTable = ({
options={SOFTWARE_TITLES_DROPDOWN_OPTIONS}
searchable={false}
onChange={handleCustomFilterDropdownChange}
tableFilterDropdown
iconName="filter"
/>
)}
<Slider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const SoftwareVulnerabilitiesTable = ({
options={getExploitedVulnerabilitiesDropdownOptions(isPremiumTier)}
searchable={false}
onChange={handleExploitedVulnFilterDropdownChange}
tableFilterDropdown
iconName="filter"
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ const ManageHostsPage = ({
options={getHostSelectStatuses(isSandboxMode)}
searchable={false}
onChange={handleStatusDropdownChange}
tableFilterDropdown
iconName="filter"
/>
<LabelFilterSelect
className={`${baseClass}__label-filter-dropdown`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ const HostsFilterBlock = ({
className={`${baseClass}__macsettings-dropdown`}
options={OS_SETTINGS_FILTER_OPTIONS}
onChange={onChangeMacSettingsFilter}
searchable={false}
iconName="filter-alt"
/>
<FilterPill
label={label}
Expand Down Expand Up @@ -414,6 +416,8 @@ const HostsFilterBlock = ({
className={`${baseClass}__os_settings-dropdown`}
options={OS_SETTINGS_FILTER_OPTIONS}
onChange={onChangeOsSettingsFilter}
searchable={false}
iconName="filter-alt"
/>
<FilterPill
label={label}
Expand Down Expand Up @@ -472,7 +476,9 @@ const HostsFilterBlock = ({
value={softwareStatus}
className={`${baseClass}__sw-install-status-dropdown`}
options={OPTIONS}
searchable={false}
onChange={onChangeSoftwareInstallStatusFilter}
iconName="filter-alt"
/>
{renderSoftwareFilterBlock([HOSTS_QUERY_PARAMS.SOFTWARE_STATUS])}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,23 @@
// and other "form-fields" in the filter block
width: initial;
}
}

// NOTE: Look more into this styling
&__os_settings-dropdown,
&__macsettings-dropdown,
&__sw-install-status-dropdown {
.Select-value {
// Vertically centers icon and text
.Select-multi-value-wrapper {
display: flex;
align-items: center;
position: initial !important;
line-height: initial !important;

&::before {
position: relative;
content: url(../assets/images/[email protected]);
transform: scale(0.5);
top: 1px;
}
}

.Select-input {
display: none !important;
}

.Select {
box-sizing: initial;
}

.Select-control {
height: 36px;
}
}

&__os_settings-dropdown,
&__macsettings-dropdown,
&__sw-install-status-dropdown {
.dropdown__select {
border: 1px solid #e2e4ea;
}

.Select-multi-value-wrapper {
width: 150px; // Fits all dropdown options without resizing
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ const PoliciesFilter = ({
const value = policyResponse;

return (
<div className={`${baseClass}__policies-block`}>
<div className={baseClass}>
<Dropdown
value={value}
className={`${baseClass}__status_dropdown`}
options={POLICY_RESPONSE_OPTIONS}
searchable={false}
onChange={onChange}
iconName="filter-alt"
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
.policies-filter {
display: flex;
justify-content: flex-start;
align-items: center;

&__status_dropdown {
width: 114px;

.Select-menu-outer {
width: 114px;
max-height: 310px;

.Select-menu {
max-height: none;

.dropdown__option {
font-size: $small !important;
}
}
}
.Select-value {
padding-left: $pad-medium;
padding-right: $pad-medium;

&::before {
display: inline-block;
position: absolute;
padding: 5px 0 0 0; // centers spin
content: url(../assets/images/[email protected]);
transform: scale(0.5);
width: 16px;
height: 26px;
left: 2px;
}
}
.Select-value-label {
padding-left: $pad-large;
font-size: $small !important;
}
.Select-multi-value-wrapper {
width: 91px; // Fits all dropdown options without resizing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const HostSoftwareTable = ({
options={DROPDOWN_OPTIONS}
searchable={false}
onChange={handleFilterDropdownChange}
tableFilterDropdown
iconName="filter"
/>
);
}, [handleFilterDropdownChange, hostSoftwareFilter]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const AddPolicyModal = ({
options={PLATFORM_FILTER_OPTIONS}
searchable={false}
onChange={onPlatformFilterChange}
tableFilterDropdown
iconName="filter"
/>
<div className={`${baseClass}__policy-selection`}>
{filteredPoliciesCount > 0 ? filteredPoliciesList : renderNoResults()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const QueriesTable = ({
options={PLATFORM_FILTER_OPTIONS}
searchable={false}
onChange={handlePlatformFilterDropdownChange}
tableFilterDropdown
iconName="filter"
/>
);
}, [platform, queryParams, router]);
Expand Down

0 comments on commit 0fe6b6c

Please sign in to comment.