From 1ed67e7c10462bd892eaf8b188e58c8a27c9a912 Mon Sep 17 00:00:00 2001 From: alexweininger Date: Thu, 3 Jun 2021 23:01:51 -0700 Subject: [PATCH] Open tag in browser after creation --- src/commands/functions/createTag.ts | 6 +++++- src/commands/functions/openFunctionTagsInBrowser.ts | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/commands/functions/createTag.ts b/src/commands/functions/createTag.ts index b154d33..34da8bc 100644 --- a/src/commands/functions/createTag.ts +++ b/src/commands/functions/createTag.ts @@ -8,6 +8,8 @@ import { selectWorkspaceFolder } from "../../utils/workspace"; import { ProgressMessage } from "../../utils/types"; import { Tag } from "../../appwrite"; import { activateTag } from "./activateTag"; +import { sleep } from '../../utils/sleep'; +import { openFunctionTagsInBrowser } from './openFunctionTagsInBrowser'; export async function createTag(item?: TagsTreeItem | Uri): Promise { if (item instanceof Uri) { @@ -136,7 +138,8 @@ async function createTagFromUri(functionId: string, command: string, uri: Uri, p return; } // somehow makes the upload work - await workspace.fs.readFile(Uri.file(tarFilePath)); + // await workspace.fs.readFile(Uri.file(tarFilePath)); + await sleep(1000); progress.report({ message: "Uploading tag", increment: 60 }); try { return await functionsClient.createTag(functionId, command, fs.createReadStream(tarFilePath)); @@ -158,6 +161,7 @@ async function tagNotification(tag: Tag): Promise { } if (action === "View in console") { // + await openFunctionTagsInBrowser(tag.functionId); } return; } diff --git a/src/commands/functions/openFunctionTagsInBrowser.ts b/src/commands/functions/openFunctionTagsInBrowser.ts index 31c40a1..d962cd0 100644 --- a/src/commands/functions/openFunctionTagsInBrowser.ts +++ b/src/commands/functions/openFunctionTagsInBrowser.ts @@ -3,11 +3,13 @@ import { ExecutionsTreeItem } from '../../tree/functions/executions/ExecutionsTr import { openUrl } from '../../utils/openUrl'; import { getConsoleUrlFromEndpoint } from '../users/openUserInConsole'; -export async function openFunctionTagsInBrowser(treeItem: ExecutionsTreeItem): Promise { - const func = treeItem.parent.func; +export async function openFunctionTagsInBrowser(treeItem: ExecutionsTreeItem | string): Promise { + + const funcId = treeItem instanceof ExecutionsTreeItem ? treeItem.parent.func.$id : treeItem; + const consoleUrl = getConsoleUrlFromEndpoint(clientConfig.endpoint); // https://console.streamlux.com/console/functions/function?id=60b1836a8e5d9&project=605ce39a30c01 - const url = `${consoleUrl}/functions/function?id=${func.$id}&project=${clientConfig.projectId}`; + const url = `${consoleUrl}/functions/function?id=${funcId}&project=${clientConfig.projectId}`; openUrl(url); }