Passed
Push — master ( 58a9e6...52bfcc )
by
unknown
02:37
created

src/utils/helpers/Selectors.ts   A

Complexity

Total Complexity 14
Complexity/F 1.08

Size

Lines of Code 59
Function Count 13

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 44
mnd 1
bc 1
fnc 13
dl 0
loc 59
rs 10
bpm 0.0769
cpm 1.0769
noi 0
c 0
b 0
f 0

13 Functions

Rating   Name   Duplication   Size   Complexity  
A Selectors.ts ➔ selectDetailsViewContainer 0 3 1
A Selectors.ts ➔ selectHighlightBackground 0 3 1
A Selectors.ts ➔ selectDetailsButtonWrapper 0 3 1
A Selectors.ts ➔ selectAllLinks 0 3 1
A Selectors.ts ➔ selectAllNodes 0 3 1
A Selectors.ts ➔ selectContainer 0 3 1
A Selectors.ts ➔ selectDetailsButtonRect 0 3 1
A Selectors.ts ➔ selectDetailsZoom 0 3 1
A Selectors.ts ➔ selectById 0 3 1
A Selectors.ts ➔ selectHighLightedNodes 0 4 2
A Selectors.ts ➔ selectDetailsExitButtonWrapper 0 3 1
A Selectors.ts ➔ selectDetailsButtonText 0 3 1
A Selectors.ts ➔ selectDetailsContainerDiv 0 3 1
1
import { select } from 'd3-selection';
2
import { LabelColors, ElementIds } from '../AppConsts';
3
import { DependencyLink, DependencyNode } from '../../components/types';
4
import { BaseType } from 'd3-selection';
5
6
export function selectHighLightedNodes() {
7
    return selectAllNodes().filter(function(this: SVGGElement) {
8
        return this.firstElementChild ? this.firstElementChild.getAttribute('fill') !== LabelColors.DEFAULT : false;
9
    });
10
}
11
12
export function selectAllNodes() {
13
    return selectById(ElementIds.LABELS).selectAll<SVGGElement, DependencyNode>('g');
14
}
15
16
export function selectAllLinks() {
17
    return selectById(ElementIds.LINKS).selectAll<SVGPathElement, DependencyLink>('path');
18
}
19
20
export function selectHighlightBackground() {
21
    return selectById(ElementIds.HIGHLIGHT_BACKGROUND);
22
}
23
24
export function selectDetailsButtonWrapper() {
25
    return selectById(ElementIds.DETAILS_BUTTON);
26
}
27
28
export function selectDetailsExitButtonWrapper() {
29
    return selectById(ElementIds.DETAILS_EXIT_BUTTON);
30
}
31
32
export function selectDetailsButtonRect() {
33
    return selectDetailsButtonWrapper().select('rect');
34
}
35
36
export function selectDetailsButtonText() {
37
    return selectDetailsButtonWrapper().select('text');
38
}
39
40
export function selectDetailsViewContainer() {
41
    return selectById(ElementIds.DETAILS_VIEW_CONTAINER);
42
}
43
44
export function selectDetailsContainerDiv() {
45
    return selectById(ElementIds.DETAILS_CONTAINER_DIV);
46
}
47
48
export function selectDetailsZoom() {
49
    return selectById(ElementIds.ZOOM_DETAILS);
50
}
51
52
export function selectContainer() {
53
    return selectById(ElementIds.CONTAINER);
54
}
55
56
export function selectById<Data = unknown>(selector: ElementIds) {
57
    return select<BaseType, Data>(`#${selector}`);
58
}
59