Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/build-and-push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,13 @@ jobs:
max-parallel: 8 # Higher parallelism for native builds
env:
DOCKER_REGISTRY: ${{ needs.set-parameters.outputs.docker_registry }}
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8

steps:
- name: Checkout Texera
uses: actions/checkout@v7
with:
ref: ${{ needs.set-parameters.outputs.branch }}

- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17

- name: Setup sbt launcher
uses: sbt/setup-sbt@67d461eba2c4753196c230e02da850757ba4775e # v1.5.14

- uses: coursier/cache-action@95e5b1029b6b86e7bac033ee44a0697d8a527d2d # v8.1.1
with:
extraSbtFiles: '["*.sbt", "project/**.{scala,sbt}", "project/build.properties" ]'

- name: Download JOOQ generated code
uses: actions/download-artifact@v8
with:
Expand Down Expand Up @@ -421,28 +406,13 @@ jobs:
max-parallel: 4 # Lower for QEMU builds
env:
DOCKER_REGISTRY: ${{ needs.set-parameters.outputs.docker_registry }}
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8

steps:
- name: Checkout Texera
uses: actions/checkout@v7
with:
ref: ${{ needs.set-parameters.outputs.branch }}

- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17

- name: Setup sbt launcher
uses: sbt/setup-sbt@67d461eba2c4753196c230e02da850757ba4775e # v1.5.14

- uses: coursier/cache-action@95e5b1029b6b86e7bac033ee44a0697d8a527d2d # v8.1.1
with:
extraSbtFiles: '["*.sbt", "project/**.{scala,sbt}", "project/build.properties" ]'

- name: Download JOOQ generated code
uses: actions/download-artifact@v8
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
[nzBodyStyle]="{padding: '3px'}"
class="list-item-card"
[class.selected]="entry.checked"
[class.has-button-group]="isPrivateSearch"
[class.editing-description]="editingDescription">
[class.has-button-group]="isPrivateSearch">
<div
(mouseenter)="hovering = true"
(mouseleave)="hovering = false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
min-height: 65px;
height: auto;

&.editing-description {
z-index: 10;
}

&:hover {
background-color: #f0f0f0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ describe("ListItemComponent", () => {

expect(workflowPersistService.updateWorkflowDescription).toHaveBeenCalledWith(1, newDescription);
expect(component.entry.description).toBe(newDescription);
expect(component.editingDescription).toBe(false);
});

it("should handle error when updating workflow description", () => {
Expand All @@ -162,7 +161,6 @@ describe("ListItemComponent", () => {

expect(workflowPersistService.updateWorkflowDescription).toHaveBeenCalledWith(1, newDescription);
expect(component.entry.description).toBe("Old Description");
expect(component.editingDescription).toBe(false);
});

describe("Form View toggle", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ export class ListItemComponent implements OnChanges {
public canShare: boolean = false;
@Input() currentUid: number | undefined;
@ViewChild("nameInput") nameInput!: ElementRef;
@ViewChild("descriptionInput") descriptionInput!: ElementRef;
editingName = false;
editingDescription = false;
renderedDescription = "";

likeCount: number = 0;
Expand Down Expand Up @@ -328,8 +326,6 @@ export class ListItemComponent implements OnChanges {
private setEditingState(propertyName: "name" | "description", state: boolean): void {
if (propertyName === "name") {
this.editingName = state;
} else if (propertyName === "description") {
this.editingDescription = state;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { HttpClientTestingModule, HttpTestingController } from "@angular/common/
import { firstValueFrom } from "rxjs";
import { take, toArray } from "rxjs/operators";

import { WORKFLOW_VERSIONS_API_BASE_URL, WorkflowVersionService } from "./workflow-version.service";
import { WorkflowVersionService } from "./workflow-version.service";
import { WorkflowActionService } from "../../../../workspace/service/workflow-graph/model/workflow-action.service";
import { WorkflowPersistService } from "../../../../common/service/workflow-persist/workflow-persist.service";
import { UndoRedoService } from "../../../../workspace/service/undo-redo/undo-redo.service";
Expand Down Expand Up @@ -203,14 +203,6 @@ describe("WorkflowVersionService", () => {
});
});

// ─── displayWorkflowVersions ──────────────────────────────────────────────

it("displayWorkflowVersions unhighlights whatever is currently highlighted", () => {
service.displayWorkflowVersions();
expect(highlightedSpy.getCurrentHighlights).toHaveBeenCalled();
expect(highlightedSpy.unhighlightElements).toHaveBeenCalledWith(["a", "b"]);
});

// ─── displayReadonlyWorkflow ──────────────────────────────────────────────

describe("displayReadonlyWorkflow", () => {
Expand Down Expand Up @@ -524,15 +516,15 @@ describe("WorkflowVersionService", () => {
it("retrieveVersionsOfWorkflow GETs /version/{wid}", async () => {
const entries: WorkflowVersionEntry[] = [{ vId: 1, creationTime: 0, content: "{}", importance: false }];
const pending = firstValueFrom(service.retrieveVersionsOfWorkflow(42));
const req = http.expectOne(`${API}/${WORKFLOW_VERSIONS_API_BASE_URL}/42`);
const req = http.expectOne(`${API}/version/42`);
expect(req.request.method).toBe("GET");
req.flush(entries);
expect(await pending).toEqual(entries);
});

it("retrieveWorkflowByVersion parses a string `content` into an object", async () => {
const pending = firstValueFrom(service.retrieveWorkflowByVersion(42, 7));
const req = http.expectOne(`${API}/${WORKFLOW_VERSIONS_API_BASE_URL}/42/7`);
const req = http.expectOne(`${API}/version/42/7`);
expect(req.request.method).toBe("GET");
req.flush({
...buildWorkflow(),
Expand All @@ -551,15 +543,15 @@ describe("WorkflowVersionService", () => {
next: () => (nextCalled = true),
complete: () => (completed = true),
});
http.expectOne(`${API}/${WORKFLOW_VERSIONS_API_BASE_URL}/42/7`).flush(null);
http.expectOne(`${API}/version/42/7`).flush(null);
expect(nextCalled).toBe(false);
expect(completed).toBe(true);
});

it("cloneWorkflowVersion POSTs to /version/clone/{vid} with the displayed id", async () => {
service.setDisplayParticularVersion(true, 11, 12);
const pending = firstValueFrom(service.cloneWorkflowVersion());
const req = http.expectOne(`${API}/${WORKFLOW_VERSIONS_API_BASE_URL}/clone/11`);
const req = http.expectOne(`${API}/version/clone/11`);
expect(req.request.method).toBe("POST");
expect(req.request.body).toEqual({ displayedVersionId: 12 });
req.flush(99);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,20 @@ import { Workflow, WorkflowContent } from "../../../../common/type/workflow";
import { WorkflowPersistService } from "../../../../common/service/workflow-persist/workflow-persist.service";
import { UndoRedoService } from "../../../../workspace/service/undo-redo/undo-redo.service";
import { isEqual } from "lodash";
import { OperatorLink, OperatorPredicate, Point } from "../../../../workspace/types/workflow-common.interface";
import { OperatorPredicate } from "../../../../workspace/types/workflow-common.interface";
import { WorkflowVersionEntry } from "../../../type/workflow-version-entry";
import { AppSettings } from "../../../../common/app-setting";
import { filter, map } from "rxjs/operators";
import { WorkflowUtilService } from "../../../../workspace/service/workflow-graph/util/workflow-util.service";

import { HttpClient } from "@angular/common/http";

export const WORKFLOW_VERSIONS_API_BASE_URL = "version";
const WORKFLOW_VERSIONS_API_BASE_URL = "version";

type WorkflowContentKeys = keyof WorkflowContent;
type Element = OperatorLink | OperatorPredicate | Point;
type DifferentOpIDsList = {
[key in "modified" | "added" | "deleted"]: string[];
};

// only element types specified in this list are consider when calculating the difference between workflows
const ELEMENT_TYPES_IN_WORKFLOW_DIFF_CALC: Partial<WorkflowContentKeys>[] = ["operators"];
// it maps a name of the element type to its ID field name used in WorkflowContent
const ID_FILED_FOR_ELEMENTS_CONFIG: { [key: string]: string } = {
operators: "operatorID",
commentBoxes: "commentBoxID",
};

@Injectable({
providedIn: "root",
})
Expand All @@ -66,11 +56,6 @@ export class WorkflowVersionService {
private http: HttpClient
) {}

public displayWorkflowVersions(): void {
// unhighlight all the current highlighted operators and links
const elements = this.workflowActionService.getJointGraphWrapper().getCurrentHighlights();
this.workflowActionService.getJointGraphWrapper().unhighlightElements(elements);
}
public setDisplayParticularVersion(flag: boolean, versionId?: number, displayedVersionId?: number): void {
if (flag) {
if (versionId != undefined) {
Expand Down Expand Up @@ -126,15 +111,19 @@ export class WorkflowVersionService {
differentOpIDsList.modified.map(id => this.highlightOpBoundary(id, "255,118,20,0.5"));
differentOpIDsList.added.map(id => this.highlightOpBoundary(id, "0,255,0,0.5"));

this.updateDeletedLinkBrackets(differentOpIDsList, "255,0,0,0.5");
}

private updateDeletedLinkBrackets(differentOpIDsList: DifferentOpIDsList, color: string) {
if (differentOpIDsList.deleted.length > 0) {
const tempWorkflow = this.workflowActionService.getTempWorkflow();
if (tempWorkflow != undefined) {
for (const link of tempWorkflow.content.links) {
if (differentOpIDsList.deleted.includes(link.source.operatorID) && link.target.operatorID != undefined) {
this.highlightOpBracket(link.target.operatorID, "255,0,0,0.5", "left-");
this.highlightOpBracket(link.target.operatorID, color, "left-");
}
if (differentOpIDsList.deleted.includes(link.target.operatorID) && link.source.operatorID != undefined) {
this.highlightOpBracket(link.source.operatorID, "255,0,0,0.5", "right-");
this.highlightOpBracket(link.source.operatorID, color, "right-");
}
}
}
Expand All @@ -157,60 +146,35 @@ export class WorkflowVersionService {
.attr("path." + position + "boundary/stroke", "rgba(" + color + ")");
}

// TODO: the logic of the function will be refined later
public getWorkflowsDifference(workflowContent1: WorkflowContent, workflowContent2: WorkflowContent) {
let eleType;
this.operatorPropertyDiff = {};
const difference: DifferentOpIDsList = { added: [], modified: [], deleted: [] };
// get a list of element types that are changed between versions
const eleTypeWithDiffList: WorkflowContentKeys[] = [];
for (eleType of ELEMENT_TYPES_IN_WORKFLOW_DIFF_CALC) {
if (!isEqual(workflowContent1[eleType], workflowContent2[eleType])) {
eleTypeWithDiffList.push(eleType);
}
if (isEqual(workflowContent1.operators, workflowContent2.operators)) {
return difference;
}

for (eleType of eleTypeWithDiffList) {
if (ELEMENT_TYPES_IN_WORKFLOW_DIFF_CALC.includes(eleType)) {
let eleID;
// return an object with key: ID of the element, value: detailed content of the element
let getEleIDMap = function (workflowContent: WorkflowContent, eleType: WorkflowContentKeys) {
const elements = workflowContent[eleType] as Element[];
const eleIDtoContentMap: { [key: string]: Element } = {};
for (const element of elements) {
eleIDtoContentMap[element[ID_FILED_FOR_ELEMENTS_CONFIG[eleType] as keyof Element]] = element;
}
return eleIDtoContentMap;
};

const eleIDtoContentMap1 = getEleIDMap(workflowContent1, eleType);
const eleIDtoContentMap2 = getEleIDMap(workflowContent2, eleType);

for (eleID of Object.keys(eleIDtoContentMap2)) {
if (!Object.keys(eleIDtoContentMap1).includes(eleID)) {
// there is an addition if the element ID exist in historical but not current workflow version
difference.added.push(eleID);
} else {
// there might be a modification if the element ID exist in both historical and current workflow versions
if (!isEqual(eleIDtoContentMap1[eleID], eleIDtoContentMap2[eleID])) {
// if the contents in two workflow versions are different for the same element ID
difference.modified.push(eleID);
if (eleType == "operators") {
this.operatorPropertyDiff[eleID] = this.getOperatorsDifference(
eleIDtoContentMap1[eleID] as OperatorPredicate,
eleIDtoContentMap2[eleID] as OperatorPredicate
);
}
}
}
}
const operatorsById = (workflow: WorkflowContent): Record<string, OperatorPredicate> => {
const operators: Record<string, OperatorPredicate> = {};
for (const operator of workflow.operators) {
operators[operator.operatorID] = operator;
}
return operators;
};

const firstById = operatorsById(workflowContent1);
const secondById = operatorsById(workflowContent2);
for (const id of Object.keys(secondById)) {
if (!Object.hasOwn(firstById, id)) {
difference.added.push(id);
} else if (!isEqual(firstById[id], secondById[id])) {
difference.modified.push(id);
this.operatorPropertyDiff[id] = this.getOperatorsDifference(firstById[id], secondById[id]);
}
}

for (eleID of Object.keys(eleIDtoContentMap1)) {
if (!Object.keys(eleIDtoContentMap2).includes(eleID)) {
// there is a deletion if the element ID exist in current but not historical workflow version
difference.deleted.push(eleID);
}
}
for (const id of Object.keys(firstById)) {
if (!Object.hasOwn(secondById, id)) {
difference.deleted.push(id);
}
}
return difference;
Expand Down Expand Up @@ -293,19 +257,7 @@ export class WorkflowVersionService {
this.highlightOpBoundary(id, "0,0,0,0");
}

if (differentOpIDsList.deleted.length > 0) {
const tempWorkflow = this.workflowActionService.getTempWorkflow();
if (tempWorkflow != undefined) {
for (const link of tempWorkflow.content.links) {
if (differentOpIDsList.deleted.includes(link.source.operatorID) && link.target.operatorID != undefined) {
this.highlightOpBracket(link.target.operatorID, "0,0,0,0", "left-");
}
if (differentOpIDsList.deleted.includes(link.target.operatorID) && link.source.operatorID != undefined) {
this.highlightOpBracket(link.source.operatorID, "0,0,0,0", "right-");
}
}
}
}
this.updateDeletedLinkBrackets(differentOpIDsList, "0,0,0,0");
this.operatorPropertyDiff = {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,9 @@ export class VersionsListComponent implements OnInit {
if (this.versionsList == undefined) {
return;
}
if (!$event) {
while (++index < this.versionsList.length && !this.versionsList[index].importance) {
this.versionsList[index].expand = false;
}
} else {
while (++index < this.versionsList.length && !this.versionsList[index].importance) {
this.versionsList[index].expand = true;
}
const expand = !!$event;
while (++index < this.versionsList.length && !this.versionsList[index].importance) {
this.versionsList[index].expand = expand;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1216,14 +1216,6 @@ describe("MenuComponent", () => {
});

describe("version history", () => {
it("onClickGetAllVersions delegates to workflowVersionService.displayWorkflowVersions", () => {
const displaySpy = vi.spyOn(workflowVersionService, "displayWorkflowVersions").mockImplementation(() => {});

component.onClickGetAllVersions();

expect(displaySpy).toHaveBeenCalledTimes(1);
});

it("closeParticularVersionDisplay delegates to workflowVersionService", () => {
const closeSpy = vi.spyOn(workflowVersionService, "closeParticularVersionDisplay").mockImplementation(() => {});

Expand Down
4 changes: 0 additions & 4 deletions frontend/src/app/workspace/component/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1067,10 +1067,6 @@ export class MenuComponent implements OnInit, OnDestroy {
});
}

onClickGetAllVersions() {
this.workflowVersionService.displayWorkflowVersions();
}

private handleWorkflowVersionDisplay(): void {
this.workflowVersionService
.getDisplayParticularVersionStream()
Expand Down
Loading
Loading