Skip to content

Commit

Permalink
fix: move action to contribution file
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Apr 15, 2024
1 parent 55b33b4 commit bebabb0
Showing 1 changed file with 152 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= <loic@coderpad.io>
Date: Mon, 15 Apr 2024 10:52:20 +0200
Subject: [PATCH] fix: move action from service file to contribution

---
.../browser/gettingStarted.contribution.ts | 45 +++++++++++++++++-
.../browser/gettingStartedService.ts | 46 +------------------
2 files changed, 46 insertions(+), 45 deletions(-)

diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts
index 66b9062611f..353af173d3f 100644
--- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts
+++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.ts
@@ -15,7 +15,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import { KeyCode } from 'vs/base/common/keyCodes';
import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/editor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
-import { IWalkthroughsService } from 'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService';
+import { IWalkthroughsService, hiddenEntriesConfigurationKey, walkthroughMetadataConfigurationKey } from 'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService';
import { GettingStartedEditorOptions, GettingStartedInput } from 'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedInput';
import { registerWorkbenchContribution2, WorkbenchPhase } from 'vs/workbench/common/contributions';
import { ConfigurationScope, Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
@@ -30,6 +30,8 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import { StartupPageEditorResolverContribution, StartupPageRunnerContribution } from 'vs/workbench/contrib/welcomeGettingStarted/browser/startupPage';
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
+import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
+import { Memento } from 'vs/workbench/common/memento';

export * as icons from 'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedIcons';

@@ -341,3 +343,44 @@ configurationRegistry.registerConfiguration({
registerWorkbenchContribution2(WorkspacePlatformContribution.ID, WorkspacePlatformContribution, WorkbenchPhase.AfterRestored);
registerWorkbenchContribution2(StartupPageEditorResolverContribution.ID, StartupPageEditorResolverContribution, WorkbenchPhase.BlockRestore);
registerWorkbenchContribution2(StartupPageRunnerContribution.ID, StartupPageRunnerContribution, WorkbenchPhase.AfterRestored);
+
+registerAction2(class extends Action2 {
+ constructor() {
+ super({
+ id: 'resetGettingStartedProgress',
+ category: localize2('developer', "Developer"),
+ title: localize2('resetWelcomePageWalkthroughProgress', "Reset Welcome Page Walkthrough Progress"),
+ f1: true
+ });
+ }
+
+ run(accessor: ServicesAccessor) {
+ const gettingStartedService = accessor.get(IWalkthroughsService);
+ const storageService = accessor.get(IStorageService);
+
+ storageService.store(
+ hiddenEntriesConfigurationKey,
+ JSON.stringify([]),
+ StorageScope.PROFILE,
+ StorageTarget.USER);
+
+ storageService.store(
+ walkthroughMetadataConfigurationKey,
+ JSON.stringify([]),
+ StorageScope.PROFILE,
+ StorageTarget.USER);
+
+ const memento = new Memento('gettingStartedService', accessor.get(IStorageService));
+ const record = memento.getMemento(StorageScope.PROFILE, StorageTarget.USER);
+ for (const key in record) {
+ if (Object.prototype.hasOwnProperty.call(record, key)) {
+ try {
+ gettingStartedService.deprogressStep(key);
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ memento.saveMemento();
+ }
+});
diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
index ae62d18f2d0..5bf6ad46471 100644
--- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
+++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@@ -3,11 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

-import { createDecorator, IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
+import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Emitter, Event } from 'vs/base/common/event';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { Memento } from 'vs/workbench/common/memento';
-import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr, ContextKeyExpression, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Disposable } from 'vs/base/common/lifecycle';
@@ -28,7 +27,7 @@ import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/
import { dirname } from 'vs/base/common/path';
import { coalesce, flatten } from 'vs/base/common/arrays';
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
-import { localize, localize2 } from 'vs/nls';
+import { localize } from 'vs/nls';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { checkGlobFileExists } from 'vs/workbench/services/extensions/common/workspaceContains';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
@@ -668,45 +667,4 @@ const convertInternalMediaPathsToBrowserURIs = (path: string | { hc: string; hcL
}
};

-registerAction2(class extends Action2 {
- constructor() {
- super({
- id: 'resetGettingStartedProgress',
- category: localize2('developer', "Developer"),
- title: localize2('resetWelcomePageWalkthroughProgress', "Reset Welcome Page Walkthrough Progress"),
- f1: true
- });
- }
-
- run(accessor: ServicesAccessor) {
- const gettingStartedService = accessor.get(IWalkthroughsService);
- const storageService = accessor.get(IStorageService);
-
- storageService.store(
- hiddenEntriesConfigurationKey,
- JSON.stringify([]),
- StorageScope.PROFILE,
- StorageTarget.USER);
-
- storageService.store(
- walkthroughMetadataConfigurationKey,
- JSON.stringify([]),
- StorageScope.PROFILE,
- StorageTarget.USER);
-
- const memento = new Memento('gettingStartedService', accessor.get(IStorageService));
- const record = memento.getMemento(StorageScope.PROFILE, StorageTarget.USER);
- for (const key in record) {
- if (Object.prototype.hasOwnProperty.call(record, key)) {
- try {
- gettingStartedService.deprogressStep(key);
- } catch (e) {
- console.error(e);
- }
- }
- }
- memento.saveMemento();
- }
-});
-
registerSingleton(IWalkthroughsService, WalkthroughsService, InstantiationType.Delayed);
--
2.34.1

0 comments on commit bebabb0

Please sign in to comment.