Skip to content

Commit

Permalink
chore: add unstable indicators for json settings (#231158)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 authored Oct 12, 2024
1 parent d91b89d commit eb9e2d8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { IWorkbenchEnvironmentService } from '../../../services/environment/comm
import { IPreferencesEditorModel, IPreferencesService, ISetting, ISettingsEditorModel, ISettingsGroup } from '../../../services/preferences/common/preferences.js';
import { DefaultSettingsEditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel } from '../../../services/preferences/common/preferencesModels.js';
import { IUserDataProfileService } from '../../../services/userDataProfile/common/userDataProfile.js';
import { EXPERIMENTAL_INDICATOR_DESCRIPTION, PREVIEW_INDICATOR_DESCRIPTION } from '../common/preferences.js';

export interface IPreferencesRenderer extends IDisposable {
render(): void;
Expand Down Expand Up @@ -547,6 +548,7 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
}
const configuration = configurationRegistry[setting.key];
if (configuration) {
this.handleUnstableSettingConfiguration(setting, configuration, markerData);
if (this.handlePolicyConfiguration(setting, configuration, markerData)) {
continue;
}
Expand All @@ -565,7 +567,7 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
break;
}
} else {
markerData.push(this.gemerateUnknownConfigurationMarker(setting));
markerData.push(this.generateUnknownConfigurationMarker(setting));
}
}
}
Expand Down Expand Up @@ -605,7 +607,7 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
});
}
} else {
markerData.push(this.gemerateUnknownConfigurationMarker(setting));
markerData.push(this.generateUnknownConfigurationMarker(setting));
}
}
}
Expand Down Expand Up @@ -694,6 +696,16 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
}
}

private handleUnstableSettingConfiguration(setting: ISetting, configuration: IConfigurationPropertySchema, markerData: IMarkerData[]): void {
if (configuration.tags?.includes('preview')) {
markerData.push(this.generatePreviewSettingMarker(setting));
}
// Enable after further review and experimental -> onExP migration

This comment has been minimized.

Copy link
@DaZuiZui

DaZuiZui Oct 12, 2024

// After further review of the feature implementation and experimental testing,
// migrate the feature to the onExP environment and enable it for production use.

// if (configuration.tags?.includes('experimental')) {
// markerData.push(this.generateExperimentalSettingMarker(setting));
// }
}

private generateUnsupportedApplicationSettingMarker(setting: ISetting): IMarkerData {
return {
severity: MarkerSeverity.Hint,
Expand All @@ -720,7 +732,7 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
};
}

private gemerateUnknownConfigurationMarker(setting: ISetting): IMarkerData {
private generateUnknownConfigurationMarker(setting: ISetting): IMarkerData {
return {
severity: MarkerSeverity.Hint,
tags: [MarkerTag.Unnecessary],
Expand All @@ -741,6 +753,23 @@ class UnsupportedSettingsRenderer extends Disposable implements languages.CodeAc
}];
}

private generatePreviewSettingMarker(setting: ISetting): IMarkerData {
return {
severity: MarkerSeverity.Info,
...setting.range,
message: PREVIEW_INDICATOR_DESCRIPTION
};
}

// @ts-expect-error
private generateExperimentalSettingMarker(setting: ISetting): IMarkerData {
return {
severity: MarkerSeverity.Info,
...setting.range,
message: EXPERIMENTAL_INDICATOR_DESCRIPTION
};
}

private addCodeActions(range: IRange, codeActions: languages.CodeAction[]): void {
let actions = this.codeActions.get(this.settingsEditorModel.uri);
if (!actions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ConfigurationTarget } from '../../../../platform/configuration/common/c
import { IUserDataProfilesService } from '../../../../platform/userDataProfile/common/userDataProfile.js';
import { IUserDataSyncEnablementService } from '../../../../platform/userDataSync/common/userDataSync.js';
import { SettingsTreeSettingElement } from './settingsTreeModels.js';
import { POLICY_SETTING_TAG } from '../common/preferences.js';
import { EXPERIMENTAL_INDICATOR_DESCRIPTION, POLICY_SETTING_TAG, PREVIEW_INDICATOR_DESCRIPTION } from '../common/preferences.js';
import { IWorkbenchConfigurationService } from '../../../services/configuration/common/configuration.js';
import { IHoverService } from '../../../../platform/hover/browser/hover.js';
import type { IHoverOptions, IHoverWidget } from '../../../../base/browser/ui/hover/hover.js';
Expand Down Expand Up @@ -328,9 +328,7 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
localize('previewLabel', "Preview") :
localize('experimentalLabel', "Experimental");

const content = isPreviewSetting ?
localize('previewSettingDescription', "The setting is in the process of becoming stable.") :
localize('experimentalSettingDescription', "The setting is experimental and may change names or be removed.");
const content = isPreviewSetting ? PREVIEW_INDICATOR_DESCRIPTION : EXPERIMENTAL_INDICATOR_DESCRIPTION;
const showHover = (focus: boolean) => {
return this.hoverService.showHover({
...this.defaultHoverOptions,
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/contrib/preferences/common/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { raceTimeout } from '../../../../base/common/async.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';
import { IStringDictionary } from '../../../../base/common/collections.js';
import { IExtensionRecommendations } from '../../../../base/common/product.js';
import { localize } from '../../../../nls.js';
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
import { IExtensionGalleryService, IGalleryExtension } from '../../../../platform/extensionManagement/common/extensionManagement.js';
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
Expand Down Expand Up @@ -174,3 +175,6 @@ export function compareTwoNullableNumbers(a: number | undefined, b: number | und
return 0;
}
}

export const PREVIEW_INDICATOR_DESCRIPTION = localize('previewIndicatorDescription', "This setting controls a feature that is in active development.");
export const EXPERIMENTAL_INDICATOR_DESCRIPTION = localize('experimentalIndicatorDescription', "This setting controls a feature that may change or be removed in the future. Adjusting this setting may result in instability.");

0 comments on commit eb9e2d8

Please sign in to comment.