This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebind overwrite dialog by adding check for modification time bias (#862
) Rebind overwrite dialog by adding check for modification time bias Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>
- Loading branch information
Showing
6 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "next" | ||
}, | ||
"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" | ||
} | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
extensions/eclipse-che-theia-filesystem/src/browser/che-filesystem-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters