Skip to content

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

TaskActivityPanel initial implementation

Tianzhou Chen155662d7d601
diff --git a/frontend/src/miragejs/factories/activity.js b/frontend/src/miragejs/factories/activity.js
index ac36dc8605..9147565df2 100644
--- a/frontend/src/miragejs/factories/activity.js
+++ b/frontend/src/miragejs/factories/activity.js
@@ -1,28 +1,27 @@
-import { randomNumber } from "./utils";
import { Factory } from "miragejs";
-import faker from "faker";
export default {
activity: Factory.extend({
- name() {
- return "activity " + faker.fake("{{lorem.word}}");
+ createdTs(i) {
+ return Date.now() - (10 - i) * 1800 * 1000;
},
- description() {
- return faker.fake("{{lorem.sentence}}");
+ lastUpdatedTs(i) {
+ return Date.now() - (10 - i) * 3600 * 1000;
},
- creator() {
- return (
- faker.fake("{{name.lastName}}") + " " + faker.fake("{{name.firstName}}")
- );
+ actionType() {
+ return "bytebase.task.comment.create";
},
- link(i) {
- return "actlink" + (i + 1);
+ containerId() {
+ return "0";
},
- startTs() {
- return Date.now() - 3600 * 1000;
+ creator() {
+ return {
+ id: "100",
+ name: "John Appleseed",
+ };
},
- endTs() {
- return Date.now() + randomNumber(3600 * 1000);
+ payload() {
+ return {};
},
}),
};
diff --git a/frontend/src/miragejs/factories/workspace.js b/frontend/src/miragejs/factories/workspace.js
index 3e6b183c8f..4f66660e14 100644
--- a/frontend/src/miragejs/factories/workspace.js
+++ b/frontend/src/miragejs/factories/workspace.js
@@ -1,5 +1,4 @@
import { Factory } from "miragejs";
-import faker from "faker";
export default {
workspace: Factory.extend({
@@ -9,15 +8,6 @@ export default {
slug(i) {
return "ws" + (i + 1);
},
- afterCreate(workspace, server) {
- server.create("activity", {
- workspace,
- name: workspace.name + " activity1 " + faker.fake("{{lorem.word}}"),
- });
- server.create("activity", {
- workspace,
- name: workspace.name + " activity2 " + faker.fake("{{lorem.word}}"),
- });
- },
+ afterCreate(workspace, server) {},
}),
};
diff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.js
index fd7956c204..1e9685cb61 100644
--- a/frontend/src/miragejs/routes/index.js
+++ b/frontend/src/miragejs/routes/index.js
@@ -294,8 +294,23 @@ export default function routes() {
// Activity
this.get("/activity", function (schema, request) {
- return schema.activities.where({
- workspaceId: WORKSPACE_ID,
+ const {
+ queryParams: { containerid: containerId, type },
+ } = request;
+ return schema.activities.where((activity) => {
+ if (activity.workspaceId != WORKSPACE_ID) {
+ return false;
+ }
+
+ if (containerId && containerId != activity.containerId) {
+ return false;
+ }
+
+ if (type && !activity.actionType.startsWith(type)) {
+ return false;
+ }
+
+ return true;
});
});
diff --git a/frontend/src/miragejs/seeds/index.js b/frontend/src/miragejs/seeds/index.js
index 6f8b1ab22e..b4c4b4235c 100644
--- a/frontend/src/miragejs/seeds/index.js
+++ b/frontend/src/miragejs/seeds/index.js
@@ -58,7 +58,7 @@ const workspacesSeeder = (server) => {
const ws2DBA = server.schema.users.find(4);
const ws2Dev = server.schema.users.find(1);
- server.create("task", {
+ let task = server.create("task", {
type: "bytebase.general",
name: "General Task",
creator: {
@@ -81,7 +81,32 @@ const workspacesSeeder = (server) => {
workspace: workspace1,
});
- server.create("task", {
+ server.create("activity", {
+ actionType: "bytebase.task.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ workspace: workspace1,
+ });
+
+ for (let i = 0; i < 3; i++) {
+ server.create("activity", {
+ actionType: "bytebase.task.comment.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ payload: {
+ content: faker.fake("{{lorem.paragraph}}"),
+ },
+ workspace: workspace1,
+ });
+ }
+
+ task = server.create("task", {
type: "bytebase.datasource.create",
name: "Request data source for environment - " + environmentList1[1].name,
creator: {
@@ -108,8 +133,33 @@ const workspacesSeeder = (server) => {
workspace: workspace1,
});
+ server.create("activity", {
+ actionType: "bytebase.task.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ workspace: workspace1,
+ });
+
+ for (let i = 0; i < 3; i++) {
+ server.create("activity", {
+ actionType: "bytebase.task.comment.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ payload: {
+ content: faker.fake("{{lorem.paragraph}}"),
+ },
+ workspace: workspace1,
+ });
+ }
+
for (let i = 0; i < 5; i++) {
- server.create("task", {
+ task = server.create("task", {
creator: {
id: ws1Dev1.id,
name: ws1Dev1.name,
@@ -122,10 +172,35 @@ const workspacesSeeder = (server) => {
...fillStage(environmentList1),
workspace: workspace1,
});
+
+ server.create("activity", {
+ actionType: "bytebase.task.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ workspace: workspace1,
+ });
+
+ for (let i = 0; i < 3; i++) {
+ server.create("activity", {
+ actionType: "bytebase.task.comment.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ payload: {
+ content: faker.fake("{{lorem.paragraph}}"),
+ },
+ workspace: workspace1,
+ });
+ }
}
for (let i = 0; i < 15; i++) {
- server.create("task", {
+ task = server.create("task", {
creator: {
id: ws1Owner.id,
name: ws1Owner.name,
@@ -138,10 +213,35 @@ const workspacesSeeder = (server) => {
...fillStage(environmentList1),
workspace: workspace1,
});
+
+ server.create("activity", {
+ actionType: "bytebase.task.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Owner.id,
+ name: ws1Owner.name,
+ },
+ workspace: workspace1,
+ });
+
+ for (let i = 0; i < 3; i++) {
+ server.create("activity", {
+ actionType: "bytebase.task.comment.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ payload: {
+ content: faker.fake("{{lorem.paragraph}}"),
+ },
+ workspace: workspace1,
+ });
+ }
}
for (let i = 0; i < 15; i++) {
- server.create("task", {
+ task = server.create("task", {
creator: {
id: ws1Dev2.id,
name: ws1Dev2.name,
@@ -154,9 +254,34 @@ const workspacesSeeder = (server) => {
...fillStage(environmentList1),
workspace: workspace1,
});
+
+ server.create("activity", {
+ actionType: "bytebase.task.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev2.id,
+ name: ws1Dev2.name,
+ },
+ workspace: workspace1,
+ });
+
+ for (let i = 0; i < 3; i++) {
+ server.create("activity", {
+ actionType: "bytebase.task.comment.create",
+ containerId: task.id,
+ creator: {
+ id: ws1DBA.id,
+ name: ws1DBA.name,
+ },
+ payload: {
+ content: faker.fake("{{lorem.paragraph}}"),
+ },
+ workspace: workspace1,
+ });
+ }
}
- server.create("task", {
+ task = server.create("task", {
creator: {
id: ws2Dev.id,
name: ws2Dev.name,
@@ -169,6 +294,16 @@ const workspacesSeeder = (server) => {
workspace: workspace2,
});
+ server.create("activity", {
+ actionType: "bytebase.task.create",
+ containerId: task.id,
+ creator: {
+ id: ws1Dev1.id,
+ name: ws1Dev1.name,
+ },
+ workspace: workspace2,
+ });
+
// Naming convention
// xxx <<workspace #>><<group #>><<project #>>
// e.g. group 12 (1st workspace and 1st group inside)
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index e18ac2953d..b8d7ce38f7 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -1,14 +1,18 @@
import axios from "axios";
-import { UserId, Activity, ActivityState } from "../../types";
+import { UserId, TaskId, Activity, ActivityState } from "../../types";
const state: () => ActivityState = () => ({
activityListByUser: new Map(),
+ activityListByTask: new Map(),
});
const getters = {
activityListByUser: (state: ActivityState) => (userId: UserId) => {
return state.activityListByUser.get(userId);
},
+ activityListByTask: (state: ActivityState) => (taskId: TaskId) => {
+ return state.activityListByTask.get(taskId);
+ },
};
const actions = {
@@ -17,6 +21,14 @@ const actions = {
commit("setActivityListForUser", { userId, activityList });
return activityList;
},
+
+ async fetchActivityListForTask({ commit }: any, taskId: TaskId) {
+ const activityList = (
+ await axios.get(`/api/activity?containerid=${taskId}&type=bytebase.task.`)
+ ).data.data;
+ commit("setActivityListForTask", { taskId, activityList });
+ return activityList;
+ },
};
const mutations = {
@@ -32,6 +44,19 @@ const mutations = {
) {
state.activityListByUser.set(userId, activityList);
},
+
+ setActivityListForTask(
+ state: ActivityState,
+ {
+ taskId,
+ activityList,
+ }: {
+ taskId: UserId;
+ activityList: Activity[];
+ }
+ ) {
+ state.activityListByTask.set(taskId, activityList);
+ },
};
export default {
diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.ts
index e9847c66d3..7bd9786a66 100644
--- a/frontend/src/types/bytebase.ts
+++ b/frontend/src/types/bytebase.ts
@@ -36,9 +36,6 @@ export type NewUser = Omit<User, "id">;
export type Bookmark = ResourceObject & {};
export type NewBookmark = Omit<Bookmark, "id">;
-export type Activity = ResourceObject & {};
-export type ActivityNew = Omit<Activity, "id">;
-
// Stage
export type StageType = "SIMPLE" | "ENVIRONMENT";
@@ -130,6 +127,37 @@ export type TaskPatch = {
payload?: any;
};
+// Activity
+export type TaskActionType =
+ | "bytebase.task.create"
+ | "bytebase.task.comment.create"
+ | "bytebase.task.field.update";
+
+export type ActionType = TaskActionType;
+
+export type ActionCommentCreatePayload = {
+ content: string;
+};
+
+export type ActionPayloadType = ActionCommentCreatePayload;
+
+export type Activity = ResourceObject & {
+ attributes: {
+ createdTs: number;
+ lastUpdatedTs: number;
+ actionType: ActionType;
+ // The object where this activity belongs
+ // e.g if actionType is "bytebase.task.xxx", then this field refers to the corresponding task's id.
+ containerId: TaskId;
+ creator: {
+ id: string;
+ name: string;
+ };
+ payload?: ActionPayloadType;
+ };
+};
+export type ActivityNew = Omit<Environment, "id">;
+
// Environment
export type Environment = ResourceObject & {
attributes: {
@@ -236,6 +264,7 @@ export interface BookmarkState {
export interface ActivityState {
activityListByUser: Map<UserId, Activity[]>;
+ activityListByTask: Map<TaskId, Activity[]>;
}
export interface TaskState {
diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vue
index e27cc0bdbc..262cd6442b 100644
--- a/frontend/src/views/TaskActivityPanel.vue
+++ b/frontend/src/views/TaskActivityPanel.vue
@@ -1,8 +1,8 @@
<template>
<div>
- <div class="divide-y divide-gray-200">
+ <div class="divide-y divide-block-border">
<div class="pb-4">
- <h2 id="activity-title" class="text-lg font-medium text-gray-900">
+ <h2 id="activity-title" class="text-lg font-medium text-main">
Activity
</h2>
</div>
@@ -10,123 +10,59 @@
<!-- Activity feed-->
<div class="flow-root">
<ul class="-mb-8">
- <li>
- <div class="relative pb-8">
+ <li v-for="(activity, index) in activityList" :key="index">
+ <div :id="'activity' + (index + 1)" class="relative pb-8">
<span
- class="absolute top-5 left-5 -ml-px h-full w-0.5 bg-gray-200"
+ v-if="index != activityList.length - 1"
+ class="absolute top-5 left-5 -ml-px h-full w-0.5 bg-block-border"
aria-hidden="true"
></span>
<div class="relative flex items-start space-x-3">
- <div class="relative">
- <img
- class="h-10 w-10 rounded-full bg-gray-400 flex items-center justify-center ring-8 ring-white"
- src="https://images.unsplash.com/photo-1520785643438-5bf77931f493?ixlib=rb-=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=facearea&amp;facepad=8&amp;w=256&amp;h=256&amp;q=80"
- alt=""
- />
-
- <span
- class="absolute -bottom-0.5 -right-1 bg-white rounded-tl px-0.5 py-px"
- >
- <!-- Heroicon name: solid/chat-alt -->
- <svg
- class="h-5 w-5 text-gray-400"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- >
- <path
- fill-rule="evenodd"
- d="M18 5v8a2 2 0 01-2 2h-5l-5 4v-4H4a2 2 0 01-2-2V5a2 2 0 012-2h12a2 2 0 012 2zM7 8H5v2h2V8zm2 0h2v2H9V8zm6 0h-2v2h2V8z"
- clip-rule="evenodd"
- />
- </svg>
- </span>
- </div>
- <div class="min-w-0 flex-1">
+ <template
+ v-if="
+ activity.attributes.actionType == 'bytebase.task.create'
+ "
+ >
<div>
- <div class="text-sm">
- <a href="#" class="font-medium text-gray-900"
- >Eduardo Benz</a
- >
- </div>
- <p class="mt-0.5 text-sm text-gray-500">
- Commented 6d ago
- </p>
- </div>
- <div class="mt-2 text-sm text-gray-700">
- <p>
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- Tincidunt nunc ipsum tempor purus vitae id. Morbi in
- vestibulum nec varius. Et diam cursus quis sed purus
- nam.
- </p>
- </div>
- </div>
- </div>
- </div>
- </li>
-
- <li>
- <div class="relative pb-8">
- <span
- class="absolute top-5 left-5 -ml-px h-full w-0.5 bg-gray-200"
- aria-hidden="true"
- ></span>
- <div class="relative flex items-start space-x-3">
- <div>
- <div class="relative px-1">
- <div
- class="h-8 w-8 bg-gray-100 rounded-full ring-8 ring-white flex items-center justify-center"
- >
- <!-- Heroicon name: solid/user-circle -->
- <svg
- class="h-5 w-5 text-gray-500"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
+ <div class="relative pl-1">
+ <div
+ class="h-8 w-8 bg-control-bg rounded-full ring-8 ring-white flex items-center justify-center"
>
- <path
- fill-rule="evenodd"
- d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-6-3a2 2 0 11-4 0 2 2 0 014 0zm-2 4a5 5 0 00-4.546 2.916A5.986 5.986 0 0010 16a5.986 5.986 0 004.546-2.084A5 5 0 0010 11z"
- clip-rule="evenodd"
- />
- </svg>
+ <svg
+ class="w-6 h-6 text-control"
+ fill="currentColor"
+ viewBox="0 0 20 20"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ fill-rule="evenodd"
+ d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z"
+ clip-rule="evenodd"
+ ></path>
+ </svg>
+ </div>
</div>
</div>
- </div>
- <div class="min-w-0 flex-1 py-1.5">
- <div class="text-sm text-gray-500">
- <a href="#" class="font-medium text-gray-900"
- >Hilary Mahy</a
- >
- assigned
- <a href="#" class="font-medium text-gray-900"
- >Kristin Watson</a
+ </template>
+ <template
+ v-else-if="
+ activity.attributes.actionType ==
+ 'bytebase.task.comment.create'
+ "
+ >
+ <div class="relative">
+ <BBAvatar
+ class="rounded-full ring-8 ring-white"
+ :username="currentUser.attributes.name"
>
- <span class="whitespace-nowrap">2d ago</span>
- </div>
- </div>
- </div>
- </div>
- </li>
+ </BBAvatar>
- <li>
- <div class="relative pb-8">
- <span
- class="absolute top-5 left-5 -ml-px h-full w-0.5 bg-gray-200"
- aria-hidden="true"
- ></span>
- <div class="relative flex items-start space-x-3">
- <div>
- <div class="relative px-1">
- <div
- class="h-8 w-8 bg-gray-100 rounded-full ring-8 ring-white flex items-center justify-center"
+ <span
+ class="absolute -bottom-0.5 -right-1 bg-white rounded-tl px-0.5 py-px"
>
- <!-- Heroicon name: solid/tag -->
+ <!-- Heroicon name: solid/chat-alt -->
<svg
- class="h-5 w-5 text-gray-500"
+ class="h-3.5 w-3.5 text-control-light"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
@@ -134,146 +70,49 @@
>
<path
fill-rule="evenodd"
- d="M17.707 9.293a1 1 0 010 1.414l-7 7a1 1 0 01-1.414 0l-7-7A.997.997 0 012 10V5a3 3 0 013-3h5c.256 0 .512.098.707.293l7 7zM5 6a1 1 0 100-2 1 1 0 000 2z"
+ d="M18 5v8a2 2 0 01-2 2h-5l-5 4v-4H4a2 2 0 01-2-2V5a2 2 0 012-2h12a2 2 0 012 2zM7 8H5v2h2V8zm2 0h2v2H9V8zm6 0h-2v2h2V8z"
clip-rule="evenodd"
/>
</svg>
- </div>
- </div>
- </div>
- <div class="min-w-0 flex-1 py-0">
- <div class="text-sm leading-8 text-gray-500">
- <span class="mr-0.5">
- <a href="#" class="font-medium text-gray-900"
- >Hilary Mahy</a
- >
- added tags
- </span>
- <span class="mr-0.5">
- <a
- href="#"
- class="relative inline-flex items-center rounded-full border border-gray-300 px-3 py-0.5 text-sm"
- >
- <span
- class="absolute flex-shrink-0 flex items-center justify-center"
- >
- <span
- class="h-1.5 w-1.5 rounded-full bg-rose-500"
- aria-hidden="true"
- ></span>
- </span>
- <span class="ml-3.5 font-medium text-gray-900"
- >Bug</span
- >
- </a>
-
- <a
- href="#"
- class="relative inline-flex items-center rounded-full border border-gray-300 px-3 py-0.5 text-sm"
- >
- <span
- class="absolute flex-shrink-0 flex items-center justify-center"
- >
- <span
- class="h-1.5 w-1.5 rounded-full bg-indigo-500"
- aria-hidden="true"
- ></span>
- </span>
- <span class="ml-3.5 font-medium text-gray-900"
- >Accessibility</span
- >
- </a>
</span>
- <span class="whitespace-nowrap">6h ago</span>
</div>
- </div>
- </div>
- </div>
- </li>
-
- <li>
- <div class="relative pb-8">
- <div class="relative flex items-start space-x-3">
- <div class="relative">
- <img
- class="h-10 w-10 rounded-full bg-gray-400 flex items-center justify-center ring-8 ring-white"
- src="https://images.unsplash.com/photo-1531427186611-ecfd6d936c79?ixlib=rb-=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=facearea&amp;facepad=8&amp;w=256&amp;h=256&amp;q=80"
- alt=""
- />
-
- <span
- class="absolute -bottom-0.5 -right-1 bg-white rounded-tl px-0.5 py-px"
- >
- <!-- Heroicon name: solid/chat-alt -->
- <svg
- class="h-5 w-5 text-gray-400"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- >
- <path
- fill-rule="evenodd"
- d="M18 5v8a2 2 0 01-2 2h-5l-5 4v-4H4a2 2 0 01-2-2V5a2 2 0 012-2h12a2 2 0 012 2zM7 8H5v2h2V8zm2 0h2v2H9V8zm6 0h-2v2h2V8z"
- clip-rule="evenodd"
- />
- </svg>
- </span>
- </div>
+ </template>
<div class="min-w-0 flex-1">
- <div>
- <div class="text-sm">
- <a href="#" class="font-medium text-gray-900"
- >Jason Meyers</a
+ <div class="min-w-0 flex-1 py-1.5">
+ <div class="text-sm text-control-light">
+ <span class="font-medium text-main">{{
+ activity.attributes.creator.name
+ }}</span>
+ {{ actionSentence(activity.attributes.actionType) }}
+ <a
+ :href="'#activity' + (index + 1)"
+ class="link whitespace-nowrap"
+ >{{ humanizeTs(activity.attributes.createdTs) }}</a
>
</div>
- <p class="mt-0.5 text-sm text-gray-500">
- Commented 2h ago
- </p>
- </div>
- <div class="mt-2 text-sm text-gray-700">
- <p>
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- Tincidunt nunc ipsum tempor purus vitae id. Morbi in
- vestibulum nec varius. Et diam cursus quis sed purus
- nam. Scelerisque amet elit non sit ut tincidunt
- condimentum. Nisl ultrices eu venenatis diam.
- </p>
</div>
+ <template
+ v-if="
+ activity.attributes.actionType ==
+ 'bytebase.task.comment.create'
+ "
+ >
+ <div class="mt-2 text-sm text-control">
+ {{ activity.attributes.payload.content }}
+ </div>
+ </template>
</div>
</div>
</div>
</li>
</ul>
</div>
+
<div class="mt-6">
<div class="flex space-x-3">
<div class="flex-shrink-0">
<div class="relative">
- <img
- class="h-10 w-10 rounded-full bg-gray-400 flex items-center justify-center ring-8 ring-white"
- src="https://images.unsplash.com/photo-1517365830460-955ce3ccd263?ixlib=rb-=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=8&w=256&h=256&q=80"
- alt=""
- />
-
- <span
- class="absolute -bottom-0.5 -right-1 bg-white rounded-tl px-0.5 py-px"
- >
- <!-- Heroicon name: solid/chat-alt -->
- <svg
- class="h-5 w-5 text-gray-400"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- >
- <path
- fill-rule="evenodd"
- d="M18 5v8a2 2 0 01-2 2h-5l-5 4v-4H4a2 2 0 01-2-2V5a2 2 0 012-2h12a2 2 0 012 2zM7 8H5v2h2V8zm2 0h2v2H9V8zm6 0h-2v2h2V8z"
- clip-rule="evenodd"
- />
- </svg>
- </span>
+ <BBAvatar :username="currentUser.attributes.name"> </BBAvatar>
</div>
</div>
<div class="min-w-0 flex-1">
@@ -285,30 +124,10 @@
name="comment"
rows="3"
class="shadow-sm block w-full focus:ring-gray-900 focus:border-gray-900 sm:text-sm border-gray-300 rounded-md"
- placeholder="Leave a comment"
+ placeholder="Leave a comment..."
></textarea>
</div>
- <div class="mt-6 flex items-center justify-end space-x-4">
- <button
- type="button"
- class="inline-flex justify-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-900"
- >
- <!-- Heroicon name: solid/check-circle -->
- <svg
- class="-ml-1 mr-2 h-5 w-5 text-success"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- >
- <path
- fill-rule="evenodd"
- d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
- clip-rule="evenodd"
- />
- </svg>
- <span>Close issue</span>
- </button>
+ <div class="mt-6 flex items-center justify-start space-x-4">
<button
type="submit"
class="inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-gray-900 hover:bg-black focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-900"
@@ -326,8 +145,10 @@
</template>
<script lang="ts">
-import { PropType } from "vue";
-import { Task } from "../types";
+import { computed, inject, watchEffect, PropType } from "vue";
+import { useStore } from "vuex";
+import { UserStateSymbol } from "../components/ProvideUser.vue";
+import { User, Task, TaskActionType } from "../types";
export default {
name: "TaskActivityPanel",
@@ -338,6 +159,41 @@ export default {
},
},
components: {},
- setup(props, ctx) {},
+ setup(props, ctx) {
+ const store = useStore();
+
+ const currentUser = inject<User>(UserStateSymbol);
+
+ const prepareActivityList = () => {
+ store
+ .dispatch("activity/fetchActivityListForTask", props.task.id)
+ .catch((error) => {
+ console.log(error);
+ });
+ };
+
+ const activityList = computed(() =>
+ store.getters["activity/activityListByTask"](props.task.id)
+ );
+
+ watchEffect(prepareActivityList);
+
+ const actionSentence = (actionType: TaskActionType) => {
+ switch (actionType) {
+ case "bytebase.task.create":
+ return "created task";
+ case "bytebase.task.comment.create":
+ return "commented";
+ case "bytebase.task.field.update":
+ return "updated";
+ }
+ };
+
+ return {
+ currentUser,
+ activityList,
+ actionSentence,
+ };
+ },
};
</script>