Skip to content

Commit

Permalink
Merge pull request #322 from mitre-attack/fix/#204-technique-hover
Browse files Browse the repository at this point in the history
Fix/#204 technique hover
  • Loading branch information
isaisabel committed Jul 20, 2021
2 parents e401945 + 2420182 commit 1985779
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
26 changes: 13 additions & 13 deletions nav-app/src/app/matrix/technique-cell/technique-cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ export class TechniqueCellComponent implements OnInit {
if (this.showContextmenu) return false;
if (this.viewModel.highlightedTechniques.size === 0) return false;

return (this.viewModel.highlightedTechniques.has(this.technique.id) && this.viewModel.highlightedTactic && this.viewModel.highlightedTactic.id == this.tactic.id);
return (this.viewModel.highlightedTechnique === this.technique && this.viewModel.highlightedTactic && this.viewModel.highlightedTactic.id === this.tactic.id);
}


public get isHighlighted(): boolean {
if (this.viewModel.selectTechniquesAcrossTactics) {
if (this.viewModel.selectSubtechniquesWithParent) {
return this.technique.isSubtechnique && this.viewModel.highlightedTechniques.has(this.technique.parent.id);
}
}
else if (this.viewModel.highlightedTactic && this.viewModel.highlightedTactic.id == this.tactic.id) {
if (this.viewModel.selectSubtechniquesWithParent) {
return this.technique.isSubtechnique && this.viewModel.highlightedTechniques.has(this.technique.parent.id);
let isHighlighted = this.showContextmenu;
let idToMatch = this.technique.id;
if (this.viewModel.selectSubtechniquesWithParent && this.technique.isSubtechnique) idToMatch = this.technique.parent.id;

if (this.viewModel.highlightedTechniques.has(idToMatch)) {
if (!this.viewModel.highlightedTactic) { // highlight is called from search component
return true;
} else {
const isTacticMatching = this.viewModel.highlightedTactic === this.tactic;
return (this.viewModel.selectTechniquesAcrossTactics || isTacticMatching);
}
}
if (this.viewModel.highlightedTechniques.has(this.technique.id)) { // for highlighting techniques from the techniques search component, where highlightedTactic is null
return true;
}

return this.showContextmenu;
return isHighlighted;
}

constructor(public configService: ConfigService, public dataService: DataService) { }
Expand Down
3 changes: 3 additions & 0 deletions nav-app/src/app/viewmodels.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ export class ViewModel {

public highlightedTactic: Tactic = null;
public highlightedTechniques: Set<string> = new Set<string>();
public highlightedTechnique: Technique = null; // the Technique that was actually moused over

/**
* Highlight the given technique under the given tactic
Expand All @@ -506,6 +507,7 @@ export class ViewModel {
*/
public highlightTechnique(technique: Technique, tactic?: Tactic | null) {
if (this.selectSubtechniquesWithParent && technique.isSubtechnique) this.highlightedTechniques.add(technique.parent.id);
this.highlightedTechnique = technique;
this.highlightedTechniques.add(technique.id);
this.highlightedTactic = tactic;
}
Expand All @@ -514,6 +516,7 @@ export class ViewModel {
*/
public clearHighlight() {
this.highlightedTactic = null;
this.highlightedTechnique = null;
this.highlightedTechniques = new Set<string>();
}

Expand Down

0 comments on commit 1985779

Please sign in to comment.