提交 883eafa6 编写于 作者: B Benjamin Pasero

status - adopt visibility for send feedback entry

上级 12fb60ec
......@@ -75,6 +75,11 @@ export interface IStatusbarService {
* @param name human readable name the entry is about
*/
addEntry(entry: IStatusbarEntry, id: string, name: string, alignment: StatusbarAlignment, priority?: number): IStatusbarEntryAccessor;
/**
* Allows to update an entry's visibilty with the provided ID.
*/
updateEntryVisibility(id: string, visible: boolean): void;
}
export interface IStatusbarEntryAccessor extends IDisposable {
......
......@@ -395,6 +395,14 @@ export class StatusbarPart extends Part implements IStatusbarService {
return entries;
}
updateEntryVisibility(id: string, visible: boolean): void {
if (visible) {
this.viewModel.show(id);
} else {
this.viewModel.hide(id);
}
}
createContentArea(parent: HTMLElement): HTMLElement {
this.element = parent;
......
......@@ -8,7 +8,6 @@ import { IStatusbarRegistry, Extensions, StatusbarItemDescriptor } from 'vs/work
import { StatusbarAlignment } from 'vs/platform/statusbar/common/statusbar';
import { FeedbackStatusbarItem } from 'vs/workbench/contrib/feedback/electron-browser/feedbackStatusbarItem';
import { localize } from 'vs/nls';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
// Register Statusbar item
Registry.as<IStatusbarRegistry>(Extensions.Statusbar).registerStatusbarItem(new StatusbarItemDescriptor(
......@@ -18,20 +17,3 @@ Registry.as<IStatusbarRegistry>(Extensions.Statusbar).registerStatusbarItem(new
StatusbarAlignment.RIGHT,
-100 /* towards the end of the right hand side */
));
// Configuration: Workbench
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': 'workbench',
'order': 7,
'title': localize('workbenchConfigurationTitle', "Workbench"),
'type': 'object',
'properties': {
'workbench.statusBar.feedback.visible': {
'type': 'boolean',
'default': true,
'description': localize('feedbackVisibility', "Controls the visibility of the Twitter feedback (smiley) in the status bar at the bottom of the workbench.")
}
}
});
\ No newline at end of file
......@@ -18,10 +18,9 @@ import { editorWidgetBackground, widgetShadow, inputBorder, inputForeground, inp
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
import { Button } from 'vs/base/browser/ui/button/button';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { OcticonLabel } from 'vs/base/browser/ui/octiconLabel/octiconLabel';
export const FEEDBACK_VISIBLE_CONFIG = 'workbench.statusBar.feedback.visible';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export interface IFeedback {
feedback: string;
......@@ -67,6 +66,7 @@ export class FeedbackDropdown extends Dropdown {
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IIntegrityService private readonly integrityService: IIntegrityService,
@IThemeService private readonly themeService: IThemeService,
@IStatusbarService private readonly statusbarService: IStatusbarService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
super(container, {
......@@ -91,6 +91,10 @@ export class FeedbackDropdown extends Dropdown {
dom.addClass(this.element, 'send-feedback');
this.element.title = nls.localize('sendFeedback', "Tweet Feedback");
if (!this.configurationService.getValue('workbench.statusBar.feedback.visible')) {
this.statusbarService.updateEntryVisibility('status.feedback', false);
}
}
protected getAnchor(): HTMLElement | IAnchor {
......@@ -404,7 +408,7 @@ export class FeedbackDropdown extends Dropdown {
}
if (this.hideButton && !this.hideButton.checked) {
this.configurationService.updateValue(FEEDBACK_VISIBLE_CONFIG, false);
this.statusbarService.updateEntryVisibility('status.feedback', false);
}
super.hide();
......
......@@ -5,14 +5,13 @@
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { FeedbackDropdown, IFeedback, IFeedbackDelegate, FEEDBACK_VISIBLE_CONFIG } from 'vs/workbench/contrib/feedback/electron-browser/feedback';
import { FeedbackDropdown, IFeedback, IFeedbackDelegate } from 'vs/workbench/contrib/feedback/electron-browser/feedback';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import product from 'vs/platform/product/node/product';
import { Themable, STATUS_BAR_ITEM_HOVER_BACKGROUND } from 'vs/workbench/common/theme';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { clearNode, EventHelper, addClass, removeClass, addDisposableListener } from 'vs/base/browser/dom';
class TwitterFeedbackService implements IFeedbackDelegate {
......@@ -50,33 +49,21 @@ class TwitterFeedbackService implements IFeedbackDelegate {
export class FeedbackStatusbarItem extends Themable implements IStatusbarItem {
private dropdown: FeedbackDropdown | undefined;
private enabled: boolean;
private container: HTMLElement;
constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IContextViewService private readonly contextViewService: IContextViewService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IThemeService themeService: IThemeService
) {
super(themeService);
this.enabled = this.configurationService.getValue(FEEDBACK_VISIBLE_CONFIG);
this.registerListeners();
}
private registerListeners(): void {
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateStyles()));
this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
}
private onConfigurationUpdated(event: IConfigurationChangeEvent): void {
if (event.affectsConfiguration(FEEDBACK_VISIBLE_CONFIG)) {
this.enabled = this.configurationService.getValue(FEEDBACK_VISIBLE_CONFIG);
this.update();
}
}
render(element: HTMLElement): IDisposable {
......@@ -93,10 +80,9 @@ export class FeedbackStatusbarItem extends Themable implements IStatusbarItem {
}
private update(): IDisposable {
const enabled = product.sendASmile && this.enabled;
// Create
if (enabled) {
if (product.sendASmile) {
if (!this.dropdown) {
this.dropdown = this._register(this.instantiationService.createInstance(FeedbackDropdown, this.container, {
contextViewProvider: this.contextViewService,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册