Skip to content

Commit dbc9c89

Browse files
author
NarrowsProjects
committed
chore: move the warning state to top-level model
1 parent 094a95c commit dbc9c89

29 files changed

Lines changed: 91 additions & 60 deletions

lib/public/Model.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,24 @@ export default class Model extends Observable {
101101
this.router.bubbleTo(this);
102102
registerFrontLinkListener((e) => this.router.handleLinkEvent(e));
103103

104+
// Setup warnings
105+
this._warnings = new Map();
106+
104107
// Models
105108

106109
this.home = new HomePageModel(this);
107110
this.home.bubbleTo(this);
108111

109-
this.lhcPeriods = new LhcPeriodsModel(this.router);
112+
this.lhcPeriods = new LhcPeriodsModel(this.router, this.warnings);
110113
this.lhcPeriods.bubbleTo(this);
111114

112-
this.dataPasses = new DataPassesModel(this.router);
115+
this.dataPasses = new DataPassesModel(this.router, this.warnings);
113116
this.dataPasses.bubbleTo(this);
114117

115118
this.qcFlags = new QcFlagsModel(this);
116119
this.qcFlags.bubbleTo(this);
117120

118-
this.simulationPasses = new SimulationPassesModel(this.router);
121+
this.simulationPasses = new SimulationPassesModel(this.router, this.warnings);
119122
this.simulationPasses.bubbleTo(this);
120123

121124
this.qcFlagTypes = new QcFlagTypesModel(this);
@@ -192,6 +195,14 @@ export default class Model extends Observable {
192195
this.dropdownMenu = false;
193196
}
194197

198+
/**
199+
* Returns warnings map
200+
* @returns {Map<string, string>} warnings map
201+
*/
202+
get warnings() {
203+
return this._warnings;
204+
}
205+
195206
/**
196207
* Delegates sub-model actions depending on new location of the page
197208
* @returns {vnode} The page to be loaded

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ export class FilteringModel extends Observable {
150150
const unknownFilters = [];
151151
const setFilterErrors = [];
152152

153-
for (const entry of Object.entries(filter)) {
154-
const [key, value] = entry;
155-
153+
for (const [key, value] of Object.entries(filter)) {
156154
if (key in this._filters) {
157155
try {
158156
this._filters[key].normalized = value;
159157
} catch {
160-
setFilterErrors.push(`${buildUrl('', entry).slice(1)}`);
158+
setFilterErrors.push(`${buildUrl('', { [key]: value }).slice(1)}`);
161159
}
162160
} else {
163161
unknownFilters.push(`'${key}'`);

lib/public/models/OverviewModel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ import { SortModel } from '../components/common/table/SortModel.js';
3535
export class OverviewPageModel extends Observable {
3636
/**
3737
* Constructor
38+
* @param {Map<string, string>} warnings a map storing warnings to show to the user
3839
*/
39-
constructor() {
40+
constructor(warnings) {
4041
super();
41-
this._warnings = new Map();
42+
this._warnings = warnings;
4243
this._sortModel = new SortModel();
4344
this._sortModel.observe(() => {
4445
this._pagination.silentlySetCurrentPage(1);

lib/public/views/DataPasses/DataPassesModel.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ export class DataPassesModel extends Observable {
2222
/**
2323
* The constructor of the model
2424
* @param {QueryRouter} router router that controls the application's page navigation
25+
* @param {Map<string, string>} warnings a map storing warnings to show to the user
2526
*/
26-
constructor(router) {
27+
constructor(router, warnings) {
2728
super();
2829

29-
this._perLhcPeriodOverviewModel = new DataPassesPerLhcPeriodOverviewModel(router, 'data-passes-per-lhc-period-overview');
30+
this._perLhcPeriodOverviewModel = new DataPassesPerLhcPeriodOverviewModel(router, 'data-passes-per-lhc-period-overview', warnings);
3031
this._perLhcPeriodOverviewModel.bubbleTo(this);
3132

32-
this._perSimulationPassOverviewModel = new DataPassesPerSimulationPassOverviewModel(router, 'data-passes-per-simulation-pass-overview');
33+
this._perSimulationPassOverviewModel =
34+
new DataPassesPerSimulationPassOverviewModel(router, 'data-passes-per-simulation-pass-overview', warnings);
3335
this._perSimulationPassOverviewModel.bubbleTo(this);
3436
}
3537

lib/public/views/DataPasses/DataPassesOverviewModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class DataPassesOverviewModel extends OverviewPageModel {
2525
* @param {QueryRouter} router router that controls the application's page navigation
2626
* @param {string} pageIdentifier string that indicates what page this model represents
2727
*/
28-
constructor(router, pageIdentifier) {
29-
super();
28+
constructor(router, pageIdentifier, warnings) {
29+
super(warnings);
3030
this._filteringModel = new FilteringModel(
3131
router,
3232
{

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ export class DataPassesPerLhcPeriodOverviewModel extends DataPassesOverviewModel
2121
* Constructor
2222
* @param {QueryRouter} router router that controls the application's page navigation
2323
* @param {string} pageIdentifier string that indicates what page this model represents
24+
* @param {Map<string, string>} warnings a map storing warnings to show to the user
2425
*/
25-
constructor(router, pageIdentifier) {
26-
super(router, pageIdentifier);
26+
constructor(router, pageIdentifier, warnings) {
27+
super(router, pageIdentifier, warnings);
2728
this._lhcPeriodId = null;
2829
}
2930

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ export class DataPassesPerSimulationPassOverviewModel extends DataPassesOverview
2323
* Constructor
2424
* @param {QueryRouter} router router that controls the application's page navigation
2525
* @param {string} pageIdentifier string that indicates what page this model represents
26+
* @param {Map<string, string>} warnings a map storing warnings to show to the user
2627
*/
27-
constructor(router, pageIdentifier) {
28-
super(router, pageIdentifier);
28+
constructor(router, pageIdentifier, warnings) {
29+
super(router, pageIdentifier, warnings);
2930
this._simulationPass = new ObservableData(RemoteData.notAsked());
3031
this._simulationPass.bubbleTo(this);
3132
}

lib/public/views/Environments/EnvironmentModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class EnvironmentModel extends Observable {
2929
super();
3030

3131
// Sub-models
32-
this._overviewModel = new EnvironmentOverviewModel(model, 'env-overview');
32+
this._overviewModel = new EnvironmentOverviewModel(model, 'env-overview', model.warnings);
3333
this._overviewModel.bubbleTo(this);
3434

3535
this._detailsModel = new EnvironmentDetailsModel();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ export class EnvironmentOverviewModel extends OverviewPageModel {
2929
* Constructor
3030
* @param {Model} model global model
3131
* @param {string} pageIdentifier string that indicates what page this model represents
32+
* @param {Map<string, string>} warnings a map storing warnings to show to the user
3233
*/
33-
constructor(model, pageIdentifier) {
34-
super();
34+
constructor(model, pageIdentifier, warnings) {
35+
super(warnings);
3536

3637
this._filteringModel = new FilteringModel(
3738
model.router,

lib/public/views/LhcFills/LhcFills.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class LhcFills extends Observable {
2929
this.model = model;
3030

3131
// Sub-models
32-
this._overviewModel = new LhcFillsOverviewModel(model.router, true, 'lhc-fill-overview');
32+
this._overviewModel = new LhcFillsOverviewModel(model.router, true, 'lhc-fill-overview', model.warnings);
3333
this._overviewModel.bubbleTo(this);
3434

3535
this._detailsModel = new LhcFillDetailsModel();

0 commit comments

Comments
 (0)