-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a300c0e
commit 18c217b
Showing
84 changed files
with
974 additions
and
692 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
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,13 @@ | ||
import { getProjectGraphService } from './machines/get-services'; | ||
|
||
export class ExternalApi { | ||
projectGraphService = getProjectGraphService(); | ||
|
||
focusProject(projectName: string) { | ||
this.projectGraphService.send({ type: 'focusProject', projectName }); | ||
} | ||
|
||
enableExperimentalFeatures() { | ||
window.appConfig.showExperimentalFeatures = true; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
graph/client/src/app/feature-projects/hooks/use-project-graph-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,18 @@ | ||
import { useSelector } from '@xstate/react'; | ||
import { ProjectGraphState } from '../machines/interfaces'; | ||
import { getProjectGraphService } from '../../machines/get-services'; | ||
|
||
export type ProjectGraphSelector<T> = ( | ||
projectGraphState: ProjectGraphState | ||
) => T; | ||
|
||
export function useProjectGraphSelector<T>( | ||
selectorFunc: ProjectGraphSelector<T> | ||
): T { | ||
const projectGraphService = getProjectGraphService(); | ||
|
||
return useSelector<typeof projectGraphService, T>( | ||
projectGraphService, | ||
selectorFunc | ||
); | ||
} |
4 changes: 2 additions & 2 deletions
4
...src/app/machines/custom-selected.state.ts → ...rojects/machines/custom-selected.state.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
4 changes: 2 additions & 2 deletions
4
.../client/src/app/machines/focused.state.ts → ...eature-projects/machines/focused.state.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
5 changes: 3 additions & 2 deletions
5
graph/client/src/app/machines/graph.actor.ts → .../feature-projects/machines/graph.actor.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
112 changes: 112 additions & 0 deletions
112
graph/client/src/app/feature-projects/machines/interfaces.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,112 @@ | ||
import { GraphPerfReport } from '../../interfaces'; | ||
import { | ||
ProjectGraphDependency, | ||
ProjectGraphProjectNode, | ||
} from 'nx/src/config/project-graph'; | ||
import { ActionObject, ActorRef, State, StateNodeConfig } from 'xstate'; | ||
import { GraphRenderEvents, RouteEvents } from '../../machines/interfaces'; | ||
|
||
// The hierarchical schema for the states | ||
export interface ProjectGraphSchema { | ||
states: { | ||
idle: {}; | ||
unselected: {}; | ||
focused: {}; | ||
textFiltered: {}; | ||
customSelected: {}; | ||
tracing: {}; | ||
}; | ||
} | ||
|
||
export type TracingAlgorithmType = 'shortest' | 'all'; | ||
|
||
// The events that the machine handles | ||
export type ProjectGraphMachineEvents = | ||
| { | ||
type: 'setSelectedProjectsFromGraph'; | ||
selectedProjectNames: string[]; | ||
perfReport: GraphPerfReport; | ||
} | ||
| { type: 'selectProject'; projectName: string } | ||
| { type: 'deselectProject'; projectName: string } | ||
| { type: 'selectProjects'; projectNames: string[] } | ||
| { type: 'deselectProjects'; projectNames: string[] } | ||
| { type: 'selectAll' } | ||
| { type: 'deselectAll' } | ||
| { type: 'selectAffected' } | ||
| { type: 'setGroupByFolder'; groupByFolder: boolean } | ||
| { type: 'setTracingStart'; projectName: string } | ||
| { type: 'setTracingEnd'; projectName: string } | ||
| { type: 'clearTraceStart' } | ||
| { type: 'clearTraceEnd' } | ||
| { type: 'setTracingAlgorithm'; algorithm: TracingAlgorithmType } | ||
| { type: 'setCollapseEdges'; collapseEdges: boolean } | ||
| { type: 'setIncludeProjectsByPath'; includeProjectsByPath: boolean } | ||
| { type: 'incrementSearchDepth' } | ||
| { type: 'decrementSearchDepth' } | ||
| { type: 'setSearchDepthEnabled'; searchDepthEnabled: boolean } | ||
| { type: 'setSearchDepth'; searchDepth: number } | ||
| { type: 'focusProject'; projectName: string } | ||
| { type: 'unfocusProject' } | ||
| { type: 'filterByText'; search: string } | ||
| { type: 'clearTextFilter' } | ||
| { | ||
type: 'notifyProjectGraphSetProjects'; | ||
projects: ProjectGraphProjectNode[]; | ||
dependencies: Record<string, ProjectGraphDependency[]>; | ||
affectedProjects: string[]; | ||
workspaceLayout: { | ||
libsDir: string; | ||
appsDir: string; | ||
}; | ||
} | ||
| { | ||
type: 'updateGraph'; | ||
projects: ProjectGraphProjectNode[]; | ||
dependencies: Record<string, ProjectGraphDependency[]>; | ||
}; | ||
|
||
// The context (extended state) of the machine | ||
export interface ProjectGraphContext { | ||
projects: ProjectGraphProjectNode[]; | ||
dependencies: Record<string, ProjectGraphDependency[]>; | ||
affectedProjects: string[]; | ||
selectedProjects: string[]; | ||
focusedProject: string | null; | ||
textFilter: string; | ||
includePath: boolean; | ||
searchDepth: number; | ||
searchDepthEnabled: boolean; | ||
groupByFolder: boolean; | ||
collapseEdges: boolean; | ||
workspaceLayout: { | ||
libsDir: string; | ||
appsDir: string; | ||
}; | ||
graphActor: ActorRef<GraphRenderEvents>; | ||
routeSetterActor: ActorRef<RouteEvents>; | ||
routeListenerActor: ActorRef<ProjectGraphMachineEvents>; | ||
lastPerfReport: GraphPerfReport; | ||
tracing: { | ||
start: string; | ||
end: string; | ||
algorithm: TracingAlgorithmType; | ||
}; | ||
} | ||
|
||
export type ProjectGraphStateNodeConfig = StateNodeConfig< | ||
ProjectGraphContext, | ||
{}, | ||
ProjectGraphMachineEvents, | ||
ActionObject<ProjectGraphContext, ProjectGraphMachineEvents> | ||
>; | ||
|
||
export type ProjectGraphState = State< | ||
ProjectGraphContext, | ||
ProjectGraphMachineEvents, | ||
any, | ||
{ | ||
value: any; | ||
context: ProjectGraphContext; | ||
} | ||
>; |
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
File renamed without changes.
59 changes: 59 additions & 0 deletions
59
graph/client/src/app/feature-projects/machines/selectors.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,59 @@ | ||
// nx-ignore-next-line | ||
import type { ProjectGraphProjectNode } from '@nrwl/devkit'; | ||
import { ProjectGraphSelector } from '../hooks/use-project-graph-selector'; | ||
import { GraphPerfReport, WorkspaceLayout } from '../../interfaces'; | ||
import { TracingAlgorithmType } from './interfaces'; | ||
|
||
export const allProjectsSelector: ProjectGraphSelector< | ||
ProjectGraphProjectNode[] | ||
> = (state) => state.context.projects; | ||
|
||
export const workspaceLayoutSelector: ProjectGraphSelector<WorkspaceLayout> = ( | ||
state | ||
) => state.context.workspaceLayout; | ||
|
||
export const selectedProjectNamesSelector: ProjectGraphSelector<string[]> = ( | ||
state | ||
) => state.context.selectedProjects; | ||
|
||
export const projectIsSelectedSelector: ProjectGraphSelector<boolean> = ( | ||
state | ||
) => state.context.selectedProjects.length > 0; | ||
|
||
export const lastPerfReportSelector: ProjectGraphSelector<GraphPerfReport> = ( | ||
state | ||
) => state.context.lastPerfReport; | ||
|
||
export const focusedProjectNameSelector: ProjectGraphSelector<string> = ( | ||
state | ||
) => state.context.focusedProject; | ||
|
||
export const searchDepthSelector: ProjectGraphSelector<{ | ||
searchDepth: number; | ||
searchDepthEnabled: boolean; | ||
}> = (state) => ({ | ||
searchDepth: state.context.searchDepth, | ||
searchDepthEnabled: state.context.searchDepthEnabled, | ||
}); | ||
|
||
export const includePathSelector: ProjectGraphSelector<boolean> = (state) => | ||
state.context.includePath; | ||
|
||
export const groupByFolderSelector: ProjectGraphSelector<boolean> = (state) => | ||
state.context.groupByFolder; | ||
|
||
export const collapseEdgesSelector: ProjectGraphSelector<boolean> = (state) => | ||
state.context.collapseEdges; | ||
|
||
export const textFilterSelector: ProjectGraphSelector<string> = (state) => | ||
state.context.textFilter; | ||
|
||
export const hasAffectedProjectsSelector: ProjectGraphSelector<boolean> = ( | ||
state | ||
) => state.context.affectedProjects.length > 0; | ||
|
||
export const getTracingInfo: ProjectGraphSelector<{ | ||
start: string; | ||
end: string; | ||
algorithm: TracingAlgorithmType; | ||
}> = (state) => state.context.tracing; |
4 changes: 2 additions & 2 deletions
4
...t/src/app/machines/text-filtered.state.ts → ...-projects/machines/text-filtered.state.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
4 changes: 2 additions & 2 deletions
4
.../client/src/app/machines/tracing.state.ts → ...eature-projects/machines/tracing.state.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
6 changes: 3 additions & 3 deletions
6
...ient/src/app/machines/unselected.state.ts → ...ure-projects/machines/unselected.state.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
7 changes: 2 additions & 5 deletions
7
graph/client/src/app/feature-projects/panels/collapse-edges-panel.stories.tsx
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
7 changes: 2 additions & 5 deletions
7
graph/client/src/app/feature-projects/panels/focused-project-panel.stories.tsx
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
7 changes: 2 additions & 5 deletions
7
graph/client/src/app/feature-projects/panels/group-by-folder-panel.stories.tsx
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
2 changes: 1 addition & 1 deletion
2
graph/client/src/app/feature-projects/panels/rankdir-panel.stories.tsx
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: 1 addition & 2 deletions
3
graph/client/src/app/feature-projects/panels/rankdir-panel.tsx
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: 2 additions & 2 deletions
4
graph/client/src/app/feature-projects/panels/search-depth.stories.tsx
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
Oops, something went wrong.