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

Improve the 'file has changed' dialog #6873

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/filesystem/src/browser/filesystem-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import '../../src/browser/style/index.css';

import { ContainerModule, interfaces } from 'inversify';
import { ResourceResolver, CommandContribution } from '@theia/core/lib/common';
import { WebSocketConnectionProvider, FrontendApplicationContribution, ConfirmDialog, LabelProviderContribution } from '@theia/core/lib/browser';
import { WebSocketConnectionProvider, FrontendApplicationContribution, ConfirmDialog, LabelProviderContribution, LabelProvider } from '@theia/core/lib/browser';
import { FileSystem, fileSystemPath, FileShouldOverwrite, FileStat } from '../common';
import {
fileSystemWatcherPath, FileSystemWatcherServer,
Expand All @@ -31,6 +31,7 @@ import { FileSystemFrontendContribution } from './filesystem-frontend-contributi
import { FileSystemProxyFactory } from './filesystem-proxy-factory';
import { FileUploadService } from './file-upload-service';
import { FileTreeLabelProvider } from './file-tree/file-tree-label-provider';
import URI from '@theia/core/lib/common/uri';

export default new ContainerModule(bind => {
bindFileSystemPreferences(bind);
Expand All @@ -40,15 +41,16 @@ export default new ContainerModule(bind => {
);
bind(FileSystemWatcherServer).to(ReconnectingFileSystemWatcherServer);
bind(FileSystemWatcher).toSelf().inSingletonScope();
bind(FileShouldOverwrite).toFunction(async function (file: FileStat, stat: FileStat): Promise<boolean> {
bind(FileShouldOverwrite).toDynamicValue(context => async (file: FileStat, stat: FileStat): Promise<boolean> => {
const labelProvider = context.container.get(LabelProvider);
const dialog = new ConfirmDialog({
title: `The file '${file.uri}' has been changed on the file system.`,
msg: 'Do you want to overwrite the changes made on the file system?',
title: `The file '${labelProvider.getName(new URI(file.uri))}' has been changed on the file system.`,
msg: `Do you want to overwrite the changes made to '${labelProvider.getLongName(new URI(file.uri))}' on the file system?`,
ok: 'Yes',
cancel: 'No'
});
return !!await dialog.open();
});
}).inSingletonScope();

bind(FileSystemProxyFactory).toSelf();
bind(FileSystem).toDynamicValue(ctx => {
Expand Down