Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: show VCS PR URL in issue (#11439)

ecmadaoc1d6183665f9
diff --git a/backend/api/gitops/azure.go b/backend/api/gitops/azure.go
index f0cfeb3598..8ff16e1765 100644
--- a/backend/api/gitops/azure.go
+++ b/backend/api/gitops/azure.go
@@ -3,6 +3,7 @@ package gitops
import (
"context"
"encoding/json"
+ "strings"
"github.com/pkg/errors"
@@ -17,6 +18,13 @@ func getAzurePullRequestInfo(ctx context.Context, vcsProvider *store.VCSProvider
return nil, errors.Errorf("failed to unmarshal push event, error %v", err)
}
+ if strings.ToLower(pushEvent.Resource.Status) != "completed" {
+ return nil, errors.Errorf("invalid pull request status: %v", pushEvent.Resource.Status)
+ }
+ if strings.ToLower(pushEvent.Resource.MergeStatus) != "succeeded" {
+ return nil, errors.Errorf("invalid pull request merge status: %v", pushEvent.Resource.MergeStatus)
+ }
+
targetBranch, err := vcs.Branch(pushEvent.Resource.TargetRefName)
if err != nil {
return nil, errors.Errorf("failed to get target branch, error %v", err)
diff --git a/backend/api/v1/vcs_connector_service.go b/backend/api/v1/vcs_connector_service.go
index ab496ea3b5..1804b3f72b 100644
--- a/backend/api/v1/vcs_connector_service.go
+++ b/backend/api/v1/vcs_connector_service.go
@@ -484,7 +484,7 @@ func createVCSWebhook(ctx context.Context, vcsProvider *store.VCSProviderMessage
ConsumerInputs: azure.WebhookCreateConsumerInputs{
URL: fmt.Sprintf("%s/hook/%s", bytebaseEndpointURL, webhookEndpointID),
AcceptUntrustedCerts: true,
- HTTPHeaders: fmt.Sprintf("X-Azure-Token: Bearer %s", webhookSecretToken),
+ HTTPHeaders: fmt.Sprintf("X-Azure-Token: %s", webhookSecretToken),
},
EventType: "git.pullrequest.merged",
PublisherID: "tfs",
diff --git a/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue b/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue
index 67f29707f4..f510a905a9 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue
@@ -1,12 +1,76 @@
<template>
<div
- v-if="false"
- class="text-sm text-control-light flex flex-col items-start gap-y-1"
- ></div>
+ v-if="issue.planEntity?.vcsSource && vcsConnector"
+ class="text-sm text-control-light flex space-x-1 items-center"
+ >
+ <VCSIcon v-if="vcsProvider" :type="vcsProvider.type" />
+ <a
+ :href="issue.planEntity?.vcsSource.pullRequestUrl"
+ target="_blank"
+ class="normal-link"
+ >
+ {{ `${vcsConnector.branch}@${vcsConnector.fullPath}` }}
+ </a>
+ </div>
</template>
<script setup lang="ts">
import { computed } from "vue";
+import { watchEffect } from "vue";
+import { useIssueContext } from "@/components/IssueV1";
+import {
+ useCurrentUserV1,
+ useVCSConnectorStore,
+ useVCSProviderStore,
+} from "@/store";
+import { hasWorkspacePermissionV2, hasProjectPermissionV2 } from "@/utils";
+
+const { issue } = useIssueContext();
+
+const currentUser = useCurrentUserV1();
+const vcsConnectorStore = useVCSConnectorStore();
+const vcsProviderStore = useVCSProviderStore();
+
+watchEffect(async () => {
+ if (!issue.value.planEntity?.vcsSource?.vcsConnector) {
+ return;
+ }
+
+ const connector = await vcsConnectorStore.getOrFetchConnectorByName(
+ issue.value.planEntity?.vcsSource?.vcsConnector
+ );
+ await vcsProviderStore.getOrFetchVCSByName(connector.vcsProvider);
+});
+
+const vcsConnector = computed(() => {
+ if (!issue.value.planEntity?.vcsSource?.vcsConnector) {
+ return;
+ }
+ if (
+ !hasProjectPermissionV2(
+ issue.value.projectEntity,
+ currentUser.value,
+ "bb.vcsConnectors.get"
+ )
+ ) {
+ return;
+ }
+ return vcsConnectorStore.getConnectorByName(
+ issue.value.planEntity?.vcsSource?.vcsConnector
+ );
+});
+
+const vcsProvider = computed(() => {
+ if (!vcsConnector.value) {
+ return;
+ }
+ if (
+ !hasWorkspacePermissionV2(currentUser.value, "bb.identityProviders.get")
+ ) {
+ return;
+ }
+ return vcsProviderStore.getVCSByName(vcsConnector.value.vcsProvider);
+});
defineExpose({
shown: computed(() => {
diff --git a/frontend/src/components/RepositoryPanel.vue b/frontend/src/components/RepositoryPanel.vue
index 7b47773c58..5c1909f20f 100644
--- a/frontend/src/components/RepositoryPanel.vue
+++ b/frontend/src/components/RepositoryPanel.vue
@@ -65,7 +65,7 @@
<script lang="ts" setup>
import isEmpty from "lodash-es/isEmpty";
import { computed, reactive, watch } from "vue";
-import { useVCSV1Store, useVCSConnectorStore } from "@/store";
+import { useVCSProviderStore, useVCSConnectorStore } from "@/store";
import { getVCSConnectorId } from "@/store/modules/v1/common";
import type { Project } from "@/types/proto/v1/project_service";
import { VCSConnector } from "@/types/proto/v1/vcs_connector_service";
@@ -92,7 +92,7 @@ const emit = defineEmits<{
(event: "cancel"): void;
}>();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const vcsConnectorStore = useVCSConnectorStore();
const state = reactive<LocalState>({
diff --git a/frontend/src/components/RepositorySelectionPanel.vue b/frontend/src/components/RepositorySelectionPanel.vue
index b49db0fc7f..0123f95cd7 100644
--- a/frontend/src/components/RepositorySelectionPanel.vue
+++ b/frontend/src/components/RepositorySelectionPanel.vue
@@ -43,7 +43,11 @@
import { RefreshCwIcon, ChevronRightIcon } from "lucide-vue-next";
import { reactive, computed, onMounted } from "vue";
import BBSpin from "@/bbkit/BBSpin.vue";
-import { pushNotification, useCurrentUserV1, useVCSV1Store } from "@/store";
+import {
+ pushNotification,
+ useCurrentUserV1,
+ useVCSProviderStore,
+} from "@/store";
import type { ProjectRepositoryConfig } from "@/types";
import type { VCSRepository } from "@/types/proto/v1/vcs_provider_service";
import { VCSProvider_Type } from "@/types/proto/v1/vcs_provider_service";
@@ -63,7 +67,7 @@ const emit = defineEmits<{
}>();
const currentUser = useCurrentUserV1();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const state = reactive<LocalState>({
repositoryList: [],
searchText: "",
diff --git a/frontend/src/components/RepositoryVCSProviderPanel.vue b/frontend/src/components/RepositoryVCSProviderPanel.vue
index beaf035a8b..e6c2b485cc 100644
--- a/frontend/src/components/RepositoryVCSProviderPanel.vue
+++ b/frontend/src/components/RepositoryVCSProviderPanel.vue
@@ -38,7 +38,7 @@ export default { name: "RepositoryVCSProviderPanel" };
<script setup lang="ts">
import { reactive, computed, watchEffect } from "vue";
import { hasWorkspacePermissionV2 } from "@/utils";
-import { useCurrentUserV1, useVCSV1Store } from "@/store";
+import { useCurrentUserV1, useVCSProviderStore } from "@/store";
import type { VCSProvider } from "@/types/proto/v1/vcs_provider_service";
import { WORKSPACE_ROUTE_GITOPS } from "@/router/dashboard/workspaceRoutes";
@@ -51,7 +51,7 @@ const emit = defineEmits<{
(event: "set-vcs", payload: VCSProvider): void;
}>();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const state = reactive<LocalState>({});
const currentUserV1 = useCurrentUserV1();
diff --git a/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue b/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
index 33d8d9cf4c..f7789551aa 100644
--- a/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
+++ b/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
@@ -169,7 +169,7 @@ import { NRadio, NRadioGroup } from "naive-ui";
import { Status } from "nice-grpc-common";
import { computed, onUnmounted, reactive } from "vue";
import { useI18n } from "vue-i18n";
-import { useVCSV1Store } from "@/store";
+import { useVCSProviderStore } from "@/store";
import { vcsProviderPrefix } from "@/store/modules/v1/common";
import type { VCSConfig } from "@/types";
import { TEXT_VALIDATION_DELAY } from "@/types";
@@ -193,7 +193,7 @@ const state = reactive<LocalState>({
showUrlError:
!isEmpty(props.config.instanceUrl) && !isUrl(props.config.instanceUrl),
});
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
onUnmounted(() => {
if (state.urlValidationTimer) {
diff --git a/frontend/src/components/VCS/VCSSetupWizard.vue b/frontend/src/components/VCS/VCSSetupWizard.vue
index 0daa2a86a3..270920c091 100644
--- a/frontend/src/components/VCS/VCSSetupWizard.vue
+++ b/frontend/src/components/VCS/VCSSetupWizard.vue
@@ -21,7 +21,11 @@ import { reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { WORKSPACE_ROUTE_GITOPS } from "@/router/dashboard/workspaceRoutes";
-import { pushNotification, useVCSV1Store, useCurrentUserV1 } from "@/store";
+import {
+ pushNotification,
+ useVCSProviderStore,
+ useCurrentUserV1,
+} from "@/store";
import type { VCSConfig } from "@/types";
import type { VCSProvider } from "@/types/proto/v1/vcs_provider_service";
import { VCSProvider_Type } from "@/types/proto/v1/vcs_provider_service";
@@ -43,7 +47,7 @@ interface LocalState {
const { t } = useI18n();
const router = useRouter();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const currentUser = useCurrentUserV1();
const state = reactive<LocalState>({
diff --git a/frontend/src/store/modules/v1/index.ts b/frontend/src/store/modules/v1/index.ts
index 79233e3704..c397bb8b1c 100644
--- a/frontend/src/store/modules/v1/index.ts
+++ b/frontend/src/store/modules/v1/index.ts
@@ -16,7 +16,7 @@ export * from "./experimental-issue";
export * from "./subscription";
export * from "./actuator";
export * from "./sql";
-export * from "./vcs";
+export * from "./vcs_provider";
export * from "./vcs_connector";
export * from "./changeHistory";
export * from "./dbSchema";
diff --git a/frontend/src/store/modules/v1/vcs_connector.ts b/frontend/src/store/modules/v1/vcs_connector.ts
index b8eb08f2fa..0cc89f5f11 100644
--- a/frontend/src/store/modules/v1/vcs_connector.ts
+++ b/frontend/src/store/modules/v1/vcs_connector.ts
@@ -62,6 +62,11 @@ export const useVCSConnectorStore = defineStore("vcs_connector_v1", () => {
return cached.find((item) => item.name === name);
};
+ const getConnectorByName = (connectorName: string) => {
+ const { projectId, vcsConnectorId } = getVCSConnectorId(connectorName);
+ return getConnector(`${projectNamePrefix}${projectId}`, vcsConnectorId);
+ };
+
const setCache = (project: string, connector: VCSConnector) => {
const cached = getConnectorList(project);
cached.push(connector);
@@ -95,6 +100,14 @@ export const useVCSConnectorStore = defineStore("vcs_connector_v1", () => {
return connector;
};
+ const getOrFetchConnectorByName = async (connectorName: string) => {
+ const { projectId, vcsConnectorId } = getVCSConnectorId(connectorName);
+ return getOrFetchConnector(
+ `${projectNamePrefix}${projectId}`,
+ vcsConnectorId
+ );
+ };
+
const createConnector = async (
project: string,
vcsConnectorId: string,
@@ -137,7 +150,9 @@ export const useVCSConnectorStore = defineStore("vcs_connector_v1", () => {
getOrFetchConnectors,
getConnectorList,
getOrFetchConnector,
+ getOrFetchConnectorByName,
getConnector,
+ getConnectorByName,
createConnector,
deleteConnector,
updateConnector,
diff --git a/frontend/src/store/modules/v1/vcs.ts b/frontend/src/store/modules/v1/vcs_provider.ts
similarity index 98%
rename from frontend/src/store/modules/v1/vcs.ts
rename to frontend/src/store/modules/v1/vcs_provider.ts
index 7edc5da5c8..fd96ea2e7d 100644
--- a/frontend/src/store/modules/v1/vcs.ts
+++ b/frontend/src/store/modules/v1/vcs_provider.ts
@@ -10,7 +10,7 @@ import { vcsProviderPrefix } from "./common";
type VCSProviderCacheKey = [string /* vcs name */];
-export const useVCSV1Store = defineStore("vcs_v1", () => {
+export const useVCSProviderStore = defineStore("vcs_provider", () => {
const cacheByName = useCache<VCSProviderCacheKey, VCSProvider | undefined>(
"bb.vcs-provider.by-name"
);
diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vue
index 742d92b8a4..ff0495107a 100644
--- a/frontend/src/views/SettingWorkspaceVCS.vue
+++ b/frontend/src/views/SettingWorkspaceVCS.vue
@@ -37,13 +37,13 @@ import {
WORKSPACE_ROUTE_GITOPS_CREATE,
WORKSPACE_ROUTE_GITOPS_DETAIL,
} from "@/router/dashboard/workspaceRoutes";
-import { useCurrentUserV1, useVCSV1Store } from "@/store";
+import { useCurrentUserV1, useVCSProviderStore } from "@/store";
import { getVCSProviderId } from "@/store/modules/v1/common";
import type { VCSProvider } from "@/types/proto/v1/vcs_provider_service";
import { hasWorkspacePermissionV2 } from "@/utils";
const currentUser = useCurrentUserV1();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const router = useRouter();
const { t } = useI18n();
diff --git a/frontend/src/views/SettingWorkspaceVCSDetail.vue b/frontend/src/views/SettingWorkspaceVCSDetail.vue
index ba7f9bb358..698bc4ca70 100644
--- a/frontend/src/views/SettingWorkspaceVCSDetail.vue
+++ b/frontend/src/views/SettingWorkspaceVCSDetail.vue
@@ -127,7 +127,7 @@ import {
pushNotification,
useCurrentUserV1,
useVCSConnectorStore,
- useVCSV1Store,
+ useVCSProviderStore,
} from "@/store";
import { vcsProviderPrefix } from "@/store/modules/v1/common";
import type { VCSUIType } from "@/types";
@@ -145,7 +145,7 @@ const props = defineProps<{
const router = useRouter();
const currentUser = useCurrentUserV1();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const vcsConnectorStore = useVCSConnectorStore();
const vcs = computed((): VCSProvider | undefined => {
diff --git a/frontend/src/views/project/ProjectVersionControlDetail.vue b/frontend/src/views/project/ProjectVersionControlDetail.vue
index 9bd1ca940b..110419f8fc 100644
--- a/frontend/src/views/project/ProjectVersionControlDetail.vue
+++ b/frontend/src/views/project/ProjectVersionControlDetail.vue
@@ -18,7 +18,7 @@ import { PROJECT_V1_ROUTE_GITOPS } from "@/router/dashboard/projectV1";
import {
useVCSConnectorStore,
useProjectV1Store,
- useVCSV1Store,
+ useVCSProviderStore,
useCurrentUserV1,
pushNotification,
} from "@/store";
@@ -33,7 +33,7 @@ const props = defineProps<{
}>();
const vcsConnectorStore = useVCSConnectorStore();
-const vcsProviderStore = useVCSV1Store();
+const vcsProviderStore = useVCSProviderStore();
const projectV1Store = useProjectV1Store();
const currentUser = useCurrentUserV1();
const router = useRouter();
diff --git a/frontend/src/views/project/ProjectVersionControlPanel.vue b/frontend/src/views/project/ProjectVersionControlPanel.vue
index aa2bcab9ca..795258817b 100644
--- a/frontend/src/views/project/ProjectVersionControlPanel.vue
+++ b/frontend/src/views/project/ProjectVersionControlPanel.vue
@@ -32,7 +32,7 @@ import {
useVCSConnectorStore,
useProjectV1Store,
useCurrentUserV1,
- useVCSV1Store,
+ useVCSProviderStore,
} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import { getVCSConnectorId } from "@/store/modules/v1/common";
@@ -46,7 +46,7 @@ const props = defineProps<{
const projectV1Store = useProjectV1Store();
const currentUser = useCurrentUserV1();
-const vcsV1Store = useVCSV1Store();
+const vcsV1Store = useVCSProviderStore();
const vcsConnectorStore = useVCSConnectorStore();
const router = useRouter();
const { t } = useI18n();