Add "Open collection in browser" command

This commit is contained in:
alexweininger 2021-06-03 22:51:02 -07:00
parent 2e77f93759
commit 095483ef9d
5 changed files with 4359 additions and 14 deletions

4345
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -335,6 +335,12 @@
"icon": "$(link-external)",
"category": "Appwrite"
},
{
"command": "vscode-appwrite.openCollectionInBrowser",
"title": "Open collection in browser",
"icon": "$(link-external)",
"category": "Appwrite"
},
{
"command": "vscode-appwrite.viewMore",
"title": "View more",
@ -488,6 +494,11 @@
"command": "vscode-appwrite.viewCollectionAsJson",
"when": "viewItem == collection"
},
{
"command": "vscode-appwrite.openCollectionInBrowser",
"when": "viewItem == collection",
"group": "inline"
},
{
"command": "vscode-appwrite.deleteCollection",
"when": "viewItem == collection"

View file

@ -0,0 +1,6 @@
import { CollectionTreeItem } from '../../tree/database/CollectionTreeItem';
import { openUrl } from '../../utils/openUrl';
export async function openCollectionInBrowser(treeItem: CollectionTreeItem): Promise<void> {
openUrl(treeItem.getUrl());
}

View file

@ -43,6 +43,7 @@ import { openFunctionSettingsInBrowser } from './functions/openFunctionSettingsI
import { openFunctionTagsInBrowser } from './functions/openFunctionTagsInBrowser';
import { viewMore } from './common/viewMore';
import { openCollectionInBrowser } from './database/openCollectionInBrowser';
class CommandRegistrar {
constructor(private readonly context: ExtensionContext) {}
@ -106,6 +107,7 @@ export function registerCommands(context: ExtensionContext): void {
registerCommand("createPermission", createPermission, "database");
registerCommand("deletePermission", deletePermission, "database");
registerCommand("editPermission", editPermission, "database");
registerCommand("openCollectionInBrowser", openCollectionInBrowser);
/** Health **/
registerCommand("refreshHealth", undefined, "health");

View file

@ -1,6 +1,7 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { Collection } from "../../appwrite";
import { databaseClient } from "../../client";
import { clientConfig, databaseClient } from "../../client";
import { getConsoleUrlFromEndpoint } from '../../commands/users/openUserInConsole';
import { AppwriteTreeItemBase } from "../../ui/AppwriteTreeItemBase";
import { DatabaseTreeItemProvider } from "./DatabaseTreeItemProvider";
import { DocumentsTreeItem } from "./DocumentsTreeItem";
@ -12,6 +13,12 @@ export class CollectionTreeItem extends AppwriteTreeItemBase {
super(undefined, collection.name);
}
// https://console.streamlux.com/console/database/collection?id=607cb2d6a21a8&project=605ce39a30c01
public getUrl(): string {
const consoleUrl = getConsoleUrlFromEndpoint(clientConfig.endpoint);
return `${consoleUrl}/database/collection?id=${this.collection.$id}&project=${clientConfig.projectId}`;
}
public async getChildren(): Promise<TreeItem[]> {
return [new RulesTreeItem(this), new PermissionsTreeItem(this), new DocumentsTreeItem(this)];
}