Skip to content

Commit

Permalink
feat(vsc): Add PDP notification (#1716)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
Co-authored-by: Jo毛l Galeran <Jolg42@users.noreply.github.com>
  • Loading branch information
3 people committed May 13, 2024
1 parent c5e3132 commit 48e0775
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
"/path/to/your/schema.prisma"
],
"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"
},
"prisma.showPrismaDataPlatformNotification": {
"type": "boolean",
"default": "true",
"description": "If checked, a notification will be displayed, once, on the next activation of the Prisma extension only."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExtensionContext } from 'vscode'
import plugins from './plugins'

export function activate(context: ExtensionContext): void {
plugins.map(async (plugin) => {
void plugins.map(async (plugin) => {
const enabled = await plugin.enabled()
if (enabled) {
console.log(`Activating ${plugin.name}`)
Expand Down
22 changes: 22 additions & 0 deletions packages/vscode/src/notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { workspace, window, env, Uri, ConfigurationTarget } from 'vscode'

export const showPDPNotification = async () => {
const pdpNotif = workspace.getConfiguration('prisma').get('showPrismaDataPlatformNotification', true)

if (!pdpNotif) return

void window
.showInformationMessage(
'Supercharge your Prisma ORM usage with global database caching, serverless connection pooling and real-time database events.',
'Visit Prisma Data Platform',
)
.then((v) => {
if (v === undefined) return

void env.openExternal(Uri.parse('https://pris.ly/vscode/pdp'))
})

await workspace
.getConfiguration('prisma')
.update('showPrismaDataPlatformNotification', false, ConfigurationTarget.Global)
}
3 changes: 3 additions & 0 deletions packages/vscode/src/plugins/prisma-language-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { PrismaVSCodePlugin } from '../types'
import paths from 'env-paths'
import FileWatcher from 'watcher'
import { CodelensProvider, generateClient } from '../../CodeLensProvider'
import { showPDPNotification } from '../../notifications'

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

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

await showPDPNotification()

context.subscriptions.push(
// when the file watcher settings change, we need to ensure they are applied
workspace.onDidChangeConfiguration((event) => {
Expand Down

0 comments on commit 48e0775

Please sign in to comment.