Skip to content

Commit

Permalink
filter target nodes for agent field
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Aug 29, 2024
1 parent 10ed2f3 commit b4a87b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/app/Shared/Redux/Filters/TopologyFilterSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface TopologyFilters {
targetFilters: {
category: string;
filters: {
Agent: boolean[];
Agent: string[];
Alias: string[];
ConnectionUrl: string[];
JvmId: string[];
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Shared/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const isTargetNodeFiltered = ({ target }: TargetNode, filters?: TopologyF
}
let matched = true;
if (filters.Agent && filters.Agent.length) {
matched = matched && filters.Agent.includes(target.agent);
matched = matched && filters.Agent.includes(target.agent.toString());
}
if (filters.Alias && filters.Alias.length) {
matched = matched && filters.Alias.includes(target.alias);
Expand Down
20 changes: 5 additions & 15 deletions src/app/Topology/Toolbar/TopologyFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,10 @@ export const TopologyFilter: React.FC<{ isDisabled?: boolean }> = ({ isDisabled,
value={{
toString: () => opt,
compareTo: (other) => {
let otherString;
if (typeof other === 'string') {
otherString = other;
} else if (typeof other === 'boolean') {
otherString ? 'true' : 'false';
} else if (isKeyValue(other)) {
otherString = keyValueToString(other);
} else {
otherString = `${other}`;
}

const regex = new RegExp(otherString, 'i');
const regex = new RegExp(
typeof other === 'string' ? other : isKeyValue(other) ? keyValueToString(other) : `${other}`,
'i',
);
return regex.test(opt);
},
...{
Expand Down Expand Up @@ -370,9 +362,7 @@ export const fieldValueToStrings = (value: unknown): string[] => {
if (value === undefined || value === null) {
return [];
}
if (typeof value === 'boolean') {
return [value ? 'true' : 'false'];
} else if (typeof value === 'object') {
if (typeof value === 'object') {
if (Array.isArray(value)) {
if (value.length > 0 && typeof value[0] === 'object') {
if (isKeyValue(value[0])) {
Expand Down

0 comments on commit b4a87b2

Please sign in to comment.