Skip to content

Commit 857805a

Browse files
authored
fix(web): fix database page bugs & add storage refresh (#761)
1 parent be1d88e commit 857805a

File tree

29 files changed

+362
-166
lines changed

29 files changed

+362
-166
lines changed

web/public/locales/en/translation.json

+16-11
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
"PolicyNameTip": "Please enter a policy ID",
2424
"RulesContent": "Rule content",
2525
"RulesNum": "Number of Rules",
26-
"Search": "Please enter ID to query",
2726
"SelectCollection": "Select Collection",
2827
"SelectFunction": "Please select a cloud function",
29-
"CollectionNameRule": "The collection name can only contain English, _ or -",
3028
"EmptyCollectionTip": "You have not created a collection",
3129
"EmptyDataText": "No data information,",
32-
"EmptyPolicyTip": "You have not created a policy"
30+
"EmptyPolicyTip": "You have not created a policy",
31+
"EmptyRuleTip": "This policy has no rules yet,",
32+
"Query": "Please enter the ID and press Enter to query",
33+
"Search": "Please enter ID to search",
34+
"CreateTagTip": "Press \"Enter\" or \"Space\" to separate tags, each tag can be up to 16 characters",
35+
"CollectionNameRule": "The collection name can only start with a letter and consist of 3 to 32 characters including letters, _ or -"
3336
},
3437
"Add": "Add ",
3538
"AddData": "new data",
@@ -57,23 +60,23 @@
5760
"Name": "name",
5861
"Operation": "Operation",
5962
"Page": "Page",
60-
"Save": "save",
63+
"Save": "Save",
6164
"Search": "Search",
6265
"ToConfirm": "to determine",
6366
"Total": "Total",
6467
"Update": "Update ",
65-
"UpdateSuccess": "update success",
66-
"moreOperations": "more operations",
68+
"UpdateSuccess": "Update Success",
69+
"moreOperations": "More Operations",
6770
"FunctionPanel": {
6871
"AddFunction": "Add Function",
6972
"Code": "Function Template",
70-
"ConfirmDeploy": "Confirm release",
73+
"ConfirmDeploy": "Confirm Release",
7174
"CustomDependence": "Custom",
7275
"CustomDependenceTip": "No custom dependencies yet",
7376
"Debug": "Run",
7477
"DebugResult": "Run Result",
7578
"DeleteConfirm": "Are you sure you want to delete the function?",
76-
"Dependence": "Dependence",
79+
"Dependence": "NPM Dependence",
7780
"DependenceAdd": "Add Dependencies",
7881
"DependenceEdit": "Edit Dependencies",
7982
"DependenceName": "Dependency Package Name",
@@ -169,7 +172,9 @@
169172
"BucketNameRule": "Can only contain lowercase English, numbers, and the beginning and end cannot be numbers or -",
170173
"BucketNamePlaceholder": "bucket-name",
171174
"StorageList": "Cloud Storage List",
172-
"EmptyStorageTip": "You have not created a Bucket"
175+
"EmptyStorageTip": "You have not created a Bucket",
176+
"UploadFile": "Upload File",
177+
"UploadFolder": "Upload Folder"
173178
},
174179
"TriggerPanel": {
175180
"AddTrigger": "Add Trigger",
@@ -195,7 +200,7 @@
195200
"CreateError": "field cannot be empty"
196201
},
197202
"Refresh": "Refresh",
198-
"RefreshData": "Refresh Data",
203+
"RefreshData": "Refresh",
199204
"EditTip": "modified, unpublished",
200205
"NoInfo": "No information"
201-
}
206+
}

web/public/locales/zh-CN/translation.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"AddData": "添加数据",
3434
"AddIndex": "添加索引",
3535
"IndexName": "索引名称",
36-
"Search": "请输入ID进行查询",
36+
"Search": "请输入ID进行搜索",
37+
"Query": "请输入ID按回车进行查询",
3738
"EmptyCollectionText": "暂无集合信息,",
3839
"EmptyDataText": "暂无数据信息,",
3940
"EmptyCollectionTip": "您还没有创建集合",
@@ -50,7 +51,9 @@
5051
"AddRules": "添加规则",
5152
"RulesNum": "规则数",
5253
"RulesContent": "规则内容",
53-
"CollectionNameRule": "集合名称只能包含英文, _ 或者 -"
54+
"CollectionNameRule": "集合名称只能由字母开头,包含字母, _ 或者 - 的3至32个字符组成",
55+
"EmptyRuleTip": "此策略还没有规则,",
56+
"CreateTagTip": "按「回车键」或「空格键」分隔标签,每个标签最多由16个字符组成"
5457
},
5558
"FunctionPanel": {
5659
"Debug": "运行",
@@ -70,7 +73,7 @@
7073
"Description": "函数描述",
7174
"Code": "函数模板",
7275
"isSupport": "是否支持",
73-
"Dependence": "依赖",
76+
"Dependence": "NPM依赖",
7477
"CustomDependence": "自定义依赖",
7578
"CustomDependenceTip": "暂无自定义依赖",
7679
"SystemDependence": "内置依赖",
@@ -153,7 +156,10 @@
153156
"Success": "上传成功",
154157
"EmptyText": "暂无Bucket数据,",
155158
"BucketNameRule": "只能包含小写英文、数字,开头和结尾不能是数字或 -",
156-
"BucketNamePlaceholder": "bucket-name"
159+
"BucketNamePlaceholder": "bucket-name",
160+
"UploadFile": "上传文件",
161+
"UploadFolder": "上传文件夹",
162+
"Bucket": "Bucket"
157163
},
158164
"Search": "搜索",
159165
"Close": "关闭",
@@ -197,4 +203,4 @@
197203
"Refresh": "刷新",
198204
"RefreshData": "刷新数据",
199205
"NoInfo": "暂无信息"
200-
}
206+
}

web/public/locales/zh/translation.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323
"PolicyNameTip": "请输入策略标识",
2424
"RulesContent": "规则内容",
2525
"RulesNum": "规则数",
26-
"Search": "请输入ID进行查询",
26+
"Search": "请输入ID进行搜索",
27+
"Query": "请输入ID按回车进行查询",
2728
"SelectCollection": "选择集合",
2829
"SelectFunction": "请选择云函数",
29-
"CollectionNameRule": "集合名称只能包含英文, _ 或者 -",
30+
"CollectionNameRule": "集合名称只能由字母开头,包含字母, _ 或者 - 的3至32个字符组成",
3031
"EmptyCollectionTip": "您还没有创建集合",
3132
"EmptyDataText": "暂无数据信息,",
32-
"EmptyPolicyTip": "您还没有创建策略"
33+
"EmptyPolicyTip": "您还没有创建策略",
34+
"EmptyRuleTip": "此策略还没有规则,",
35+
"CreateTagTip": "按「回车键」或「空格键」分隔标签,每个标签最多由16个字符组成"
3336
},
3437
"Add": "添加",
3538
"AddData": "新增数据",
@@ -73,7 +76,7 @@
7376
"Debug": "运行",
7477
"DebugResult": "运行结果",
7578
"DeleteConfirm": "确认要删除函数吗?",
76-
"Dependence": "依赖",
79+
"Dependence": "NPM依赖",
7780
"DependenceAdd": "添加依赖",
7881
"DependenceEdit": "编辑依赖",
7982
"DependenceName": "依赖包名",
@@ -169,7 +172,9 @@
169172
"EditBucket": "编辑Bucket",
170173
"DeleteBucket": "删除Bucket",
171174
"BucketNamePlaceholder": "bucket-name",
172-
"EmptyStorageTip": "您还没有创建Bucket"
175+
"EmptyStorageTip": "您还没有创建Bucket",
176+
"UploadFile": "上传文件",
177+
"UploadFolder": "上传文件夹"
173178
},
174179
"TriggerPanel": {
175180
"AddTrigger": "新建触发器",

web/src/chakraTheme.ts

+3
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ const Badge = {
282282
borderRadius: "50px",
283283
textTransform: "none",
284284
fontWeight: "medium",
285+
display: "flex",
286+
justifyContent: "center",
287+
alignItems: "center",
285288
}),
286289
variants: {
287290
Started: {

web/src/components/Editor/JsonEditor.tsx

+16-17
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,6 @@ function JsonEditor(props: {
2929
const subscriptionRef = useRef<monaco.IDisposable | undefined>(undefined);
3030
const monacoEl = useRef(null);
3131

32-
// onChange
33-
useEffect(() => {
34-
subscriptionRef.current?.dispose();
35-
36-
if (onChange) {
37-
subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event) => {
38-
onChange(editorRef.current?.getValue());
39-
});
40-
}
41-
}, [onChange]);
42-
43-
useEffect(() => {
44-
if (monacoEl && editorRef.current && value !== editorRef.current?.getValue()) {
45-
editorRef.current?.getModel()?.setValue(value);
46-
}
47-
}, [value]);
48-
4932
useEffect(() => {
5033
if (monacoEl && !editorRef.current) {
5134
editorRef.current = monaco.editor.create(monacoEl.current!, {
@@ -75,6 +58,22 @@ function JsonEditor(props: {
7558
return () => {};
7659
}, [value]);
7760

61+
// onChange
62+
useEffect(() => {
63+
subscriptionRef.current?.dispose();
64+
65+
if (onChange) {
66+
subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event) => {
67+
onChange(editorRef.current?.getValue());
68+
});
69+
}
70+
}, [onChange]);
71+
72+
useEffect(() => {
73+
if (monacoEl && editorRef.current && value !== editorRef.current?.getValue()) {
74+
editorRef.current?.getModel()?.setValue(value);
75+
}
76+
}, [value]);
7877
return <div style={{ height: height, width: "100%" }} ref={monacoEl}></div>;
7978
}
8079

web/src/components/FileUpload/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ function FileUpload(props: { onUpload: (files: any) => void; uploadType: "file"
8383
{t("StoragePanel.Drag")}
8484
</p>
8585
<button className={styles.uploadButton} onClick={onButtonClick}>
86-
{t("StoragePanel.Upload") +
87-
(uploadType === "file" ? t("StoragePanel.File") : t("StoragePanel.Folder"))}
86+
{uploadType === "file" ? t("StoragePanel.UploadFile") : t("StoragePanel.UploadFolder")}
8887
</button>
8988
</div>
9089
</label>

web/src/components/InputTag/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from "react";
22
import { Input, Tag, TagCloseButton, TagLabel } from "@chakra-ui/react";
3+
import { t } from "i18next";
34

45
export default function InputTag(props: { value: string[]; onChange: (value: string[]) => any }) {
56
const { value, onChange } = props;
@@ -20,7 +21,7 @@ export default function InputTag(props: { value: string[]; onChange: (value: str
2021
return (
2122
<>
2223
<Input
23-
placeholder=" 按「回车键」或「空格键」分隔标签,每个标签最多由16个字符组成"
24+
placeholder={String(t("CollectionPanel.CreateTagTip"))}
2425
className="mb-2"
2526
value={inputV}
2627
onKeyDown={(e) => handleEnter(e)}

web/src/components/Pagination/index.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ export default function Pagination(props: {
1919
const { page, total, limit } = values;
2020
const maxPage = total && limit ? Math.ceil(total / limit) : -1;
2121

22+
if (maxPage > 0 && page && page > maxPage) {
23+
onChange({
24+
...values,
25+
page: maxPage,
26+
});
27+
} else if (page && page < 1) {
28+
onChange({
29+
...values,
30+
page: 1,
31+
});
32+
}
33+
2234
return (
2335
<HStack alignItems="center" spacing={"1"} display="flex" whiteSpace={"nowrap"}>
2436
<Text as="div" className="text-lg mr-2">

web/src/constants/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export enum SUPPORTED_METHODS {
3333

3434
export enum APP_PHASE_STATUS {
3535
Creating = "Creating",
36+
Created = "Created",
3637
Started = "Started",
3738
Starting = "Starting",
3839
Restarting = "Restarting",

web/src/main.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ if (typeof (window as any).global === "undefined") {
88
(window as any).global = window;
99
}
1010

11-
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
12-
<React.StrictMode>
13-
<App />
14-
</React.StrictMode>,
15-
);
11+
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(<App />);

0 commit comments

Comments
 (0)