Skip to content

Commit

Permalink
Add last modification date to recent workspaces
Browse files Browse the repository at this point in the history
Added a label to identify the last modified date to recent workspace entries

Signed-off-by: Vincent Fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Aug 14, 2018
1 parent 26fa9af commit d43c0ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@theia/variable-resolver": "^0.3.13",
"@types/fs-extra": "^4.0.2",
"fs-extra": "^4.0.2",
"moment": "^2.21.0",
"valid-filename": "^2.0.1"
},
"publishConfig": {
Expand Down Expand Up @@ -49,4 +50,4 @@
"nyc": {
"extends": "../../configs/nyc.json"
}
}
}
8 changes: 7 additions & 1 deletion packages/workspace/src/browser/quick-open-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { WorkspaceService } from './workspace-service';
import URI from '@theia/core/lib/common/uri';
import { MessageService } from '@theia/core/lib/common';
import { FileSystem, FileSystemUtils } from '@theia/filesystem/lib/common';
import * as moment from 'moment';

@injectable()
export class QuickOpenWorkspace implements QuickOpenModel {
Expand All @@ -38,10 +39,15 @@ export class QuickOpenWorkspace implements QuickOpenModel {

for (const workspace of workspaces) {
const uri = new URI(workspace);
const stat = await this.fileSystem.getFileStat(workspace);
if (!stat) {
continue;
}
const lastModification = moment(stat.lastModification).fromNow();
this.items.push(new QuickOpenGroupItem({
label: uri.path.base,
description: (home) ? FileSystemUtils.tildifyPath(uri.path.toString(), home) : uri.path.toString(),
groupLabel: (workspace === workspaces[0]) ? 'Current Workspace' : '',
groupLabel: (workspace === workspaces[0]) ? 'Current Workspace' : `Modified ${lastModification}`,
run: (mode: QuickOpenMode): boolean => {
if (mode !== QuickOpenMode.OPEN) {
return false;
Expand Down

0 comments on commit d43c0ac

Please sign in to comment.