Skip to content

feat: connect workspace filesystem navigator #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tomzohar
Copy link
Contributor

@tomzohar tomzohar commented Mar 26, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: CONTRIBUTING.md
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

implement filesystem navigator in connect workspace domain

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

using a form input to get the absolute path to the workspace

Issue Number: #7

What is the new behavior?

allowing the user to navigate his filesystem and connect any angular workspace

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

image

image

@nx-cloud
Copy link

nx-cloud bot commented Mar 26, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1af8843. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 3 targets

Sent with 💌 from NxCloud.

@codecov
Copy link

codecov bot commented Mar 26, 2023

Codecov Report

Merging #106 (1af8843) into master (8774af7) will increase coverage by 2.06%.
The diff coverage is 98.03%.

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   64.34%   66.40%   +2.06%     
==========================================
  Files          77       81       +4     
  Lines         589      643      +54     
  Branches       27       32       +5     
==========================================
+ Hits          379      427      +48     
- Misses        209      214       +5     
- Partials        1        2       +1     
Flag Coverage Δ *Carryforward flag
cli-daemon 49.86% <ø> (ø) Carriedforward from 864c908
cli-gui 89.83% <ø> (ø)
configuration 100.00% <ø> (ø) Carriedforward from 864c908
executors 100.00% <ø> (ø) Carriedforward from 864c908
generators 75.75% <ø> (ø) Carriedforward from 864c908
shared ∅ <ø> (∅) Carriedforward from 864c908
ui 100.00% <ø> (ø) Carriedforward from 864c908
workspace-manager 91.17% <98.03%> (-1.51%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
...oolbar/filesystem-navigator-toolbar.component.html 100.00% <ø> (ø)
...stem-navigator/filesystem-navigator.component.html 100.00% <ø> (ø)
...s/connect-workspace/connect-workspace.component.ts 97.43% <97.05%> (+22.43%) ⬆️
...connect-workspace/connect-workspace.component.html 100.00% <100.00%> (ø)
...ce-manager/src/lib/mocks/connect-workspace.mock.ts 100.00% <100.00%> (ø)
...-toolbar/filesystem-navigator-toolbar.component.ts 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@tomzohar tomzohar requested a review from a team March 26, 2023 13:27
const path$ = currentWorkspacePath
? of(currentWorkspacePath)
: this.workspaceManagerApiService.getHomeDir();
path$.subscribe((path: string) => this.path$.next(path));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to handle unsubscribing?

Copy link
Contributor Author

@tomzohar tomzohar Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the of observable completes after emitting and the http observable also completes

this.initWorkspacePath();
});

combineLatest([this.path$, this.pathSeparator$])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

directories$ could just be an observable and you can remove the takeUntil

Suggested change
combineLatest([this.path$, this.pathSeparator$])
this.directories$ = combineLatest([this.path$, this.pathSeparator$]).pipe(
switchMap(([path, separator]) => {
path && separator && this.setIsAngularWorkspace(path, separator);
return path
? this.workspaceManagerApiService.getDirectoriesInPath(path)
: of([]);
}),
)

this.workspaceManagerApiService
.getPathSeparator()
.subscribe((separator) => {
this.pathSeparator$.next(separator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pathSeparator$ can also be an observable, the same as directories$

<button
mat-raised-button
color="primary"
[disabled]="(isAngularWorkspace$ | async) === false"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it should be hidden entirely if not angular workspace (having a disabled button without some explanation can be confusing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the explanation is in the icons of the file system
if you click an angular workspace folder the connect button is enabled
if you click a regular folder it's disabled

{
provide: WorkspaceManagerApiService,
useValue: workspaceManagerApiServiceMock,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of exposing getWorkspaceManagerApiServiceMock(), expose a provideWorkspaceManagerTesting() that returns an Provider[] and includes all the mocks that are needed for testing workspace-manager (including connect-workspace)

path$.subscribe((path: string) => this.path$.next(path));
}

private setIsAngularWorkspace(path: string, separator: string): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it should be part of filesystem-navigator, and you should add an output to that component instead of isAngularWorkspace$ behavior subject you have here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is what i did in the last PR and you and @OmerGronich said to keep the component dumb
I also think that this calculation should be done inside the navigator

private destroyed$ = new Subject<boolean>();

ngOnInit(): void {
this.workspaceManagerApiService
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are too many subscribes that ends up assigning the returned value into another subject that is being subscribed in the template with async pipe. try to think how this can be avoided and instead of subjects and subscribes in ts work as much as you can with streams that are being subscribed with async pipe

Comment on lines +8 to +11
<ng-container
actions
[ngTemplateOutlet]="fsNavigatorActions"
></ng-container>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would've put it directly in the toolbar component instead of using ng-content twice (this goes with the previous comment of moving the isAngularWorkspace logic into the navigator component)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants