-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27e6ea7
commit 49130ca
Showing
10 changed files
with
246 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ges/vsx-registry/src/browser/recommended-extensions/recommended-extensions-json-schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { inject, injectable, postConstruct } from 'inversify'; | ||
import { InMemoryResources } from '@theia/core'; | ||
import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store'; | ||
import { IJSONSchema } from '@theia/core/lib/common/json-schema'; | ||
import URI from '@theia/core/lib/common/uri'; | ||
|
||
export const extensionsSchemaID = 'vscode://schemas/extensions'; | ||
const extensionsConfigurationSchema: IJSONSchema = { | ||
$id: extensionsSchemaID, | ||
default: { recommendations: [] }, | ||
type: 'object', | ||
|
||
properties: { | ||
recommendations: { | ||
title: 'A list of extensions recommended for users of this workspace. Should use the form "<publisher>.<extension name>"', | ||
type: 'array', | ||
items: { | ||
type: 'string', | ||
pattern: '^\\w[\\w-]+\\.\\w[\\w-]+$' | ||
}, | ||
default: [], | ||
}, | ||
unwantedRecommendations: { | ||
title: 'A list of extensions recommended by default that should not be recommended to users of this workspace. Should use the form "<publisher>.<extension name>"', | ||
type: 'array', | ||
items: { | ||
type: 'string', | ||
pattern: '^\\w[\\w-]+\\.\\w[\\w-]+$' | ||
}, | ||
default: [], | ||
} | ||
} | ||
}; | ||
|
||
@injectable() | ||
export class ExtensionSchemaContribution implements JsonSchemaContribution { | ||
protected readonly uri = new URI(extensionsSchemaID); | ||
@inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources; | ||
|
||
@postConstruct() | ||
protected init(): void { | ||
this.inmemoryResources.add(this.uri, JSON.stringify(extensionsConfigurationSchema)); | ||
} | ||
|
||
registerSchemas(context: JsonSchemaRegisterContext): void { | ||
context.registerSchema({ | ||
fileMatch: ['extensions.json'], | ||
url: this.uri.toString(), | ||
}); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...stry/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { createPreferenceProxy, PreferenceContribution, PreferenceSchema, PreferenceScope, PreferenceService } from '@theia/core/lib/browser'; | ||
import { JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store'; | ||
import { PreferenceConfiguration } from '@theia/core/lib/browser/preferences/preference-configurations'; | ||
import { interfaces } from 'inversify'; | ||
import { ExtensionSchemaContribution, extensionsSchemaID } from './recommended-extensions-json-schema'; | ||
|
||
export interface RecommendedExtensions { | ||
recommendations?: string[]; | ||
unwantedRecommendations?: string[]; | ||
} | ||
|
||
export const recommendedExtensionsPreferencesSchema: PreferenceSchema = { | ||
type: 'object', | ||
scope: PreferenceScope.Folder, | ||
properties: { | ||
extensions: { | ||
$ref: extensionsSchemaID, | ||
description: 'A list of the names of extensions recommended for use in this workspace.', | ||
defaultValue: { recommendations: [] }, | ||
}, | ||
}, | ||
}; | ||
|
||
const IGNORE_RECOMMENDATIONS_ID = 'extensions.ignoreRecommendations'; | ||
|
||
export const recommendedExtensionNotificationPreferencesSchema: PreferenceSchema = { | ||
type: 'object', | ||
scope: PreferenceScope.Folder, | ||
properties: { | ||
[IGNORE_RECOMMENDATIONS_ID]: { | ||
description: 'Controls whether notifications are shown for extension recommendations.', | ||
default: false, | ||
type: 'boolean' | ||
} | ||
} | ||
}; | ||
|
||
export const ExtensionNotificationPreferences = Symbol('ExtensionNotificationPreferences'); | ||
|
||
export function bindExtensionPreferences(bind: interfaces.Bind): void { | ||
bind(ExtensionSchemaContribution).toSelf().inSingletonScope(); | ||
bind(JsonSchemaContribution).toService(ExtensionSchemaContribution); | ||
bind(PreferenceContribution).toConstantValue({ schema: recommendedExtensionsPreferencesSchema }); | ||
bind(PreferenceConfiguration).toConstantValue({ name: 'extensions' }); | ||
|
||
bind(ExtensionNotificationPreferences).toDynamicValue(({ container }) => { | ||
const preferenceService = container.get<PreferenceService>(PreferenceService); | ||
return createPreferenceProxy(preferenceService, recommendedExtensionNotificationPreferencesSchema); | ||
}).inSingletonScope(); | ||
bind(PreferenceContribution).toConstantValue({ schema: recommendedExtensionNotificationPreferencesSchema }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.