All files / app/codeCharta/ui/ribbonBar/searchPanel searchPanel.component.ts

91.3% Statements 21/23
50% Branches 2/4
85.71% Functions 6/7
90.9% Lines 20/22

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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 653x 3x   3x   3x 3x 3x 3x 3x 3x 3x                                     3x 8x             8x     8x 8x         8x     8x           1x 1x       3x      
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core"
import { Store } from "@ngrx/store"
import { CcState } from "../../../../codeCharta/codeCharta.model"
import { isSearchPanelPinnedSelector } from "../../../state/store/appSettings/isSearchPanelPinned/isSearchPanelPinned.selector"
import { Subscription } from "rxjs"
import { RibbonBarPanelComponent } from "../ribbonBarPanel/ribbonBarPanel.component"
import { SearchBarComponent } from "./searchBar/searchBar.component"
import { SearchPanelModeSelectorComponent } from "./searchPanelModeSelector/searchPanelModeSelector.component"
import { RibbonBarPanelSettingsComponent } from "../ribbonBarPanel/ribbonBarPanelSettings.component"
import { BlacklistPanelComponent } from "./blacklistPanel/blacklistPanel.component"
import { MatchingFilesCounterComponent } from "./matchingFilesCounter/matchingFilesCounter.component"
import { MapTreeViewComponent } from "./mapTreeView/mapTreeView.component"
 
export type SearchPanelMode = "treeView" | "blacklist" | "minimized"
 
@Component({
    selector: "cc-search-panel",
    templateUrl: "./searchPanel.component.html",
    styleUrls: ["./searchPanel.component.scss"],
    standalone: true,
    imports: [
        RibbonBarPanelComponent,
        SearchBarComponent,
        SearchPanelModeSelectorComponent,
        RibbonBarPanelSettingsComponent,
        BlacklistPanelComponent,
        MatchingFilesCounterComponent,
        MapTreeViewComponent
    ]
})
export class SearchPanelComponent implements OnInit, OnDestroy {
    searchPanelMode: SearchPanelMode = "minimized"
    isSearchPanelPinned: boolean
    isSearchPanelPinnedSubscription: Subscription
 
    @ViewChild(RibbonBarPanelComponent)
    private panelRef!: RibbonBarPanelComponent
 
    constructor(private readonly store: Store<CcState>) {}
 
    ngOnInit(): void {
        this.isSearchPanelPinnedSubscription = this.store.select(isSearchPanelPinnedSelector).subscribe(isSearchPanelPinned => {
            this.isSearchPanelPinned = isSearchPanelPinned
        })
    }
 
    ngOnDestroy(): void {
        this.isSearchPanelPinnedSubscription.unsubscribe()
    }
 
    updateSearchPanelMode = (searchPanelMode: SearchPanelMode) => {
        this.searchPanelMode = this.searchPanelMode === searchPanelMode ? "minimized" : searchPanelMode
        this.panelRef.isExpanded = this.searchPanelMode !== "minimized"
    }
 
    openSearchPanel() {
        this.searchPanelMode = "treeView"
        this.panelRef.isExpanded = true
    }
 
    onToggleSettings($event: boolean) {
        this.searchPanelMode = $event ? "treeView" : "minimized"
    }
}