Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explorer - add "Open Recent" to web serverless empty explorer #143464

Merged
merged 1 commit into from Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/vs/workbench/browser/actions/windowActions.ts
Expand Up @@ -232,9 +232,11 @@ abstract class BaseOpenRecentAction extends Action2 {

export class OpenRecentAction extends BaseOpenRecentAction {

static ID = 'workbench.action.openRecent';

constructor() {
super({
id: 'workbench.action.openRecent',
id: OpenRecentAction.ID,
title: {
value: localize('openRecent', "Open Recent..."),
mnemonicTitle: localize({ key: 'miMore', comment: ['&& denotes a mnemonic'] }, "&&More..."),
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/browser/parts/titlebar/menubarControl.ts
Expand Up @@ -39,6 +39,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import { IsMacNativeContext, IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';

export type IOpenRecentAction = IAction & { uri: URI; remoteAuthority?: string };

Expand Down Expand Up @@ -592,7 +593,7 @@ export class CustomMenubarControl extends MenubarControl {

private insertActionsBefore(nextAction: IAction, target: IAction[]): void {
switch (nextAction.id) {
case 'workbench.action.openRecent':
case OpenRecentAction.ID:
target.push(...this.getOpenRecentActions());
break;

Expand Down
64 changes: 54 additions & 10 deletions src/vs/workbench/contrib/files/browser/explorerViewlet.ts
Expand Up @@ -29,9 +29,10 @@ import { KeyChord, KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { Registry } from 'vs/platform/registry/common/platform';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { WorkbenchStateContext, RemoteNameContext } from 'vs/workbench/common/contextkeys';
import { WorkbenchStateContext, RemoteNameContext, OpenFolderWorkspaceSupportContext } from 'vs/workbench/common/contextkeys';
import { IsIOSContext, IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
import { AddRootFolderAction, OpenFolderAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
import { isMacintosh, isWeb } from 'vs/base/common/platform';
import { Codicon } from 'vs/base/common/codicons';
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
Expand Down Expand Up @@ -282,43 +283,86 @@ export const VIEW_CONTAINER: ViewContainer = viewContainerRegistry.registerViewC

const openFolder = localize('openFolder', "Open Folder");
const addAFolder = localize('addAFolder', "add a folder");
const openRecent = localize('openRecent', "Open Recent");

const addRootFolderButton = `[${openFolder}](command:${AddRootFolderAction.ID})`;
const addAFolderButton = `[${addAFolder}](command:${AddRootFolderAction.ID})`;

const commandId = (isMacintosh && !isWeb) ? OpenFileFolderAction.ID : OpenFolderAction.ID;
const openFolderButton = `[${openFolder}](command:${commandId})`;

const openFolderButton = `[${openFolder}](command:${(isMacintosh && !isWeb) ? OpenFileFolderAction.ID : OpenFolderAction.ID})`;
const openRecentButton = `[${openRecent}](command:${OpenRecentAction.ID})`;

const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
content: localize({ key: 'noWorkspaceHelp', comment: ['Please do not translate the word "commmand", it is part of our internal syntax which must not change'] },
"You have not yet added a folder to the workspace.\n{0}", addRootFolderButton),
when: ContextKeyExpr.and(WorkbenchStateContext.isEqualTo('workspace'), IsIOSContext.toNegated()),
when: ContextKeyExpr.and(
// inside a .code-workspace
WorkbenchStateContext.isEqualTo('workspace'),
// but not on iOS (TODO@isidorn why?)
IsIOSContext.toNegated(),
// unless we cannot enter or open workspaces (e.g. web serverless)
OpenFolderWorkspaceSupportContext
),
group: ViewContentGroups.Open,
order: 1
});

viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
content: localize({ key: 'noFolderHelpWeb', comment: ['Please do not translate the word "commmand", it is part of our internal syntax which must not change'] },
"You have not yet opened a folder.\n{0}\n{1}", addRootFolderButton, openRecentButton),
when: ContextKeyExpr.and(
// inside a .code-workspace
WorkbenchStateContext.isEqualTo('workspace'),
// we cannot enter workspaces (e.g. web serverless)
OpenFolderWorkspaceSupportContext.toNegated()
),
group: ViewContentGroups.Open,
order: 1
});

viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
content: localize({ key: 'remoteNoFolderHelp', comment: ['Please do not translate the word "commmand", it is part of our internal syntax which must not change'] },
"Connected to remote.\n{0}", openFolderButton),
when: ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), RemoteNameContext.notEqualsTo(''), IsWebContext.toNegated()),
when: ContextKeyExpr.and(
// not inside a .code-workspace
WorkbenchStateContext.notEqualsTo('workspace'),
// connected to a remote
RemoteNameContext.notEqualsTo(''),
// but not in web
IsWebContext.toNegated()),
group: ViewContentGroups.Open,
order: 1
});

viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
content: localize({ key: 'noFolderButEditorsHelp', comment: ['Please do not translate the word "commmand", it is part of our internal syntax which must not change'] },
"You have not yet opened a folder.\n{0}\nOpening a folder will close all currently open editors. To keep them open, {0} instead.", openFolderButton, addAFolderButton),
when: ContextKeyExpr.and(ContextKeyExpr.has('editorIsOpen'), ContextKeyExpr.or(ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), RemoteNameContext.isEqualTo('')), ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), IsWebContext))),
"You have not yet opened a folder.\n{0}\nOpening a folder will close all currently open editors. To keep them open, {1} instead.", openFolderButton, addAFolderButton),
when: ContextKeyExpr.and(
// editors are opened
ContextKeyExpr.has('editorIsOpen'),
ContextKeyExpr.or(
// not inside a .code-workspace and local
ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), RemoteNameContext.isEqualTo('')),
// not inside a .code-workspace and web
ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), IsWebContext)
)
),
group: ViewContentGroups.Open,
order: 1
});

viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
content: localize({ key: 'noFolderHelp', comment: ['Please do not translate the word "commmand", it is part of our internal syntax which must not change'] },
"You have not yet opened a folder.\n{0}", openFolderButton),
when: ContextKeyExpr.and(ContextKeyExpr.has('editorIsOpen')?.negate(), ContextKeyExpr.or(ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), RemoteNameContext.isEqualTo('')), ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), IsWebContext))),
when: ContextKeyExpr.and(
// no editor is open
ContextKeyExpr.has('editorIsOpen')?.negate(),
ContextKeyExpr.or(
// not inside a .code-workspace and local
ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), RemoteNameContext.isEqualTo('')),
// not inside a .code-workspace and web
ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), IsWebContext)
)
),
group: ViewContentGroups.Open,
order: 1
});
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/watermark/browser/watermark.ts
Expand Up @@ -16,6 +16,7 @@ import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { OpenFolderAction, OpenFileFolderAction, OpenFileAction } from 'vs/workbench/browser/actions/workspaceActions';
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
import { ShowAllCommandsAction } from 'vs/workbench/contrib/quickaccess/browser/commandsQuickAccess';
import { Parts, IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { FindInFilesActionId } from 'vs/workbench/contrib/search/common/constants';
Expand Down Expand Up @@ -47,7 +48,7 @@ const quickAccess: WatermarkEntry = { text: nls.localize('watermark.quickAccess'
const openFileNonMacOnly: WatermarkEntry = { text: nls.localize('watermark.openFile', "Open File"), id: OpenFileAction.ID, mac: false };
const openFolderNonMacOnly: WatermarkEntry = { text: nls.localize('watermark.openFolder', "Open Folder"), id: OpenFolderAction.ID, mac: false };
const openFileOrFolderMacOnly: WatermarkEntry = { text: nls.localize('watermark.openFileFolder', "Open File or Folder"), id: OpenFileFolderAction.ID, mac: true };
const openRecent: WatermarkEntry = { text: nls.localize('watermark.openRecent', "Open Recent"), id: 'workbench.action.openRecent' };
const openRecent: WatermarkEntry = { text: nls.localize('watermark.openRecent', "Open Recent"), id: OpenRecentAction.ID };
const newUntitledFile: WatermarkEntry = { text: nls.localize('watermark.newUntitledFile', "New Untitled File"), id: NEW_UNTITLED_FILE_COMMAND_ID };
const newUntitledFileMacOnly: WatermarkEntry = Object.assign({ mac: true }, newUntitledFile);
const findInFiles: WatermarkEntry = { text: nls.localize('watermark.findInFiles', "Find in Files"), id: FindInFilesActionId };
Expand Down
Expand Up @@ -71,6 +71,7 @@ import { getTelemetryLevel } from 'vs/platform/telemetry/common/telemetryUtils';
import { WorkbenchStateContext } from 'vs/workbench/common/contextkeys';
import { IsIOSContext } from 'vs/platform/contextkey/common/contextkeys';
import { AddRootFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';
import { Checkbox } from 'vs/base/browser/ui/checkbox/checkbox';
import { Codicon } from 'vs/base/common/codicons';
import { restoreWalkthroughsConfigurationKey, RestoreWalkthroughsConfigurationValue } from 'vs/workbench/contrib/welcomePage/browser/welcomePage';
Expand Down Expand Up @@ -347,7 +348,7 @@ export class GettingStartedPage extends EditorPane {
break;
}
case 'showMoreRecents': {
this.commandService.executeCommand('workbench.action.openRecent');
this.commandService.executeCommand(OpenRecentAction.ID);
break;
}
case 'seeAllWalkthroughs': {
Expand Down Expand Up @@ -1100,7 +1101,7 @@ export class GettingStartedPage extends EditorPane {
$('button.button-link',
{
'x-dispatch': 'showMoreRecents',
title: localize('show more recents', "Show All Recent Folders {0}", this.getKeybindingLabel('workbench.action.openRecent'))
title: localize('show more recents', "Show All Recent Folders {0}", this.getKeybindingLabel(OpenRecentAction.ID))
}, 'More...')),
renderElement: renderRecent,
contextService: this.contextService
Expand Down
Expand Up @@ -24,6 +24,7 @@ import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { OpenRecentAction } from 'vs/workbench/browser/actions/windowActions';

export class NativeMenubarControl extends MenubarControl {

Expand Down Expand Up @@ -138,7 +139,7 @@ export class NativeMenubarControl extends MenubarControl {

menuToDispose.dispose();
} else {
if (menuItem.id === 'workbench.action.openRecent') {
if (menuItem.id === OpenRecentAction.ID) {
const actions = this.getOpenRecentActions().map(this.transformOpenRecentAction);
menuToPopulate.items.push(...actions);
}
Expand Down