Skip to content

Commit 744e1a7

Browse files
committed
Support for new pipeline format
1 parent 2fc16d4 commit 744e1a7

3 files changed

Lines changed: 12 additions & 22 deletions

File tree

src/main/resources/static/js/pages/editor/Editor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
createSource,
66
createWidget,
77
loadSources,
8-
saveSources,
98
} from "./utils/editorActions.js";
109
import { debounce } from "../../shared/modules/utils.js";
1110
import {
@@ -30,7 +29,7 @@ export default class Editor {
3029
this.initGrid();
3130

3231
// Load existing data
33-
loadSources(config.sources || []);
32+
loadSources(config.sources || [], config.generators || []);
3433
state.grid.load(config.widgets || []);
3534

3635
// Replace whitespaces in the id with dashes
@@ -133,7 +132,8 @@ export default class Editor {
133132
const pipelines = await getPipelines();
134133
const config = {
135134
id: id,
136-
sources: saveSources(),
135+
sources: state.sources,
136+
generators: state.generators,
137137
widgets: state.grid.save(false),
138138
};
139139

src/main/resources/static/js/pages/editor/controller/SourceController.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class SourceController {
1414
this.item = item;
1515
}
1616

17-
init() {
17+
init(generators) {
1818
const buttons = this.root.querySelectorAll("button");
1919
const options = this.root.querySelector(".dv-dropdown-menu");
2020
const body = this.root.querySelector(".dv-source-card-body");
@@ -26,10 +26,13 @@ export default class SourceController {
2626
);
2727

2828
// Load existing generators
29-
for (const config of this.item.createsGenerators) {
29+
for (const config of [
30+
...(this.item.createsGenerators || []),
31+
...generators,
32+
]) {
3033
this.appendGenerator(body, config);
3134
}
32-
this.item.createsGenerators = [];
35+
delete this.item.createsGenerators;
3336

3437
// Append available generator options
3538
Object.values(configs).forEach((Generator) => {

src/main/resources/static/js/pages/editor/utils/editorActions.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,17 @@ import WidgetController from "../controller/WidgetController.js";
44
import SourceController from "../controller/SourceController.js";
55
import GeneratorController from "../controller/GeneratorController.js";
66

7-
export function loadSources(configs) {
7+
export function loadSources(sources, generators) {
88
const container = document.querySelector(".dv-sources-container");
99

10-
for (const config of configs) {
10+
for (const config of sources) {
1111
const controller = createSource(config);
1212

1313
container.prepend(controller.root);
14-
controller.init();
14+
controller.init(generators);
1515
}
1616
}
1717

18-
export function saveSources() {
19-
const sources = structuredClone(state.sources);
20-
21-
for (const generator of state.generators) {
22-
const { source: id, ...rest } = generator;
23-
const source = sources.find((item) => item.id === id);
24-
25-
source.createsGenerators.push(rest);
26-
}
27-
28-
return sources;
29-
}
30-
3118
export function createSource(config) {
3219
const source = deepClone(config);
3320
source.id = source.id || randomId("Source");

0 commit comments

Comments
 (0)