Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
add case hash open link
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev committed Dec 1, 2023
1 parent 4764d60 commit 595c381
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
31 changes: 31 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
} from './data/codemodConfigSchema';
import { parsePrivateCodemodsEnvelope } from './data/privateCodemodsEnvelopeSchema';
import { GlobalStateTokenStorage, UserService } from './components/userService';
import { isLeft } from 'fp-ts/lib/Either';

export const enum SEARCH_PARAMS_KEYS {
ENGINE = 'engine',
Expand Down Expand Up @@ -987,6 +988,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,
);
Expand All @@ -995,6 +997,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(
Expand Down

0 comments on commit 595c381

Please sign in to comment.