blob: 2f38f3496e4b9b2a2e6818e9a56e61327649d810 [file] [log] [blame]
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02001import Feature from '../common/architecture/features/Feature';
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02002import ScriptFilterListProvider from '../common/architecture/scripts/ScriptFilterListProvider';
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +02003import ExtraInfoFeature from './extraInfo/extraInfo.feature';
Adrià Vilanova Martínezc78c3ad2024-05-18 00:35:51 +02004import WorkflowsFeature from './workflows/workflows.feature';
Adrià Vilanova61f782f2024-05-31 22:57:24 +00005import LoadDraftsFeature from './loadDrafts/loadDrafts.feature';
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02006
7export type ConcreteFeatureClass = { new (): Feature };
8
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02009export default class Features extends ScriptFilterListProvider {
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +020010 private features: ConcreteFeatureClass[] = [
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +020011 ExtraInfoFeature,
Adrià Vilanova61f782f2024-05-31 22:57:24 +000012 LoadDraftsFeature,
Adrià Vilanova Martínezc78c3ad2024-05-18 00:35:51 +020013 WorkflowsFeature,
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +020014 ];
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020015 private initializedFeatures: Feature[];
16
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020017 protected getUnfilteredScriptsList() {
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020018 const features = this.getFeatures();
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020019 return features.map((feature) => feature.getScripts()).flat(1);
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020020 }
21
22 private getFeatures() {
23 if (this.initializedFeatures === undefined) {
24 this.initializedFeatures = this.features.map((feature) => new feature());
25 }
26 return this.initializedFeatures;
27 }
28}