Skip to content

Commit a97f3f7

Browse files
authored
web: KB 9.0 compatibility (#2062)
1 parent 8e46e9a commit a97f3f7

File tree

6 files changed

+106
-38
lines changed

6 files changed

+106
-38
lines changed

web/public/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
"Pause": "Pause",
238238
"PauseTips": "Are you sure you want to pause this application?",
239239
"RestartTips": "Restart the database together?",
240+
"RestartTips1": "Are you sure you want to restart the application?",
240241
"CommonSetting": "Common Settings",
241242
"EditorFont": "Editor Font",
242243
"FontSize": "Font Size",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
"Pause": "暂停应用",
238238
"PauseTips": "确定要暂停此应用吗?",
239239
"RestartTips": "同时重启数据库?",
240+
"RestartTips1": "确定要重启应用?",
240241
"CommonSetting": "常用设置",
241242
"EditorFont": "编辑器字体",
242243
"FontSize": "字体大小",

web/public/locales/zh/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@
237237
"Pause": "暂停应用",
238238
"PauseTips": "确定要暂停此应用吗?",
239239
"RestartTips": "同时重启数据库?",
240+
"RestartTips1": "确定要重启应用?",
240241
"CommonSetting": "常用设置",
241242
"EditorFont": "编辑器字体",
242243
"FontSize": "字体大小",

web/src/layouts/Auth/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useEffect } from "react";
12
import { useTranslation } from "react-i18next";
23
import { Outlet } from "react-router-dom";
34
import { useColorMode } from "@chakra-ui/react";
@@ -14,13 +15,17 @@ export default function LoginReg() {
1415
const { colorMode } = useColorMode();
1516
const darkMode = colorMode === COLOR_MODE.dark;
1617
const { showInfo } = useGlobalStore(({ showInfo }) => ({ showInfo }));
17-
showInfo(
18-
<a href="https://bja.sealos.run" className="font-bold underline transition ease-in-out">
19-
{t("Auth.migrationNotice")}
20-
</a>,
21-
null,
22-
true,
23-
);
18+
19+
useEffect(() => {
20+
showInfo(
21+
<a href="https://bja.sealos.run" className="font-bold underline transition ease-in-out">
22+
{t("Auth.migrationNotice")}
23+
</a>,
24+
null,
25+
true,
26+
);
27+
// eslint-disable-next-line react-hooks/exhaustive-deps
28+
}, []);
2429

2530
return (
2631
<div

web/src/pages/app/setting/SysSetting/AppInfoList/index.tsx

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,37 +81,61 @@ const AppEnvList: React.FC<AppEnvListProps> = (props = {}) => {
8181

8282
{currentApp?.phase === APP_PHASE_STATUS.Started ? (
8383
<>
84-
<ConfirmButton
85-
headerText={t("SettingPanel.Restart")}
86-
bodyText={
87-
<Checkbox
88-
colorScheme="primary"
89-
mt={4}
90-
isChecked={!onlyRuntimeFlag}
91-
onChange={(e) => setOnlyRuntimeFlag(!e.target.checked)}
84+
{currentApp?.bundle?.resource?.dedicatedDatabase?.limitCPU ? (
85+
<ConfirmButton
86+
headerText={t("SettingPanel.Restart")}
87+
bodyText={
88+
<Checkbox
89+
colorScheme="primary"
90+
mt={4}
91+
isChecked={!onlyRuntimeFlag}
92+
onChange={(e) => setOnlyRuntimeFlag(!e.target.checked)}
93+
>
94+
{t("SettingPanel.RestartTips")}
95+
</Checkbox>
96+
}
97+
confirmButtonText={String(t("Confirm"))}
98+
onSuccessAction={async (event) => {
99+
event?.preventDefault();
100+
updateCurrentApp(currentApp!, APP_STATUS.Restarting, onlyRuntimeFlag);
101+
setOnlyRuntimeFlag(true);
102+
}}
103+
>
104+
<Button
105+
className="mr-2"
106+
fontWeight={"semibold"}
107+
size={"sm"}
108+
color={"grayModern.600"}
109+
bg={"none"}
110+
_hover={{ color: "primary.600" }}
92111
>
93-
{t("SettingPanel.RestartTips")}
94-
</Checkbox>
95-
}
96-
confirmButtonText={String(t("Confirm"))}
97-
onSuccessAction={async (event) => {
98-
event?.preventDefault();
99-
updateCurrentApp(currentApp!, APP_STATUS.Restarting, onlyRuntimeFlag);
100-
setOnlyRuntimeFlag(true);
101-
}}
102-
>
103-
<Button
104-
className="mr-2"
105-
fontWeight={"semibold"}
106-
size={"sm"}
107-
color={"grayModern.600"}
108-
bg={"none"}
109-
_hover={{ color: "primary.600" }}
112+
<MdRestartAlt size={16} className="mr-1" />
113+
{t("SettingPanel.Restart")}
114+
</Button>
115+
</ConfirmButton>
116+
) : (
117+
<ConfirmButton
118+
headerText={t("SettingPanel.Restart")}
119+
bodyText={t("SettingPanel.RestartTips1")}
120+
confirmButtonText={String(t("Confirm"))}
121+
onSuccessAction={async (event) => {
122+
event?.preventDefault();
123+
updateCurrentApp(currentApp!, APP_STATUS.Restarting);
124+
}}
110125
>
111-
<MdRestartAlt size={16} className="mr-1" />
112-
{t("SettingPanel.Restart")}
113-
</Button>
114-
</ConfirmButton>
126+
<Button
127+
className="mr-2"
128+
fontWeight={"semibold"}
129+
size={"sm"}
130+
color={"grayModern.600"}
131+
bg={"none"}
132+
_hover={{ color: "primary.600" }}
133+
>
134+
<MdRestartAlt size={16} className="mr-1" />
135+
{t("SettingPanel.Restart")}
136+
</Button>
137+
</ConfirmButton>
138+
)}
115139

116140
<Button
117141
className="mr-2"

web/src/pages/home/mods/List/index.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ function List(props: { appList: TApplicationItem[] }) {
199199
)}
200200

201201
{item.phase === APP_PHASE_STATUS.Started &&
202-
item.state === APP_STATUS.Running && (
202+
item.state === APP_STATUS.Running &&
203+
(item.bundle.resource.dedicatedDatabase?.limitCPU ? (
203204
<ConfirmButton
204205
headerText={t("SettingPanel.Restart")}
205206
bodyText={
@@ -245,7 +246,42 @@ function List(props: { appList: TApplicationItem[] }) {
245246
</span>
246247
</MenuItem>
247248
</ConfirmButton>
248-
)}
249+
) : (
250+
<ConfirmButton
251+
headerText={t("SettingPanel.Restart")}
252+
bodyText={t("SettingPanel.RestartTips1")}
253+
confirmButtonText={String(t("Confirm"))}
254+
onSuccessAction={async (event) => {
255+
event?.preventDefault();
256+
const res = await updateAppStateMutation.mutateAsync({
257+
appid: item.appid,
258+
state: APP_STATUS.Restarting,
259+
});
260+
if (!res.error) {
261+
queryClient.setQueryData(APP_LIST_QUERY_KEY, (old: any) => {
262+
return {
263+
...old,
264+
data: old.data.map((app: any) => {
265+
if (app.appid === item.appid) {
266+
return {
267+
...app,
268+
phase: APP_STATUS.Restarting,
269+
};
270+
}
271+
return app;
272+
}),
273+
};
274+
});
275+
}
276+
}}
277+
>
278+
<MenuItem minH="40px" display={"block"}>
279+
<span className="text-primary block">
280+
{t("SettingPanel.Restart")}
281+
</span>
282+
</MenuItem>
283+
</ConfirmButton>
284+
))}
249285

250286
{item.phase === APP_PHASE_STATUS.Stopped &&
251287
item.state === APP_STATUS.Stopped && (

0 commit comments

Comments
 (0)