-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement fixate file explorer #2788
- Loading branch information
1 parent
24b6c77
commit b152a33
Showing
15 changed files
with
141 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...p/codeCharta/state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createAction, props } from "@ngrx/store" | ||
|
||
export const setIsFileExplorerPinned = createAction("SET_IS_FILE_EXPLORER_PINNED", props<{ value: boolean }>()) | ||
export const toggleIsFileExplorerPinned = createAction("TOGGLE_IS_FILE_EXPLORER_PINNED") |
21 changes: 21 additions & 0 deletions
21
...eCharta/state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.reducer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { isFileExplorerPinned } from "./isFileExplorerPinned.reducer" | ||
import { setIsFileExplorerPinned, toggleIsFileExplorerPinned } from "./isFileExplorerPinned.actions" | ||
|
||
describe("isFileExplorerPinned", () => { | ||
describe("Action: SET_IS_FILE_EXPLORER_PINNED", () => { | ||
it("should set new isFileExplorerPinned", () => { | ||
const result = isFileExplorerPinned(false, setIsFileExplorerPinned({ value: true })) | ||
|
||
expect(result).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe("Action: TOGGLE_IS_FILE_EXPLORER_PINNED", () => { | ||
it("should toggle state", () => { | ||
const result = isFileExplorerPinned(false, setIsFileExplorerPinned({ value: true })) | ||
const toggledResult = isFileExplorerPinned(result, toggleIsFileExplorerPinned()) | ||
|
||
expect(toggledResult).toBe(!result) | ||
}) | ||
}) | ||
}) |
10 changes: 10 additions & 0 deletions
10
...p/codeCharta/state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.reducer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createReducer, on } from "@ngrx/store" | ||
import { setIsFileExplorerPinned, toggleIsFileExplorerPinned } from "./isFileExplorerPinned.actions" | ||
import { setState } from "../../util/setState.reducer.factory" | ||
|
||
export const defaultIsFileExplorerPinned = false | ||
export const isFileExplorerPinned = createReducer( | ||
defaultIsFileExplorerPinned, | ||
on(setIsFileExplorerPinned, setState(defaultIsFileExplorerPinned)), | ||
on(toggleIsFileExplorerPinned, state => !state) | ||
) |
4 changes: 4 additions & 0 deletions
4
.../codeCharta/state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.selector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createSelector } from "@ngrx/store" | ||
import { appSettingsSelector } from "../appSettings.selector" | ||
|
||
export const isFileExplorerPinnedSelector = createSelector(appSettingsSelector, appSettings => appSettings.isFileExplorerPinned) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
visualization/app/codeCharta/ui/searchPanel/thumbTackButton/thumbTackButton.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<button class="box-rounded" (click)="onClick()" title="Pin file explorer" [className]="(isFileExplorerPinned$ | async) ? 'pinned' : ''"> | ||
<i class="fa fa-thumb-tack"></i> | ||
</button> |
3 changes: 3 additions & 0 deletions
3
visualization/app/codeCharta/ui/searchPanel/thumbTackButton/thumbTackButton.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pinned { | ||
background-color: rgba($color: #979797, $alpha: 1); | ||
} |
29 changes: 29 additions & 0 deletions
29
...alization/app/codeCharta/ui/searchPanel/thumbTackButton/thumbTackButton.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { fireEvent, render, screen } from "@testing-library/angular" | ||
import { MockStore, provideMockStore } from "@ngrx/store/testing" | ||
import { TestBed } from "@angular/core/testing" | ||
|
||
import { ThumbTackButtonComponent } from "./thumbTackButton.component" | ||
import { isFileExplorerPinnedSelector } from "../../../state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.selector" | ||
import { toggleIsFileExplorerPinned } from "../../../state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.actions" | ||
|
||
describe("ThumbTackButtonComponent", () => { | ||
it("should toggle isFileExplorerPinned on click", async () => { | ||
const { detectChanges } = await render(ThumbTackButtonComponent, { | ||
providers: [provideMockStore({ selectors: [{ selector: isFileExplorerPinnedSelector, value: true }] })] | ||
}) | ||
const store = TestBed.inject(MockStore) | ||
|
||
expect(screen.getByTitle("Pin file explorer")).toBeTruthy() | ||
|
||
const dispatchSpy = jest.spyOn(store, "dispatch") | ||
const button = screen.getByRole("button") | ||
fireEvent.click(button) | ||
expect(dispatchSpy).toHaveBeenCalledWith(toggleIsFileExplorerPinned()) | ||
|
||
store.overrideSelector(isFileExplorerPinnedSelector, false) | ||
store.refreshState() | ||
detectChanges() | ||
|
||
expect(screen.getByTitle("Pin file explorer")).toBeTruthy() | ||
}) | ||
}) |
27 changes: 27 additions & 0 deletions
27
visualization/app/codeCharta/ui/searchPanel/thumbTackButton/thumbTackButton.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component, OnInit, ViewEncapsulation } from "@angular/core" | ||
import { Store } from "@ngrx/store" | ||
import { Observable } from "rxjs" | ||
import { CcState } from "../../../codeCharta.model" | ||
|
||
import { toggleIsFileExplorerPinned } from "../../../state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.actions" | ||
import { isFileExplorerPinnedSelector } from "../../../state/store/appSettings/isFileExplorerPinned/isFileExplorerPinned.selector" | ||
|
||
@Component({ | ||
selector: "cc-thumb-tack-button", | ||
templateUrl: "./thumbTackButton.component.html", | ||
styleUrls: ["./thumbTackButton.component.scss"], | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class ThumbTackButtonComponent implements OnInit { | ||
isFileExplorerPinned$: Observable<boolean> | ||
|
||
constructor(private store: Store<CcState>) {} | ||
|
||
ngOnInit(): void { | ||
this.isFileExplorerPinned$ = this.store.select(isFileExplorerPinnedSelector) | ||
} | ||
|
||
onClick() { | ||
this.store.dispatch(toggleIsFileExplorerPinned()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters