diff --git a/package.json b/package.json index d522b1d..5cac0f7 100644 --- a/package.json +++ b/package.json @@ -353,6 +353,11 @@ ], "menus": { "view/title": [ + { + "command": "vscode-appwrite.addProject", + "when": "view == Projects", + "group": "navigation" + }, { "command": "vscode-appwrite.OpenUsersDocumentation", "when": "view == Users", @@ -512,11 +517,6 @@ "when": "viewItem =~ /^(permission)$/", "group": "inline" }, - { - "command": "vscode-appwrite.setActiveProject", - "when": "viewItem =~ /^(appwriteProject)$/", - "group": "inline" - }, { "command": "vscode-appwrite.removeProject", "when": "viewItem =~ /(appwriteProject)/" diff --git a/src/commands/project/setActiveProject.ts b/src/commands/project/setActiveProject.ts deleted file mode 100644 index e485efe..0000000 --- a/src/commands/project/setActiveProject.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { setActiveProjectId } from '../../settings'; -import { ProjectTreeItem } from "../../tree/projects/ProjectTreeItem"; - -export async function setActiveProject(treeItem: ProjectTreeItem): Promise { - if (treeItem === undefined) { - return; - } - - if (!(treeItem instanceof ProjectTreeItem)) { - return; - } - - await setActiveProjectId(treeItem.project.projectId); -} diff --git a/src/commands/registerCommands.ts b/src/commands/registerCommands.ts index f51bb1e..3217b7d 100644 --- a/src/commands/registerCommands.ts +++ b/src/commands/registerCommands.ts @@ -23,26 +23,25 @@ import { openUserInConsole } from "./users/openUserInConsole"; import { refreshUsersList } from "./users/refreshUsersList"; import { viewUserPrefs } from "./users/viewUserPrefs"; import { editPermission } from "./database/permissions/editPermission"; -import { setActiveProject } from "./project/setActiveProject"; import { removeProject } from "./project/removeProject"; -import { createTag } from './functions/createTag'; -import { createExecution } from './functions/createExecution'; -import { activateTag } from './functions/activateTag'; -import { editValue } from './common/editValue'; -import { deleteFunction } from './functions/deleteFunction'; -import { createFunction } from './functions/createFunction'; -import { createFunctionVar } from './functions/createFunctionVar'; -import { deleteFunctionVar } from './functions/deleteFunctionVar'; -import { deleteTag } from './functions/deleteTag'; -import { viewExecutionErrors } from './functions/viewExecutionErrors'; -import { viewExecutionOutput } from './functions/viewExecutionOutput'; -import { copyExecutionErrors } from './functions/copyExecutionErrors'; -import { copyExecutionOutput } from './functions/copyExecutionOutput'; -import { openExecutionsInBrowser } from './functions/openExecutionsInBrowser'; -import { openFunctionSettingsInBrowser } from './functions/openFunctionSettingsInBrowser'; -import { openFunctionTagsInBrowser } from './functions/openFunctionTagsInBrowser'; +import { createTag } from "./functions/createTag"; +import { createExecution } from "./functions/createExecution"; +import { activateTag } from "./functions/activateTag"; +import { editValue } from "./common/editValue"; +import { deleteFunction } from "./functions/deleteFunction"; +import { createFunction } from "./functions/createFunction"; +import { createFunctionVar } from "./functions/createFunctionVar"; +import { deleteFunctionVar } from "./functions/deleteFunctionVar"; +import { deleteTag } from "./functions/deleteTag"; +import { viewExecutionErrors } from "./functions/viewExecutionErrors"; +import { viewExecutionOutput } from "./functions/viewExecutionOutput"; +import { copyExecutionErrors } from "./functions/copyExecutionErrors"; +import { copyExecutionOutput } from "./functions/copyExecutionOutput"; +import { openExecutionsInBrowser } from "./functions/openExecutionsInBrowser"; +import { openFunctionSettingsInBrowser } from "./functions/openFunctionSettingsInBrowser"; +import { openFunctionTagsInBrowser } from "./functions/openFunctionTagsInBrowser"; -import { viewMore } from './common/viewMore'; +import { viewMore } from "./common/viewMore"; class CommandRegistrar { constructor(private readonly context: ExtensionContext) {} @@ -116,7 +115,6 @@ export function registerCommands(context: ExtensionContext): void { /** Projects **/ registerCommand("addProject", connectAppwrite, "all"); - registerCommand("setActiveProject", setActiveProject, "all"); registerCommand("refreshProjects", undefined, "projects"); registerCommand("removeProject", removeProject, "all"); diff --git a/src/settings.ts b/src/settings.ts index 72a7474..725abf7 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -30,7 +30,6 @@ export async function addProjectConfiguration(projectConfig: AppwriteProjectConf const projects = await getAppwriteProjects(); await configuration.update("projects", [...projects, projectConfig], true); - await setActiveProjectId(projectConfig.projectId); } export async function getActiveProjectId(): Promise { @@ -53,21 +52,9 @@ export async function getActiveProjectConfiguration(): Promise { - const configuration = workspace.getConfiguration("appwrite"); - await configuration.update("activeProjectId", projectId, true); - const active = await getActiveProjectConfiguration(); - createAppwriteClient(active); -} - export async function updateActiveProjectId(): Promise { const projects = await getAppwriteProjects(); if (projects.length > 0) { diff --git a/src/tree/projects/AddProjectTreeItem.ts b/src/tree/projects/AddProjectTreeItem.ts new file mode 100644 index 0000000..a24940e --- /dev/null +++ b/src/tree/projects/AddProjectTreeItem.ts @@ -0,0 +1,16 @@ +import { ThemeIcon, TreeItem } from "vscode"; + +export class AddProjectTreeItem extends TreeItem { + iconPath = new ThemeIcon("add"); + + constructor() { + super("Add Appwrite project"); + } + + contextValue = ""; + + command = { + command: "vscode-appwrite.addProject", + title: "Add Appwrite project", + }; +} diff --git a/src/tree/projects/ProjectTreeItem.ts b/src/tree/projects/ProjectTreeItem.ts index 3be2eae..d01cb46 100644 --- a/src/tree/projects/ProjectTreeItem.ts +++ b/src/tree/projects/ProjectTreeItem.ts @@ -17,6 +17,7 @@ export class ProjectTreeItem extends AppwriteTreeItemBase { const name = project.nickname ?? "Project"; this.label = `${name}`; this.contextValue = `appwriteProject${active ? "_active" : ""}`; + this.description = project.endpoint; this.sdk = createAppwriteSdk(project); } diff --git a/src/tree/projects/ProjectsTreeItemProvider.ts b/src/tree/projects/ProjectsTreeItemProvider.ts index 17bdbfe..b749016 100644 --- a/src/tree/projects/ProjectsTreeItemProvider.ts +++ b/src/tree/projects/ProjectsTreeItemProvider.ts @@ -36,6 +36,8 @@ export class ProjectsTreeItemProvider implements vscode.TreeDataProvider new ProjectTreeItem(config, config.projectId === activeProjectId)); + const projectTreeItems = configs.map((config) => new ProjectTreeItem(config, config.projectId === activeProjectId)); + + return projectTreeItems; } }