vscodium/patches/feat-announcements.patch
2024-04-04 23:14:54 +02:00

111 lines
5.0 KiB
Diff

diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts
index 66b9062..0a659dc 100644
--- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts
+++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts
@@ -315,2 +315,8 @@ configurationRegistry.registerConfiguration({
},
+ 'workbench.welcomePage.extraAnnouncements': {
+ scope: ConfigurationScope.MACHINE,
+ type: 'boolean',
+ default: true,
+ description: localize('workbench.welcomePage.extraAnnouncements', "When enabled, the get started page loads additional announcements from VSCodium's repository.")
+ },
'workbench.startupEditor': {
diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
index a73549a..fc95016 100644
--- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
+++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
@@ -115,4 +115,8 @@ type GettingStartedActionEvent = {
type RecentEntry = (IRecentFolder | IRecentWorkspace) & { id: string };
+type AnnouncementEntry = { id: string, title: string, url: string };
const REDUCED_MOTION_KEY = 'workbench.welcomePage.preferReducedMotion';
+
+const BUILTIN_ANNOUNCEMENTS: AnnouncementEntry[] = [/* BUILTIN_ANNOUNCEMENTS */];
+
export class GettingStartedPage extends EditorPane {
@@ -151,2 +155,4 @@ export class GettingStartedPage extends EditorPane {
private gettingStartedList?: GettingStartedIndexList<IResolvedWalkthrough>;
+ private announcementList?: GettingStartedIndexList<AnnouncementEntry>;
+ private announcementData?: AnnouncementEntry[];
private videoList?: GettingStartedIndexList<IWelcomePageStartEntry>;
@@ -844,2 +850,3 @@ export class GettingStartedPage extends EditorPane {
const gettingStartedList = this.buildGettingStartedWalkthroughsList();
+ const announcementList = await this.buildAnnouncementList();
@@ -856,6 +863,6 @@ export class GettingStartedPage extends EditorPane {
this.container.classList.remove('noVideos');
- reset(rightColumn, videoList?.getDomElement(), gettingStartedList.getDomElement());
+ reset(rightColumn, videoList?.getDomElement(), gettingStartedList.getDomElement(), announcementList.getDomElement());
} else {
this.container.classList.add('noVideos');
- reset(rightColumn, gettingStartedList.getDomElement());
+ reset(rightColumn, gettingStartedList.getDomElement(), announcementList.getDomElement());
}
@@ -866,3 +873,3 @@ export class GettingStartedPage extends EditorPane {
this.container.classList.remove('noVideos');
- reset(rightColumn, videoList?.getDomElement());
+ reset(rightColumn, videoList?.getDomElement(), announcementList.getDomElement());
}
@@ -870,3 +877,3 @@ export class GettingStartedPage extends EditorPane {
this.container.classList.add('noVideos');
- reset(rightColumn);
+ reset(rightColumn, announcementList.getDomElement());
}
@@ -1023,2 +1030,55 @@ export class GettingStartedPage extends EditorPane {
+ private async buildAnnouncementList(): Promise<GettingStartedIndexList<AnnouncementEntry>> {
+ const renderAnnouncement = (announcement: AnnouncementEntry) => {
+ const { title, url } = announcement;
+ const li = $('li');
+
+ const anchor: HTMLLinkElement = $('a');
+ anchor.href = url;
+ anchor.innerText = title;
+ anchor.target = '_blank';
+ li.appendChild(anchor);
+
+ return li;
+ };
+
+ if (this.announcementList) { this.announcementList.dispose(); }
+
+ const announcementList = this.announcementList = new GettingStartedIndexList({
+ title: localize('announcements', "VSCodium Announcements"),
+ klass: 'announcements',
+ limit: 5,
+ empty: $('.empty-recent', {}, localize('noAnnouncements', "There are no current announcements.")),
+ renderElement: renderAnnouncement,
+ contextService: this.contextService
+ });
+
+ if (!this.announcementData) {
+ const showExtras = this.configurationService.getValue<boolean>('workbench.welcomePage.extraAnnouncements');
+
+ if (showExtras) {
+ const branch = this.productService.quality === 'insider' ? 'insider' : 'master';
+ await fetch(`https://raw.githubusercontent.com/VSCodium/vscodium/${branch}/announcements-extra.json`)
+ .then(async res => {
+ if (res.ok) {
+ var extraAnnouncements = await res.json() as AnnouncementEntry[];
+
+ this.announcementData = [...extraAnnouncements, ...BUILTIN_ANNOUNCEMENTS];
+ } else {
+ this.announcementData = BUILTIN_ANNOUNCEMENTS;
+ }
+ })
+ .catch(err => {
+ this.announcementData = BUILTIN_ANNOUNCEMENTS;
+ });
+ } else {
+ this.announcementData = BUILTIN_ANNOUNCEMENTS;
+ }
+ }
+
+ announcementList.setEntries(this.announcementData);
+
+ return announcementList;
+ }
+
private buildStartList(): GettingStartedIndexList<IWelcomePageStartEntry> {