Skip to content

Commit ac5492c

Browse files
committed
show refresh and collapse all actions
1 parent a311d7b commit ac5492c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/vs/workbench/browser/parts/views/treeView.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class TreeView extends Disposable implements ITreeView {
127127
private _hasIconForParentNode = false;
128128
private _hasIconForLeafNode = false;
129129
private _showCollapseAllAction = false;
130+
private _showRefreshAction = false;
130131

131132
private focused: boolean = false;
132133
private domNode!: HTMLElement;
@@ -284,12 +285,26 @@ export class TreeView extends Disposable implements ITreeView {
284285
}
285286
}
286287

288+
get showRefreshAction(): boolean {
289+
return this._showRefreshAction;
290+
}
291+
292+
set showRefreshAction(showRefreshAction: boolean) {
293+
if (this._showRefreshAction !== !!showRefreshAction) {
294+
this._showRefreshAction = !!showRefreshAction;
295+
this._onDidChangeActions.fire();
296+
}
297+
}
298+
287299
getPrimaryActions(): IAction[] {
300+
const actions: IAction[] = [];
301+
if (this.showRefreshAction) {
302+
actions.push(new Action('vs.tree.refresh', localize('refresh', "Refresh"), 'monaco-tree-action codicon-refresh', true, () => this.refresh()));
303+
}
288304
if (this.showCollapseAllAction) {
289-
return [new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action codicon-collapse-all', true, () => this.tree ? new CollapseAllAction<ITreeItem, ITreeItem, FuzzyScore>(this.tree, true).run() : Promise.resolve())];
290-
} else {
291-
return [];
305+
actions.push(new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action codicon-collapse-all', true, () => this.tree ? new CollapseAllAction<ITreeItem, ITreeItem, FuzzyScore>(this.tree, true).run() : Promise.resolve()));
292306
}
307+
return actions;
293308
}
294309

295310
getSecondaryActions(): IAction[] {

src/vs/workbench/contrib/userDataSync/browser/userDataSyncHistory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export class UserDataSyncHistoryViewContribution implements IWorkbenchContributi
4040
const name = localize('title', "Sync History");
4141
const viewEnablementContext = CONTEXT_SHOW_USER_DATA_SYNC_HISTORY_VIEW.bindTo(this.contextKeyService);
4242
const treeView = this.instantiationService.createInstance(TreeView, this.viewId, name);
43+
treeView.showCollapseAllAction = true;
44+
treeView.showRefreshAction = true;
4345
const disposable = treeView.onDidChangeVisibility(visible => {
4446
if (visible && !treeView.dataProvider) {
4547
disposable.dispose();
@@ -52,7 +54,7 @@ export class UserDataSyncHistoryViewContribution implements IWorkbenchContributi
5254
name,
5355
ctorDescriptor: new SyncDescriptor(TreeViewPane),
5456
when: ContextKeyExpr.and(CONTEXT_SYNC_ENABLEMENT, CONTEXT_SHOW_USER_DATA_SYNC_HISTORY_VIEW),
55-
canToggleVisibility: false,
57+
canToggleVisibility: true,
5658
canMoveView: true,
5759
treeView,
5860
collapsed: false,

0 commit comments

Comments
 (0)