Skip to content

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

feat(i18n): translate ActivityTable.vue, with a small refactor (#146)

Liu Ji07bfe0b67ce3
diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json
index 2907c0eab1..326b9ea340 100644
--- a/frontend/.vscode/settings.json
+++ b/frontend/.vscode/settings.json
@@ -1,12 +1,18 @@
{
- "i18n-ally.localesPaths": [
- "src/locales"
- ],
- "i18n-ally.enabledParsers": [
- "yaml"
- ],
+ "i18n-ally.localesPaths": ["src/locales"],
+ "i18n-ally.enabledParsers": ["yaml"],
"i18n-ally.keystyle": "nested",
"i18n-ally.sourceLanguage": "en",
"i18n-ally.displayLanguage": "en",
- "i18n-ally.editor.preferEditor": true
-}
\ No newline at end of file
+ "i18n-ally.editor.preferEditor": true,
+ "eslint.validate": [
+ "javascript",
+ "javascriptreact",
+ "typescript",
+ "typescriptreact",
+ "vue"
+ ],
+ "editor.codeActionsOnSave": {
+ "source.fixAll.eslint": true
+ }
+}
diff --git a/frontend/components.d.ts b/frontend/components.d.ts
index 5f00923479..eadbdd0f24 100644
--- a/frontend/components.d.ts
+++ b/frontend/components.d.ts
@@ -3,7 +3,10 @@
declare module 'vue' {
export interface GlobalComponents {
+ 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']
@@ -76,6 +79,7 @@ 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']
@@ -111,13 +115,16 @@ declare module 'vue' {
'HeroiconsSolid:home': typeof import('virtual:vite-icons/heroicons-solid/home')['default']
'HeroiconsSolid:informationCircle': typeof import('virtual:vite-icons/heroicons-solid/information-circle')['default']
'HeroiconsSolid:minus': typeof import('virtual:vite-icons/heroicons-solid/minus')['default']
+ 'HeroiconsSolid:officeBuilding': typeof import('virtual:vite-icons/heroicons-solid/office-building')['default']
'HeroiconsSolid:pencil': typeof import('virtual:vite-icons/heroicons-solid/pencil')['default']
'HeroiconsSolid:plus': typeof import('virtual:vite-icons/heroicons-solid/plus')['default']
'HeroiconsSolid:plusSm': typeof import('virtual:vite-icons/heroicons-solid/plus-sm')['default']
'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']
InboxList: typeof import('./src/components/InboxList.vue')['default']
IndexTable: typeof import('./src/components/IndexTable.vue')['default']
diff --git a/frontend/src/components/ActivityTable.vue b/frontend/src/components/ActivityTable.vue
index b444d15568..ff0a340173 100644
--- a/frontend/src/components/ActivityTable.vue
+++ b/frontend/src/components/ActivityTable.vue
@@ -12,15 +12,7 @@
<div class="flex flew-row space-x-1">
<span
v-if="activity.level != `INFO`"
- class="
- w-5
- h-5
- flex
- items-center
- justify-center
- rounded-full
- select-none
- "
+ class="w-5 h-5 flex items-center justify-center rounded-full select-none"
>
<template v-if="activity.level === `WARN`">
<heroicons-outline:information-circle class="text-warning" />
@@ -30,47 +22,13 @@
</template>
</span>
<span>{{ activityName(activity.type) }}</span>
- <template v-if="activityTypeLink(activity)">
- <a
- v-if="activityTypeLink(activity).external"
- :href="activityTypeLink(activity).path"
- target="_blank"
- class="normal-link flex flex-row items-center"
- >
- <span>{{ activityTypeLink(activity).title }}</span>
- <heroicons-outline:external-link class="w-4 h-4" />
- </a>
- <router-link
- v-else
- class="normal-link"
- :to="activityTypeLink(activity).path"
- >
- {{ activityTypeLink(activity).title }}
- </router-link>
- </template>
+ <ActivityTypeLink :activity="activity" />
</div>
</BBTableCell>
<BBTableCell class="w-96">
<div class="flex flex-row space-x-1">
<span>{{ activity.comment }}</span>
- <template v-if="activityCommentLink(activity)">
- <a
- v-if="activityCommentLink(activity).external"
- :href="activityCommentLink(activity).path"
- target="_blank"
- class="normal-link flex flex-row items-center"
- >
- <span>{{ activityCommentLink(activity).title }}</span>
- <heroicons-outline:external-link class="w-4 h-4" />
- </a>
- <router-link
- v-else
- class="normal-link"
- :to="activityCommentLink(activity).path"
- >
- {{ activityCommentLink(activity).title }}
- </router-link>
- </template>
+ <ActivityCommentLink :activity="activity" />
</div>
</BBTableCell>
<BBTableCell class="w-8">
@@ -87,40 +45,16 @@
</template>
<script lang="ts">
-import { PropType } from "vue";
+import { computed, PropType } from "vue";
+import { useI18n } from "vue-i18n";
import { BBTableColumn } from "../bbkit/types";
-import {
- Activity,
- ActivityProjectRepositoryPushPayload,
- ActivityProjectDatabaseTransferPayload,
- activityName,
-} from "../types";
-import { issueSlug } from "../utils";
-
-type Link = {
- title: string;
- path: string;
- external: boolean;
-};
-
-const COLUMN_LIST: BBTableColumn[] = [
- {
- title: "Name",
- },
- {
- title: "Comment",
- },
- {
- title: "Created",
- },
- {
- title: "Invoker",
- },
-];
+import { Activity, activityName } from "../types";
+import ActivityTypeLink from "./ActivityTable/ActivityTypeLink.vue";
+import ActivityCommentLink from "./ActivityTable/ActivityCommentLink.vue";
export default {
name: "ActivityTable",
- components: {},
+ components: { ActivityTypeLink, ActivityCommentLink },
props: {
activityList: {
required: true,
@@ -128,53 +62,26 @@ export default {
},
},
setup() {
- const activityTypeLink = (activity: Activity): Link | undefined => {
- switch (activity.type) {
- case "bb.project.repository.push": {
- const payload =
- activity.payload as ActivityProjectRepositoryPushPayload;
- return {
- title: payload.pushEvent.fileCommit.id.substring(0, 7),
- path: payload.pushEvent.fileCommit.url,
- external: true,
- };
- }
- case "bb.project.database.transfer": {
- const payload =
- activity.payload as ActivityProjectDatabaseTransferPayload;
- return {
- title: payload.databaseName,
- path: `/db/${payload.databaseId}`,
- external: false,
- };
- }
- }
- return undefined;
- };
+ const { t } = useI18n();
- const activityCommentLink = (activity: Activity): Link | undefined => {
- switch (activity.type) {
- case "bb.project.repository.push": {
- const payload =
- activity.payload as ActivityProjectRepositoryPushPayload;
- if (payload.issueId && payload.issueName) {
- return {
- title: `issue/${payload.issueId}`,
- path: `/issue/${issueSlug(payload.issueName!, payload.issueId!)}`,
- external: false,
- };
- }
- break;
- }
- }
- return undefined;
- };
+ const COLUMN_LIST = computed((): BBTableColumn[] => [
+ {
+ title: t("activity.name"),
+ },
+ {
+ title: t("activity.comment"),
+ },
+ {
+ title: t("activity.created"),
+ },
+ {
+ title: t("activity.invoker"),
+ },
+ ]);
return {
activityName,
COLUMN_LIST,
- activityTypeLink,
- activityCommentLink,
};
},
};
diff --git a/frontend/src/components/ActivityTable/ActivityCommentLink.vue b/frontend/src/components/ActivityTable/ActivityCommentLink.vue
new file mode 100644
index 0000000000..d379ad66e0
--- /dev/null
+++ b/frontend/src/components/ActivityTable/ActivityCommentLink.vue
@@ -0,0 +1,54 @@
+<template>
+ <template v-if="link">
+ <a
+ v-if="link.external"
+ :href="link.path"
+ target="_blank"
+ class="normal-link flex flex-row items-center"
+ >
+ <span>{{ link.title }}</span>
+ <heroicons-outline:external-link class="w-4 h-4" />
+ </a>
+ <router-link v-else class="normal-link" :to="link.path">
+ {{ link.title }}
+ </router-link>
+ </template>
+</template>
+
+<script lang="ts">
+import { computed, defineComponent, PropType } from "vue";
+import { Activity, ActivityProjectRepositoryPushPayload } from "../../types";
+import { issueSlug } from "../../utils/slug";
+import { Link } from "./types";
+
+export default defineComponent({
+ name: "ActivityCommentLink",
+ props: {
+ activity: {
+ type: Object as PropType<Activity>,
+ required: true,
+ },
+ },
+ setup(props) {
+ const link = computed((): Link | undefined => {
+ const { activity } = props;
+ switch (activity.type) {
+ case "bb.project.repository.push": {
+ const payload =
+ activity.payload as ActivityProjectRepositoryPushPayload;
+ if (payload.issueId && payload.issueName) {
+ return {
+ title: `issue/${payload.issueId}`,
+ path: `/issue/${issueSlug(payload.issueName!, payload.issueId!)}`,
+ external: false,
+ };
+ }
+ break;
+ }
+ }
+ return undefined;
+ });
+ return { link };
+ },
+});
+</script>
diff --git a/frontend/src/components/ActivityTable/ActivityTypeLink.vue b/frontend/src/components/ActivityTable/ActivityTypeLink.vue
new file mode 100644
index 0000000000..aa602ad362
--- /dev/null
+++ b/frontend/src/components/ActivityTable/ActivityTypeLink.vue
@@ -0,0 +1,63 @@
+<template>
+ <template v-if="link">
+ <a
+ v-if="link.external"
+ :href="link.path"
+ target="_blank"
+ class="normal-link flex flex-row items-center"
+ >
+ <span>{{ link.title }}</span>
+ <heroicons-outline:external-link class="w-4 h-4" />
+ </a>
+ <router-link v-else class="normal-link" :to="link.path">
+ {{ link.title }}
+ </router-link>
+ </template>
+</template>
+
+<script lang="ts">
+import { computed, defineComponent, PropType } from "vue";
+import {
+ Activity,
+ ActivityProjectRepositoryPushPayload,
+ ActivityProjectDatabaseTransferPayload,
+} from "../../types";
+import { Link } from "./types";
+
+export default defineComponent({
+ name: "ActivityTypeLink",
+ props: {
+ activity: {
+ type: Object as PropType<Activity>,
+ required: true,
+ },
+ },
+ setup(props) {
+ const link = computed((): Link | undefined => {
+ const { activity } = props;
+ switch (activity.type) {
+ case "bb.project.repository.push": {
+ const payload =
+ activity.payload as ActivityProjectRepositoryPushPayload;
+ return {
+ title: payload.pushEvent.fileCommit.id.substring(0, 7),
+ path: payload.pushEvent.fileCommit.url,
+ external: true,
+ };
+ }
+ case "bb.project.database.transfer": {
+ const payload =
+ activity.payload as ActivityProjectDatabaseTransferPayload;
+ return {
+ title: payload.databaseName,
+ path: `/db/${payload.databaseId}`,
+ external: false,
+ };
+ }
+ }
+ return undefined;
+ });
+ return { link };
+ },
+});
+</script>
diff --git a/frontend/src/components/ActivityTable/types.ts b/frontend/src/components/ActivityTable/types.ts
new file mode 100644
index 0000000000..4e087debbf
--- /dev/null
+++ b/frontend/src/components/ActivityTable/types.ts
@@ -0,0 +1,5 @@
+export type Link = {
+ title: string;
+ path: string;
+ external: boolean;
+};
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index 36dab29dbe..ceb623f764 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -27,3 +27,8 @@ kbar:
preferences:
common: Preferences
change-language: Change Language…
+activity:
+ name: Name
+ comment: Comment
+ created: Created
+ invoker: Invoker
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index 676c98156b..18d9d5939a 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -27,3 +27,8 @@ kbar:
preferences:
common: 偏好设置
change-language: 更改语言…
+activity:
+ name: 名称
+ comment: 注释
+ created: 创建于
+ invoker: 执行者