Skip to content

Commit

Permalink
Merge branch 'master' of github.com:inmanta/web-console into issue/60…
Browse files Browse the repository at this point in the history
…59-error-message-extraction
  • Loading branch information
matborowczyk committed Jan 21, 2025
2 parents 40dcb68 + 3a92c61 commit 36c2781
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelogs/unreleased/6154-autolayout-bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Resolved the issue of cells overlapping in the instance composer
issue-nr: 6154
change-type: patch
destination-branches: [master, iso8]
sections:
bugfix: "{{description}}"
3 changes: 3 additions & 0 deletions changelogs/unreleased/buildmaster-env-config-scenario.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: Fix env 1.6 scenario to take in account all env settings
change-type: patch
destination-branches: [master, iso8]
67 changes: 66 additions & 1 deletion cypress/e2e/scenario-1-environment.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe("Environment", () => {
});
}

xit("1.6 Edit environment configuration", function () {
it("1.6 Edit environment configuration", function () {
cy.visit("/console/environment/create");
fillCreateEnvForm({
envName: testName(6),
Expand Down Expand Up @@ -362,6 +362,39 @@ describe("Environment", () => {

// specific to ISO
if (Cypress.env("edition") === "iso") {
// Change enable_batched_partial_compiles
cy.get('[aria-label="Row-enable_batched_partial_compiles"]')
.find(".pf-v6-c-switch")
.click();

cy.get('[data-testid="Warning"]').should("exist");
cy.get('[aria-label="Row-enable_batched_partial_compiles"]')
.find('[aria-label="SaveAction"]')
.click();
cy.get('[data-testid="Warning"]').should("not.exist");

// Change lsm_expert_mode
cy.get('[aria-label="Row-enable_lsm_expert_mode"]')
.find(".pf-v6-c-switch")
.click();

cy.get('[data-testid="Warning"]').should("exist");
cy.get('[aria-label="Row-enable_lsm_expert_mode"]')
.find('[aria-label="SaveAction"]')
.click();
cy.get('[data-testid="Warning"]').should("not.exist");

// Change enable_lsm_transfer_optimization
cy.get('[aria-label="Row-enable_lsm_transfer_optimization"]')
.find(".pf-v6-c-switch")
.click();

cy.get('[data-testid="Warning"]').should("exist");
cy.get('[aria-label="Row-enable_lsm_transfer_optimization"]')
.find('[aria-label="SaveAction"]')
.click();
cy.get('[data-testid="Warning"]').should("not.exist");

// Change lsm_partial_compile
cy.get('[aria-label="Row-lsm_partial_compile"]')
.find(".pf-v6-c-switch")
Expand All @@ -374,6 +407,15 @@ describe("Environment", () => {
cy.get('[data-testid="Warning"]').should("not.exist");
}

//change environment_metrics_retention
cy.get('[aria-label="Row-environment_metrics_retention"]')
.find(".pf-v6-c-form-control")
.type("{selectAll}375");
cy.get('[data-testid="Warning"]').should("exist");
cy.get('[aria-label="Row-environment_metrics_retention"]')
.find('[aria-label="SaveAction"]')
.click();

//change notification_retention
cy.get('[aria-label="Row-notification_retention"]')
.find(".pf-v6-c-form-control")
Expand All @@ -397,6 +439,29 @@ describe("Environment", () => {
.click();
cy.get('[data-testid="Warning"]').should("not.exist");

//Change recompile_backoff
cy.get('[aria-label="Row-recompile_backoff"]')
.find(".pf-v6-c-form-control")
.type("{selectAll}2");
cy.get('[data-testid="Warning"]').should("exist");
cy.get('[aria-label="Row-recompile_backoff"]')
.find('[aria-label="SaveAction"]')
.click();
cy.get('[data-testid="Warning"]').should("not.exist");
cy.get('[aria-label="Row-recompile_backoff"]')
.find(".pf-v6-c-form-control input")
.should("have.value", "2");

//Change reset_deploy_progress_on_start
cy.get('[aria-label="Row-reset_deploy_progress_on_start"]')
.find(".pf-v6-c-switch")
.click();
cy.get('[data-testid="Warning"]').should("exist");
cy.get('[aria-label="Row-reset_deploy_progress_on_start"]')
.find('[aria-label="SaveAction"]')
.click();
cy.get('[data-testid="Warning"]').should("not.exist");

//Change resource_action_logs_retention
cy.get('[aria-label="Row-resource_action_logs_retention"]')
.find(".pf-v6-c-form-control")
Expand Down
12 changes: 10 additions & 2 deletions cypress/e2e/scenario-2.1-basic-service.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ if (Cypress.env("edition") === "iso") {
cy.get('[aria-label="History-Row"]').eq(0).should("contain", "up");

// Selecting a version in the table should change the tags in the heading of the page.
cy.get('[aria-label="History-Row"]').eq(1).click();
cy.get('[aria-label="History-Row"]')
.eq(1)
.within(() => {
cy.get('[data-label="version"]').click(); //it's done to avoid flake where the tooltip comes in a way and click ins't triggered
});
cy.get('[data-testid="selected-version"]').should(
"have.text",
"Version: 2",
Expand Down Expand Up @@ -490,7 +494,11 @@ if (Cypress.env("edition") === "iso") {
.click();

// change version and go to events page. The second version should contain a validation report.
cy.get('[aria-label="History-Row"]').eq(7).click();
cy.get('[aria-label="History-Row"]')
.eq(7)
.within(() => {
cy.get('[data-label="version"]').click(); //it's done to avoid flake where the tooltip comes in a way and click ins't triggered
});
cy.get('[data-testid="selected-version"]').should(
"have.text",
"Version: 2",
Expand Down
73 changes: 73 additions & 0 deletions src/UI/Components/Diagram/helpers/visual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
updateLabelPosition,
toggleLooseElement,
showLinkTools,
moveCellsFromColliding,
} from "./visual";

beforeAll(() => {
Expand Down Expand Up @@ -338,3 +339,75 @@ describe("showLinkTools", () => {
expect(linkView.hasTools()).toBeFalsy();
});
});

describe("moveCellsFromColliding", () => {
it("should move cells to avoid collision", () => {
const graph = new dia.Graph();

new dia.Paper({
model: graph,
});

const entityA = createComposerEntity({
serviceModel: Service.a,
isCore: false,
isEmbeddedEntity: false,
isInEditMode: false,
attributes: InstanceAttributesA,
});
const entityB = createComposerEntity({
serviceModel: Service.a,
isCore: false,
isEmbeddedEntity: false,
isInEditMode: false,
attributes: InstanceAttributesB,
});

graph.addCell(entityA);
graph.addCell(entityB);

entityA.set("position", { x: 0, y: 0 });
entityB.set("position", { x: 0, y: 0 });

moveCellsFromColliding(graph, graph.getCells());

const updatedCells = graph.getCells();

expect(updatedCells[0].position()).toEqual({ x: 0, y: 50 });
expect(updatedCells[1].position()).toEqual({ x: 0, y: 0 });
});

it("should not move cells if they are not colliding", () => {
const graph = new dia.Graph();

new dia.Paper({
model: graph,
});
const entityA = createComposerEntity({
serviceModel: Service.a,
isCore: false,
isEmbeddedEntity: false,
isInEditMode: false,
attributes: InstanceAttributesA,
});
const entityB = createComposerEntity({
serviceModel: Service.a,
isCore: false,
isEmbeddedEntity: false,
isInEditMode: false,
attributes: InstanceAttributesB,
});

graph.addCell(entityA);
graph.addCell(entityB);

entityA.set("position", { x: 0, y: 0 });
entityB.set("position", { x: 200, y: 200 });

moveCellsFromColliding(graph, graph.getCells());
const updatedCells = graph.getCells();

expect(updatedCells[0].position()).toEqual({ x: 0, y: 0 });
expect(updatedCells[1].position()).toEqual({ x: 200, y: 200 });
});
});
31 changes: 31 additions & 0 deletions src/UI/Components/Diagram/helpers/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,34 @@ const removeConnectionData = (
dispatchUpdateServiceOrderItems(elementCell, ActionEnum.UPDATE);
}
};

/**
* Function that checks if the cells are colliding and moves them if they are
*
* @param {dia.Graph} graph - The jointJS graph to which entities are be added.
* @param {dia.Cell[]} cells - the array of cells to check for collisions
*/
export const moveCellsFromColliding = (graph: dia.Graph, cells: dia.Cell[]) => {
cells.map((cell) => {
let isColliding = false;

do {
const overlappingCells = graph
.findModelsInArea(cell.getBBox())
.filter((el) => el.id !== cell.id);

if (overlappingCells.length > 0) {
isColliding = true;
// an overlap found, change the position
const coordinates = cell.position();

cell.set("position", {
x: coordinates.x,
y: coordinates.y + 50,
});
} else {
isColliding = false;
}
} while (isColliding);
});
};
4 changes: 4 additions & 0 deletions src/UI/Components/Diagram/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
applyCoordinatesToCells,
getCellsCoordinates,
getKeyAttributesNames,
moveCellsFromColliding,
} from "./helpers";
import { toggleLooseElement } from "./helpers";
import {
Expand Down Expand Up @@ -170,6 +171,9 @@ export function diagramInit(
if (parsedCoordinates.version === "v2") {
applyCoordinatesToCells(graph, parsedCoordinates.data);
}

// check for overlapping cells and adjust the position - this is the case when some cells are added through regular forms
moveCellsFromColliding(graph, cells);
}
}

Expand Down

0 comments on commit 36c2781

Please sign in to comment.