Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(frontend): retire inbox page (#10278)
boojack85198fd89eca
diff --git a/frontend/src/components/InboxList.vue b/frontend/src/components/InboxList.vuedeleted file mode 100644index c87f7e32f4..0000000000--- a/frontend/src/components/InboxList.vue+++ /dev/null@@ -1,254 +0,0 @@-<template>- <ul v-if="inboxList.length > 0">- <li- v-for="(inbox, index) in inboxList"- :key="index"- class="p-3 hover:bg-control-bg-hover cursor-default"- :class="actionLink(inbox.activity) ? 'cursor-pointer' : 'cursor-default'"- @click.prevent="clickInbox(inbox)"- >- <div class="flex space-x-3">- <PrincipalAvatar- :username="getUser(inbox.activity)?.title"- :size="'SMALL'"- :class="inbox.activity?.comment ? '' : '-mt-0.5'"- />- <div class="flex-1 space-y-1">- <div class="flex w-full justify-between space-x-2">- <h3- class="text-sm font-base text-control-light flex flex-row items-center whitespace-nowrap"- >- <template v-if="showCreator(inbox.activity)">- <router-link- :to="`/users/${getUserEmail(inbox.activity)}`"- class="mr-1 font-medium text-main hover:underline"- @click.stop- >{{ getUser(inbox.activity)?.title }}</router-link- >- </template>- <span> {{ actionSentence(inbox.activity) }}</span>- <template- v-if="inbox.activity?.level == LogEntity_Level.LEVEL_WARNING"- >- <heroicons-outline:exclamation- class="ml-1 h-6 w-6 text-warning"- />- </template>- <template- v-else-if="inbox.activity?.level == LogEntity_Level.LEVEL_ERROR"- >- <heroicons-outline:exclamation-circle- class="ml-1 w-6 h-6 text-error"- />- </template>- </h3>- <p class="text-sm text-control whitespace-nowrap">- {{- humanizeTs((inbox.activity?.createTime?.getTime() ?? 0) / 1000)- }}- </p>- </div>- <div v-if="inbox.activity?.comment" class="text-sm text-control">- {{ inbox.activity.comment }}- </div>- </div>- </div>- </li>- </ul>- <div v-else class="text-center text-control-light py-4">- {{ $t("common.no-data") }}- </div>-</template>--<script lang="ts" setup>-import dayjs from "dayjs";-import { isEmpty } from "lodash-es";-import { PropType } from "vue";-import { useI18n } from "vue-i18n";-import { useRouter } from "vue-router";-import { useInboxV1Store, useActivityV1Store } from "@/store";-import { useUserStore } from "@/store";-import { InboxMessage_Status } from "@/types/proto/v1/inbox_service";-import { InboxMessage } from "@/types/proto/v1/inbox_service";-import {- LogEntity,- LogEntity_Action,- LogEntity_Level,-} from "@/types/proto/v1/logging_service";-import { extractUserResourceName } from "@/utils";-import PrincipalAvatar from "../components/PrincipalAvatar.vue";-import {- ActivityIssueCommentCreatePayload,- ActivityIssueCreatePayload,- ActivityIssueFieldUpdatePayload,- ActivityIssueStatusUpdatePayload,- ActivityTaskStatusUpdatePayload,- ActivityTaskStatementUpdatePayload,- ActivityTaskEarliestAllowedTimeUpdatePayload,-} from "../types";-import { issueActivityActionSentence } from "../utils";--defineProps({- inboxList: {- required: true,- type: Object as PropType<InboxMessage[]>,- },-});--const { t } = useI18n();-const inboxV1Store = useInboxV1Store();-const activityV1Store = useActivityV1Store();-const router = useRouter();--const getUserEmail = (activity: LogEntity | undefined) => {- return extractUserResourceName(activity?.creator ?? "");-};--const getUser = (activity: LogEntity | undefined) => {- const email = getUserEmail(activity);- return useUserStore().getUserByEmail(email);-};--const actionLink = (activity: LogEntity | undefined): string => {- if (!activity) {- return "";- }- if (activity.resource.startsWith("issues")) {- return `/issue/${activityV1Store.getResourceId(activity)}`;- } else if (- activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE- ) {- const payload = JSON.parse(- activity.payload- ) as ActivityTaskStatusUpdatePayload;- return `/issue/${activityV1Store.getResourceId(activity)}?task=${- payload.taskId- }`;- }-- return "";-};--const showCreator = (activity: LogEntity | undefined): boolean => {- return (- activity?.resource.startsWith("issues") ||- activity?.action ==- LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE ||- activity?.action ==- LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE- );-};--const actionSentence = (activity: LogEntity | undefined): string => {- if (activity?.resource.startsWith("issues")) {- const [tid, params] = issueActivityActionSentence(activity);- const actionStr = t(tid, params);- switch (activity.action) {- case LogEntity_Action.ACTION_ISSUE_CREATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityIssueCreatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- case LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityIssueCommentCreatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- case LogEntity_Action.ACTION_ISSUE_FIELD_UPDATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityIssueFieldUpdatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- case LogEntity_Action.ACTION_ISSUE_STATUS_UPDATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityIssueStatusUpdatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- }- return actionStr;- }- switch (activity?.action) {- case LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityTaskStatusUpdatePayload;- let actionStr = t(`activity.sentence.changed`);- switch (payload.newStatus) {- case "PENDING": {- if (payload.oldStatus == "RUNNING") {- actionStr = t(`activity.sentence.canceled`);- } else if (payload.oldStatus == "PENDING_APPROVAL") {- actionStr = t(`activity.sentence.approved`);- }- break;- }- case "RUNNING": {- actionStr = t(`activity.sentence.started`);- break;- }- case "DONE": {- actionStr = t(`activity.sentence.completed`);- break;- }- case "FAILED": {- actionStr = t(`activity.sentence.failed`);- break;- }- }- return `${t("activity.subject-prefix.task")} '${- payload.taskName- }' ${actionStr} - '${payload?.issueName || ""}'`;- }- case LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityTaskStatementUpdatePayload;- return t("activity.sentence.changed-from-to", {- name: "SQL",- oldValue: payload.oldStatement,- newValue: payload.newStatement,- });- }- case LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE: {- const payload = JSON.parse(- activity.payload- ) as ActivityTaskEarliestAllowedTimeUpdatePayload;- const oldTs = payload.oldEarliestAllowedTs;- const newTs = payload.newEarliestAllowedTs;-- return t("activity.sentence.changed-from-to", {- name: "earliest allowed time",- oldValue: oldTs- ? dayjs(oldTs * 1000)- : t("task.earliest-allowed-time-unset"),- newValue: newTs- ? dayjs(newTs * 1000)- : t("task.earliest-allowed-time-unset"),- });- }- }-- return "";-};--const clickInbox = (inbox: InboxMessage) => {- if (inbox.status == InboxMessage_Status.STATUS_UNREAD) {- inbox.status = InboxMessage_Status.STATUS_READ;- inboxV1Store.patchInbox(inbox).then(() => {- inboxV1Store.updateInboxSummary({- unread: -1,- unreadError:- inbox.activity?.level === LogEntity_Level.LEVEL_ERROR ? -1 : 0,- });- });- }- const link = actionLink(inbox.activity);- if (!isEmpty(link)) {- router.push(link);- }-};-</script>diff --git a/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue b/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vueindex ff68d6a223..1748074256 100644--- a/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue+++ b/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue@@ -22,7 +22,7 @@</NButton></template></LogFilter>- <div class="relative min-h-[8rem]">+ <div class="relative min-h-[8rem] w-full max-w-full overflow-auto"><LogTable:slow-query-log-list="slowQueryLogList":show-placeholder="!loading"diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.tsindex d60d784826..c87868e9ee 100644--- a/frontend/src/router/dashboard/workspace.ts+++ b/frontend/src/router/dashboard/workspace.ts@@ -70,19 +70,6 @@ const workspaceRoutes: RouteRecordRaw[] = [leftSidebar: true,},},- {- path: "inbox",- name: "workspace.inbox",- meta: { title: () => t("common.inbox") },- components: {- content: () => import("@/views/Inbox.vue"),- leftSidebar: DashboardSidebar,- },- props: {- content: true,- leftSidebar: true,- },- },{path: "slow-query",name: "workspace.slow-query",diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.tsindex 2211c9274d..ed1c24271e 100644--- a/frontend/src/store/modules/v1/database.ts+++ b/frontend/src/store/modules/v1/database.ts@@ -68,7 +68,7 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {}};const fetchDatabaseList = async (args: Partial<ListDatabasesRequest>) => {- const { databases } = await databaseServiceClient.listDatabases(args);+ const { databases } = await databaseServiceClient.searchDatabases(args);const composedDatabaseList = await upsertDatabaseMap(databases);return composedDatabaseList;};diff --git a/frontend/src/store/modules/v1/inbox.ts b/frontend/src/store/modules/v1/inbox.tsdeleted file mode 100644index d0909a7558..0000000000--- a/frontend/src/store/modules/v1/inbox.ts+++ /dev/null@@ -1,76 +0,0 @@-import dayjs from "dayjs";-import utc from "dayjs/plugin/utc";-import { defineStore } from "pinia";-import { reactive } from "vue";-import { inboxServiceClient } from "@/grpcweb";-import { InboxMessage, InboxSummary } from "@/types/proto/v1/inbox_service";--dayjs.extend(utc);--export const useInboxV1Store = defineStore("inbox_v1", () => {- const inboxMessageList = reactive<InboxMessage[]>([]);- const inboxSummary = reactive<InboxSummary>({- unread: 0,- unreadError: 0,- });-- const fetchInboxList = async (readCreatedAfterTs: number) => {- if (inboxMessageList.length > 0) {- return inboxMessageList;- }- const resp = await inboxServiceClient.listInbox({- filter: `create_time >= ${dayjs(readCreatedAfterTs).utc().format()}`,- });-- inboxMessageList.splice(0, inboxMessageList.length);- for (const inbox of resp.inboxMessages) {- inboxMessageList.push(inbox);- }-- return inboxMessageList;- };-- const fetchInboxSummary = async () => {- const summary = await inboxServiceClient.getInboxSummary({});- inboxSummary.unread = summary.unread;- inboxSummary.unreadError = summary.unreadError;- return inboxSummary;- };-- const updateInboxSummary = (summary: InboxSummary) => {- inboxSummary.unread += summary.unread;- inboxSummary.unreadError += summary.unreadError;- return inboxSummary;- };-- const patchInbox = async (inboxMessage: Partial<InboxMessage>) => {- const index = inboxMessageList.findIndex(- (i) => i.name === inboxMessage.name- );- if (index < 0) {- return;- }- const existed = inboxMessageList[index];-- const inbox = await inboxServiceClient.updateInbox({- inboxMessage,- updateMask: ["status"],- });-- inboxMessageList[index] = {- ...inbox,- activity: existed.activity,- };-- return inboxMessageList[index];- };-- return {- inboxSummary,- inboxMessageList,- fetchInboxList,- fetchInboxSummary,- updateInboxSummary,- patchInbox,- };-});diff --git a/frontend/src/store/modules/v1/index.ts b/frontend/src/store/modules/v1/index.tsindex 7c6321c4f1..6faa99f36e 100644--- a/frontend/src/store/modules/v1/index.ts+++ b/frontend/src/store/modules/v1/index.ts@@ -22,7 +22,6 @@ export * from "./vcs";export * from "./changeHistory";export * from "./dbSchema";export * from "./activity";-export * from "./inbox";export * from "./anomaly";export * from "./schemaEditor";export * from "./changelist";diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vueindex a8397d4702..a23d7abd6b 100644--- a/frontend/src/views/DashboardHeader.vue+++ b/frontend/src/views/DashboardHeader.vue@@ -58,13 +58,6 @@<router-link to="/setting/general" exact-active-class=""><Settings class="w-6 h-6" /></router-link>- <router-link to="/inbox" exact-active-class="">- <span- v-if="inboxSummary.unread > 0"- class="absolute rounded-full ml-4 -mt-1 h-2 w-2 bg-accent opacity-75"- ></span>- <heroicons-outline:bell class="w-6 h-6" />- </router-link><div class="ml-2"><ProfileBrandingLogo><ProfileDropdown />@@ -91,17 +84,12 @@ import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";import { useKBarHandler } from "@bytebase/vue-kbar";import { Settings, ChevronDownIcon } from "lucide-vue-next";import { storeToRefs } from "pinia";-import { computed, reactive, watchEffect } from "vue";+import { computed, reactive } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { useCurrentProject } from "@/components/Project/useCurrentProject";-import {- useSubscriptionV1Store,- useInboxV1Store,- useCurrentUserV1,-} from "@/store";+import { useSubscriptionV1Store } from "@/store";import { PlanType } from "@/types/proto/v1/subscription_service";-import { extractUserUID } from "@/utils";import BytebaseLogo from "../components/BytebaseLogo.vue";import ProfileBrandingLogo from "../components/ProfileBrandingLogo.vue";import ProfileDropdown from "../components/ProfileDropdown.vue";@@ -114,7 +102,6 @@ interface LocalState {}const { t } = useI18n();-const inboxV1Store = useInboxV1Store();const subscriptionStore = useSubscriptionV1Store();const router = useRouter();const { locale } = useLanguage();@@ -142,23 +129,8 @@ const onClickSearchButton = () => {handler.value.show();};-const me = useCurrentUserV1();-const { currentPlan } = storeToRefs(subscriptionStore);-const prepareInboxSummary = () => {- // It will also be called when user logout- if (extractUserUID(me.value.name) !== String(UNKNOWN_ID)) {- inboxV1Store.fetchInboxSummary();- }-};--watchEffect(prepareInboxSummary);--const inboxSummary = computed(() => {- return inboxV1Store.inboxSummary;-});-const kbarActions = computed(() => {return [defineAction({@@ -168,13 +140,6 @@ const kbarActions = computed(() => {keywords: "navigation",perform: () => router.push({ name: "setting.workspace.member" }),}),- defineAction({- id: "bb.navigation.global.inbox",- name: "Inbox",- section: t("kbar.navigation"),- keywords: "navigation",- perform: () => router.push({ name: "setting.inbox" }),- }),];});useRegisterActions(kbarActions);diff --git a/frontend/src/views/Inbox.vue b/frontend/src/views/Inbox.vuedeleted file mode 100644index 1c5ec2089a..0000000000--- a/frontend/src/views/Inbox.vue+++ /dev/null@@ -1,120 +0,0 @@-<template>- <div class="space-y-4 py-4">- <div class="mx-6 space-y-2">- <div- class="flex items-center justify-between pb-2 border-b border-block-border"- >- <div class="text-lg leading-6 font-medium text-main">- {{ $t("common.unread") }}- </div>- <NButton @click="markAllAsRead">- <Check class="h-auto w-4 mr-1" />- {{ $t("inbox.mark-all-as-read") }}- </NButton>- </div>- <InboxList :inbox-list="state.unreadList" />- </div>- <div class="mt-6 mx-6 space-y-2">- <div- class="text-lg leading-6 font-medium text-main pb-2 border-b border-block-border"- >- {{ $t("common.read") }}- </div>- <InboxList class="opacity-70" :inbox-list="state.readList" />- <div class="mt-2 flex justify-end">- <NButton quaternary type="primary" @click.prevent="viewOlder">- {{ $t("inbox.view-older") }}- </NButton>- </div>- </div>- </div>-</template>--<script lang="ts" setup>-import { Check } from "lucide-vue-next";-import { NButton } from "naive-ui";-import { reactive, watchEffect } from "vue";-import { useRouter } from "vue-router";-import { useCurrentUser, useInboxV1Store } from "@/store";-import { UNKNOWN_ID } from "@/types";-import {- InboxMessage,- InboxMessage_Status,-} from "@/types/proto/v1/inbox_service";-import InboxList from "../components/InboxList.vue";--// We alway fetch all "UNREAD" items. But for "READ" items, by default, we only fetch the most recent 7 days.-// And each time clicking "View older" will extend 7 days further.-const READ_INBOX_DURATION_STEP = 3600 * 24 * 7;--interface LocalState {- readList: InboxMessage[];- unreadList: InboxMessage[];- readCreatedAfterTs: number;-}--const inboxV1Store = useInboxV1Store();-const router = useRouter();--const state = reactive<LocalState>({- readList: [],- unreadList: [],- readCreatedAfterTs:- parseInt(router.currentRoute.value.query.created as string) ||- Math.ceil(Date.now() / 1000) - READ_INBOX_DURATION_STEP,-});--const currentUser = useCurrentUser();--const prepareInboxList = () => {- // It will also be called when user logout- if (currentUser.value.id != UNKNOWN_ID) {- inboxV1Store.fetchInboxList(state.readCreatedAfterTs).then((list) => {- state.readList = [];- state.unreadList = [];-- for (const item of list) {- if (!item.activity) {- continue;- }- if (item.status == InboxMessage_Status.STATUS_READ) {- state.readList.push(item);- } else if (item.status == InboxMessage_Status.STATUS_UNREAD) {- state.unreadList.push(item);- }- }- });- }-};--watchEffect(prepareInboxList);--const markAllAsRead = async () => {- const list = await Promise.all(- state.unreadList.map(async (item) => {- item.status = InboxMessage_Status.STATUS_READ;- // TODO: use batch instead.- await inboxV1Store.patchInbox(item);- return item;- })- );- state.readList.push(...list);- state.unreadList = [];- await inboxV1Store.fetchInboxSummary();-};--const viewOlder = () => {- state.readCreatedAfterTs -= READ_INBOX_DURATION_STEP;- router- .replace({- name: "workspace.inbox",- query: {- ...router.currentRoute.value.query,- created: state.readCreatedAfterTs,- },- })- .then(() => {- prepareInboxList();- });-};-</script>