MCPcopy Create free account
hub / github.com/Vespa314/cflow / UpdateLocalStorageDialog

Function UpdateLocalStorageDialog

web/src/components/UpdateLocalStorageDialog.tsx:15–68  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

13}
14
15const UpdateLocalStorageDialog: React.FC<Props> = (props: Props) => {
16 const t = useTranslate();
17 const { destroy, localStoragePath, confirmCallback } = props;
18 const globalStore = useGlobalStore();
19 const [path, setPath] = useState(localStoragePath || "");
20
21 const handleCloseBtnClick = () => {
22 destroy();
23 };
24
25 const handleConfirmBtnClick = async () => {
26 try {
27 await api.upsertSystemSetting({
28 name: "local-storage-path",
29 value: JSON.stringify(path),
30 });
31 await globalStore.fetchSystemStatus();
32 } catch (error: any) {
33 console.error(error);
34 toast.error(error.response.data.message);
35 }
36 if (confirmCallback) {
37 confirmCallback();
38 }
39 destroy();
40 };
41
42 return (
43 <>
44 <div className="dialog-header-container">
45 <p className="title-text">{t("setting.storage-section.update-local-path")}</p>
46 <button className="btn close-btn" onClick={handleCloseBtnClick}>
47 <Icon.X />
48 </button>
49 </div>
50 <div className="dialog-content-container max-w-xs">
51 <p className="text-sm break-words mb-1">{t("setting.storage-section.update-local-path-description")}</p>
52 <Input
53 className="mb-2"
54 placeholder={t("setting.storage-section.local-storage-path")}
55 fullWidth
56 value={path}
57 onChange={(e) => setPath(e.target.value)}
58 />
59 <div className="mt-2 w-full flex flex-row justify-end items-center space-x-1">
60 <Button variant="plain" color="neutral" onClick={handleCloseBtnClick}>
61 {t("common.cancel")}
62 </Button>
63 <Button onClick={handleConfirmBtnClick}>{t("common.update")}</Button>
64 </div>
65 </div>
66 </>
67 );
68};
69
70function showUpdateLocalStorageDialog(localStoragePath?: string, confirmCallback?: () => void) {
71 generateDialog(

Callers

nothing calls this directly

Calls 2

useTranslateFunction · 0.90
useGlobalStoreFunction · 0.90

Tested by

no test coverage detected