Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/pages/Setting/Setting.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import { Card, Form, Input, Row, Col, notification } from 'antd';
import { useIntl } from 'umi';

import { setBaseURL, getBaseURL } from '@/helpers';
import ActionBar from '@/components/ActionBar';
Expand All @@ -15,6 +16,8 @@ const Setting: React.FC = () => {
const isWorkspace = false;
const canFetchGrafana = (isSuperAdmin && !isWorkspace) || isWorkspace;

const { formatMessage } = useIntl();

useEffect(() => {
form.setFieldsValue({
baseURL: getBaseURL(),
Expand Down Expand Up @@ -46,7 +49,7 @@ const Setting: React.FC = () => {
resolve();
}),
]).then(() => {
notification.success({ message: '更新配置成功' });
notification.success({ message: formatMessage({ id: 'setting.update.configuration.successfully' }) });
setTimeout(() => {
window.location.reload();
}, 500);
Expand All @@ -55,22 +58,22 @@ const Setting: React.FC = () => {

return (
<>
<PageContainer title="设置">
<PageContainer title={formatMessage({ id: 'set' })}>
<Card>
<Row>
<Col span={10}>
<Form form={form} labelCol={{ span: 7 }}>
{!isWorkspace && (
<Form.Item label="API 地址" name="baseURL">
<Form.Item label={formatMessage({ id: 'setting.api.address' })} name="baseURL">
<Input />
</Form.Item>
)}
{canFetchGrafana && (
<Form.Item
label="Grafana 地址"
label={formatMessage({ id: 'setting.grafana.address' })}
name="grafanaURL"
extra="Grafana 地址,需以 http 或 https 开头"
rules={[{ pattern: new RegExp(/^https?:\/\//), message: '非法的地址' }]}
extra={formatMessage({ id: 'setting.grafana.address.rule' })}
rules={[{ pattern: new RegExp(/^https?:\/\//), message: formatMessage({ id: 'setting.grafana.address.illegality' }) }]}
>
<Input />
</Form.Item>
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Setting/locales/en-US.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
'setting.update.configuration.successfully': 'Update Configuration Successfully',
'setting':'Setting',
'setting.api.address':'API Address',
'setting.grafana.address':'Grafana Address',
'setting.grafana.address.rule':'Grafana address should begin with HTTP or HTTPS',
'setting.grafana.address.illegality':'Address is illegality',
};
8 changes: 8 additions & 0 deletions src/pages/Setting/locales/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
'setting.update.configuration.successfully': '更新配置成功',
'setting':'设置',
'setting.api.address':'API 地址',
'setting.grafana.address':'Grafana 地址',
'setting.grafana.address.rule':'Grafana 地址需以 HTTP 或 HTTPS 开头',
'setting.grafana.address.illegality':'非法的地址',
};