Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Rebind overwrite dialog by adding check for modification time bias #862

Merged
merged 2 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions che-theia-init-sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sources:
- extensions/eclipse-che-theia-file-sync-tracker
- extensions/eclipse-che-theia-cli-endpoint
- extensions/eclipse-che-theia-workspace
- extensions/eclipse-che-theia-filesystem
plugins:
- plugins/containers-plugin
- plugins/workspace-plugin
Expand Down
7 changes: 7 additions & 0 deletions extensions/eclipse-che-theia-filesystem/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.browser_modules
lib
*.log
*-app/*
!*-app/package.json
.idea
29 changes: 29 additions & 0 deletions extensions/eclipse-che-theia-filesystem/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@eclipse-che/theia-filesystem-extension",
"keywords": [
"theia-extension"
],
"version": "0.0.1",
"files": [
"lib",
"src"
],
"dependencies": {
"@theia/filesystem": "1.4.0-next.89694867"
azatsarynnyy marked this conversation as resolved.
Show resolved Hide resolved
},
"scripts": {
"prepare": "yarn clean && yarn build",
"clean": "rimraf lib",
"format": "tsfmt -r --useTsfmt ../../configs/tsfmt.json",
"lint": "eslint --cache=true --no-error-on-unmatched-pattern=true \"{src,test}/**/*.{ts,tsx}\"",
"compile": "tsc",
"build": "concurrently -n \"format,lint,compile\" -c \"red,green,blue\" \"yarn format\" \"yarn lint\" \"yarn compile\"",
"watch": "tsc -w"
},
"license": "EPL-2.0",
"theiaExtensions": [
{
"frontend": "lib/browser/che-filesystem-module"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { ContainerModule } from 'inversify';
import { LabelProvider, ConfirmDialog } from '@theia/core/lib/browser';
import { FileShouldOverwrite, FileStat } from '@theia/filesystem/lib/common/filesystem';
import URI from '@theia/core/lib/common/uri';

export default new ContainerModule((bind, unbind, isBound, rebind) => {
rebind(FileShouldOverwrite).toDynamicValue(context => async (file: FileStat, stat: FileStat): Promise<boolean> => {
if (Math.abs(file.lastModification - stat.lastModification) <= 1) {
return true;
}

const labelProvider = context.container.get(LabelProvider);
const dialog = new ConfirmDialog({
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();
});
15 changes: 15 additions & 0 deletions extensions/eclipse-che-theia-filesystem/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../configs/base.tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"lib": [
"es6",
"dom"
],
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
}