Skip to content

Commit

Permalink
add setting for vscode notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless committed Nov 21, 2024
1 parent c5ba9e8 commit 67bb04f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
15 changes: 15 additions & 0 deletions apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,21 @@
"nxConsole.nxWorkspacePath": {
"type": "string",
"description": "Specifies the relative path to the root directory of the Nx workspace. Can be configured on a user or workspace level."
},
"nxConsole.nxCloudNotifications": {
"type": "enum",
"enum": [
"all",
"errors",
"none"
],
"enumDescriptions": [
"Show all Nx Cloud notifications",
"Show only error Nx Cloud notifications",
"Show no Nx Cloud notifications"
],
"default": "all",
"description": "Controls which notifications are shown in the Nx Cloud view."
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions libs/vscode/configuration/src/lib/configuration-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const GLOBAL_CONFIG_KEYS = [
'showProjectDetailsView',
'showNodeVersionOnStartup',
'nxWorkspacePath',
'nxCloudNotifications',
] as const;

export type GlobalConfig = {
Expand All @@ -30,6 +31,7 @@ export type GlobalConfig = {
showProjectDetailsView: boolean;
showNodeVersionOnStartup: boolean;
nxWorkspacePath: string;
nxCloudNotifications: 'all' | 'errors' | 'none';
};

/**
Expand Down
21 changes: 16 additions & 5 deletions libs/vscode/nx-cloud-view/src/lib/init-nx-cloud-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import { getWorkspacePath } from '@nx-console/vscode/utils';
import { importNxPackagePath } from '@nx-console/shared/npm';
import { CIPEInfo, CIPEInfoError } from '@nx-console/shared/types';
import { isCompleteStatus, isFailedStatus } from '@nx-console/shared/utils';
import { getNxWorkspacePath } from '@nx-console/vscode/configuration';
import {
getNxWorkspacePath,
GlobalConfigurationStore,
} from '@nx-console/vscode/configuration';
import { execSync } from 'child_process';
import { get } from 'http';

Expand Down Expand Up @@ -243,6 +246,14 @@ function compareCIPEDataAndSendNotification(
oldInfo: CIPEInfo[],
newInfo: CIPEInfo[]
) {
const nxCloudNotificationsSetting = GlobalConfigurationStore.instance.get(
'nxCloudNotifications'
);

if (nxCloudNotificationsSetting === 'none') {
return;
}

oldInfo.forEach((oldCIPE) => {
const newCIPE = newInfo.find(
(newCIPE) =>
Expand All @@ -262,10 +273,10 @@ function compareCIPEDataAndSendNotification(
? window.showInformationMessage
: window.showErrorMessage)(
`CIPE for branch ${oldCIPE.branch} has completed`,
'View Details',
'View Results',
'OK'
).then(async (selection) => {
if (selection === 'View Details') {
if (selection === 'View Results') {
commands.executeCommand('vscode.open', newCIPE.cipeUrl);
}
});
Expand All @@ -290,11 +301,11 @@ function compareCIPEDataAndSendNotification(
window
.showErrorMessage(
`${newFailedRun.command} has failed on branch ${newCIPE.branch}`,
'View Details',
'View Results',
'OK'
)
.then(async (selection) => {
if (selection === 'View Details') {
if (selection === 'View Results') {
commands.executeCommand('vscode.open', newFailedRun.runUrl);
}
});
Expand Down

0 comments on commit 67bb04f

Please sign in to comment.