From d22b47f3f0f6aafefee2567af6437901fd4428d3 Mon Sep 17 00:00:00 2001 From: freshavocado7 Date: Wed, 11 Sep 2024 11:08:22 +0200 Subject: [PATCH] refactor: Rename object_diff to object_comparison --- frontend/src/components/DiffView.jsx | 2 +- templates/index.yaml | 12 +- templates/model-diff.html.j2 | 158 ------------------ ...diff.html.j2 => object_comparison.html.j2} | 2 +- 4 files changed, 5 insertions(+), 169 deletions(-) delete mode 100644 templates/model-diff.html.j2 rename templates/{object_diff.html.j2 => object_comparison.html.j2} (99%) diff --git a/frontend/src/components/DiffView.jsx b/frontend/src/components/DiffView.jsx index 32fadcc..fdf083e 100644 --- a/frontend/src/components/DiffView.jsx +++ b/frontend/src/components/DiffView.jsx @@ -23,7 +23,7 @@ export const DiffView = ({ objectID, endpoint, diffData }) => { .then(() => { let url; if (diffData.change) { - url = `${endpoint}object_diff/${objectID}`; + url = `${endpoint}object_comparison/${objectID}`; } fetch(url, { method: 'GET', diff --git a/templates/index.yaml b/templates/index.yaml index 331b5d5..0993ff8 100644 --- a/templates/index.yaml +++ b/templates/index.yaml @@ -17,15 +17,9 @@ categories: scope: name: object type: CapellaModule - - idx: model-diff - template: model-diff.html.j2 - name: Model Version Diff - description: Template to visualize differences between two model versions - isExperimental: true - single: true - - idx: object_diff - template: object_diff.html.j2 - name: Object Diff + - idx: object_comparison + template: object_comparison.html.j2 + name: Object Comparison description: Template to visualize differences between two objects isExperimental: true single: true diff --git a/templates/model-diff.html.j2 b/templates/model-diff.html.j2 deleted file mode 100644 index a9cca99..0000000 --- a/templates/model-diff.html.j2 +++ /dev/null @@ -1,158 +0,0 @@ -{# - Copyright DB InfraGO AG and contributors - SPDX-License-Identifier: Apache-2.0 -#} - -{% from 'common_macros.html.j2' import linked_name, linked_name_with_icon %} - -{% if "metadata" in diff_data %} -{% if "old_revision" in diff_data["metadata"] %} -

Model Change Assessment Report

-

This report provides an analysis of changes to the following model repository:

-

- Repository: {{ diff_data["metadata"]["model"]["path"] | e }}
- Entry point: {{ diff_data["metadata"]["model"]["entrypoint"] | e }} -

-

The review of changes covers the following commits:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PreviousCurrent
Author{{ diff_data["metadata"]["old_revision"]["author"] | e }}{{ diff_data["metadata"]["new_revision"]["author"] | e }}
Revision{{ diff_data["metadata"]["old_revision"]["revision"] | e }}{{ diff_data["metadata"]["new_revision"]["revision"] | e }}
Date & time of commit{{ diff_data["metadata"]["old_revision"]["date"] | e }}{{ diff_data["metadata"]["new_revision"]["date"] | e }}
Commit message{{ diff_data["metadata"]["old_revision"]["description"] | e }}{{ diff_data["metadata"]["new_revision"]["description"] | e }}
Commit ID (hash){{ diff_data["metadata"]["old_revision"]["hash"] | e }}{{ diff_data["metadata"]["new_revision"]["hash"] | e }}
- -{% macro pretty_stats(stats) %} -( - {% if stats["created"] %}+{{stats["created"]}} / {% endif %} - {% if stats["deleted"] %}-{{stats["deleted"]}} / {% endif %} - {% if stats["modified"] %}Δ{{stats["modified"]}}{% endif %} -) -{% endmacro %} - - -{% macro display_basic_changes(key, objects, color) %} - {% if key in objects %} -

{{key | upper}} ({{ objects[key] | length }})

-
- -
- {% endif %} -{% endmacro %} - - -{% macro spell_changes_out(changes) %} -
- {{ display_basic_changes("created", changes, "#009900") | safe}} - {% if "modified" in changes %} -

MODIFIED ({{ changes["modified"] | length }})

-
- {% for obj in changes["modified"] %} - {% set object = model.by_uuid(obj["uuid"]) %} -

{{ linked_name_with_icon(object) | safe }}

-
-
    - {% for change in obj["attributes"] %} -
  • {{ change }}: - {% if "diff" in obj["attributes"][change] %} - {{ obj["attributes"][change]["diff"]["display_name"] | safe}} - {% else %} - {{ obj["attributes"][change]["previous"] | e }} -> {{ obj["attributes"][change]["current"] | e }} - {% endif %} -
  • - {% endfor %} -
- {{ display_basic_changes("introduced", obj, "#009900") | safe }} - {{ display_basic_changes("removed", obj, "red") | safe}} -
- {% endfor %} -
- {% endif %} - {{ display_basic_changes("deleted", changes, "red") | safe }} -
-{% endmacro %} - -{% set LAYER = {"oa": "Operational Analysis", "sa": "System Analysis", "la": "Logical Architecture", "pa": "Physical Architecture"}%} - -

Object Changes {{ pretty_stats(diff_data["objects"].stats) | safe }}

-
-{% for layer in LAYER %} - {% set layer_data = diff_data["objects"][layer] %} - {% if layer_data and layer_data.stats %} -

{{LAYER[layer]}} {{ pretty_stats(layer_data.stats) | safe }}

- {% macro render_section(diff_data, layer) %} -
- {% for obj_type, obj_type_items in diff_data["objects"][layer].items() - if obj_type != "stats" and obj_type_items.stats %} -

{{ obj_type }} {{ pretty_stats(obj_type_items.stats) | safe }}

- {{ spell_changes_out(obj_type_items) | safe }} - {% endfor %} -
- {% endmacro %} - {{ render_section(diff_data, layer) | safe }} - {% endif %} -{% endfor %} -{% endif %} -
-{% else %} -

Could not generate model comparison report.

-

Select 'Deep clone' before running the session or select a model that belongs to a git repo for developer mode.

-{% endif %} - -

Diagram changes

-
- {% for layer in LAYER %} - {% set layer_data = diff_data["diagrams"][layer] %} - {% if layer_data and layer_data.stats %} -

{{LAYER[layer]}} {{ pretty_stats(layer_data.stats) | safe }}

-
- {% for diag_type, diags in diff_data.diagrams[layer].items() %} - {% if diags.stats %} -

{{diag_type}} {{pretty_stats(diags.stats) | safe }}

- {{ spell_changes_out(diags) | safe }} - {% endif %} - {% endfor %} -
- {% endif %} - {% endfor %} -
diff --git a/templates/object_diff.html.j2 b/templates/object_comparison.html.j2 similarity index 99% rename from templates/object_diff.html.j2 rename to templates/object_comparison.html.j2 index d90c37c..fa368d9 100644 --- a/templates/object_diff.html.j2 +++ b/templates/object_comparison.html.j2 @@ -149,5 +149,5 @@ {% endif %} {{show_other_attributes(object, object_diff) | safe}} {% else %} -

deleted

+

Object not found

{% endif %}