Skip to content

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

Manually scroll into activity anchor

天舟2daa06e2f13f
diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vue
index 7f40f77e9e..e14457cf62 100644
--- a/frontend/src/views/TaskActivityPanel.vue
+++ b/frontend/src/views/TaskActivityPanel.vue
@@ -295,6 +295,7 @@ import {
PropType,
} from "vue";
import { useStore } from "vuex";
+import { useRouter } from "vue-router";
import {
Task,
Activity,
@@ -308,6 +309,7 @@ import { fieldFromId, TaskTemplate, TaskBuiltinFieldId } from "../plugins";
interface LocalState {
showDeleteCommentModal: boolean;
editCommentMode: boolean;
+ activityList: Activity[];
activeActivity?: Activity;
}
@@ -327,6 +329,8 @@ export default {
components: {},
setup(props, { emit }) {
const store = useStore();
+ const router = useRouter();
+
const newComment = ref("");
const newCommentTextArea = ref();
const editComment = ref("");
@@ -335,6 +339,7 @@ export default {
const state = reactive<LocalState>({
showDeleteCommentModal: false,
editCommentMode: false,
+ activityList: [],
});
const keyboardHandler = (e: KeyboardEvent) => {
@@ -369,6 +374,35 @@ export default {
const prepareActivityList = () => {
store
.dispatch("activity/fetchActivityListForTask", props.task.id)
+ .then((list: Activity[]) => {
+ // Filter out the subscriber change
+ state.activityList = list.filter((activity: Activity) => {
+ if (activity.actionType == "bytebase.task.field.update") {
+ let containUserVisibleChange = false;
+ for (const update of (activity.payload as ActionTaskFieldUpdatePayload)
+ ?.changeList || []) {
+ if (update.fieldId != TaskBuiltinFieldId.SUBSCRIBER_LIST) {
+ containUserVisibleChange = true;
+ break;
+ }
+ }
+ return containUserVisibleChange;
+ }
+ return true;
+ });
+
+ // The activity list and its anchor is not immediately available when the task shows up.
+ // Thus the scrollBehavior set in the vue router won't work (also tried promise to resolve async with no luck either)
+ // So we manually use scrollIntoView after rendering the activity list.
+ nextTick(() => {
+ if (router.currentRoute.value.hash) {
+ const el = document.getElementById(
+ router.currentRoute.value.hash.slice(1)
+ );
+ el?.scrollIntoView();
+ }
+ });
+ })
.catch((error) => {
console.log(error);
});
@@ -376,26 +410,6 @@ export default {
watchEffect(prepareActivityList);
- // Filter out the subscriber change
- const activityList = computed(() =>
- store.getters["activity/activityListByTask"](props.task.id).filter(
- (activity: Activity) => {
- if (activity.actionType == "bytebase.task.field.update") {
- let containUserVisibleChange = false;
- for (const update of (activity.payload as ActionTaskFieldUpdatePayload)
- ?.changeList || []) {
- if (update.fieldId != TaskBuiltinFieldId.SUBSCRIBER_LIST) {
- containUserVisibleChange = true;
- break;
- }
- }
- return containUserVisibleChange;
- }
- return true;
- }
- )
- );
-
const cancelEditComment = () => {
editComment.value = "";
state.activeActivity = undefined;
@@ -590,7 +604,6 @@ export default {
editComment,
editCommentTextArea,
currentUser,
- activityList,
actionSentence,
doCreateComment,
cancelEditComment,