Skip to content

Commit 48e0775

Browse files
DruuejanpioJolg42
authored
feat(vsc): Add PDP notification (#1716)
Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com> Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
1 parent c5e3132 commit 48e0775

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

packages/vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
"/path/to/your/schema.prisma"
146146
],
147147
"description": "If you have a Prisma schema file in a custom path, you will need to provide said path `/path/to/your/schema.prisma` to run generate"
148+
},
149+
"prisma.showPrismaDataPlatformNotification": {
150+
"type": "boolean",
151+
"default": "true",
152+
"description": "If checked, a notification will be displayed, once, on the next activation of the Prisma extension only."
148153
}
149154
}
150155
},

packages/vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ExtensionContext } from 'vscode'
22
import plugins from './plugins'
33

44
export function activate(context: ExtensionContext): void {
5-
plugins.map(async (plugin) => {
5+
void plugins.map(async (plugin) => {
66
const enabled = await plugin.enabled()
77
if (enabled) {
88
console.log(`Activating ${plugin.name}`)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { workspace, window, env, Uri, ConfigurationTarget } from 'vscode'
2+
3+
export const showPDPNotification = async () => {
4+
const pdpNotif = workspace.getConfiguration('prisma').get('showPrismaDataPlatformNotification', true)
5+
6+
if (!pdpNotif) return
7+
8+
void window
9+
.showInformationMessage(
10+
'Supercharge your Prisma ORM usage with global database caching, serverless connection pooling and real-time database events.',
11+
'Visit Prisma Data Platform',
12+
)
13+
.then((v) => {
14+
if (v === undefined) return
15+
16+
void env.openExternal(Uri.parse('https://pris.ly/vscode/pdp'))
17+
})
18+
19+
await workspace
20+
.getConfiguration('prisma')
21+
.update('showPrismaDataPlatformNotification', false, ConfigurationTarget.Global)
22+
}

packages/vscode/src/plugins/prisma-language-server/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { PrismaVSCodePlugin } from '../types'
3737
import paths from 'env-paths'
3838
import FileWatcher from 'watcher'
3939
import { CodelensProvider, generateClient } from '../../CodeLensProvider'
40+
import { showPDPNotification } from '../../notifications'
4041

4142
const packageJson = require('../../../../package.json') // eslint-disable-line
4243

@@ -210,6 +211,8 @@ const plugin: PrismaVSCodePlugin = {
210211
} as any, // eslint-disable-line @typescript-eslint/no-explicit-any
211212
}
212213

214+
await showPDPNotification()
215+
213216
context.subscriptions.push(
214217
// when the file watcher settings change, we need to ensure they are applied
215218
workspace.onDidChangeConfiguration((event) => {

0 commit comments

Comments
 (0)