From d58c48771e03e0cb58d55c0fdfa452a1d4fdedd8 Mon Sep 17 00:00:00 2001 From: Alexander Mysak Date: Fri, 1 Dec 2023 13:30:23 +0100 Subject: [PATCH 1/3] add case hash open link --- package.json | 2 +- src/extension.ts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b924ac8..20d5e151 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "intuita-vscode-extension", "displayName": "Intuita", "description": " Discover, run & manage codemods faster & easier.", - "version": "0.36.17", + "version": "0.36.18", "publisher": "Intuita", "icon": "img/intuita_square128.png", "repository": { diff --git a/src/extension.ts b/src/extension.ts index 05d2d56a..2e00070c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -46,6 +46,7 @@ import { import { parsePrivateCodemodsEnvelope } from './data/privateCodemodsEnvelopeSchema'; import { GlobalStateTokenStorage, UserService } from './components/userService'; import { HomeDirectoryService } from './data/readHomeDirectoryCases'; +import { isLeft } from 'fp-ts/lib/Either'; export const enum SEARCH_PARAMS_KEYS { ENGINE = 'engine', @@ -988,6 +989,7 @@ export async function activate(context: vscode.ExtensionContext) { const codemodSource = urlParams.get( SEARCH_PARAMS_KEYS.CODEMOD_SOURCE, ); + const codemodHashDigest = urlParams.get( SEARCH_PARAMS_KEYS.CODEMOD_HASH_DIGEST, ); @@ -996,6 +998,35 @@ export async function activate(context: vscode.ExtensionContext) { ); const state = store.getState(); + const [hash, casesString] = uri.toString().split('/').reverse(); + const codemodRunCaseHash = + casesString === 'cases' && hash ? hash : null; + + // user is routed to a specific dry run case + if (codemodRunCaseHash !== null) { + vscode.commands.executeCommand( + 'workbench.view.extension.intuitaViewId', + ); + + const validation = caseHashCodec.decode(codemodRunCaseHash); + if (isLeft(validation)) { + throw new Error( + prettyReporter.report(validation).join('\n'), + ); + } + const hash = validation.right; + + // if there is no such hash in runs + if (!state.case.ids.includes(hash)) { + vscode.window.showErrorMessage('Unexistant case hash'); + return; + } + + // otherwise open tab and set selected run + store.dispatch(actions.setActiveTabId('codemodRuns')); + store.dispatch(actions.setSelectedCaseHash(hash)); + } + // user is exporting codemod from studio into extension if (codemodSource !== null) { vscode.commands.executeCommand( From 735cd680092a4a2b2b5a4d44c7b2df2530dcdb05 Mon Sep 17 00:00:00 2001 From: Alexander Mysak Date: Fri, 1 Dec 2023 13:33:17 +0100 Subject: [PATCH 2/3] typo --- src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 2e00070c..4c4b250b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1018,7 +1018,7 @@ export async function activate(context: vscode.ExtensionContext) { // if there is no such hash in runs if (!state.case.ids.includes(hash)) { - vscode.window.showErrorMessage('Unexistant case hash'); + vscode.window.showErrorMessage('Unexistent case hash'); return; } From 159a349590caaba0ba79daf4c910533e147f7121 Mon Sep 17 00:00:00 2001 From: Alexander Mysak Date: Fri, 1 Dec 2023 13:35:23 +0100 Subject: [PATCH 3/3] typo x2 --- src/extension.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 4c4b250b..8e2da11c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1018,7 +1018,9 @@ export async function activate(context: vscode.ExtensionContext) { // if there is no such hash in runs if (!state.case.ids.includes(hash)) { - vscode.window.showErrorMessage('Unexistent case hash'); + vscode.window.showErrorMessage( + 'Requested hash does not exist', + ); return; }