-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): refactor graph implementation details (#27267)
Co-authored-by: nartc <[email protected]>
- Loading branch information
1 parent
320d9f2
commit 4fd639b
Showing
209 changed files
with
674 additions
and
8,596 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
155 changes: 155 additions & 0 deletions
155
graph/client/src/app/feature-projects/machines/composite-graph.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import { ProjectGraphStateNodeConfig } from './interfaces'; | ||
import { assign } from '@xstate/immer'; | ||
import { send } from 'xstate'; | ||
|
||
export const compositeGraphStateConfig: ProjectGraphStateNodeConfig = { | ||
entry: [ | ||
assign((ctx, event) => { | ||
if (event.type !== 'enableCompositeGraph') return; | ||
ctx.compositeGraph.enabled = true; | ||
ctx.compositeGraph.context = event.context || undefined; | ||
}), | ||
send( | ||
(ctx) => ({ | ||
type: 'notifyGraphUpdateGraph', | ||
projects: ctx.projects, | ||
dependencies: ctx.dependencies, | ||
fileMap: ctx.fileMap, | ||
affectedProjects: ctx.affectedProjects, | ||
workspaceLayout: ctx.workspaceLayout, | ||
groupByFolder: ctx.groupByFolder, | ||
selectedProjects: ctx.selectedProjects, | ||
composite: ctx.compositeGraph, | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
exit: [ | ||
send(() => ({ type: 'notifyGraphDisableCompositeGraph' }), { | ||
to: (ctx) => ctx.graphActor, | ||
}), | ||
assign((ctx) => { | ||
ctx.compositeGraph.enabled = false; | ||
ctx.compositeGraph.context = undefined; | ||
}), | ||
], | ||
on: { | ||
focusProject: { | ||
actions: [ | ||
assign((ctx, event) => { | ||
if (event.type !== 'focusProject') return; | ||
ctx.focusedProject = event.projectName; | ||
}), | ||
send( | ||
(context, event) => ({ | ||
type: 'notifyGraphFocusProject', | ||
projectName: context.focusedProject, | ||
searchDepth: context.searchDepthEnabled ? context.searchDepth : -1, | ||
}), | ||
{ to: (context) => context.graphActor } | ||
), | ||
], | ||
}, | ||
unfocusProject: { | ||
actions: [ | ||
assign((ctx, event) => { | ||
if (event.type !== 'unfocusProject') return; | ||
ctx.focusedProject = null; | ||
}), | ||
send((ctx) => ({ | ||
type: 'enableCompositeGraph', | ||
context: ctx.compositeGraph.context, | ||
})), | ||
], | ||
}, | ||
deselectProject: { | ||
actions: [ | ||
send( | ||
(ctx, event) => ({ | ||
type: 'notifyGraphHideProjects', | ||
projectNames: [event.projectName], | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
}, | ||
selectProject: { | ||
actions: [ | ||
send( | ||
(ctx, event) => ({ | ||
type: 'notifyGraphShowProjects', | ||
projectNames: [event.projectName], | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
}, | ||
expandCompositeNode: { | ||
actions: [ | ||
send( | ||
(ctx, event) => ({ | ||
type: 'notifyGraphExpandCompositeNode', | ||
id: event.id, | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
}, | ||
collapseCompositeNode: { | ||
actions: [ | ||
send( | ||
(ctx, event) => ({ | ||
type: 'notifyGraphCollapseCompositeNode', | ||
id: event.id, | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
}, | ||
enableCompositeGraph: { | ||
actions: [ | ||
assign((ctx, event) => { | ||
if (event.type !== 'enableCompositeGraph') return; | ||
ctx.compositeGraph.enabled = true; | ||
ctx.compositeGraph.context = event.context || undefined; | ||
}), | ||
send( | ||
(ctx, event) => ({ | ||
type: 'notifyGraphUpdateGraph', | ||
projects: ctx.projects, | ||
dependencies: ctx.dependencies, | ||
fileMap: ctx.fileMap, | ||
affectedProjects: ctx.affectedProjects, | ||
workspaceLayout: ctx.workspaceLayout, | ||
groupByFolder: ctx.groupByFolder, | ||
selectedProjects: ctx.selectedProjects, | ||
composite: ctx.compositeGraph, | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
}, | ||
disableCompositeGraph: { | ||
target: 'unselected', | ||
}, | ||
updateGraph: { | ||
actions: [ | ||
'setGraph', | ||
send( | ||
(ctx, event) => ({ | ||
type: 'notifyGraphUpdateGraph', | ||
projects: ctx.projects, | ||
dependencies: ctx.dependencies, | ||
fileMap: ctx.fileMap, | ||
affectedProjects: ctx.affectedProjects, | ||
workspaceLayout: ctx.workspaceLayout, | ||
groupByFolder: ctx.groupByFolder, | ||
selectedProjects: ctx.selectedProjects, | ||
composite: ctx.compositeGraph, | ||
}), | ||
{ to: (ctx) => ctx.graphActor } | ||
), | ||
], | ||
}, | ||
}, | ||
}; |
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
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
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.