Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1066/display tooltip description in frontend #3162

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
18d5a1e
chore(deps): update dependency @types/node to v18
renovate[bot] Nov 17, 2022
4e68eb9
chore(deps): update dependency @types/node to v18
renovate[bot] Nov 23, 2022
bfda176
Migrate to nodev18
Nov 23, 2022
f3c4adf
Merge branch 'renovate/node-18.x' of github.com:MaibornWolff/codechar…
Nov 23, 2022
943b806
Add: attributeDescriptor TEST to multiple Files (Still one compile er…
BenediktMehl Nov 25, 2022
4dace64
Add: missing reducer statement - no compile error anymore#1066
BenediktMehl Nov 30, 2022
ca783f3
Refactor: rename "Size" metric in legendPanel to "Area"#1066
BenediktMehl Nov 30, 2022
8a98721
Refactor: some consoleprints and delete unused variables and methods"…
BenediktMehl Nov 30, 2022
ac1580b
Refactor: delete "test" node in attributeDescriptors layout#1066
BenediktMehl Nov 30, 2022
dbcb3fa
Add: entry for download feature #1066
BenediktMehl Nov 30, 2022
b58ddd2
Refactor: move getDescription function to legendMetrics #1066
BenediktMehl Nov 30, 2022
ec3d0a5
Add: implementation for merged attributeDescriptors.merger #1066
BenediktMehl Nov 30, 2022
8c31b19
Add: attributeDescriptor to attributeDescriptors settings #1066
BenediktMehl Nov 30, 2022
0512829
Add: if condition to show description in legend block for every metri…
BenediktMehl Nov 30, 2022
c5c0c96
Refactor: methods and settings layout to fit new cc.json format #1066
BenediktMehl Nov 30, 2022
f56167f
Fix: test errors #1066
BenediktMehl Nov 30, 2022
21823bb
Add: title for legend blocks in legend #1066
BenediktMehl Dec 1, 2022
fde8889
Fix: remove title from color picker #1066
BenediktMehl Dec 1, 2022
aa25ee4
Add: case for existing title and missing description #1066
BenediktMehl Dec 1, 2022
a7d3dbe
Refactor: text in legendBlock to be uniform #1066
BenediktMehl Dec 2, 2022
cc84e0f
Merge branch 'main' into feature/1066/display-tooltip-description-in-…
BenediktMehl Dec 2, 2022
fc4b906
Refactor: metricTitles cases to fit to new attribute descriptors #1066
BenediktMehl Dec 2, 2022
7085c50
Fix: failing tests #1066
BenediktMehl Dec 2, 2022
461c299
Fix: format tests #1066
BenediktMehl Dec 2, 2022
59acbe2
Fix: test coverage #1066
BenediktMehl Dec 7, 2022
5f484ad
Fix: test coverage error #1066
BenediktMehl Dec 7, 2022
d0e7169
Update webpack and tapable
Dec 8, 2022
8f19f4b
Fix: test coverage error second try #1066
BenediktMehl Dec 7, 2022
099eae1
Refactor: metric name to key #1066
BenediktMehl Dec 8, 2022
dc8351e
Merge branch 'main' into renovate/node-18.x
friedrich-roskosch-mw Dec 8, 2022
43ebeb9
Fix: refactoring erros #1066
BenediktMehl Dec 8, 2022
9e7bbb2
Chore: Merge main
friedrich-roskosch-mw Dec 8, 2022
4de5873
Merge branch 'main' into renovate/node-18.x
friedrich-roskosch-mw Dec 8, 2022
d6d9180
Merge remote-tracking branch 'origin/renovate/node-18.x' into renovat…
friedrich-roskosch-mw Dec 8, 2022
50a1f14
Chore: Update puppeteer to see if that fixes the pipeline
friedrich-roskosch-mw Dec 8, 2022
b9d6a1f
Chore: remove now unused method from puppeteer helper
friedrich-roskosch-mw Dec 8, 2022
48f45f8
Test: change jest testTimeout to 80s #1066
BenediktMehl Dec 8, 2022
4b8b321
Fix: PR comments #1066
BenediktMehl Dec 8, 2022
3cbe2d3
Revert "Test: change jest testTimeout to 80s #1066"
BenediktMehl Dec 8, 2022
8121ef7
Fix: test error #1066
BenediktMehl Dec 8, 2022
0f5e5d5
TEST Refactor: change "testTimeout": 800000 #2326
BenediktMehl Dec 9, 2022
8ce820e
TEST Refactor: waitForFileChooser({ timeout: 800_000 #2326
BenediktMehl Dec 9, 2022
baf77cf
TEST Refactor: don't runInBand #2326
BenediktMehl Dec 9, 2022
0b6b477
fix: downgrade puppeteer 19 -> 16 again
friedrich-roskosch-mw Dec 9, 2022
eb3ffdc
Revert "TEST Refactor: waitForFileChooser({ timeout: 800_000 #2326"
BenediktMehl Dec 9, 2022
345f166
Revert "TEST Refactor: don't runInBand #2326"
BenediktMehl Dec 9, 2022
4cd007a
Revert "TEST Refactor: change "testTimeout": 800000 #2326"
BenediktMehl Dec 9, 2022
df987b6
fix: upgrade puppeteer one last time 16 -> 17
friedrich-roskosch-mw Dec 9, 2022
ae29ac8
Merge branch 'renovate/node-18.x' into feature/1066/display-tooltip-d…
BenediktMehl Dec 9, 2022
4e03ad5
Add: Test for attributeDescriptors.reducer #2326
BenediktMehl Dec 9, 2022
188f37e
Merge branch 'main' into feature/1066/display-tooltip-description-in-…
friedrich-roskosch-mw Dec 9, 2022
e18d987
Merge branch 'main' into feature/1066/display-tooltip-description-in-…
BenediktMehl Dec 9, 2022
44491f6
Add changelog entry #2326
BenediktMehl Dec 9, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

### Chore 👨‍💻 👩‍💻

- Metric titles in the legend are read from cc.json now [#3162](https://github.com/MaibornWolff/codecharta/pull/3162)
- Add attribute descriptors to SoureCodeParser [#3166](https://github.com/MaibornWolff/codecharta/pull/3166)

## [1.112.1] - 2022-12-01
Expand Down
12 changes: 11 additions & 1 deletion visualization/app/codeCharta/codeCharta.api.model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { Vector3 } from "three"
import { AttributeTypes, AttributeTypeValue, CodeMapNode, Edge, MarkedPackage, RecursivePartial, Settings } from "./codeCharta.model"
import {
AttributeDescriptors,
AttributeTypes,
AttributeTypeValue,
CodeMapNode,
Edge,
MarkedPackage,
RecursivePartial,
Settings
} from "./codeCharta.model"

export interface ExportCCFile {
projectName: string
apiVersion: string
fileChecksum: string
nodes: CodeMapNode[]
attributeTypes?: AttributeTypes | OldAttributeTypes
attributeDescriptors?: AttributeDescriptors
edges?: Edge[]
markedPackages?: MarkedPackage[]
blacklist?: ExportBlacklistItem[]
Expand Down
13 changes: 13 additions & 0 deletions visualization/app/codeCharta/codeCharta.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface Settings {

export interface FileSettings {
attributeTypes: AttributeTypes
attributeDescriptors: AttributeDescriptors
blacklist: Array<BlacklistItem>
edges: Edge[]
markedPackages: MarkedPackage[]
Expand Down Expand Up @@ -186,6 +187,18 @@ export interface AttributeTypes {
edges?: { [key: string]: AttributeTypeValue }
}

export interface AttributeDescriptors {
[key: string]: AttributeDescriptor
}

export interface AttributeDescriptor {
title: string
description: string
hintLowValue: string
hintHighValue: string
link: string
}

export enum AttributeTypeValue {
absolute = "absolute",
relative = "relative"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe("loadFileService", () => {
settings: {
fileSettings: {
attributeTypes: { nodes: {}, edges: {} },
attributeDescriptors: {},
blacklist: [],
edges: [],
markedPackages: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ describe("UpdateFileSettingsEffect", () => {
edges: [],
markedPackages: [],
blacklist: [],
attributeTypes: {}
attributeTypes: {},
attributeDescriptors: {}
}
})
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Inject } from "@angular/core"
import { Inject, Injectable } from "@angular/core"
import { filter, map } from "rxjs"
import { getVisibleFiles, isPartialState } from "../../../model/files/files.helper"
import { isActionOfType } from "../../../util/reduxHelper"
Expand All @@ -12,6 +12,7 @@ import { getMergedAttributeTypes } from "./utils/attributeTypes.merger"
import { getMergedBlacklist } from "./utils/blacklist.merger"
import { getMergedEdges } from "./utils/edges.merger"
import { getMergedMarkedPackages } from "./utils/markedPackages.merger"
import { getMergedAttributeDescriptors } from "./utils/attributeDescriptors.merger"

@Injectable()
export class UpdateFileSettingsEffect {
Expand All @@ -25,12 +26,16 @@ export class UpdateFileSettingsEffect {
const visibleFiles = getVisibleFiles(state.files)
const withUpdatedPath = isPartialState(state.files)
const allAttributeTypes = visibleFileStatesSelector(state).map(({ file }) => file.settings.fileSettings.attributeTypes)
const allAttributeDescriptors = visibleFileStatesSelector(state).map(
({ file }) => file.settings.fileSettings.attributeDescriptors
)
return setState({
fileSettings: {
edges: getMergedEdges(visibleFiles, withUpdatedPath),
markedPackages: getMergedMarkedPackages(visibleFiles, withUpdatedPath),
blacklist: getMergedBlacklist(visibleFiles, withUpdatedPath),
attributeTypes: getMergedAttributeTypes(allAttributeTypes)
attributeTypes: getMergedAttributeTypes(allAttributeTypes),
attributeDescriptors: getMergedAttributeDescriptors(allAttributeDescriptors)
}
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { AttributeDescriptors } from "../../../../codeCharta.model"
import { getMergedAttributeDescriptors } from "./attributeDescriptors.merger"

describe("AttributeDescriptorsMerger", () => {
describe("getMergedAttributeDescriptors", () => {
let attributes1: AttributeDescriptors
let attributes2: AttributeDescriptors
let attributes3: AttributeDescriptors

beforeEach(() => {
attributes1 = {}

attributes2 = {
rloc: {
title: "rloc2",
description: "",
hintLowValue: "",
hintHighValue: "",
link: "https://www.npmjs.com/package/metric-gardener"
}
}

attributes3 = {
rloc: {
title: "rloc3",
description: "DescriptionRloc3",
hintLowValue: "",
hintHighValue: "",
link: "https://www.npmjs.com/package/metric-gardener"
},
comment_lines: {
title: "Comment Lines",
description: "Number of lines containing either comment or commented-out code",
hintLowValue: "",
hintHighValue: "",
link: "https://www.npmjs.com/package/metric-gardener"
}
}
})

it("should merge attributeDescriptors if one file does not contain any attributeDescriptors", () => {
const attributeDescriptors = getMergedAttributeDescriptors([attributes1, attributes2])

expect(attributeDescriptors).toEqual(attributes2)
})

it("should merge attributeDescriptors. If they share the same key, simply take the first attributeDescriptor", () => {
const attributeDescriptors = getMergedAttributeDescriptors([attributes2, attributes3])

const expected = {
rloc: {
title: "rloc2",
description: "",
hintLowValue: "",
hintHighValue: "",
link: "https://www.npmjs.com/package/metric-gardener"
},
comment_lines: {
title: "Comment Lines",
description: "Number of lines containing either comment or commented-out code",
hintLowValue: "",
hintHighValue: "",
link: "https://www.npmjs.com/package/metric-gardener"
}
}

expect(attributeDescriptors).toEqual(expected)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { AttributeDescriptors } from "../../../../codeCharta.model"

export function getMergedAttributeDescriptors(allAttributeDescriptors: AttributeDescriptors[]): AttributeDescriptors {
const uniqueAttributeDescriptors = {}

for (const attributeDescriptors of allAttributeDescriptors) {
for (const attributeDescriptorKey of Object.keys(attributeDescriptors)) {
if (!uniqueAttributeDescriptors[attributeDescriptorKey]) {
uniqueAttributeDescriptors[attributeDescriptorKey] = attributeDescriptors[attributeDescriptorKey]
}
}
}

return uniqueAttributeDescriptors
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { AttributeDescriptors, CCAction } from "../../../../codeCharta.model"

export enum AttributeDescriptorsActions {
SET_ATTRIBUTE_DESCRIPTORS = "SET_ATTRIBUTE_DESCRIPTORS"
}

export interface SetAttributeDescriptorsAction extends CCAction {
type: AttributeDescriptorsActions.SET_ATTRIBUTE_DESCRIPTORS
payload: AttributeDescriptors
}

export type AttributeDescriptorsAction = SetAttributeDescriptorsAction

export function setAttributeDescriptors(
attributeDescriptors: AttributeDescriptors = defaultAttributeDescriptors
): SetAttributeDescriptorsAction {
return {
type: AttributeDescriptorsActions.SET_ATTRIBUTE_DESCRIPTORS,
payload: attributeDescriptors
}
}

export const defaultAttributeDescriptors: AttributeDescriptors = {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { attributeDescriptors } from "./attributeDescriptors.reducer"
import { STATE } from "../../../../util/dataMocks"
import { AttributeDescriptors } from "../../../../codeCharta.model"
import { AttributeDescriptorsAction, setAttributeDescriptors } from "./attributeDescriptors.action"

describe("attributeDescriptors", () => {
const defaultValue: AttributeDescriptors = {}

describe("Default State", () => {
it("should initialize the default state", () => {
const result = attributeDescriptors(undefined, {} as AttributeDescriptorsAction)

expect(result).toEqual(defaultValue)
})
})

describe("Action: SET_ATTRIBUTE_DESCRIPTORS", () => {
it("should set new attributeDescriptors", () => {
const result = attributeDescriptors(defaultValue, setAttributeDescriptors(STATE.fileSettings.attributeDescriptors))

expect(result).toEqual(STATE.fileSettings.attributeDescriptors)
})

it("should set default attributeDescriptors", () => {
const result = attributeDescriptors(STATE.fileSettings.attributeDescriptors, setAttributeDescriptors())

expect(result).toEqual(defaultValue)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AttributeDescriptorsAction, AttributeDescriptorsActions, setAttributeDescriptors } from "./attributeDescriptors.action"

export function attributeDescriptors(state = setAttributeDescriptors().payload, action: AttributeDescriptorsAction) {
if (action.type === AttributeDescriptorsActions.SET_ATTRIBUTE_DESCRIPTORS) {
return action.payload
}
return state
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CcState } from "../../store"

export const attributeDescriptorsSelector = (state: CcState) => state.fileSettings.attributeDescriptors
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CCAction, FileSettings, RecursivePartial } from "../../../codeCharta.model"

import { defaultAttributeTypes } from "./attributeTypes/attributeTypes.actions"
import { defaultAttributeDescriptors } from "./attributeDescriptors/attributeDescriptors.action"
import { defaultBlacklist } from "./blacklist/blacklist.actions"
import { defaultEdges } from "./edges/edges.actions"
import { defaultMarkedPackages } from "./markedPackages/markedPackages.actions"
Expand All @@ -25,6 +26,7 @@ export function setFileSettings(fileSettings: RecursivePartial<FileSettings> = d

export const defaultFileSettings: FileSettings = {
attributeTypes: defaultAttributeTypes,
attributeDescriptors: defaultAttributeDescriptors,
blacklist: defaultBlacklist,
edges: defaultEdges,
markedPackages: defaultMarkedPackages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { edges } from "./edges/edges.reducer"
import { attributeTypes } from "./attributeTypes/attributeTypes.reducer"
import { blacklist } from "./blacklist/blacklist.reducer"
import { combineReducers } from "redux"
import { attributeDescriptors } from "./attributeDescriptors/attributeDescriptors.reducer"

const fileSettings = combineReducers({
markedPackages,
edges,
attributeTypes,
attributeDescriptors,
blacklist
})

Expand Down
1 change: 1 addition & 0 deletions visualization/app/codeCharta/state/store/state.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function isSetStateAction(action: Action): action is SetStateAction {

const objectWithDynamicKeysInStore = new Set([
"fileSettings.attributeTypes",
"fileSettings.attributeDescriptors",
"fileSettings.blacklist",
"fileSettings.edges",
"fileSettings.markedPackages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</span>
</div>
<div class="cc-labelled-color-picker-label">
<span *ngFor="let label of labels" [title]="label"> {{ label }} <br *ngIf="!last" /></span>
<span *ngFor="let label of labels"> {{ label }} <br *ngIf="!last" /></span>
</div>
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<div *ngIf="legendMetric.description" class="legend-block">
{{ metricFor }} metric (<span class="bold">{{ legendMetric.metricName }}</span
>: {{ legendMetric.description }})
</div>
<div *ngIf="!legendMetric.description" class="legend-block">
{{ metricFor }} metric: <span class="bold">{{ legendMetric.metricName }}</span>
</div>
<ng-container *ngIf="legendMetric.title; then titleExists; else onlyShowName" class="legend-block"></ng-container>
<ng-template #titleExists>
<ng-container *ngIf="legendMetric.description; then showTitleAndDescription; else showTitle"></ng-container>
</ng-template>

<ng-template #showTitleAndDescription>
<div title="{{ legendMetric.key + ': ' + legendMetric.description }}">
{{ metricFor }} metric: <span class="bold">{{ legendMetric.title }}</span> ({{ legendMetric.key }})
</div>
</ng-template>
<ng-template #showTitle>
<div title="{{ legendMetric.key }}">
{{ metricFor }} metric: <span class="bold">{{ legendMetric.title }}</span> ({{ legendMetric.key }})
</div>
</ng-template>
<ng-template #onlyShowName>
<div title="{{ legendMetric.key }}">
{{ metricFor }} metric: <span class="bold">{{ legendMetric.key }}</span>
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div class="block-wrapper" [class.visible]="isLegendVisible" [class.isAttributeSideBarVisible]="isAttributeSideBarVisibleService.isOpen">
<div *ngIf="!(isDeltaState$ | async)">
<cc-legend-block [metricFor]="'Size'" [legendMetric]="areaMetric$ | async"></cc-legend-block>
<cc-legend-block [metricFor]="'Area'" [legendMetric]="areaMetric$ | async"></cc-legend-block>
BenediktMehl marked this conversation as resolved.
Show resolved Hide resolved
<cc-legend-block [metricFor]="'Height'" [legendMetric]="heightMetric$ | async"></cc-legend-block>
<cc-legend-block *ngIf="edgeMetric$ | async; let edgeMetric" [metricFor]="'Edge'" [legendMetric]="edgeMetric"></cc-legend-block>

<hr />
<cc-legend-block [metricFor]="'Color'" [legendMetric]="colorMetric$ | async"></cc-legend-block>
<cc-color-picker-for-map-color [mapColorFor]="'positive'"></cc-color-picker-for-map-color>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ describe("LegendPanelController", () => {
expect(areDeltaEntriesShown).toBe(false)

const metricDescriptions = container.querySelectorAll("cc-legend-block")
expect(metricDescriptions[0].textContent).toMatch("Size metric (loc: lines of code)")
expect(metricDescriptions[1].textContent).toMatch("Height metric (mcc: cyclomatic complexity)")
expect(metricDescriptions[2].textContent).toMatch("Color metric (rloc: real lines of code)")
expect(metricDescriptions[0].textContent).toMatch("Area metric: Lines of Code (loc)")
expect(metricDescriptions[1].textContent).toMatch("Height metric: Cyclomatic Complexity (mcc)")
expect(metricDescriptions[2].textContent).toMatch("Color metric: Real Lines of Code (rloc)")
})

it("should display legend for delta mode", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createSelector } from "../../../state/angular-redux/createSelector"
import { areaMetricSelector } from "../../../state/store/dynamicSettings/areaMetric/areaMetric.selector"
import { attributeDescriptorsSelector } from "../../../state/store/fileSettings/attributeDescriptors/attributesDescriptors.selector"
import { CcState } from "../../../state/store/store"
import { metricDescriptions } from "../../../util/metric/metricDescriptions"
import { LegendMetric } from "./legendMetric"
import { getLegendMetric, LegendMetric } from "./legendMetric"

export const legendAreaMetricSelector: (state: CcState) => LegendMetric = createSelector([areaMetricSelector], areaMetric => ({
metricName: areaMetric,
description: metricDescriptions.get(areaMetric)
}))
export const legendAreaMetricSelector: (state: CcState) => LegendMetric = createSelector(
[areaMetricSelector, attributeDescriptorsSelector],
(areaMetric, attributeDescriptors) => getLegendMetric(areaMetric, attributeDescriptors)
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createSelector } from "../../../state/angular-redux/createSelector"
import { colorMetricSelector } from "../../../state/store/dynamicSettings/colorMetric/colorMetric.selector"
import { CcState } from "../../../state/store/store"
import { metricDescriptions } from "../../../util/metric/metricDescriptions"
import { LegendMetric } from "./legendMetric"
import { getLegendMetric, LegendMetric } from "./legendMetric"
import { attributeDescriptorsSelector } from "../../../state/store/fileSettings/attributeDescriptors/attributesDescriptors.selector"

export const legendColorMetricSelector: (state: CcState) => LegendMetric = createSelector([colorMetricSelector], colorMetric => ({
metricName: colorMetric,
description: metricDescriptions.get(colorMetric)
}))
export const legendColorMetricSelector: (state: CcState) => LegendMetric = createSelector(
[colorMetricSelector, attributeDescriptorsSelector],
(colorMetric, attributeDescriptors) => getLegendMetric(colorMetric, attributeDescriptors)
)
Loading