From 0d5a78f47faaea5541750516b93140ffeff15b3d Mon Sep 17 00:00:00 2001 From: Victor Savkin Date: Fri, 31 May 2019 09:35:57 -0400 Subject: [PATCH] feat: add support for notifications --- apps/electron/src/app/start-server.ts | 11 +++++++++- apps/vscode/src/app/start-server.ts | 29 ++++++++++++++++++++++++--- package.json | 4 ++-- yarn.lock | 16 +++++++-------- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/apps/electron/src/app/start-server.ts b/apps/electron/src/app/start-server.ts index 8e14123f1b..013b2d38e4 100644 --- a/apps/electron/src/app/start-server.ts +++ b/apps/electron/src/app/start-server.ts @@ -34,9 +34,14 @@ export async function startServer( 'store', 'selectDirectory', 'pseudoTerminalFactory', - 'assetsPath' + 'assetsPath', + 'showNotification' ]; + const showNotification = () => { + // todo, implement this + }; + const assetsPath = path.join(__dirname, 'assets/public'); const providers = [ { provide: 'serverAddress', useValue: `http://localhost:${port}` }, @@ -49,6 +54,10 @@ export async function startServer( { provide: 'assetsPath', useValue: assetsPath + }, + { + provide: 'showNotification', + useValue: showNotification } ]; diff --git a/apps/vscode/src/app/start-server.ts b/apps/vscode/src/app/start-server.ts index d40398b538..798c93d613 100644 --- a/apps/vscode/src/app/start-server.ts +++ b/apps/vscode/src/app/start-server.ts @@ -1,4 +1,4 @@ -import { ExtensionContext, window } from 'vscode'; +import { commands, ExtensionContext, window } from 'vscode'; import { createServerModule, SelectDirectory, @@ -43,6 +43,27 @@ export async function startServer( }); }; + const showNotification = ( + message: string, + notificationCommands: { label: string; action: any }[] + ) => { + window + .showInformationMessage( + message, + ...notificationCommands.map(c => c.label) + ) + .then(res => { + const selectedCommand = notificationCommands.find(n => n.label === res); + if (selectedCommand) { + commands.executeCommand( + selectedCommand.action.extension, + undefined, + selectedCommand.action.route + ); + } + }); + }; + const pseudoTerminalFactory = getPseudoTerminalFactory(context); const exports = [ @@ -50,7 +71,8 @@ export async function startServer( 'store', 'selectDirectory', 'pseudoTerminalFactory', - 'assetsPath' + 'assetsPath', + 'showNotification' ]; const assetsPath = path.join(context.extensionPath, 'assets', 'public'); @@ -68,7 +90,8 @@ export async function startServer( { provide: 'store', useValue: store }, { provide: 'selectDirectory', useValue: selectDirectory }, { provide: 'pseudoTerminalFactory', useValue: pseudoTerminalFactory }, - { provide: 'assetsPath', useValue: assetsPath } + { provide: 'assetsPath', useValue: assetsPath }, + { provide: 'showNotification', useValue: showNotification } ]; console.log('starting server on port', port); diff --git a/package.json b/package.json index 5b2b905b83..d640d9b0d8 100644 --- a/package.json +++ b/package.json @@ -112,8 +112,8 @@ "@nestjs/common": "5.7.0", "@nestjs/core": "5.7.0", "@nestjs/graphql": "5.5.1", - "@nrwl/angular-console-enterprise-electron": "0.3.548", - "@nrwl/angular-console-enterprise-frontend": "0.3.548", + "@nrwl/angular-console-enterprise-electron": "0.3.555", + "@nrwl/angular-console-enterprise-frontend": "0.3.555", "@types/d3-hierarchy": "^1.1.6", "@types/d3-selection": "^1.4.1", "@types/d3-shape": "^1.3.1", diff --git a/yarn.lock b/yarn.lock index c38cf52c10..e5f3fcdc5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -638,10 +638,10 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== -"@nrwl/angular-console-enterprise-electron@0.3.548": - version "0.3.548" - resolved "https://registry.yarnpkg.com/@nrwl/angular-console-enterprise-electron/-/angular-console-enterprise-electron-0.3.548.tgz#aa038fb26eccdfc2bd99b079e077c4c8f482b8f1" - integrity sha512-MUMlfUaKxLVoy6AsaGhZzg6/HClRR95RGyHAQe2JTZZHVhd10FGDLCdD+gFQ3jba4cZyrzOEGzbu63TMWSjNKA== +"@nrwl/angular-console-enterprise-electron@0.3.555": + version "0.3.555" + resolved "https://registry.yarnpkg.com/@nrwl/angular-console-enterprise-electron/-/angular-console-enterprise-electron-0.3.555.tgz#53d8332a5184e5d6155ec4851c15256b4beb92d1" + integrity sha512-JPsVO6rhuk3Pp45PdD3pMvbIAhw/Rgui5Xbxxr9gUWiiH1BGbXWxJrjjVB7PGy2DVvGoA2mEMZ/ogI8QsN9yuQ== dependencies: apollo-cache-inmemory "1.3.10" apollo-client "^2.3.5" @@ -651,10 +651,10 @@ node-fetch "2.3.0" request "2.88.0" -"@nrwl/angular-console-enterprise-frontend@0.3.548": - version "0.3.548" - resolved "https://registry.yarnpkg.com/@nrwl/angular-console-enterprise-frontend/-/angular-console-enterprise-frontend-0.3.548.tgz#d57a7ee52d614f60711620d2c668671112bd63fe" - integrity sha512-mE9WqAdW4H6p8C0LDPudzFukcItCB8+JUSOgTAIlA0SXmgHVsGxAHZ2R8AFdJSGBipAvr69SExqLuENlcFxCMw== +"@nrwl/angular-console-enterprise-frontend@0.3.555": + version "0.3.555" + resolved "https://registry.yarnpkg.com/@nrwl/angular-console-enterprise-frontend/-/angular-console-enterprise-frontend-0.3.555.tgz#e2b8d188852326a788e5d38f124594c04671a388" + integrity sha512-W1FTe86+7aBZq4X4401n0pvvckyaMrlw9OwHhB+qCLvMyCnbnxLd0wcipsSCWaBhYFHxztHxoxUCHg6EgS3crQ== dependencies: d3-ease "^1.0.5" d3-format "^1.3.2"