-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from badsyntax/refresh-subtree
Add ability to refresh projects & dbcontexts
- Loading branch information
Showing
10 changed files
with
158 additions
and
35 deletions.
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,26 @@ | ||
import * as vscode from 'vscode'; | ||
import { CommandProvider } from '../commands/CommandProvider'; | ||
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand'; | ||
|
||
import { | ||
dbContextsCache, | ||
DbContextTreeItem, | ||
} from '../treeView/DbContextTreeItem'; | ||
import type { IAction } from './IAction'; | ||
|
||
export class RefreshDbContextTreeAction implements IAction { | ||
constructor(private readonly item: DbContextTreeItem) {} | ||
|
||
public async run() { | ||
const cacheId = DbContextTreeItem.getCacheId( | ||
this.item.workspaceRoot, | ||
this.item.projectFile.name, | ||
this.item.label, | ||
); | ||
dbContextsCache.clear(cacheId); | ||
await vscode.commands.executeCommand( | ||
CommandProvider.getCommandName(RefreshTreeCommand.commandName), | ||
false, | ||
); | ||
} | ||
} |
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,21 @@ | ||
import * as vscode from 'vscode'; | ||
import { CommandProvider } from '../commands/CommandProvider'; | ||
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand'; | ||
import { projectsCache, ProjectTreeItem } from '../treeView/ProjectTreeItem'; | ||
import type { IAction } from './IAction'; | ||
|
||
export class RefreshProjectTreeAction implements IAction { | ||
constructor(private readonly item: ProjectTreeItem) {} | ||
|
||
public async run() { | ||
const cacheId = ProjectTreeItem.getCacheId( | ||
this.item.workspaceRoot, | ||
this.item.label, | ||
); | ||
projectsCache.clear(cacheId); | ||
await vscode.commands.executeCommand( | ||
CommandProvider.getCommandName(RefreshTreeCommand.commandName), | ||
false, | ||
); | ||
} | ||
} |
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,17 @@ | ||
import { clearTreeCache } from '../treeView/treeCache'; | ||
import type { TreeDataProvider } from '../treeView/TreeDataProvider'; | ||
import type { IAction } from './IAction'; | ||
|
||
export class RefreshTreeAction implements IAction { | ||
constructor( | ||
private readonly treeDataProvider: TreeDataProvider, | ||
private readonly clearCache = true, | ||
) {} | ||
|
||
public async run() { | ||
if (this.clearCache) { | ||
clearTreeCache(); | ||
} | ||
this.treeDataProvider.refresh(); | ||
} | ||
} |
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
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,18 @@ | ||
import { RefreshDbContextTreeAction } from '../actions/RefreshDbContextTreeAction'; | ||
import type { DbContextTreeItem } from '../treeView/DbContextTreeItem'; | ||
import { Command } from './Command'; | ||
|
||
export class RefreshDbContextTreeCommand extends Command { | ||
public static commandName = 'refreshDbContextTree'; | ||
|
||
constructor(private readonly item?: DbContextTreeItem) { | ||
super(); | ||
} | ||
|
||
public async run() { | ||
if (!this.item) { | ||
return; | ||
} | ||
await new RefreshDbContextTreeAction(this.item).run(); | ||
} | ||
} |
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,18 @@ | ||
import { RefreshProjectTreeAction } from '../actions/RefreshProjectTreeAction'; | ||
import type { ProjectTreeItem } from '../treeView/ProjectTreeItem'; | ||
import { Command } from './Command'; | ||
|
||
export class RefreshProjectTreeCommand extends Command { | ||
public static commandName = 'refreshProjectTree'; | ||
|
||
constructor(private readonly item?: ProjectTreeItem) { | ||
super(); | ||
} | ||
|
||
public async run() { | ||
if (!this.item) { | ||
return; | ||
} | ||
await new RefreshProjectTreeAction(this.item).run(); | ||
} | ||
} |
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