Skip to content

Commit b4e30b7

Browse files
authored
[O2B-1491] Add current status filtering for environments (#2031)
* Allow users to filter by an environment's current status now, including environments with an unknown status. * The user is prompted with a list of checkboxes to choose from
1 parent bf9d5f4 commit b4e30b7

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

lib/domain/enums/StatusAcronyms.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const statusAcronyms = Object.freeze({
1919
RUNNING: 'R',
2020
ERROR: 'E',
2121
DESTROYED: 'X',
22+
DONE: 'X',
2223
});
2324

2425
exports.statusAcronyms = statusAcronyms;

lib/public/domain/enums/statusAcronym.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const StatusAcronym = Object.freeze({
1818
CONFIGURED: 'C',
1919
RUNNING: 'R',
2020
ERROR: 'E',
21-
MIXED: 'M',
2221
DESTROYED: 'X',
2322
DONE: 'X',
2423
});

lib/public/views/Environments/ActiveColumns/environmentsActiveColumns.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { environmentStatusHistoryLegendComponent } from '../../../components/env
2424
import { infoTooltip } from '../../../components/common/popover/infoTooltip.js';
2525
import { aliEcsEnvironmentLinkComponent } from '../../../components/common/externalLinks/aliEcsEnvironmentLinkComponent.js';
2626
import { StatusAcronym } from '../../../domain/enums/statusAcronym.mjs';
27+
import { checkboxes } from '../../../components/Filters/common/filters/checkboxFilter.js';
2728
import { rawTextFilter } from '../../../components/Filters/common/filters/rawTextFilter.js';
2829

2930
/**
@@ -95,6 +96,14 @@ export const environmentsActiveColumns = {
9596
size: 'w-10',
9697
noEllipsis: true,
9798
format: (_, environment) => displayEnvironmentStatus(environment),
99+
100+
/**
101+
* Status filter component
102+
*
103+
* @param {EnvironmentOverviewModel} environmentOverviewModel the environment overview model
104+
* @return {Component} the filter component
105+
*/
106+
filter: (environmentOverviewModel) => checkboxes(environmentOverviewModel.filteringModel.get('currentStatus').selectionModel),
98107
},
99108
historyItems: {
100109
name: h('.flex-row.g2.items-center', ['Status History', infoTooltip(environmentStatusHistoryLegendComponent())]),

lib/public/views/Environments/Overview/EnvironmentOverviewModel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
import { buildUrl } from '/js/src/index.js';
1515
import { FilteringModel } from '../../../components/Filters/common/FilteringModel.js';
1616
import { OverviewPageModel } from '../../../models/OverviewModel.js';
17+
import { SelectionFilterModel } from '../../../components/Filters/common/filters/SelectionFilterModel.js';
1718
import { RawTextFilterModel } from '../../../components/Filters/common/filters/RawTextFilterModel.js';
1819
import { debounce } from '../../../utilities/debounce.js';
20+
import { coloredEnvironmentStatusComponent } from '../ColoredEnvironmentStatusComponent.js';
21+
import { StatusAcronym } from '../../../domain/enums/statusAcronym.mjs';
1922

2023
/**
2124
* Environment overview page model
@@ -29,6 +32,13 @@ export class EnvironmentOverviewModel extends OverviewPageModel {
2932
super();
3033

3134
this._filteringModel = new FilteringModel({
35+
currentStatus: new SelectionFilterModel({
36+
availableOptions: Object.keys(StatusAcronym).map((status) => ({
37+
value: status,
38+
label: coloredEnvironmentStatusComponent(status),
39+
rawLabel: status,
40+
})),
41+
}),
3242
ids: new RawTextFilterModel(),
3343
});
3444

test/public/envs/overview.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,35 @@ module.exports = () => {
294294
await page.waitForSelector(filterPanelSelector, { visible: true });
295295
});
296296

297+
it('should successfully filter environments by their current status', async () => {
298+
/**
299+
* Checks that all the rows of the given table have a valid current status
300+
*
301+
* @param {string[]} authorizedCurrentStatuses the list of valid current statuses
302+
* @return {void}
303+
*/
304+
const checkTableCurrentStatuses = async (authorizedCurrentStatuses) => {
305+
const rows = await page.$$('tbody tr');
306+
for (const row of rows) {
307+
expect(await row.evaluate((rowItem) => {
308+
const rowId = rowItem.id;
309+
return document.querySelector(`#${rowId}-status-text`).innerText;
310+
})).to.be.oneOf(authorizedCurrentStatuses);
311+
}
312+
};
313+
314+
const currentStatusSelectorPrefix = '.status-filter #checkboxes-checkbox-';
315+
const getCurrentStatusCheckboxSelector = (statusName) => `${currentStatusSelectorPrefix}${statusName}`;
316+
317+
await page.$eval(getCurrentStatusCheckboxSelector("RUNNING"), (element) => element.click());
318+
await waitForTableLength(page, 2);
319+
await checkTableCurrentStatuses(["RUNNING"]);
320+
321+
await page.$eval(getCurrentStatusCheckboxSelector("DEPLOYED"), (element) => element.click());
322+
await waitForTableLength(page, 3);
323+
await checkTableCurrentStatuses(["RUNNING", "DEPLOYED"]);
324+
});
325+
297326
it('should successfully filter environments by their IDs', async () => {
298327
/**
299328
* This is the sequence to test filtering the environments on IDs.

0 commit comments

Comments
 (0)