Skip to content

Commit 58b9eef

Browse files
author
NarrowsProjects
committed
feat: make the warnings removable
1 parent 6c86a23 commit 58b9eef

18 files changed

Lines changed: 58 additions & 36 deletions

File tree

lib/public/components/Filters/common/FilteringModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ export class FilteringModel extends Observable {
161161
}
162162

163163
if (unknownFilters.length) {
164-
this._warnings['Unknown Filters'] = unknownFilters.join(', ');
164+
this._warnings.set('Unknown Filters', unknownFilters.join(', '));
165165
} else {
166-
delete this._warnings['Unknown Filters'];
166+
this._warnings.delete('Unknown Filters');
167167
}
168168
if (notify) {
169169
this.notify();
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
import { h } from '/js/src/index.js';
2+
import { iconX } from '/js/src/icons.js';
23

34
/**
45
* Component to display whenever a page has warnings.
56
*
6-
* @param {Array<(string, string)>} warnings an array of warnings and messages
7+
* @param {OverviewPageModel} overviewModel model that controlls an overview page
78
* @returns {Component} the warning componen
89
*/
9-
export const warningComponent = (warnings) => {
10-
if (!warnings.length) {
10+
export const warningComponent = (overviewModel) => {
11+
const { warnings } = overviewModel;
12+
13+
if (!warnings.size) {
1114
return null;
1215
}
1316

14-
return h('details.alert alert-warning', [
17+
return h('details.alert.alert-warning', [
1518
h('summary', 'Warnings'),
16-
h('ul', warnings.map(([key, message]) => h('li', `${key}: ${message}`))),
19+
h('ul', warnings.entries().toArray().map(([key, message]) =>
20+
h('li.flex-row.items-center', [
21+
h(
22+
'.btn.btn-pill.alert-warning.mh1',
23+
{
24+
onclick: () => {
25+
warnings.delete(key);
26+
overviewModel.notify();
27+
},
28+
},
29+
iconX(),
30+
),
31+
h('strong.mh1', `${key}:`),
32+
h('span', message),
33+
]))),
1734
]);
1835
};

lib/public/models/OverviewModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,6 @@ export class OverviewPageModel extends Observable {
257257
* @return {object} the warning model
258258
*/
259259
get warnings() {
260-
return this._warnings.entries().toArray();
260+
return this._warnings;
261261
}
262262
}

lib/public/views/DataPasses/PerLhcPeriodOverview/DataPassesPerLhcPeriodOverviewPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ const getRowClasses = ({ versions }) => {
4343
* @returns {Component} The overview screen
4444
*/
4545
export const DataPassesPerLhcPeriodOverviewPage = ({ dataPasses: { perLhcPeriodOverviewModel: dataPassesPerLhcPeriodOverviewModel } }) => {
46-
const { filteringModel, warnings, sortModel, pagination, items } = dataPassesPerLhcPeriodOverviewModel;
46+
const { filteringModel, sortModel, pagination, items } = dataPassesPerLhcPeriodOverviewModel;
4747

4848
pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT));
4949

5050
return h('', {
5151
onremove: () => dataPassesPerLhcPeriodOverviewModel.reset(),
5252
}, [
5353
h('.flex-row.header-container.pv2', filtersPanelPopover(filteringModel, dataPassesActiveColumns)),
54-
warningComponent(warnings),
54+
warningComponent(dataPassesPerLhcPeriodOverviewModel),
5555
h('.w-100.flex-column', [
5656
table(items, dataPassesActiveColumns, { classes: getRowClasses }, null, { sort: sortModel }),
5757
paginationComponent(pagination),

lib/public/views/DataPasses/PerSimulationPassOverview/DataPassesPerSimulationPassOverviewPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const getRowClasses = ({ versions }) => {
4747
*/
4848
export const DataPassesPerSimulationPassOverviewPage = ({ dataPasses: {
4949
perSimulationPassOverviewModel: dataPassesPerSimulationPassOverviewModel } }) => {
50-
const { items, simulationPass, pagination, warnings, filteringModel, sortModel } = dataPassesPerSimulationPassOverviewModel;
50+
const { items, simulationPass, pagination, filteringModel, sortModel } = dataPassesPerSimulationPassOverviewModel;
5151

5252
pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT));
5353

@@ -68,7 +68,7 @@ export const DataPassesPerSimulationPassOverviewPage = ({ dataPasses: {
6868
}),
6969
),
7070
]),
71-
warningComponent(warnings),
71+
warningComponent(dataPassesPerSimulationPassOverviewModel),
7272
h('.w-100.flex-column', [
7373
table(items, dataPassesActiveColumns, { classes: getRowClasses }, null, { sort: sortModel }),
7474
paginationComponent(pagination),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const PAGE_USED_HEIGHT = 181;
2929
* @returns {Object} Html page
3030
*/
3131
export const environmentOverviewComponent = (envsOverviewModel) => {
32-
const { pagination, environments, warnings } = envsOverviewModel;
32+
const { pagination, environments } = envsOverviewModel;
3333

3434
pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT));
3535

@@ -38,7 +38,7 @@ export const environmentOverviewComponent = (envsOverviewModel) => {
3838
'.flex-row.header-container.g2.pv2',
3939
filtersPanelPopover(envsOverviewModel, environmentsActiveColumns),
4040
),
41-
warningComponent(warnings),
41+
warningComponent(envsOverviewModel),
4242
h('.w-100.flex-column', [
4343
h('.header-container.pv2'),
4444
table(environments, environmentsActiveColumns, { classes: 'table-sm' }),

lib/public/views/LhcFills/Overview/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export const Index = (model) => h('', {
4242
* @returns {Object} Html page
4343
*/
4444
const showLhcFillsTable = (lhcFillsOverviewModel) => {
45-
const { items, pagination, filteringModel, warnings } = lhcFillsOverviewModel;
45+
const { items, pagination, filteringModel } = lhcFillsOverviewModel;
4646
pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT, 1));
4747

4848
return [
4949
h('.flex-row.header-container.g2.pv2', [
5050
filtersPanelPopover(lhcFillsOverviewModel, lhcFillsActiveColumns),
5151
toggleFilter(filteringModel.get('hasStableBeams'), 'STABLE BEAM ONLY'),
5252
]),
53-
warningComponent(warnings),
53+
warningComponent(lhcFillsOverviewModel),
5454
h('.w-100.flex-column', [
5555
table(items, lhcFillsActiveColumns, null, { tableClasses: '.table-sm' }),
5656
paginationComponent(pagination),

lib/public/views/Logs/Overview/LogsOverviewModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class LogsOverviewModel extends Observable {
191191
* @return {object} the warning model
192192
*/
193193
get warnings() {
194-
return Object.entries(this._warnings);
194+
return this._warnings;
195195
}
196196

197197
/**

lib/public/views/Logs/Overview/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const PAGE_USED_HEIGHT = 215;
3131
* @return {Component} Returns a vnode with the table containing the logs
3232
*/
3333
const logOverviewScreen = ({ logs: { overviewModel: logsOverviewModel } }) => {
34-
const { pagination, filteringModel, logs, overviewSortModel, warnings } = logsOverviewModel;
34+
const { pagination, filteringModel, logs, overviewSortModel } = logsOverviewModel;
3535

3636
pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT));
3737

@@ -43,7 +43,7 @@ const logOverviewScreen = ({ logs: { overviewModel: logsOverviewModel } }) => {
4343
]),
4444
actionButtons(),
4545
]),
46-
warningComponent(warnings),
46+
warningComponent(logsOverviewModel),
4747
h('.w-100.flex-column', [
4848
table(logs, logsActiveColumns, null, null, { sort: overviewSortModel }),
4949
paginationComponent(pagination),

lib/public/views/QcFlagTypes/Overview/QcFlagTypesOverviewPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const PAGE_USED_HEIGHT = 215;
3131
* @return {Component} The overview page
3232
*/
3333
export const QcFlagTypesOverviewPage = ({ qcFlagTypes: { overviewModel } }) => {
34-
const { items: qcFlagTypes, pagination, warnings, sortModel } = overviewModel;
34+
const { items: qcFlagTypes, pagination, sortModel } = overviewModel;
3535

3636
pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT));
3737

@@ -48,7 +48,7 @@ export const QcFlagTypesOverviewPage = ({ qcFlagTypes: { overviewModel } }) => {
4848
}),
4949
],
5050
]),
51-
warningComponent(warnings),
51+
warningComponent(overviewModel),
5252
h('.flex-column.w-100', [
5353
table(qcFlagTypes, qcFlagTypesActiveColumns, { classes: '.table-sm' }, null, { sort: sortModel }),
5454
paginationComponent(pagination),

0 commit comments

Comments
 (0)