diff --git a/README.md b/README.md index 7cb8dfa..94a1db0 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,21 @@ From [appwrite.io](https://appwrite.io) ## Features +### View database documents right inside VS Code. +![Database feature](./media/features/database/scr2.png) -Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. +### Manage database collection permissions and rules. -For example if there is an image subfolder under your extension project workspace: +![Database feature](./media/features/database/scr1.png) + +### Create and view users, user preferences, and more. +![Users feature](./media/features/users/scr1.png) + +### Quickly and easily check the health of all the Appwrite services. -### Check the health of all the Appwrite services. ![Health feature](./media/features/health/scr1.png) -> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. - ## Requirements This extension does not provide features for setting up or installing Appwrite. Only managing and interacting with Appwrite once it's running. @@ -35,20 +39,30 @@ For example: This extension contributes the following settings: -* `myExtension.enable`: enable/disable this extension -* `myExtension.thing`: set to `blah` to do something +* `appwrite.projects`: List of Appwrite project configurations. To set up a project configuration, run the `Connect to Appwrite` command. Search commands by hitting F1, then search `Connect to Appwrite`. + +After connecting to an Appwrite project, your `appwrite.projects` setting will contain: + +```json +{ + "endpoint": "https://[Domain]/v1", + "projectId": "[Project ID]", + "secret": "API key with all scopes", + "nickname": "My project" +} +``` + +We plan on adding better multi-project support in the future. ## Known Issues -Calling out known issues can help limit users opening duplicate issues against your extension. - -## Release Notes - -Users appreciate release notes as you update your extension. +If you find issues, or want to suggest features, please file them in the issues section of the repository. ### 1.0.0 -Initial release of the Appwrite extension for VS Code +Initial release of the Appwrite extension for VS Code. + +The initial release only includes features for Database, Users, and Health Appwrite APIs. However support for Storage and Functions APIs is on the way. ----------------------------------------------------------------------------------------------------------- diff --git a/media/features/database/scr1.png b/media/features/database/scr1.png new file mode 100644 index 0000000..f4afee7 Binary files /dev/null and b/media/features/database/scr1.png differ diff --git a/media/features/database/scr2.png b/media/features/database/scr2.png new file mode 100644 index 0000000..a0a5d29 Binary files /dev/null and b/media/features/database/scr2.png differ diff --git a/media/features/users/scr1.png b/media/features/users/scr1.png new file mode 100644 index 0000000..8190c02 Binary files /dev/null and b/media/features/users/scr1.png differ diff --git a/package.json b/package.json index 887a4f6..7964b03 100644 --- a/package.json +++ b/package.json @@ -25,15 +25,8 @@ "commands": [ { "command": "vscode-appwrite.Connect", - "title": "Connect to Appwrite" - }, - { - "command": "vscode-appwrite.AddProject", - "title": "Add an Appwrite project" - }, - { - "command": "vscode-appwrite.SelectProject", - "title": "Select an Appwrite project" + "title": "Connect to Appwrite", + "category": "" }, { "command": "vscode-appwrite.CreateUser", @@ -232,8 +225,7 @@ "view/item/context": [ { "command": "vscode-appwrite.viewUserPrefs", - "when": "viewItem == users.prefs", - "group": "inline" + "when": "viewItem == user" }, { "command": "vscode-appwrite.DeleteUser", @@ -318,6 +310,78 @@ "when": "viewItem =~ /^(permission)$/", "group": "inline" } + ], + "commandPalette": [ + { + "command": "vscode-appwrite.Connect" + }, + { + "command": "vscode-appwrite.CreateUser" + }, + { + "command": "vscode-appwrite.DeleteUser", + "when": "viewItem == user" + }, + { + "command": "vscode-appwrite.GetUserLogs", + "when": "viewItem == user" + }, + { + "command": "vscode-appwrite.openUserInConsole", + "when": "viewItem == user" + }, + { + "command": "vscode-appwrite.viewUserPrefs", + "when": "viewItem == user" + }, + { + "command": "vscode-appwrite.copyUserId", + "when": "viewItem == user.id" + }, + { + "command": "vscode-appwrite.copyUserEmail", + "when": "viewItem == user.email" + }, + { + "command": "vscode-appwrite.viewDocumentAsJson", + "when": "viewItem == document" + }, + { + "command": "vscode-appwrite.viewCollectionAsJson", + "when": "viewItem == collection" + }, + { + "command": "vscode-appwrite.refreshCollection", + "when": "viewItem == collection" + }, + { + "command": "vscode-appwrite.createRule", + "when": "viewItem == collection.rules" + }, + { + "command": "vscode-appwrite.removeRule", + "when": "viewItem == rule" + }, + { + "command": "vscode-appwrite.deleteDocument", + "when": "viewItem == document" + }, + { + "command": "vscode-appwrite.deleteCollection", + "when": "viewItem == collection" + }, + { + "command": "vscode-appwrite.createPermission", + "when": "viewItem == collection.permissions" + }, + { + "command": "vscode-appwrite.deletePermission", + "when": "viewItem =~ /^(permission)$/" + }, + { + "command": "vscode-appwrite.editPermission", + "when": "viewItem =~ /^(permission)$/" + } ] }, "viewsContainers": { diff --git a/src/appwrite/Users.ts b/src/appwrite/Users.ts index cd16679..368c356 100644 --- a/src/appwrite/Users.ts +++ b/src/appwrite/Users.ts @@ -11,7 +11,6 @@ export class Users { this.users = new sdk.Users(client); } public async createNewUser(context: CreateUserContext): Promise { - ext.outputChannel?.appendLog("Creating new user" + JSON.stringify(context)); await AppwriteCall(this.users.create(context.email, context.password, context.name), (user) => { window.showInformationMessage(`Created user with id: ${user.$id}`); }); diff --git a/src/commands/database/createPermission.ts b/src/commands/database/permissions/createPermission.ts similarity index 81% rename from src/commands/database/createPermission.ts rename to src/commands/database/permissions/createPermission.ts index bcaecb7..0502151 100644 --- a/src/commands/database/createPermission.ts +++ b/src/commands/database/permissions/createPermission.ts @@ -1,8 +1,8 @@ import { window } from "vscode"; -import { databaseClient } from '../../client'; -import { CollapsableTreeItem } from '../../tree/CollapsableTreeItem'; -import { PermissionsTreeItem } from "../../tree/database/settings/PermissionsTreeItem"; -import { PermissionTreeItem } from "../../tree/database/settings/PermissionTreeItem"; +import { databaseClient } from '../../../client'; +import { CollapsableTreeItem } from '../../../tree/CollapsableTreeItem'; +import { PermissionsTreeItem } from "../../../tree/database/settings/PermissionsTreeItem"; +import { PermissionTreeItem } from "../../../tree/database/settings/PermissionTreeItem"; export type CreatePermissionWizardContext = { kind: "read" | "write"; diff --git a/src/commands/database/deletePermission.ts b/src/commands/database/permissions/deletePermission.ts similarity index 79% rename from src/commands/database/deletePermission.ts rename to src/commands/database/permissions/deletePermission.ts index ffd0a58..57c1418 100644 --- a/src/commands/database/deletePermission.ts +++ b/src/commands/database/permissions/deletePermission.ts @@ -1,5 +1,5 @@ -import { databaseClient } from "../../client"; -import { PermissionTreeItem } from "../../tree/database/settings/PermissionTreeItem"; +import { databaseClient } from "../../../client"; +import { PermissionTreeItem } from "../../../tree/database/settings/PermissionTreeItem"; export async function deletePermission(treeItem: PermissionTreeItem): Promise { const collection = treeItem.parent.parent.collection; diff --git a/src/commands/database/permissions/editPermission.ts b/src/commands/database/permissions/editPermission.ts new file mode 100644 index 0000000..757ed92 --- /dev/null +++ b/src/commands/database/permissions/editPermission.ts @@ -0,0 +1,29 @@ +import { window } from 'vscode'; +import { databaseClient } from '../../../client'; +import { PermissionTreeItem } from '../../../tree/database/settings/PermissionTreeItem'; + +export async function editPermission(treeItem: PermissionTreeItem): Promise { + const editedPermission = await window.showInputBox({ + value: treeItem.permission, + }); + + if (editedPermission === undefined) { + return; + } + + const collection = treeItem.parent.parent.collection; + const kind = treeItem.kind; + + let read = Array.from(collection.$permissions.read); + let write = Array.from(collection.$permissions.write); + + if (kind === "read") { + read = read.filter((item) => item !== treeItem.permission); + read.push(editedPermission); + } else { + write = write.filter((item) => item !== treeItem.permission); + write.push(editedPermission); + } + + await databaseClient.updatePermissions(collection, read, write); +} diff --git a/src/commands/registerCommands.ts b/src/commands/registerCommands.ts index a29ac22..fd78dc1 100644 --- a/src/commands/registerCommands.ts +++ b/src/commands/registerCommands.ts @@ -3,11 +3,11 @@ import { AppwriteTree, ext } from "../extensionVariables"; import { refreshTree } from "../utils/refreshTree"; import { connectAppwrite } from "./connectAppwrite"; import { createCollection } from "./database/createCollection"; -import { createPermission } from './database/createPermission'; +import { createPermission } from './database/permissions/createPermission'; import { createRule } from "./database/createRule"; import { deleteCollection } from "./database/deleteCollection"; import { deleteDocument } from "./database/deleteDocument"; -import { deletePermission } from './database/deletePermission'; +import { deletePermission } from './database/permissions/deletePermission'; import { viewDocumentAsJson } from "./database/openDocument"; import { refreshCollection } from "./database/refreshCollection"; import { refreshCollectionsList } from "./database/refreshCollectionsList"; @@ -23,6 +23,7 @@ import { getUserLogs } from "./users/getUserLogs"; import { openUserInConsole } from "./users/openUserInConsole"; import { refreshUsersList } from "./users/refreshUsersList"; import { viewUserPrefs } from "./users/viewUserPrefs"; +import { editPermission } from './database/permissions/editPermission'; class CommandRegistrar { constructor(private readonly context: ExtensionContext) {} @@ -56,7 +57,6 @@ export function registerCommands(context: ExtensionContext): void { registerCommand("OpenDatabaseDocumentation", () => openDocumentation('database')); registerCommand("GetUserLogs", getUserLogs); registerCommand("viewDocumentAsJson", viewDocumentAsJson); - registerCommand("AddProject", addProject); registerCommand("viewCollectionAsJson", viewCollectionAsJson); registerCommand("createRule", createRule); registerCommand("removeRule", removeRule); @@ -69,4 +69,5 @@ export function registerCommands(context: ExtensionContext): void { registerCommand("deletePermission", deletePermission, 'database'); registerCommand("refreshHealth", () => {}, 'health'); registerCommand("openHealthDocumentation", () => openDocumentation('health')); + registerCommand("editPermission", editPermission, 'database'); } diff --git a/src/commands/users/viewUserPrefs.ts b/src/commands/users/viewUserPrefs.ts index 0e66a53..b666c53 100644 --- a/src/commands/users/viewUserPrefs.ts +++ b/src/commands/users/viewUserPrefs.ts @@ -1,11 +1,13 @@ import { UserPrefsTreeItem } from "../../tree/users/properties/UserPrefsTreeItem"; +import { UserTreeItem } from '../../tree/users/UserTreeItem'; import { openReadOnlyJson } from "../../ui/openReadonlyContent"; -export async function viewUserPrefs(item: UserPrefsTreeItem) { - const prefs = item.parent.user.prefs; +export async function viewUserPrefs(item: UserPrefsTreeItem | UserTreeItem) { + const userItem = item instanceof UserPrefsTreeItem ? item.parent : item; + const prefs = userItem.user.prefs; await openReadOnlyJson( - { label: `prefs`, fullId: `${item.parent.user.$id}.prefs` }, + { label: `prefs`, fullId: `${userItem.user.$id}.prefs` }, prefs ); } diff --git a/src/tree/users/properties/UserPrefsTreeItem.ts b/src/tree/users/properties/UserPrefsTreeItem.ts index f78c7c2..19b37ea 100644 --- a/src/tree/users/properties/UserPrefsTreeItem.ts +++ b/src/tree/users/properties/UserPrefsTreeItem.ts @@ -6,6 +6,11 @@ export class UserPrefsTreeItem extends UserPropertyTreeItemBase { constructor(parent: UserTreeItem) { super(parent, 'View preferences'); + this.command = { + command: 'vscode-appwrite.viewUserPrefs', + title: 'View user preferences', + arguments: [this] + }; } iconPath = new ThemeIcon("json");