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: retire logging service in frontend (#11872)
boojack194f95be8262
diff --git a/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/RollbackStatus.vue b/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/RollbackStatus.vueindex deb7f2b519..8ee959ad2d 100644--- a/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/RollbackStatus.vue+++ b/frontend/src/components/IssueV1/components/Sidebar/RollbackSection/RollbackStatus.vue@@ -18,55 +18,31 @@<templatev-else-if="config?.rollbackSqlStatus === RollbackSqlStatus.DONE">- <template- v-if="taskRollbackBy && rollbackByIssue.uid !== String(UNKNOWN_ID)"+ <NButton+ v-if="allowPreviewRollback"+ size="small"+ @click="tryRollbackTask">- <!--- here we assume that the rollbackBy issue and the original issue- are always in the same project- -->- <router-link- :to="{- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,- params: {- projectId: extractProjectResourceName(issue.project),- issueSlug: taskRollbackBy.rollbackByIssueId,- },- }"- class="text-accent inline-flex gap-x-1"- >- <span>{{ $t("common.issue") }}</span>- <span>#{{ taskRollbackBy.rollbackByIssueId }}</span>- <IssueStatusIcon :issue-status="rollbackByIssue.status" />- </router-link>- </template>- <template v-else>- <NButton- v-if="allowPreviewRollback"- size="small"- @click="tryRollbackTask"- >- {{ $t("task.rollback.preview-rollback-issue") }}- </NButton>- <NTooltip v-else :disabled="!!config?.rollbackSheet">- <template #trigger>- <NButton :disabled="true" size="small" tag="div">- {{ $t("task.rollback.preview-rollback-issue") }}- </NButton>- </template>+ {{ $t("task.rollback.preview-rollback-issue") }}+ </NButton>+ <NTooltip v-else :disabled="!!config?.rollbackSheet">+ <template #trigger>+ <NButton :disabled="true" size="small" tag="div">+ {{ $t("task.rollback.preview-rollback-issue") }}+ </NButton>+ </template>- <div v-if="!config?.rollbackSheet" class="whitespace-pre-line">- {{ $t("task.rollback.empty-rollback-statement") }}- <HideInStandaloneMode>- <LearnMoreLink- url="https://www.bytebase.com/docs/change-database/rollback-data-changes?source=console#why-i-get-the-rollback-sheet-is-empty"- color="light"- class="ml-1"- />- </HideInStandaloneMode>- </div>- </NTooltip>- </template>+ <div v-if="!config?.rollbackSheet" class="whitespace-pre-line">+ {{ $t("task.rollback.empty-rollback-statement") }}+ <HideInStandaloneMode>+ <LearnMoreLink+ url="https://www.bytebase.com/docs/change-database/rollback-data-changes?source=console#why-i-get-the-rollback-sheet-is-empty"+ color="light"+ class="ml-1"+ />+ </HideInStandaloneMode>+ </div>+ </NTooltip></template><template v-else><LoggingButton />@@ -76,21 +52,14 @@</template><script lang="ts" setup>import { NTooltip } from "naive-ui";-import { computed, reactive, ref } from "vue";+import { computed, reactive } from "vue";import { useRouter } from "vue-router";import { databaseForTask, useIssueContext } from "@/components/IssueV1";import LearnMoreLink from "@/components/LearnMoreLink.vue";import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";-import { useActivityV1Store, useSheetV1Store } from "@/store";-import type {- ActivityIssueCommentCreatePayload,- TaskRollbackBy,-} from "@/types";-import { UNKNOWN_ID, unknownIssue } from "@/types";-import { LogEntity_Action } from "@/types/proto/v1/logging_service";+import { useSheetV1Store } from "@/store";import { Task_DatabaseDataUpdate_RollbackSqlStatus as RollbackSqlStatus } from "@/types/proto/v1/rollout_service";import { extractProjectResourceName, extractSheetUID } from "@/utils";-import IssueStatusIcon from "../../IssueStatusIcon.vue";import LogButton from "./LogButton.vue";import LoggingButton from "./LoggingButton.vue";import { useRollbackContext } from "./common";@@ -121,31 +90,6 @@ const allowPreviewRollback = computed(() => {return true;});-const taskRollbackBy = computed((): TaskRollbackBy | undefined => {- const activityList = useActivityV1Store().getActivityListByIssueV1(- issue.value.uid- );- // Find the latest comment activity with TaskRollbackBy struct if possible.- for (let i = activityList.length - 1; i >= 0; i--) {- const activity = activityList[i];- if (activity.action !== LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE)- continue;- const payload = JSON.parse(activity.payload) as- | ActivityIssueCommentCreatePayload- | undefined;- if (!payload) continue;- const taskRollbackBy = payload.taskRollbackBy;- if (!taskRollbackBy) continue;- return taskRollbackBy;- }- return undefined;-});--// const rollbackByIssue = useIssueById(-// computed(() => taskRollbackBy.value?.rollbackByIssueId ?? UNKNOWN_ID)-// );-const rollbackByIssue = ref(unknownIssue()); // TODO-const tryRollbackTask = async () => {// const navigateToRollbackIssue = () => {// if (!state.rollbackIssue) return;diff --git a/frontend/src/grpcweb/index.ts b/frontend/src/grpcweb/index.tsindex ef803bd9aa..de60d99267 100644--- a/frontend/src/grpcweb/index.ts+++ b/frontend/src/grpcweb/index.ts@@ -7,6 +7,7 @@ import {} from "nice-grpc-web";import { ActuatorServiceDefinition } from "@/types/proto/v1/actuator_service";import { AnomalyServiceDefinition } from "@/types/proto/v1/anomaly_service";+import { AuditLogServiceDefinition } from "@/types/proto/v1/audit_log_service";import { AuthServiceDefinition } from "@/types/proto/v1/auth_service";import { BranchServiceDefinition } from "@/types/proto/v1/branch_service";import { CelServiceDefinition } from "@/types/proto/v1/cel_service";@@ -17,7 +18,6 @@ import { IdentityProviderServiceDefinition } from "@/types/proto/v1/idp_service"import { InstanceRoleServiceDefinition } from "@/types/proto/v1/instance_role_service";import { InstanceServiceDefinition } from "@/types/proto/v1/instance_service";import { IssueServiceDefinition } from "@/types/proto/v1/issue_service";-import { LoggingServiceDefinition } from "@/types/proto/v1/logging_service";import { OrgPolicyServiceDefinition } from "@/types/proto/v1/org_policy_service";import { ProjectServiceDefinition } from "@/types/proto/v1/project_service";import { RiskServiceDefinition } from "@/types/proto/v1/risk_service";@@ -34,7 +34,6 @@ import {authInterceptorMiddleware,errorNotificationMiddleware,} from "./middlewares";-import { AuditLogServiceDefinition } from "@/types/proto/v1/audit_log_service";// Create each grpc service client.// Reference: https://github.com/deeplay-io/nice-grpc/blob/master/packages/nice-grpc-web/README.md@@ -175,11 +174,6 @@ export const vcsConnectorServiceClient = clientFactory.create(channel);-export const loggingServiceClient = clientFactory.create(- LoggingServiceDefinition,- channel-);-export const anomalyServiceClient = clientFactory.create(AnomalyServiceDefinition,channeldiff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vueindex b78f448722..0b2fa8676f 100644--- a/frontend/src/layouts/ProjectV1Layout.vue+++ b/frontend/src/layouts/ProjectV1Layout.vue@@ -27,9 +27,7 @@</template><script lang="ts" setup>-import { useLocalStorage } from "@vueuse/core";import { computed, onMounted, watchEffect } from "vue";-import { useI18n } from "vue-i18n";import { useRoute, useRouter } from "vue-router";import ArchiveBanner from "@/components/ArchiveBanner.vue";import { useRecentProjects } from "@/components/Project/useRecentProjects";@@ -40,22 +38,14 @@ import {PROJECT_V1_ROUTE_DATABASE_GROUPS,PROJECT_V1_ROUTE_DEPLOYMENT_CONFIG,} from "@/router/dashboard/projectV1";-import {- useProjectV1Store,- useCurrentUserV1,- useActivityV1Store,- usePageMode,- pushNotification,-} from "@/store";+import { useProjectV1Store, useCurrentUserV1, usePageMode } from "@/store";import { projectNamePrefix } from "@/store/modules/v1/common";import type { QuickActionType } from "@/types";import {DEFAULT_PROJECT_V1_NAME,- activityName,QuickActionProjectPermissionMap,} from "@/types";import { State } from "@/types/proto/v1/common";-import { LogEntity_Action } from "@/types/proto/v1/logging_service";import { TenantMode } from "@/types/proto/v1/project_service";import { hasProjectPermissionV2 } from "@/utils";@@ -67,9 +57,7 @@ const route = useRoute();const router = useRouter();const currentUserV1 = useCurrentUserV1();const projectV1Store = useProjectV1Store();-const activityV1Store = useActivityV1Store();const pageMode = usePageMode();-const { t } = useI18n();const recentProjects = useRecentProjects();const project = computed(() => {@@ -112,51 +100,10 @@ const allowEdit = computed(() => {);});-const cachedNotifiedActivities = useLocalStorage<string[]>(- `bb.project.${props.projectId}.activities`,- []-);--const maximumCachedActivities = 5;-onMounted(async () => {await projectV1Store.getOrFetchProjectByName(`${projectNamePrefix}${props.projectId}`);-- if (- !hasProjectPermissionV2(project.value, currentUserV1.value, "bb.issues.get")- ) {- return;- }- activityV1Store- .fetchActivityList({- pageSize: 1,- order: "desc",- action: [LogEntity_Action.ACTION_PROJECT_REPOSITORY_PUSH],- resource: project.value.name,- })- .then((resp) => {- for (const activity of resp.logEntities) {- if (cachedNotifiedActivities.value.includes(activity.name)) {- continue;- }- cachedNotifiedActivities.value.push(activity.name);- if (cachedNotifiedActivities.value.length > maximumCachedActivities) {- cachedNotifiedActivities.value.shift();- }-- pushNotification({- module: "bytebase",- style: "INFO",- title: activityName(activity.action),- manualHide: true,- link: `/${project.value.name}/audit-logs`,- linkTitle: t("common.view"),- });- break;- }- });});const getQuickActionList = (list: QuickActionType[]): QuickActionType[] => {diff --git a/frontend/src/store/modules/v1/activity.ts b/frontend/src/store/modules/v1/activity.tsdeleted file mode 100644index 93d4c3f72a..0000000000--- a/frontend/src/store/modules/v1/activity.ts+++ /dev/null@@ -1,72 +0,0 @@-import dayjs from "dayjs";-import utc from "dayjs/plugin/utc";-import { defineStore } from "pinia";-import { reactive } from "vue";-import { loggingServiceClient } from "@/grpcweb";-import type { FindActivityMessage } from "@/types";-import type { LogEntity } from "@/types/proto/v1/logging_service";-import {- logEntity_ActionToJSON,- logEntity_LevelToJSON,-} from "@/types/proto/v1/logging_service";-import { userNamePrefix } from "./common";--dayjs.extend(utc);--const buildFilter = (find: FindActivityMessage): string => {- const filter: string[] = [];- if (find.resource) {- filter.push(`resource = "${find.resource}"`);- }- if (find.creatorEmail) {- filter.push(`creator = "${userNamePrefix}${find.creatorEmail}"`);- }- if (find.level) {- filter.push(- `level = "${find.level.map((l) => logEntity_LevelToJSON(l)).join(" | ")}"`- );- }- if (find.action) {- filter.push(- `action = "${find.action- .map((a) => logEntity_ActionToJSON(a))- .join(" | ")}"`- );- }- if (find.createdTsAfter) {- filter.push(- `create_time >= "${dayjs(find.createdTsAfter).utc().format()}"`- );- }- if (find.createdTsBefore) {- filter.push(- `create_time <= "${dayjs(find.createdTsBefore).utc().format()}"`- );- }- return filter.join(" && ");-};--// TODO(steven): migrate to `useAuditLogStore`.-export const useActivityV1Store = defineStore("activity_v1", () => {- const activityListByIssueV1 = reactive(new Map<string, LogEntity[]>());-- const fetchActivityList = async (find: FindActivityMessage) => {- const resp = await loggingServiceClient.searchLogs({- orderBy: find.order ? `create_time ${find.order}` : "",- filter: buildFilter(find),- pageSize: find.pageSize,- pageToken: find.pageToken,- });-- return resp;- };-- const getActivityListByIssueV1 = (uid: string): LogEntity[] => {- return activityListByIssueV1.get(uid) || [];- };-- return {- fetchActivityList,- getActivityListByIssueV1,- };-});diff --git a/frontend/src/store/modules/v1/index.ts b/frontend/src/store/modules/v1/index.tsindex cdd9545e39..e78fb86b08 100644--- a/frontend/src/store/modules/v1/index.ts+++ b/frontend/src/store/modules/v1/index.ts@@ -20,7 +20,6 @@ export * from "./vcs_provider";export * from "./vcs_connector";export * from "./changeHistory";export * from "./dbSchema";-export * from "./activity";export * from "./anomaly";export * from "./schemaEditor";export * from "./changelist";