Skip to content

Commit

Permalink
Merge pull request #10 from Exabyte-io/update/SOF-6182
Browse files Browse the repository at this point in the history
SOF-6182: rename defaultFlowchartId to generateFlowChartId + lint fixes
  • Loading branch information
timurbazhirov committed Oct 10, 2022
2 parents 15e5bce + 24e8430 commit ae121c5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
"@babel/preset-react": "7.16.7",
"@babel/register": "^7.16.0",
"@babel/runtime-corejs3": "7.16.8",
"@exabyte-io/ade.js": "2022.9.2-0",
"@exabyte-io/ide.js": "2022.7.28-1",
"@exabyte-io/mode.js": "2022.8.31-0",
"@exabyte-io/code.js": "2022.9.2-0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"mixwith": "^0.1.1",
Expand Down
6 changes: 3 additions & 3 deletions src/units/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export class BaseUnit extends NamedDefaultableRepetitionRuntimeItemsImportantSet
...config,
status: config.status || UNIT_STATUSES.idle,
statusTrack: config.statusTrack || [],
flowchartId: config.flowchartId || BaseUnit.defaultFlowchartId(),
flowchartId: config.flowchartId || BaseUnit.generateFlowChartId(),
});
}

static defaultFlowchartId() {
static generateFlowChartId() {
return getUUID();
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export class BaseUnit extends NamedDefaultableRepetitionRuntimeItemsImportantSet

clone(extraContext) {
const flowchartIDOverrideConfigAsExtraContext = {
flowchartId: BaseUnit.defaultFlowchartId(),
flowchartId: BaseUnit.generateFlowChartId(),
...extraContext,
};
return super.clone(flowchartIDOverrideConfigAsExtraContext);
Expand Down
31 changes: 21 additions & 10 deletions src/units/builders/UnitConfigBuilder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from "underscore";
import { getUUID } from "@exabyte-io/code.js/dist/utils";

import _ from "underscore";

export class UnitConfigBuilder {
constructor({ name, type }) {
Expand All @@ -11,7 +10,7 @@ export class UnitConfigBuilder {
this._monitors = [];
this._preProcessors = [];
this._postProcessors = [];
this._flowchartId = this.constructor.defaultFlowchartId();
this._flowchartId = this.constructor.generateFlowChartId();
}

name(str) {
Expand All @@ -24,7 +23,7 @@ export class UnitConfigBuilder {
return this;
}

static defaultFlowchartId() {
static generateFlowChartId() {
return getUUID();
}

Expand All @@ -33,27 +32,39 @@ export class UnitConfigBuilder {
return this;
}

_stringArrayToNamedObject(array) {
return array.map(name => _.isString(name) ? {name} : name);
static _stringArrayToNamedObject(array) {
return array.map((name) => (_.isString(name) ? { name } : name));
}

addPreProcessors(preProcessorNames) {
this._preProcessors = _.union(this._stringArrayToNamedObject(preProcessorNames), this._preProcessors);
this._preProcessors = _.union(
this.constructor._stringArrayToNamedObject(preProcessorNames),
this._preProcessors,
);
return this;
}

addPostProcessors(postProcessorNames) {
this._postProcessors = _.union(this._stringArrayToNamedObject(postProcessorNames), this._postProcessors);
this._postProcessors = _.union(
this.constructor._stringArrayToNamedObject(postProcessorNames),
this._postProcessors,
);
return this;
}

addResults(resultNames) {
this._results = _.union(this._stringArrayToNamedObject(resultNames), this._results);
this._results = _.union(
this.constructor._stringArrayToNamedObject(resultNames),
this._results,
);
return this;
}

addMonitors(monitorNames) {
this._monitors = _.union(this._stringArrayToNamedObject(monitorNames), this._monitors);
this._monitors = _.union(
this.constructor._stringArrayToNamedObject(monitorNames),
this._monitors,
);
return this;
}

Expand Down

0 comments on commit ae121c5

Please sign in to comment.