Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 17 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,12 @@ export class VSCodeCommands implements Disposable {
),
commands.registerCommand(
"dbtPowerUser.openTargetSelector",
async (targets, project: DBTProject, statusBar) => {
async (
targets,
project: DBTProject,
statusBar,
currentTarget?: string,
) => {
try {
if (!targets) {
return;
Expand All @@ -659,10 +664,20 @@ export class VSCodeCommands implements Disposable {
"Showing following targets",
targets,
);
const target = await window.showQuickPick(targets, {
const sortedTargets = (targets as string[]).sort((a, b) => {
if (a === currentTarget) return -1;
if (b === currentTarget) return 1;
return 0;
});
const items = sortedTargets.map((t) => ({
label: t,
description: t === currentTarget ? "(current)" : "",
}));
const selected = await window.showQuickPick(items, {
title: "Select your target",
canPickMany: false,
});
const target = selected?.label;
if (target) {
await project.setSelectedTarget(target);
await statusBar.updateStatusBar();
Expand Down
2 changes: 1 addition & 1 deletion src/statusbar/targetStatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class TargetStatusBar implements Disposable {
this.statusBar.command = {
title: "Open Target selector",
command: "dbtPowerUser.openTargetSelector",
arguments: [targets, currentProject, this],
arguments: [targets, currentProject, this, selectedTarget],
};
this.statusBar.show();
}
Expand Down
Loading