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

feat(cases): INT-2196 add case hash open link #834

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
);
Expand All @@ -996,6 +998,37 @@ 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(
'Requested hash does not exist',
);
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
Loading