Skip to content
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

feat: add show all projects in graph command #1412

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion apps/vscode/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,15 @@
}
],
"view/title": [
{
"command": "nx.graph.showAll",
"when": "view == nxProjects",
"group": "navigation@0"
},
{
"command": "nxConsole.refreshWorkspace",
"when": "view == nxProjects",
"group": "navigation"
"group": "navigation@1"
},
{
"command": "nxConsole.refreshWorkspace",
Expand Down Expand Up @@ -548,6 +553,12 @@
"command": "nx.graph.select.button",
"icon": "$(eye)"
},
{
"category": "Nx",
"title": "Show full project graph",
"command": "nx.graph.showAll",
"icon": "$(source-control)"
},
{
"category": "Nx",
"title": "run-many",
Expand Down
1 change: 1 addition & 0 deletions libs/vscode/project-graph/src/lib/graph-message-type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const enum MessageType {
focus = 'FOCUS',
select = 'SELECT',
all = 'ALL',
}
19 changes: 18 additions & 1 deletion libs/vscode/project-graph/src/lib/graph-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class GraphWebView implements Disposable {
graphService.send('GET_CONTENT');
}

async projectInWebview(projectName: string | undefined, type: MessageType) {
projectInWebview(projectName: string | undefined, type: MessageType) {
getOutputChannel().appendLine(`Graph - Opening graph for ${projectName}`);
if (!this.panel) {
this._webview();
Expand All @@ -95,6 +95,23 @@ export class GraphWebView implements Disposable {
});
}

showAllProjects() {
getOutputChannel().appendLine(`Graph - Opening full graph`);

if (!this.panel) {
this._webview();
}

this.panel?.reveal();

graphService.send('PROJECT_SELECTED', {
data: {
type: MessageType.all,
projectName: '',
},
});
}

refresh() {
graphService.send('REFRESH');
}
Expand Down
11 changes: 10 additions & 1 deletion libs/vscode/project-graph/src/lib/load-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ function injectedScript() {

function waitForAndClickOnElement(data) {
function clickOnElement() {
if(data.type === "${MessageType.all}") {
const allProjectsElement = document.querySelector(\`[data-cy="selectAllButton"]\`);
if(allProjectsElement) {
allProjectsElement.click();
return true;
} else {
return false;
}
}
const projectElement = document.querySelector(\`[data-project="\${data.projectName}"]\`);
if(projectElement) {
if (data.type === "${MessageType.focus}") {
Expand Down Expand Up @@ -271,7 +280,7 @@ function injectedScript() {
//noop
}

waitForAndClickOnElement(data);
setTimeout(() => waitForAndClickOnElement(data), 0);
})
}())
`;
Expand Down
4 changes: 4 additions & 0 deletions libs/vscode/project-graph/src/lib/project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export function projectGraph() {
getTelemetry().featureUsed('nx.graph.refresh');
graphWebView.refresh();
}),
commands.registerCommand('nx.graph.showAll', () => {
getTelemetry().featureUsed('nx.graph.showAll');
graphWebView.showAllProjects();
}),
commands.registerCommand('nx.graph.focus', async (uri: Uri | undefined) => {
getTelemetry().featureUsed('nx.graph.focus');
await openProjectWithFile(graphWebView, uri, MessageType.focus);
Expand Down