Skip to content

Commit d70dc96

Browse files
upcoming:[DI-24445] - Remove or condition when empty (linode#11967)
* upcoming:[DI-24445] - Remove or condition when empty * upcoming:[DI-24445] - PR comment * upcoming:[DI-24445] - Add changeset --------- Co-authored-by: venkatmano-akamai <[email protected]>
1 parent 2aa06af commit d70dc96

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Remove `or` condition in filtering of `/instances` call at CloudPulse Metrics ([#11967](https://github.com/linode/manager/pull/11967))

packages/manager/src/features/CloudPulse/Utils/FilterBuilder.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ it('test getResourceSelectionProperties method', () => {
142142
expect(handleResourcesSelection).toBeDefined();
143143
expect(savePreferences).toEqual(false);
144144
expect(disabled).toEqual(false);
145-
expect(JSON.stringify(xFilter)).toEqual(
146-
'{"+and":[{"region":"us-east"}],"+or":[]}'
147-
);
145+
expect(JSON.stringify(xFilter)).toEqual('{"+and":[{"region":"us-east"}]}');
148146
expect(label).toEqual(name);
149147
}
150148
});
@@ -176,7 +174,7 @@ it('test getResourceSelectionProperties method with disabled true', () => {
176174
expect(handleResourcesSelection).toBeDefined();
177175
expect(savePreferences).toEqual(false);
178176
expect(disabled).toEqual(true);
179-
expect(JSON.stringify(xFilter)).toEqual('{"+and":[],"+or":[]}');
177+
expect(JSON.stringify(xFilter)).toEqual('{"+and":[]}');
180178
expect(label).toEqual(name);
181179
}
182180
});
@@ -303,7 +301,7 @@ it('test buildXfilter method', () => {
303301

304302
result = buildXFilter(resourceSelectionConfig, {});
305303

306-
expect(JSON.stringify(result)).toEqual('{"+and":[],"+or":[]}');
304+
expect(JSON.stringify(result)).toEqual('{"+and":[]}');
307305
}
308306
});
309307

packages/manager/src/features/CloudPulse/Utils/FilterBuilder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,10 @@ export const buildXFilter = (
313313
}
314314
});
315315
}
316-
317-
return { '+and': filters, '+or': orCondition };
316+
if (orCondition.length) {
317+
return { '+and': filters, '+or': orCondition };
318+
}
319+
return { '+and': filters };
318320
};
319321

320322
/**

0 commit comments

Comments
 (0)