Skip to content

Commit c7ee6d6

Browse files
committed
feat(ui): i18n for Dashboard (Phase 1)
1 parent 77fee50 commit c7ee6d6

12 files changed

Lines changed: 151 additions & 108 deletions

File tree

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
{
22
"welcome": "Welcome",
3-
"stats": "Stats",
4-
"failedDags": "Failed DAGs",
5-
"runningDags": "Running DAGs",
6-
"activeDags": "Active DAGs",
7-
"health": "Health",
3+
"stats": {
4+
"stats": "Stats",
5+
"failedDags": "Failed DAGs",
6+
"runningDags": "Running DAGs",
7+
"activeDags": "Active DAGs"
8+
},
9+
"health": {
10+
"health": "Health",
11+
"metaDatabase": "MetaDatabase",
12+
"scheduler": "Scheduler",
13+
"triggerer": "Triggerer",
14+
"dagProcessor": "Dag Processor"
15+
},
816
"poolSlots": "Pool Slots",
917
"managePools": "Manage Pools",
10-
"history": "History",
11-
"dagRuns": "DAG Runs",
12-
"queued": "Queued",
13-
"running": "Running",
14-
"success": "Success",
15-
"failed": "Failed",
16-
"taskInstances": "Task Instances",
17-
"upstreamFailed": "Upstream Failed",
18+
"history": {
19+
"history": "History",
20+
"dagRuns": "DAG Runs",
21+
"queued": "Queued",
22+
"running": "Running",
23+
"success": "Success",
24+
"failed": "Failed",
25+
"taskInstances": "Task Instances",
26+
"upstreamFailed": "Upstream Failed"
27+
},
1828
"assetEvents": "Asset Events",
1929
"noAssetEvents": "No Asset Events found."
2030
}

airflow-core/src/airflow/ui/src/i18n/locales/zh_TW/common.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"home": "首頁",
1616
"assets": "資產",
1717
"browse": "瀏覽",
18-
"admin": "管理",
19-
"docs": "文檔"
18+
"admin": "管理者",
19+
"docs": "文件"
2020
}
2121
}
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
{
22
"welcome": "歡迎",
3-
"stats": "統計",
4-
"failedDags": "失敗的 DAG",
5-
"runningDags": "執行中的 DAG",
6-
"activeDags": "活躍的 DAG",
7-
"health": "健康狀態",
3+
"stats": {
4+
"stats": "統計",
5+
"failedDags": "失敗的 DAGs",
6+
"runningDags": "執行中的 DAGs",
7+
"activeDags": "活躍的 DAGs"
8+
},
9+
"health": {
10+
"health": "健康狀態",
11+
"metaDatabase": "元資料庫",
12+
"scheduler": "排程器",
13+
"triggerer": "觸發器",
14+
"dagProcessor": "DAG 處理器"
15+
},
816
"poolSlots": "資源池配額",
917
"managePools": "管理資源池",
10-
"history": "歷史記錄",
11-
"dagRuns": "DAG 執行",
12-
"queued": "等待中",
13-
"running": "執行中",
14-
"success": "成功",
15-
"failed": "失敗",
16-
"taskInstances": "任務實例",
17-
"upstreamFailed": "上游失敗",
18+
"history": {
19+
"history": "歷史記錄",
20+
"dagRuns": "DAG 執行",
21+
"queued": "等待中",
22+
"running": "執行中",
23+
"success": "成功",
24+
"failed": "失敗",
25+
"taskInstances": "任務實例",
26+
"upstreamFailed": "上游失敗"
27+
},
1828
"assetEvents": "資產事件",
19-
"noAssetEvents": "未找到資產事件"
29+
"noAssetEvents": "未找到資產事件"
2030
}

airflow-core/src/airflow/ui/src/layouts/Nav/Nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const Nav = () => {
6161
<NavButton
6262
disabled={!authLinks?.authorized_menu_items.includes("Dags")}
6363
icon={<DagIcon height="1.75rem" width="1.75rem" />}
64-
title="dags"
64+
title="DAGs"
6565
to="dags"
6666
/>
6767
<NavButton

airflow-core/src/airflow/ui/src/pages/Dashboard/Dashboard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919
import { Box, Heading, VStack } from "@chakra-ui/react";
20+
import { useTranslation } from "react-i18next";
2021

2122
import type { UIAlert } from "openapi/requests/types.gen";
2223
import ReactMarkdown from "src/components/ReactMarkdown";
@@ -30,6 +31,7 @@ import { Stats } from "./Stats";
3031

3132
export const Dashboard = () => {
3233
const alerts = useConfig("dashboard_alert") as Array<UIAlert>;
34+
const { t: translate } = useTranslation("dashboard");
3335

3436
return (
3537
<Box overflow="auto" px={4}>
@@ -56,7 +58,7 @@ export const Dashboard = () => {
5658
</Accordion.Root>
5759
) : undefined}
5860
<Heading mb={2} size="2xl">
59-
Welcome
61+
{translate("welcome")}
6062
</Heading>
6163
</VStack>
6264
<Box>

airflow-core/src/airflow/ui/src/pages/Dashboard/Health/Health.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919
import { Box, Flex, Heading, HStack } from "@chakra-ui/react";
20+
import { useTranslation } from "react-i18next";
2021
import { MdOutlineHealthAndSafety } from "react-icons/md";
2122

2223
import { useMonitorServiceGetHealth } from "openapi/queries";
@@ -31,36 +32,41 @@ export const Health = () => {
3132
const { data, error, isLoading } = useMonitorServiceGetHealth(undefined, {
3233
refetchInterval,
3334
});
35+
const { t: translate } = useTranslation("dashboard");
3436

3537
return (
3638
<Box>
3739
<Flex color="fg.muted" mb={2}>
3840
<MdOutlineHealthAndSafety />
3941
<Heading ml={1} size="xs">
40-
Health
42+
{translate("health.health")}
4143
</Heading>
4244
</Flex>
4345
<ErrorAlert error={error} />
4446
<HStack alignItems="center" gap={2}>
45-
<HealthBadge isLoading={isLoading} status={data?.metadatabase.status} title="MetaDatabase" />
47+
<HealthBadge
48+
isLoading={isLoading}
49+
status={data?.metadatabase.status}
50+
title={translate("health.metaDatabase")}
51+
/>
4652
<HealthBadge
4753
isLoading={isLoading}
4854
latestHeartbeat={data?.scheduler.latest_scheduler_heartbeat}
4955
status={data?.scheduler.status}
50-
title="Scheduler"
56+
title={translate("health.scheduler")}
5157
/>
5258
<HealthBadge
5359
isLoading={isLoading}
5460
latestHeartbeat={data?.triggerer.latest_triggerer_heartbeat}
5561
status={data?.triggerer.status}
56-
title="Triggerer"
62+
title={translate("health.triggerer")}
5763
/>
5864
{data?.dag_processor ? (
5965
<HealthBadge
6066
isLoading={isLoading}
6167
latestHeartbeat={data.dag_processor.latest_dag_processor_heartbeat}
6268
status={data.dag_processor.status}
63-
title="Dag Processor"
69+
title={translate("health.dagProcessor")}
6470
/>
6571
) : undefined}
6672
</HStack>

airflow-core/src/airflow/ui/src/pages/Dashboard/HistoricalMetrics/DagRunMetrics.tsx

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { Box, Separator, Heading, HStack, Stack } from "@chakra-ui/react";
2020
import type { DAGRunStates } from "openapi-gen/requests/types.gen";
21+
import { useTranslation } from "react-i18next";
2122
import { FiBarChart } from "react-icons/fi";
2223
import { Link as RouterLink } from "react-router-dom";
2324

@@ -34,32 +35,36 @@ type DagRunMetricsProps = {
3435

3536
const DAGRUN_STATES: Array<keyof DAGRunStates> = ["queued", "running", "success", "failed"];
3637

37-
export const DagRunMetrics = ({ dagRunStates, endDate, startDate, total }: DagRunMetricsProps) => (
38-
<Box borderRadius={5} borderWidth={1} p={4}>
39-
<HStack>
40-
<RouterLink
41-
to={`/dag_runs?start_date=${startDate}${endDate === undefined ? "" : `&end_date=${endDate}`}`}
42-
>
43-
<StateBadge colorPalette="blue" fontSize="md" variant="solid">
44-
<FiBarChart />
45-
{total}
46-
</StateBadge>
47-
</RouterLink>
48-
<Heading size="md">Dag Runs</Heading>
49-
</HStack>
50-
<Separator my={3} />
51-
<Stack gap={4}>
52-
{DAGRUN_STATES.map((state) => (
53-
<MetricSection
54-
endDate={endDate}
55-
key={state}
56-
kind="dag_runs"
57-
runs={dagRunStates[state]}
58-
startDate={startDate}
59-
state={state}
60-
total={total}
61-
/>
62-
))}
63-
</Stack>
64-
</Box>
65-
);
38+
export const DagRunMetrics = ({ dagRunStates, endDate, startDate, total }: DagRunMetricsProps) => {
39+
const { t: translate } = useTranslation("dashboard");
40+
41+
return (
42+
<Box borderRadius={5} borderWidth={1} p={4}>
43+
<HStack>
44+
<RouterLink
45+
to={`/dag_runs?start_date=${startDate}${endDate === undefined ? "" : `&end_date=${endDate}`}`}
46+
>
47+
<StateBadge colorPalette="blue" fontSize="md" variant="solid">
48+
<FiBarChart />
49+
{total}
50+
</StateBadge>
51+
</RouterLink>
52+
<Heading size="md">{translate("history.dagRuns")}</Heading>
53+
</HStack>
54+
<Separator my={3} />
55+
<Stack gap={4}>
56+
{DAGRUN_STATES.map((state) => (
57+
<MetricSection
58+
endDate={endDate}
59+
key={state}
60+
kind="dag_runs"
61+
runs={dagRunStates[state]}
62+
startDate={startDate}
63+
state={state}
64+
total={total}
65+
/>
66+
))}
67+
</Stack>
68+
</Box>
69+
);
70+
};

airflow-core/src/airflow/ui/src/pages/Dashboard/HistoricalMetrics/HistoricalMetrics.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import { Box, VStack, SimpleGrid, GridItem, Flex, Heading } from "@chakra-ui/react";
2020
import dayjs from "dayjs";
2121
import { useState } from "react";
22+
import { useTranslation } from "react-i18next";
2223
import { PiBooks } from "react-icons/pi";
2324

2425
import { useAssetServiceGetAssetEvents, useDashboardServiceHistoricalMetrics } from "openapi/queries";
@@ -34,6 +35,7 @@ import { TaskInstanceMetrics } from "./TaskInstanceMetrics";
3435
const defaultHour = "24";
3536

3637
export const HistoricalMetrics = () => {
38+
const { t: translate } = useTranslation("dashboard");
3739
const now = dayjs();
3840
const [startDate, setStartDate] = useState(now.subtract(Number(defaultHour), "hour").toISOString());
3941
const [endDate, setEndDate] = useState(now.toISOString());
@@ -71,7 +73,7 @@ export const HistoricalMetrics = () => {
7173
<Flex color="fg.muted" my={2}>
7274
<PiBooks />
7375
<Heading ml={1} size="xs">
74-
History
76+
{translate("history.history")}
7577
</Heading>
7678
</Flex>
7779
<ErrorAlert error={error} />

airflow-core/src/airflow/ui/src/pages/Dashboard/HistoricalMetrics/TaskInstanceMetrics.tsx

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { Box, Separator, Heading, HStack, Stack } from "@chakra-ui/react";
2020
import type { TaskInstanceState, TaskInstanceStateCount } from "openapi-gen/requests/types.gen";
21+
import { useTranslation } from "react-i18next";
2122
import { MdOutlineTask } from "react-icons/md";
2223
import { Link as RouterLink } from "react-router-dom";
2324

@@ -53,36 +54,40 @@ export const TaskInstanceMetrics = ({
5354
startDate,
5455
taskInstanceStates,
5556
total,
56-
}: TaskInstanceMetricsProps) => (
57-
<Box borderRadius={5} borderWidth={1} mt={2} p={4}>
58-
<HStack>
59-
<RouterLink
60-
to={`/task_instances?start_date=${startDate}${endDate === undefined ? "" : `&end_date=${endDate}`}`}
61-
>
62-
<StateBadge colorPalette="blue" fontSize="md" variant="solid">
63-
<MdOutlineTask />
64-
{total}
65-
</StateBadge>
66-
</RouterLink>
67-
<Heading size="md">Task Instances</Heading>
68-
</HStack>
69-
<Separator my={3} />
70-
<Stack gap={4}>
71-
{TASK_STATES.sort((stateA, stateB) =>
72-
taskInstanceStates[stateA] > taskInstanceStates[stateB] ? -1 : 1,
73-
).map((state) =>
74-
taskInstanceStates[state] > 0 ? (
75-
<MetricSection
76-
endDate={endDate}
77-
key={state}
78-
kind="task_instances"
79-
runs={taskInstanceStates[state]}
80-
startDate={startDate}
81-
state={state as TaskInstanceState}
82-
total={total}
83-
/>
84-
) : undefined,
85-
)}
86-
</Stack>
87-
</Box>
88-
);
57+
}: TaskInstanceMetricsProps) => {
58+
const { t: translate } = useTranslation("dashboard");
59+
60+
return (
61+
<Box borderRadius={5} borderWidth={1} mt={2} p={4}>
62+
<HStack>
63+
<RouterLink
64+
to={`/task_instances?start_date=${startDate}${endDate === undefined ? "" : `&end_date=${endDate}`}`}
65+
>
66+
<StateBadge colorPalette="blue" fontSize="md" variant="solid">
67+
<MdOutlineTask />
68+
{total}
69+
</StateBadge>
70+
</RouterLink>
71+
<Heading size="md">{translate("history.taskInstances", { count: total })}</Heading>
72+
</HStack>
73+
<Separator my={3} />
74+
<Stack gap={4}>
75+
{TASK_STATES.sort((stateA, stateB) =>
76+
taskInstanceStates[stateA] > taskInstanceStates[stateB] ? -1 : 1,
77+
).map((state) =>
78+
taskInstanceStates[state] > 0 ? (
79+
<MetricSection
80+
endDate={endDate}
81+
key={state}
82+
kind="task_instances"
83+
runs={taskInstanceStates[state]}
84+
startDate={startDate}
85+
state={state as TaskInstanceState}
86+
total={total}
87+
/>
88+
) : undefined,
89+
)}
90+
</Stack>
91+
</Box>
92+
);
93+
};

airflow-core/src/airflow/ui/src/pages/Dashboard/PoolSummary/PoolSummary.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919
import { Box, Heading, Flex, Skeleton, Link } from "@chakra-ui/react";
20+
import { useTranslation } from "react-i18next";
2021
import { BiTargetLock } from "react-icons/bi";
2122
import { Link as RouterLink } from "react-router-dom";
2223

@@ -27,6 +28,7 @@ import { useAutoRefresh } from "src/utils";
2728
import { type Slots, slotKeys } from "src/utils/slots";
2829

2930
export const PoolSummary = () => {
31+
const { t: translate } = useTranslation("dashboard");
3032
const refetchInterval = useAutoRefresh({});
3133
const { data, isLoading } = usePoolServiceGetPools(undefined, undefined, {
3234
refetchInterval,
@@ -71,12 +73,12 @@ export const PoolSummary = () => {
7173
<Flex alignItems="center">
7274
<BiTargetLock />
7375
<Heading ml={1} size="xs">
74-
Pool Slots
76+
{translate("poolSlots")}
7577
</Heading>
7678
</Flex>
7779
{hasPoolsAccess ? (
7880
<Link asChild color="fg.info" fontSize="xs" h={4}>
79-
<RouterLink to="/pools">Manage Pools</RouterLink>
81+
<RouterLink to="/pools">{translate("managePools")}</RouterLink>
8082
</Link>
8183
) : undefined}
8284
</Flex>

0 commit comments

Comments
 (0)