Skip to content

Commit

Permalink
restrict to run's detectors
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Aug 8, 2024
1 parent 50d613f commit 71c949e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/public/components/detector/PhysicalDetectorPickerModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ export const detectorToOption = ({ id, name }) => ({
export class PhysicalDetectorPickerModel extends PickerModel {
/**
* Constructor
* @param {Detector[]} defaultDetectors default detectors
* @param {object} [configuration] options altering model's behavior
* @param {Detector[]} [configuration.defaultDetectors] default detectors
* @param {string[]} [configuration.allowedDetectorsNames] allowed detectors names
*/
constructor(defaultDetectors) {
constructor({ defaultDetectors, allowedDetectorsNames } = {}) {
super({ multiple: true, availableOptions: RemoteData.loading(), defaultSelection: defaultDetectors.map(detectorToOption) });

Check warning on line 42 in lib/public/components/detector/PhysicalDetectorPickerModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/detector/PhysicalDetectorPickerModel.js#L41-L42

Added lines #L41 - L42 were not covered by tests

/**
Expand All @@ -45,7 +47,9 @@ export class PhysicalDetectorPickerModel extends PickerModel {
*/
const updateOptions = () => {
this.setAvailableOptions(detectorsProvider.physical$.getCurrent().apply({
Success: (detectors) => detectors.map(detectorToOption),
Success: (detectors) => detectors
.filter(({ name }) => !allowedDetectorsNames || allowedDetectorsNames.includes(name))

Check warning on line 51 in lib/public/components/detector/PhysicalDetectorPickerModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/detector/PhysicalDetectorPickerModel.js#L48-L51

Added lines #L48 - L51 were not covered by tests
.map(detectorToOption),
}));
};

Expand Down
15 changes: 12 additions & 3 deletions lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,25 @@ export class GaqFlagsOverviewModel extends OverviewPageModel {
*/
async load() {
await this._fetchGaqDetectors();
await this._fetchRun();

Check warning on line 68 in lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js#L67-L68

Added lines #L67 - L68 were not covered by tests

this._gaqDetectors$.getCurrent().match({
Success: (currentDetectors) => {
this._gaqDetectorPickerModel = new PhysicalDetectorPickerModel(currentDetectors);
this._gaqDetectorPickerModel.bubbleTo(this);
this._run$.getCurrent().match({
Success: ({ detectors }) => {
this._gaqDetectorPickerModel = new PhysicalDetectorPickerModel({

Check warning on line 74 in lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js#L70-L74

Added lines #L70 - L74 were not covered by tests
defaultDetectors: currentDetectors,
allowedDetectorsNames: detectors.split(','),
});
this._gaqDetectorPickerModel.bubbleTo(this);

Check warning on line 78 in lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js#L78

Added line #L78 was not covered by tests
},
Other: () => {},

Check warning on line 80 in lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js#L80

Added line #L80 was not covered by tests
});
},
Other: () => {},

Check warning on line 83 in lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/QcFlags/GaqFlags/GaqFlagsOverviewModel.js#L83

Added line #L83 was not covered by tests
});

this._fetchDataPass();
this._fetchRun();
super.load();
}

Expand Down

0 comments on commit 71c949e

Please sign in to comment.