Skip to content

Commit

Permalink
fix(web): update data use merge mode (#940)
Browse files Browse the repository at this point in the history
* fix(web): database merge mode

* fix(web): add createWebsite modal tool tip
LeezQ authored Mar 21, 2023
1 parent 5ed3be5 commit d62fe96
Showing 6 changed files with 33 additions and 20 deletions.
8 changes: 4 additions & 4 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -210,8 +210,7 @@
"websiteHost": "Enable website hosting",
"Inaccessible": "Inaccessible",
"isResolved": "Effective",
"cnameHostPreTip": "Add the \"CNAME\" record of the domain to resolve to",
"cnameHostSuffixTip": ", After the resolution takes effect, the custom domain name can be bound.",
"cnameTip": "Add the \"CNAME\" record of the domain to resolve to <strong>{{cnameDomain}}</strong>, After the resolution takes effect, the custom domain name can be bound.",
"editHostTip": "oss-bucket needs to be in read mode to enable website hosting",
"CreateWebHosting": "Bind custom domain name",
"CustomDomain": "Custom Domain",
@@ -324,5 +323,6 @@
"Scan with WeChat": "WeChat scan code payment",
"Order Number": "Order Number",
"payment status": "Payment status",
"Monthly": "Monthly"
}
"Monthly": "Monthly",
"CreateFolder": "New Folder"
}
9 changes: 4 additions & 5 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
@@ -210,8 +210,7 @@
"isResolved": "已生效",
"parsing": "解析中",
"websiteHost": "开启网站托管",
"cnameHostPreTip": "添加该域名的\"CNAME\" 解析到",
"cnameHostSuffixTip": "解析生效后即可绑定自定义域名。",
"cnameTip": "请对该域名添加 CNAME 记录,解析到 <strong>{{cnameDomain}}</strong> ,解析生效后即可绑定自定义域名。",
"editHostTip": "开启网站托管需要 bucket 权限是 readonly 模式",
"CreateWebHosting": "绑定自定义域名",
"CustomDomain": "自定义域名",
@@ -319,11 +318,11 @@
"Balance": "账户余额",
"ChargeNow": "充值",
"balance is insufficient": "余额不足",
"nihao": "你好",
"DeleteApp": "删除应用",
"Recharge amount": "充值金额",
"Scan with WeChat": "微信扫码支付",
"Order Number": "订单号",
"payment status": "支付状态",
"Monthly": ""
}
"Monthly": "",
"CreateFolder": "新建文件夹"
}
6 changes: 3 additions & 3 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
@@ -210,8 +210,7 @@
"isResolved": "已生效",
"parsing": "解析中",
"websiteHost": "开启网站托管",
"cnameHostPreTip": "请对该域名添加 CNAME 记录,解析到",
"cnameHostSuffixTip": ",解析生效后即可绑定自定义域名。",
"cnameTip": "请对该域名添加 CNAME 记录,解析到 <strong>{{cnameDomain}}</strong> ,解析生效后即可绑定自定义域名。",
"editHostTip": "开启网站托管需要 bucket 权限是 readonly 模式",
"CreateWebHosting": "绑定自定义域名",
"CustomDomain": "自定义域名",
@@ -324,5 +323,6 @@
"Scan with WeChat": "微信扫码支付",
"Order Number": "订单号",
"payment status": "支付状态",
"Monthly": ""
"Monthly": "",
"CreateFolder": "新建文件夹"
}
2 changes: 1 addition & 1 deletion web/src/pages/app/database/service.ts
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ export const useUpdateDataMutation = (config?: { onSuccess: (data: any) => void
async (values: any) => {
const query = db.collection(currentDB?.name!).where({ _id: values._id });
delete values._id;
const result = query.update({ ...values });
const result = query.update({ ...values }, { merge: false });
return result;
},
{
4 changes: 2 additions & 2 deletions web/src/pages/app/storages/mods/CreateFolderModal/index.tsx
Original file line number Diff line number Diff line change
@@ -44,13 +44,13 @@ function CreateModal({ onCreateSuccess }: { onCreateSuccess: () => void }) {
}, 0);
}}
>
{t("Create") + t("StoragePanel.Folder")}
{t("CreateFolder")}
</Button>

<Modal isOpen={isOpen} onClose={onClose} size="lg">
<ModalOverlay />
<ModalContent>
<ModalHeader> {t("Create") + t("StoragePanel.Folder")}</ModalHeader>
<ModalHeader> {t("CreateFolder")}</ModalHeader>
<ModalCloseButton />

<ModalBody pb={6}>
24 changes: 19 additions & 5 deletions web/src/pages/app/storages/mods/CreateWebsiteModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Trans, useTranslation } from "react-i18next";
import {
Button,
FormControl,
@@ -56,7 +56,12 @@ function CreateWebsiteModal() {
<span className="font-semibold mr-2">{t("StoragePanel.CurrentDomain")}</span>
<Link
className="cursor-pointer mr-2"
href={getOrigin(currentStorage?.websiteHosting?.domain)}
href={
currentStorage?.websiteHosting?.isCustom
? // custom domain don't support https currently
"http://" + currentStorage?.websiteHosting?.domain
: getOrigin(currentStorage?.websiteHosting?.domain)
}
isExternal
>
{currentStorage?.websiteHosting?.domain}
@@ -76,6 +81,11 @@ function CreateWebsiteModal() {
reset({});
setTimeout(() => {
setFocus("domain");
reset({
domain: currentStorage?.websiteHosting?.isCustom
? currentStorage?.websiteHosting?.domain
: "",
});
}, 0);
}
}}
@@ -149,9 +159,13 @@ function CreateWebsiteModal() {
placeholder={String(t("StoragePanel.domainTip"))}
/>
<p className="mt-2 text-grayModern-600">
{t("StoragePanel.cnameHostPreTip")}
<span className="mx-2 whitespace-nowrap">{cnameDomain}</span>
{t("StoragePanel.cnameHostSuffixTip")}
<Trans
t={t}
i18nKey="StoragePanel.cnameTip"
values={{
cnameDomain: cnameDomain,
}}
/>
</p>
</FormControl>
</VStack>

0 comments on commit d62fe96

Please sign in to comment.