forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanner.ts
More file actions
47 lines (42 loc) · 1.58 KB
/
banner.ts
File metadata and controls
47 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import * as child_process from 'child_process';
import * as os from 'os';
import { window } from 'vscode';
import { IPersistentStateFactory, PersistentState } from './common/persistentState';
const BANNER_URL = 'https://aka.ms/pvsc-at-msft';
export class BannerService {
private shouldShowBanner: PersistentState<boolean>;
constructor(persistentStateFactory: IPersistentStateFactory) {
this.shouldShowBanner = persistentStateFactory.createGlobalPersistentState('SHOW_NEW_PUBLISHER_BANNER', true);
this.showBanner();
}
private showBanner() {
if (!this.shouldShowBanner.value) {
return;
}
this.shouldShowBanner.value = false;
const message = 'The Python extension is now published by Microsoft!';
const yesButton = 'Read more';
window.showInformationMessage(message, yesButton).then((value) => {
if (value === yesButton) {
this.displayBanner();
}
});
}
private displayBanner() {
let openCommand: string | undefined;
if (os.platform() === 'win32') {
openCommand = 'explorer';
} else if (os.platform() === 'darwin') {
openCommand = '/usr/bin/open';
} else {
openCommand = '/usr/bin/xdg-open';
}
if (!openCommand) {
console.error(`Unable open ${BANNER_URL} on platform '${os.platform()}'.`);
}
child_process.spawn(openCommand, [BANNER_URL]);
}
}