From 17d8a40ed3407d32933f4b757c091054f178cc96 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Mon, 27 Jan 2025 18:27:07 +0100 Subject: [PATCH 1/4] Add IDE launcher links to issue spans --- .github/workflows/bump.yml | 23 ++++++++++++++----- .../InsightCardRenderer/index.tsx | 2 +- .../InsightCard/InsightHeader/index.tsx | 13 +++++++++-- .../common/InsightCard/InsightHeader/types.ts | 2 +- src/utils/goToSpanInIde.ts | 16 +++++++++++++ 5 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 src/utils/goToSpanInIde.ts diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index f8b1e3d5a..d65ba9c1c 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -3,9 +3,15 @@ name: Bump NPM version and push git tag on: workflow_dispatch: inputs: - version: - description: "Version to set (e.g., 1.2.3)" + version_type: + description: "Type of version bump" required: true + type: choice + options: + - major + - minor + - patch + - alpha jobs: bump: @@ -25,9 +31,14 @@ jobs: node-version-file: ".nvmrc" - run: | - npm version ${{ inputs.version }} --no-git-tag-version + if [ "${{ inputs.version_type }}" == "alpha" ]; then + npm version prerelease --preid alpha --no-git-tag-version + else + npm version ${{ inputs.version_type }} --no-git-tag-version + fi git add package.json package-lock.json - git commit -m "Bump version to ${{ inputs.version }} [skip ci]" - git tag "v${{ inputs.version }}" + VERSION=$(node -p "require('./package.json').version") + git commit -m "Bump version to $VERSION [skip ci]" + git tag "v$VERSION" git push - git push origin "v${{ inputs.version }}" + git push origin "v$VERSION" diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/index.tsx index 66f6c1279..15febd7bc 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/index.tsx +++ b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/index.tsx @@ -140,7 +140,7 @@ export const InsightCardRenderer = ({ if (spanCodeObjectId) { url = url.concat(`?uiFind=${spanCodeObjectId}`); } - window.open(url, "_blank", "noopener noreferrer"); + openURLInDefaultBrowser(url); return; } diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx index b27e51afe..65d9e1081 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx +++ b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx @@ -1,6 +1,8 @@ +import { platform } from "../../../../../../../../../platform"; import { useConfigSelector } from "../../../../../../../../../store/config/useConfigSelector"; import { isString } from "../../../../../../../../../typeGuards/isString"; import { formatTimeDistance } from "../../../../../../../../../utils/formatTimeDistance"; +import { getIdeLauncherLinkForSpan } from "../../../../../../../../../utils/getIdeLauncherLinkForSpan"; import { getInsightTypeInfo } from "../../../../../../../../../utils/getInsightTypeInfo"; import { Link } from "../../../../../../../../common/v3/Link"; import { NewTag } from "../../../../../../../../common/v3/NewTag"; @@ -53,10 +55,15 @@ export const InsightHeader = ({ const handleSpanLinkClick = () => { if (spanInfo) { - onSpanLinkClick(spanInfo.spanCodeObjectId); + onSpanLinkClick(); } }; + const spanIdeLauncherLink = + platform === "Web" && spanInfo + ? getIdeLauncherLinkForSpan(spanInfo) + : undefined; + return ( @@ -95,7 +102,9 @@ export const InsightHeader = ({ {!scope?.span && spanInfo && ( - {spanInfo.displayName} + + {spanInfo.displayName} + diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/types.ts b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/types.ts index 81ffe58b1..6db504aed 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/types.ts +++ b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/types.ts @@ -3,6 +3,6 @@ import type { GenericCodeObjectInsight } from "../../../../../../../types"; export interface InsightHeaderProps { insight: GenericCodeObjectInsight; isAsync?: boolean; - onSpanLinkClick: (spanCodeObjectId: string) => void; + onSpanLinkClick: () => void; lastUpdateTimer?: string | null; } diff --git a/src/utils/goToSpanInIde.ts b/src/utils/goToSpanInIde.ts new file mode 100644 index 000000000..3ac07189a --- /dev/null +++ b/src/utils/goToSpanInIde.ts @@ -0,0 +1,16 @@ +import type { SpanInfo } from "../types"; + +export const goToSpanInIde = (spanInfo: SpanInfo) => { + if (!spanInfo.uid) { + return; + } + + const baseURL = `${window.location.origin}/ide-launcher`; + const url = new URL(baseURL); + + url.searchParams.append("plugin.action", "GoToSpan"); + url.searchParams.append("plugin.spanUid", spanInfo.uid); + url.searchParams.append("plugin.targetTab", "issues"); + + window.open(url.toString(), "_blank", "noopener noreferrer"); +}; From b30c951631ca19e53a46d1966df320a46c2deed6 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Mon, 27 Jan 2025 18:32:33 +0100 Subject: [PATCH 2/4] Fix types --- src/types.ts | 1 + src/utils/{goToSpanInIde.ts => getIdeLauncherLinkForSpan.ts} | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename src/utils/{goToSpanInIde.ts => getIdeLauncherLinkForSpan.ts} (74%) diff --git a/src/types.ts b/src/types.ts index c861118cd..c098e8c86 100644 --- a/src/types.ts +++ b/src/types.ts @@ -98,6 +98,7 @@ export interface SpanInfo { spanCodeObjectId: string; methodCodeObjectId: string | null; kind: string | null; + uid?: string; } export interface SpanInstanceInfo { diff --git a/src/utils/goToSpanInIde.ts b/src/utils/getIdeLauncherLinkForSpan.ts similarity index 74% rename from src/utils/goToSpanInIde.ts rename to src/utils/getIdeLauncherLinkForSpan.ts index 3ac07189a..4c89c0035 100644 --- a/src/utils/goToSpanInIde.ts +++ b/src/utils/getIdeLauncherLinkForSpan.ts @@ -1,6 +1,6 @@ import type { SpanInfo } from "../types"; -export const goToSpanInIde = (spanInfo: SpanInfo) => { +export const getIdeLauncherLinkForSpan = (spanInfo: SpanInfo) => { if (!spanInfo.uid) { return; } @@ -12,5 +12,5 @@ export const goToSpanInIde = (spanInfo: SpanInfo) => { url.searchParams.append("plugin.spanUid", spanInfo.uid); url.searchParams.append("plugin.targetTab", "issues"); - window.open(url.toString(), "_blank", "noopener noreferrer"); + return url.toString(); }; From efdbef2c6b960140fbe43fc2d54250bd985c037c Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Mon, 27 Jan 2025 18:42:08 +0100 Subject: [PATCH 3/4] Extend bump action --- .github/workflows/bump.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index d65ba9c1c..7ec78818d 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -11,7 +11,10 @@ on: - major - minor - patch - - alpha + - premajor + - preminor + - prepatch + - prerelease jobs: bump: @@ -31,8 +34,8 @@ jobs: node-version-file: ".nvmrc" - run: | - if [ "${{ inputs.version_type }}" == "alpha" ]; then - npm version prerelease --preid alpha --no-git-tag-version + if [[ "${{ inputs.version_type }}" == "prerelease" || "${{ inputs.version_type }}" == "premajor" || "${{ inputs.version_type }}" == "preminor" || "${{ inputs.version_type }}" == "prepatch" ]]; then + npm version ${{ inputs.version_type }} --preid alpha --no-git-tag-version else npm version ${{ inputs.version_type }} --no-git-tag-version fi From 2c76d2cc9fbcd6552ce81e52dab0a896eb247027 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Mon, 27 Jan 2025 18:56:39 +0100 Subject: [PATCH 4/4] Open link in a new tab --- .../common/InsightCard/InsightHeader/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx index 65d9e1081..226255c26 100644 --- a/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx +++ b/src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/insightCards/common/InsightCard/InsightHeader/index.tsx @@ -102,7 +102,12 @@ export const InsightHeader = ({ {!scope?.span && spanInfo && ( - + {spanInfo.displayName}