Skip to content

Commit

Permalink
Merge pull request #1468 from deepfence/ui-v2-search-only-k8-enable-n…
Browse files Browse the repository at this point in the history
…odes-host

search hosts that are available for clusters only for pods table
  • Loading branch information
milan-deepfence authored Aug 24, 2023
2 parents f693c1a + cfcaca0 commit fa352b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type SearchableHostListProps = {
valueKey?: 'nodeId' | 'hostName' | 'nodeName';
active?: boolean;
agentRunning?: boolean;
showOnlyKubernetesHosts?: boolean;
triggerVariant?: 'select' | 'button';
helperText?: string;
color?: 'error' | 'default';
Expand All @@ -28,6 +29,7 @@ const SearchableHost = ({
valueKey = 'nodeId',
active,
agentRunning = true,
showOnlyKubernetesHosts,
triggerVariant,
helperText,
color,
Expand All @@ -54,6 +56,7 @@ const SearchableHost = ({
searchText,
active,
agentRunning,
showOnlyKubernetesHosts,
order: {
sortBy: 'host_name',
descending: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function Filters() {
</Combobox>
<SearchableHostList
valueKey="hostName"
showOnlyKubernetesHosts
scanType={ScanTypeEnum.VulnerabilityScan}
defaultSelectedHosts={searchParams.getAll('hosts')}
onClearAll={() => {
Expand Down
12 changes: 11 additions & 1 deletion deepfence_frontend/apps/dashboard/src/queries/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const searchQueries = createQueryKeys('search', {
size: number;
active?: boolean;
agentRunning?: boolean;
showOnlyKubernetesHosts?: boolean;
order?: {
sortBy: string;
descending: boolean;
Expand All @@ -38,7 +39,8 @@ export const searchQueries = createQueryKeys('search', {
nodeName: string;
}[];
}> => {
const { searchText, size, active, agentRunning, order } = filters;
const { searchText, size, active, agentRunning, showOnlyKubernetesHosts, order } =
filters;
const searchSearchNodeReq: SearchSearchNodeReq = {
node_filter: {
filters: {
Expand All @@ -48,6 +50,9 @@ export const searchQueries = createQueryKeys('search', {
...(active && { active: [active === true] }),
},
},
not_contains_filter: {
filter_in: {},
},
order_filter: {
order_fields: [
{
Expand Down Expand Up @@ -88,6 +93,11 @@ export const searchQueries = createQueryKeys('search', {
'agent_running'
] = [agentRunning];
}
if (showOnlyKubernetesHosts) {
searchSearchNodeReq.node_filter.filters.not_contains_filter!.filter_in![
'kubernetes_cluster_id'
] = [''];
}
const searchHostsApi = apiWrapper({
fn: getSearchApiClient().searchHosts,
});
Expand Down

0 comments on commit fa352b8

Please sign in to comment.