Skip to content

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

Display activity related link in the activity table

天舟c7017d3437c7
diff --git a/api/activity.go b/api/activity.go
index 990c4994ea..eb8792b4fe 100644
--- a/api/activity.go
+++ b/api/activity.go
@@ -139,7 +139,6 @@ type ActivityMemberActivateDeactivatePayload struct {
type ActivityProjectRepositoryPushPayload struct {
VCSPushEvent common.VCSPushEvent `json:"pushEvent"`
- Error string `json:"error"`
}
type Activity struct {
diff --git a/frontend/src/components/ActivityTable.vue b/frontend/src/components/ActivityTable.vue
index fae97ebe15..2af491f9d1 100644
--- a/frontend/src/components/ActivityTable.vue
+++ b/frontend/src/components/ActivityTable.vue
@@ -72,6 +72,15 @@
</BBTableCell>
<BBTableCell class="w-8">
{{ activityName(activity.actionType) }}
+ <template v-if="activityLink(activity)">
+ <a
+ :href="activityLink(activity).path"
+ target="_blank"
+ class="normal-link"
+ >
+ {{ activityLink(activity).title }}
+ </a>
+ </template>
</BBTableCell>
<BBTableCell class="w-24">
{{ activity.comment }}
@@ -92,9 +101,14 @@
<script lang="ts">
import { PropType } from "vue";
import { BBTableColumn } from "../bbkit/types";
-import { Activity } from "../types";
+import { ActionProjectRepositoryPushPayload, Activity } from "../types";
import { activityName } from "../utils";
+type Link = {
+ title: string;
+ path: string;
+};
+
const COLUMN_LIST: BBTableColumn[] = [
{
title: "",
@@ -123,9 +137,24 @@ export default {
},
},
setup(props, ctx) {
+ const activityLink = (activity: Activity): Link | undefined => {
+ switch (activity.actionType) {
+ case "bb.project.repository.push": {
+ const payload =
+ activity.payload as ActionProjectRepositoryPushPayload;
+ return {
+ title: payload.pushEvent.fileCommit.id.substring(0, 7),
+ path: payload.pushEvent.fileCommit.url,
+ };
+ }
+ }
+ return undefined;
+ };
+
return {
activityName,
COLUMN_LIST,
+ activityLink,
};
},
};
diff --git a/frontend/src/types/activity.ts b/frontend/src/types/activity.ts
index 3402a76a98..0d57e67c56 100644
--- a/frontend/src/types/activity.ts
+++ b/frontend/src/types/activity.ts
@@ -4,6 +4,7 @@ import { IssueStatus } from "./issue";
import { MemberStatus, RoleType } from "./member";
import { TaskStatus } from "./pipeline";
import { Principal } from "./principal";
+import { VCSPushEvent } from "./vcs";
export type IssueActivityType =
| "bb.issue.create"
@@ -80,6 +81,10 @@ export type ActionMemberActivateDeactivatePayload = {
role: RoleType;
};
+export type ActionProjectRepositoryPushPayload = {
+ pushEvent: VCSPushEvent;
+};
+
export type ActionPayloadType =
| ActionIssueCreatePayload
| ActionIssueCommentCreatePayload
@@ -88,7 +93,8 @@ export type ActionPayloadType =
| ActionTaskStatusUpdatePayload
| ActionMemberCreatePayload
| ActionMemberRoleUpdatePayload
- | ActionMemberActivateDeactivatePayload;
+ | ActionMemberActivateDeactivatePayload
+ | ActionProjectRepositoryPushPayload;
export type Activity = {
id: ActivityId;
diff --git a/server/webhook.go b/server/webhook.go
index 5f8adb4cec..de0fee14a2 100644
--- a/server/webhook.go
+++ b/server/webhook.go
@@ -107,12 +107,11 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
// Create a WARNING project activity if the committed file path doesn't match the expected pattern
{
- bytes, err := json.Marshal(api.ActivityProjectRepositoryPushPayload{
+ bytes, marshalErr := json.Marshal(api.ActivityProjectRepositoryPushPayload{
VCSPushEvent: vcsPushEvent,
- Error: err.Error(),
})
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(err)
+ if marshalErr != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(marshalErr)
}
activityCreate := &api.ActivityCreate{
@@ -120,6 +119,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
ContainerId: repository.ProjectId,
Type: api.ActivityProjectRepositoryPush,
Level: api.ACTIVITY_WARN,
+ Comment: err.Error(),
Payload: string(bytes),
}
_, err = s.ActivityManager.CreateActivity(context.Background(), activityCreate, &ActivityMeta{})