Skip to content

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

feat(frontend): i18n for Anomaly Center module (#182)

Yunwei Xiao02d00f50f57b
diff --git a/frontend/components.d.ts b/frontend/components.d.ts
index 4cc9e52f34..143a566168 100644
--- a/frontend/components.d.ts
+++ b/frontend/components.d.ts
@@ -6,7 +6,6 @@ declare module 'vue' {
ActivityCommentLink: typeof import('./src/components/ActivityTable/ActivityCommentLink.vue')['default']
ActivityTable: typeof import('./src/components/ActivityTable.vue')['default']
ActivityTypeLink: typeof import('./src/components/ActivityTable/ActivityTypeLink.vue')['default']
- 'ActivityTypeLink copy': typeof import('./src/components/ActivityTable/ActivityTypeLink copy.vue')['default']
AlterSchemaPrepForm: typeof import('./src/components/AlterSchemaPrepForm.vue')['default']
AnomalyTable: typeof import('./src/components/AnomalyTable.vue')['default']
ArchiveBanner: typeof import('./src/components/ArchiveBanner.vue')['default']
@@ -19,6 +18,7 @@ declare module 'vue' {
BBCheckbox: typeof import('./src/bbkit/BBCheckbox.vue')['default']
BBContextMenu: typeof import('./src/bbkit/BBContextMenu.vue')['default']
BBModal: typeof import('./src/bbkit/BBModal.vue')['default']
+ BBModalStack: typeof import('./src/bbkit/BBModalStack.vue')['default']
BBNotification: typeof import('./src/bbkit/BBNotification.vue')['default']
BBOutline: typeof import('./src/bbkit/BBOutline.vue')['default']
BBSelect: typeof import('./src/bbkit/BBSelect.vue')['default']
@@ -79,7 +79,6 @@ declare module 'vue' {
'HeroiconsOutline:inbox': typeof import('virtual:vite-icons/heroicons-outline/inbox')['default']
'HeroiconsOutline:informationCircle': typeof import('virtual:vite-icons/heroicons-outline/information-circle')['default']
'HeroiconsOutline:lightningBolt': typeof import('virtual:vite-icons/heroicons-outline/lightning-bolt')['default']
- 'HeroiconsOutline:mail': typeof import('virtual:vite-icons/heroicons-outline/mail')['default']
'HeroiconsOutline:menu': typeof import('virtual:vite-icons/heroicons-outline/menu')['default']
'HeroiconsOutline:minus': typeof import('virtual:vite-icons/heroicons-outline/minus')['default']
'HeroiconsOutline:minusCircle': typeof import('virtual:vite-icons/heroicons-outline/minus-circle')['default']
@@ -123,7 +122,6 @@ declare module 'vue' {
'HeroiconsSolid:save': typeof import('virtual:vite-icons/heroicons-solid/save')['default']
'HeroiconsSolid:search': typeof import('virtual:vite-icons/heroicons-solid/search')['default']
'HeroiconsSolid:selector': typeof import('virtual:vite-icons/heroicons-solid/selector')['default']
- 'HeroiconsSolid:sparkles': typeof import('virtual:vite-icons/heroicons-solid/sparkles')['default']
'HeroiconsSolid:star': typeof import('virtual:vite-icons/heroicons-solid/star')['default']
'HeroiconsSolid:userCircle': typeof import('virtual:vite-icons/heroicons-solid/user-circle')['default']
'HeroiconsSolid:x': typeof import('virtual:vite-icons/heroicons-solid/x')['default']
diff --git a/frontend/src/components/AnomalyTable.vue b/frontend/src/components/AnomalyTable.vue
index 4a32f46372..0f9ed58e50 100644
--- a/frontend/src/components/AnomalyTable.vue
+++ b/frontend/src/components/AnomalyTable.vue
@@ -65,7 +65,7 @@
/>
<div class="flex justify-end px-4">
<button type="button" class="btn-primary" @click.prevent="dismissModal">
- Close
+ {{ $t("common.close") }}
</button>
</div>
</div>
@@ -74,7 +74,11 @@
<script lang="ts">
import { PropType, reactive } from "vue";
+import { useRouter } from "vue-router";
import { CodeDiff } from "v-code-diff";
+import { useStore } from "vuex";
+import { useI18n } from "vue-i18n";
+
import { BBTableColumn, BBTableSectionDataSource } from "../bbkit/types";
import {
Anomaly,
@@ -85,27 +89,7 @@ import {
AnomalyInstanceConnectionPayload,
AnomalyType,
} from "../types";
-import { useStore } from "vuex";
import { databaseSlug, humanizeTs, instanceSlug } from "../utils";
-import { useRouter } from "vue-router";
-
-const COLUMN_LIST: BBTableColumn[] = [
- {
- title: "",
- },
- {
- title: "Type",
- },
- {
- title: "Detail",
- },
- {
- title: "Last seen",
- },
- {
- title: "First seen",
- },
-];
type Action = {
onClick: () => void;
@@ -133,25 +117,44 @@ export default {
setup() {
const store = useStore();
const router = useRouter();
+ const { t } = useI18n();
const state = reactive<LocalState>({
showModal: false,
});
+ const COLUMN_LIST: BBTableColumn[] = reactive([
+ {
+ title: "",
+ },
+ {
+ title: t("common.type"),
+ },
+ {
+ title: t("common.detail"),
+ },
+ {
+ title: t("anomaly.last-seen"),
+ },
+ {
+ title: t("anomaly.first-seen"),
+ },
+ ]);
+
const typeName = (type: AnomalyType): string => {
switch (type) {
case "bb.anomaly.instance.connection":
- return "Connection failure";
+ return t("anomaly.types.connection-failure");
case "bb.anomaly.instance.migration-schema":
- return "Missing migration schema";
+ return t("anomaly.types.missing-migration-schema");
case "bb.anomaly.database.backup.policy-violation":
- return "Backup enforcement violation";
+ return t("anomaly.types.backup-enforcement-viloation");
case "bb.anomaly.database.backup.missing":
- return "Missing backup";
+ return t("anomaly.types.missing-backup");
case "bb.anomaly.database.connection":
- return "Connection failure";
+ return t("anomaly.types.connection-failure");
case "bb.anomaly.database.schema.drift":
- return "Schema drift";
+ return "t('anomaly.types.schema-drift')";
}
};
@@ -207,7 +210,7 @@ export default {
},
});
},
- title: "Check instance",
+ title: t("anomaly.action.check-instance"),
};
case "bb.anomaly.instance.migration-schema":
return {
@@ -219,7 +222,7 @@ export default {
},
});
},
- title: "Check instance",
+ title: t("anomaly.action.check-instance"),
};
case "bb.anomaly.database.backup.policy-violation": {
return {
@@ -232,7 +235,7 @@ export default {
hash: "#backup",
});
},
- title: "Configure backup",
+ title: t("anomaly.action.configure-backup"),
};
}
case "bb.anomaly.database.backup.missing":
@@ -246,7 +249,7 @@ export default {
hash: "#backup",
});
},
- title: "View backup",
+ title: t("anomaly.action.view-backup"),
};
case "bb.anomaly.database.connection":
return {
@@ -258,7 +261,7 @@ export default {
},
});
},
- title: "Check instance",
+ title: t("anomaly.action.check-instance"),
};
case "bb.anomaly.database.schema.drift":
return {
@@ -266,7 +269,7 @@ export default {
state.selectedAnomaly = anomaly;
state.showModal = true;
},
- title: "View diff",
+ title: t("anomaly.action.view-diff"),
};
}
};
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index 268e3571df..b88b0469a2 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -68,7 +68,7 @@ common:
updated-at: Updated
commit: Commit
statement: Statement
- sql-statement: "SQL statement"
+ sql-statement: SQL statement
snapshot: Snapshot
status: Status
stage: Stage
@@ -78,6 +78,8 @@ common:
add: Add
query: Query
transfer: Transfer
+ detail: Detail
+ type: Type
language: Language
repository: Repository
change: Change
@@ -207,20 +209,20 @@ activity:
created: Created
invoker: Invoker
sentence:
- created-issue: "created issue"
+ created-issue: created issue
commented: commented
- reassigned-issue: "reassigned issue from {oldName} to {newName}"
- assigned-issue: "assigned issue to {newName}"
- unassigned-issue: "unassigned issue from {oldName}"
- invalid-assignee-update: "invalid assignee update"
- changed-description: "changed description"
- changed-from-to: 'changed {name} from "{oldValue}" to "{newValue}"'
- unset-from: 'unset {name} from "{oldValue}"'
- set-to: 'set {name} to "{newValue}"'
- changed-update: "changed {name} update"
- reopened-issue: "reopened issue"
- resolved-issue: "resolved issue"
- canceled-issue: "canceled issue"
+ reassigned-issue: reassigned issue from {oldName} to {newName}
+ assigned-issue: assigned issue to {newName}
+ unassigned-issue: unassigned issue from {oldName}
+ invalid-assignee-update: invalid assignee update
+ changed-description: changed description
+ changed-from-to: changed {name} from "{oldValue}" to "{newValue}"
+ unset-from: unset {name} from "{oldValue}"
+ set-to: set {name} to "{newValue}"
+ changed-update: changed {name} update
+ reopened-issue: reopened issue
+ resolved-issue: resolved issue
+ canceled-issue: canceled issue
empty: ""
changed: changed
updated: updated
@@ -230,9 +232,9 @@ activity:
completed: completed
failed: failed
task-name: " task {name}"
- committed-to-at: "committed {file} to{branch}{'@'}{repo}"
+ committed-to-at: committed {file} to{branch}{'@'}{repo}
subject-prefix:
- task: "Task"
+ task: Task
issue:
waiting-approval: Waiting Approval
opened-by-at: opened by {creator} at {time}
@@ -252,16 +254,16 @@ issue:
subscribe: Subscribe
unsubscribe: Unsubscribe
subscriber: No subscribers | 1 subscriber | {n} subscribers
- apply-to-other-stages: "Apply to other stages"
- add-sql-statement: "Add SQL statement..."
- optional-add-sql-statement: "(Optional) Add SQL statement..."
- rollback-sql: "Rollback SQL"
- add-rollback-sql-statement: "Add rollback SQL statement..."
- edit-description: "Edit description"
- add-some-description: "Add some description..."
- add-a-comment: "Add a comment"
+ apply-to-other-stages: Apply to other stages
+ add-sql-statement: Add SQL statement...
+ optional-add-sql-statement: (Optional) Add SQL statement...
+ rollback-sql: Rollback SQL
+ add-rollback-sql-statement: Add rollback SQL statement...
+ edit-description: Edit description
+ add-some-description: Add some description...
+ add-a-comment: Add a comment
edit-comment: Edit comment
- leave-a-comment: "Leave a comment..."
+ leave-a-comment: Leave a comment...
view-commit: View commit
search-issue-name: Search issue name
table:
@@ -315,8 +317,7 @@ quick-action:
transfer-in-db-hint: >-
Bytebase periodically syncs the instance schema. Newly synced databases are
first placed in this default project.
- transfer-in-db-alert: >-
- Are you sure to transfer "{ dbName }" into our project?
+ transfer-in-db-alert: Are you sure to transfer "{ dbName }" into our project?
create-db:
new-database-name: New database name
reserved-db-error: "{databaseName} is a reserved name"
@@ -499,3 +500,26 @@ workflow:
configure-gitops: Configure version control
configure-gitops-success: Successfully enabled GitOps workflow for {project}
change-gitops-success: Successfully changed repository for {project}
+anomaly:
+ attention-title: Anomaly detection
+ attention-desc: >-
+ Bytebase periodically scans the managed resources and list the detected
+ anomalies here. The list is refreshed roughly every 10 minutes.
+ table-search-placeholder: Search {type} or environment
+ table-placeholder: Hooray, no {type} anomaly detected!
+ tooltip: >-
+ {env} has {criticalCount} CRITICAL, {highCount} HIGH and {mediumCount}
+ MEDIUM anomalies
+ types:
+ connection-failure: Connection failure
+ missing-migration-schema: Missing migration schema
+ backup-enforcement-viloation: Backup enforcement violation
+ missing-backup: Missing backup
+ schema-drift: Schema drift
+ action:
+ check-instance: Check instance
+ view-backup: View backup
+ configure-backup: Configure backup
+ view-diff: View diff
+ last-seen: Last seen
+ first-seen: First seen
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index 087ed48389..d4847498fb 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -68,7 +68,7 @@ common:
updated-at: 更新于
commit: 提交
statement: 语句
- sql-statement: "SQL @:{'common.statement'}"
+ sql-statement: SQL @:{'common.statement'}
snapshot: 快照
status: 状态
stage: 阶段
@@ -78,6 +78,8 @@ common:
add: 添加
query: 查询
transfer: 转移
+ detail: 详情
+ type: 类型
language: 语言
repository: 仓库
change: 变更
@@ -203,20 +205,20 @@ activity:
created: 创建于
invoker: 执行者
sentence:
- created-issue: "创建工单"
+ created-issue: 创建工单
commented: 评论
- reassigned-issue: "将工单由 {oldName} 重新指派给 {newName}"
- assigned-issue: "将工单指派给 {newName}"
- unassigned-issue: "将工单由 {oldName} 解除指派"
- invalid-assignee-update: "无效的指派操作"
- changed-description: "修改描述"
- changed-from-to: '将 {name} 从 "{oldValue}" 修改为 "{newValue}"'
- unset-from: '撤销 {name} 的值 (从 "{oldValue}")'
- set-to: '将 {name} 设置为 "{newValue}"'
- changed-update: "修改 {name}"
- reopened-issue: "重开工单"
- resolved-issue: "解决工单"
- canceled-issue: "取消工单"
+ reassigned-issue: 将工单由 {oldName} 重新指派给 {newName}
+ assigned-issue: 将工单指派给 {newName}
+ unassigned-issue: 将工单由 {oldName} 解除指派
+ invalid-assignee-update: 无效的指派操作
+ changed-description: 修改描述
+ changed-from-to: 将 {name} 从 "{oldValue}" 修改为 "{newValue}"
+ unset-from: 撤销 {name} 的值 (从 "{oldValue}")
+ set-to: 将 {name} 设置为 "{newValue}"
+ changed-update: 修改 {name}
+ reopened-issue: 重开工单
+ resolved-issue: 解决工单
+ canceled-issue: 取消工单
empty: ""
changed: 修改
updated: 更新
@@ -225,10 +227,10 @@ activity:
started: 开始
completed: 完成
failed: 失败
- task-name: "任务 {name}"
- committed-to-at: "提交 {file} 到 {branch}{'@'}{repo}"
+ task-name: 任务 {name}
+ committed-to-at: 提交 {file} 到 {branch}{'@'}{repo}
subject-prefix:
- task: "任务"
+ task: 任务
issue:
waiting-approval: 等待批准
opened-by-at: "{id} 由 {creator} 开启于 {time}"
@@ -249,10 +251,10 @@ issue:
unsubscribe: 取消订阅
subscriber: 没有订阅者 | 1 个订阅者 | {n} 个订阅者
apply-to-other-stages: "@:{'common.apply'}到其他@:{'common.stage'}"
- add-sql-statement: "添加 SQL @:{'common.statement'}…"
- optional-add-sql-statement: "(可选)添加 SQL @:{'common.statement'}…"
+ add-sql-statement: 添加 SQL @:{'common.statement'}…
+ optional-add-sql-statement: (可选)添加 SQL @:{'common.statement'}…
rollback-sql: "@:{'common.rollback'} SQL"
- add-rollback-sql-statement: "添加 @:{'common.rollback'} SQL @:{'common.statement'}…"
+ add-rollback-sql-statement: 添加 @:{'common.rollback'} SQL @:{'common.statement'}…
edit-description: 编辑描述
add-some-description: 添加一些描述…
add-a-comment: 添加评论
@@ -444,3 +446,24 @@ workflow:
configure-gitops: 配置 Git
configure-gitops-success: 开启「{project}」GitOps 工作流成功
change-gitops-success: 变更「{project}」仓库成功
+anomaly:
+ attention-title: 异常检测
+ attention-desc: |-
+ Bytebase 会定期扫描托管资源并在这里列出检测到的异常。
+ 该列表大约每 10 分钟刷新一次。
+ table-search-placeholder: 搜索{type}或者环境
+ table-placeholder: 很棒,没有检测到{type}异常!
+ tooltip: "{env} 环境有 {criticalCount} 个严重异常, {highCount} 个高等级异常和 {mediumCount} 个中等级异常"
+ types:
+ connection-failure: 连接失败
+ missing-migration-schema: 缺少迁移 Schema
+ schema-drift: Schema 偏差
+ backup-enforcement-viloation: 违反备份策略约束
+ missing-backup: 缺少备份
+ action:
+ check-instance: 检查实例
+ view-backup: 查看备份
+ configure-backup: 配置备份
+ view-diff: 查看差异
+ last-seen: 上次出现
+ first-seen: 首次出现
diff --git a/frontend/src/views/AnomalyCenterDashboard.vue b/frontend/src/views/AnomalyCenterDashboard.vue
index 0a0c20f105..7bf5f60d84 100644
--- a/frontend/src/views/AnomalyCenterDashboard.vue
+++ b/frontend/src/views/AnomalyCenterDashboard.vue
@@ -2,8 +2,8 @@
<div class="flex flex-col px-4 pb-4">
<BBAttention
:style="'INFO'"
- :title="'Anomaly detection'"
- :description="'Bytebase periodically scans the managed resources and list the detected anomalies here. The list is refreshed roughly every 10 minutes.'"
+ :title="$t('anomaly.attention-title')"
+ :description="$t('anomaly.attention-desc')"
/>
<!-- This example requires Tailwind CSS v2.0+ -->
<div class="mt-4 space-y-4">
@@ -16,7 +16,7 @@
class="space-y-2"
>
<h3 class="text-lg leading-6 font-medium text-main">
- {{ i == 0 ? "Database" : "Instance" }}
+ {{ i == 0 ? $t("common.database") : $t("common.instance") }}
</h3>
<dl
class="grid grid-cols-1 gap-5 sm:grid-cols-2"
@@ -24,12 +24,16 @@
>
<template v-for="(summary, index) in item" :key="index">
<div class="p-4 shadow rounded-lg tooltip-wrapper">
- <span class="text-sm tooltip"
- >{{ summary.environmentName }} has
- {{ summary.criticalCount }} CRITICAL,
- {{ summary.highCount }} HIGH and
- {{ summary.mediumCount }} MEDIUM anomalies</span
- >
+ <span class="text-sm tooltip">
+ {{
+ $t("anomaly.tooltip", {
+ env: summary.environmentName,
+ criticalCount: summary.criticalCount,
+ highCount: summary.highCount,
+ mediumCount: summary.mediumCount,
+ })
+ }}
+ </span>
<dt class="textlabel">
{{ summary.environmentName }}
</dt>
@@ -73,9 +77,12 @@
ref="searchField"
class="w-72"
:placeholder="
- state.selectedIndex == DATABASE_TAB
- ? 'Search database or environment'
- : 'Search instance or environment'
+ $t('anomaly.table-search-placeholder', {
+ type:
+ state.selectedIndex == DATABASE_TAB
+ ? $t('common.database')
+ : $t('common.instance'),
+ })
"
@change-text="(text) => changeSearchText(text)"
/>
@@ -87,7 +94,11 @@
:compact-section="false"
/>
<div v-else class="text-center text-control-light">
- Hooray, no database anomaly detected!
+ {{
+ $t("anomaly.table-placeholder", {
+ type: $t("common.database"),
+ })
+ }}
</div>
</template>
<template v-else>
@@ -97,15 +108,21 @@
:compact-section="false"
/>
<div v-else class="text-center text-control-light">
- Hooray, no instance anomaly detected!
+ {{
+ $t("anomaly.table-placeholder", {
+ type: $t("common.instance"),
+ })
+ }}
</div>
</template>
</div>
</template>
<script lang="ts">
-import { computed, reactive, watchEffect } from "vue-demi";
+import { computed, reactive, watchEffect } from "vue";
import { useStore } from "vuex";
+import { useI18n } from "vue-i18n";
+
import AnomalyTable from "../components/AnomalyTable.vue";
import { Anomaly, Database, EnvironmentId } from "../types";
import {
@@ -138,6 +155,7 @@ export default {
components: { AnomalyTable },
setup() {
const store = useStore();
+ const { t } = useI18n();
const currentUser = computed(() => store.getters["auth/currentUser"]());
@@ -338,11 +356,11 @@ export default {
const tabItemList = computed((): BBTabFilterItem[] => {
return [
{
- title: "Database",
+ title: t("common.database"),
alert: databaseAnomalySectionList.value.length > 0,
},
{
- title: "Instance",
+ title: t("common.instance"),
alert: instanceAnomalySectionList.value.length > 0,
},
];