All files / app/codeCharta/ui/ribbonBar/searchPanel/mapTreeView/mapTreeViewItemIcon mapTreeViewItemIconColor.pipe.ts

100% Statements 16/16
100% Branches 4/4
100% Functions 2/2
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 335x 5x     5x 5x             5x 5x 5x   66x     248x   248x 243x   5x 1x     4x 4x      
import { Pipe, PipeTransform } from "@angular/core"
import { State } from "@ngrx/store"
 
import { CodeMapNode, CcState } from "../../../../../codeCharta.model"
import { getMarkingColor, isLeaf } from "../../../../../util/codeMapHelper"
import { isAreaValid } from "../areaMetricValidPipe.pipe"
 
@Pipe({
    name: "mapTreeViewItemIconColor",
    pure: false,
    standalone: true
})
export class MapTreeViewItemIconColorPipe implements PipeTransform {
    static readonly defaultColor = "#000000"
    static readonly areMetricZeroColor = "#BDBDBD"
 
    constructor(private state: State<CcState>) {}
 
    transform(value: CodeMapNode): string | undefined {
        const { areaMetric } = this.state.getValue().dynamicSettings
 
        if (!isAreaValid(value, areaMetric)) {
            return MapTreeViewItemIconColorPipe.areMetricZeroColor
        }
        if (isLeaf(value)) {
            return undefined
        }
 
        const markingColor = getMarkingColor(value, this.state.getValue().fileSettings.markedPackages)
        return markingColor || MapTreeViewItemIconColorPipe.defaultColor
    }
}