@plutonhq/core-frontend 0.1.25 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/@types/backups.d.ts +4 -1
- package/dist-lib/@types/backups.d.ts.map +1 -1
- package/dist-lib/@types/plans.d.ts +2 -0
- package/dist-lib/@types/plans.d.ts.map +1 -1
- package/dist-lib/@types/restores.d.ts +2 -0
- package/dist-lib/@types/restores.d.ts.map +1 -1
- package/dist-lib/components/Device/DeviceInfo/DeviceInfo.module.scss.js +26 -26
- package/dist-lib/components/Plan/BackupEvents/BackupEvents.d.ts.map +1 -1
- package/dist-lib/components/Plan/BackupEvents/BackupEvents.js +27 -27
- package/dist-lib/components/Plan/BackupEvents/BackupEvents.js.map +1 -1
- package/dist-lib/components/Plan/PlanBackups/PlanBackups.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanBackups/PlanBackups.js +26 -26
- package/dist-lib/components/Plan/PlanBackups/PlanBackups.js.map +1 -1
- package/dist-lib/components/Plan/PlanForm/PlanForm.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanForm/PlanForm.js +64 -80
- package/dist-lib/components/Plan/PlanForm/PlanForm.js.map +1 -1
- package/dist-lib/components/Plan/PlanHistory/PlanHistory.js +1 -1
- package/dist-lib/components/Plan/PlanHistory/PlanHistory.js.map +1 -1
- package/dist-lib/components/Plan/PlanPruneModal/PlanPruneModal.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanPruneModal/PlanPruneModal.js +62 -26
- package/dist-lib/components/Plan/PlanPruneModal/PlanPruneModal.js.map +1 -1
- package/dist-lib/components/Plan/PlanSettings/PlanPruneSettings.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanSettings/PlanPruneSettings.js +138 -62
- package/dist-lib/components/Plan/PlanSettings/PlanPruneSettings.js.map +1 -1
- package/dist-lib/components/Plan/PlanSettings/PlanSettings.module.scss.js +42 -42
- package/dist-lib/components/Plan/PlanSettings/PlanSourceSettings.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanSettings/PlanSourceSettings.js +39 -30
- package/dist-lib/components/Plan/PlanSettings/PlanSourceSettings.js.map +1 -1
- package/dist-lib/components/Plan/PlanStats/PlanStats.d.ts.map +1 -1
- package/dist-lib/components/Plan/PlanStats/PlanStats.js +25 -25
- package/dist-lib/components/Plan/PlanStats/PlanStats.js.map +1 -1
- package/dist-lib/components/Plan/PlanStats/PlanStats.module.scss.js +1 -1
- package/dist-lib/components/common/Icon/Icon.d.ts.map +1 -1
- package/dist-lib/components/common/Icon/Icon.js +12 -1
- package/dist-lib/components/common/Icon/Icon.js.map +1 -1
- package/dist-lib/components/common/StatusLabel/StatusLabel.d.ts +1 -1
- package/dist-lib/components/common/StatusLabel/StatusLabel.d.ts.map +1 -1
- package/dist-lib/components/common/StatusLabel/StatusLabel.js +17 -12
- package/dist-lib/components/common/StatusLabel/StatusLabel.js.map +1 -1
- package/dist-lib/components/common/form/IntervalField/IntervalField.d.ts.map +1 -1
- package/dist-lib/components/common/form/IntervalField/IntervalField.js +66 -46
- package/dist-lib/components/common/form/IntervalField/IntervalField.js.map +1 -1
- package/dist-lib/components/common/form/NumberInput/NumberInput.module.scss.js +4 -4
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.d.ts.map +1 -1
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.js +49 -47
- package/dist-lib/components/common/form/StoragePicker/StoragePicker.js.map +1 -1
- package/dist-lib/components/common/form/TagsInput/TagsInput.d.ts +2 -1
- package/dist-lib/components/common/form/TagsInput/TagsInput.d.ts.map +1 -1
- package/dist-lib/components/common/form/TagsInput/TagsInput.js +15 -15
- package/dist-lib/components/common/form/TagsInput/TagsInput.js.map +1 -1
- package/dist-lib/components/common/form/TimePicker/TimePicker.module.scss.js +13 -13
- package/dist-lib/hooks/usePlanSingleActions.js +7 -7
- package/dist-lib/hooks/usePlanSingleActions.js.map +1 -1
- package/dist-lib/styles/core-frontend.css +1 -1
- package/dist-lib/styles/global.scss +6 -0
- package/dist-lib/utils/constants.js +1 -1
- package/dist-lib/utils/constants.js.map +1 -1
- package/dist-lib/utils/helpers.d.ts +2 -0
- package/dist-lib/utils/helpers.d.ts.map +1 -1
- package/dist-lib/utils/helpers.js +55 -33
- package/dist-lib/utils/helpers.js.map +1 -1
- package/dist-lib/utils/plans.js +6 -6
- package/dist-lib/utils/plans.js.map +1 -1
- package/dist-lib/utils.js +34 -33
- package/package.json +1 -1
- package/src/@types/backups.ts +4 -1
- package/src/@types/plans.ts +2 -0
- package/src/@types/restores.ts +2 -0
- package/src/components/Device/DeviceInfo/DeviceInfo.module.scss +1 -0
- package/src/components/Plan/BackupEvents/BackupEvents.tsx +5 -3
- package/src/components/Plan/PlanBackups/PlanBackups.tsx +5 -2
- package/src/components/Plan/PlanForm/PlanForm.tsx +1 -19
- package/src/components/Plan/PlanHistory/PlanHistory.tsx +1 -1
- package/src/components/Plan/PlanPruneModal/PlanPruneModal.tsx +54 -11
- package/src/components/Plan/PlanSettings/PlanPruneSettings.tsx +145 -61
- package/src/components/Plan/PlanSettings/PlanSettings.module.scss +5 -0
- package/src/components/Plan/PlanSettings/PlanSourceSettings.tsx +15 -1
- package/src/components/Plan/PlanStats/PlanStats.module.scss +3 -0
- package/src/components/Plan/PlanStats/PlanStats.tsx +2 -8
- package/src/components/common/Icon/Icon.tsx +12 -0
- package/src/components/common/StatusLabel/StatusLabel.tsx +7 -1
- package/src/components/common/form/IntervalField/IntervalField.tsx +21 -1
- package/src/components/common/form/NumberInput/NumberInput.module.scss +1 -0
- package/src/components/common/form/StoragePicker/StoragePicker.tsx +8 -1
- package/src/components/common/form/TagsInput/TagsInput.tsx +3 -2
- package/src/components/common/form/TimePicker/TimePicker.module.scss +1 -0
- package/src/hooks/usePlanSingleActions.tsx +2 -2
- package/src/styles/global.scss +6 -0
- package/src/utils/constants.ts +1 -1
- package/src/utils/helpers.ts +25 -0
- package/src/utils/plans.ts +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
2
|
-
import { useState as d, useEffect as
|
|
2
|
+
import { useState as d, useEffect as N } from "react";
|
|
3
3
|
import n from "./TagsInput.module.scss.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
4
|
+
import D from "../../Icon/Icon.js";
|
|
5
|
+
import F from "../FormField/FormField.js";
|
|
6
|
+
const K = ({ label: u, description: h, customClasses: f = "", hint: v = "", fieldValue: a = [], onUpdate: c, icon: y, type: i = "tag", inline: T }) => {
|
|
7
7
|
const [s, o] = d(() => Array.isArray(a) ? a : []), [l, g] = d("");
|
|
8
|
-
|
|
8
|
+
N(() => {
|
|
9
9
|
Array.isArray(a) && o(a);
|
|
10
10
|
}, [a]);
|
|
11
11
|
const m = (t) => {
|
|
@@ -13,39 +13,39 @@ const E = ({ label: u, description: h, customClasses: f = "", fieldValue: a = []
|
|
|
13
13
|
const e = [...s, t];
|
|
14
14
|
o(e), g(""), c(e);
|
|
15
15
|
}
|
|
16
|
-
}, T = (t) => {
|
|
17
|
-
const e = s.filter((w) => t !== w);
|
|
18
|
-
o(e), c(e);
|
|
19
16
|
}, x = (t) => {
|
|
17
|
+
const e = s.filter((A) => t !== A);
|
|
18
|
+
o(e), c(e);
|
|
19
|
+
}, $ = (t) => {
|
|
20
20
|
if (t.target.value.includes(",")) {
|
|
21
21
|
const e = t.target.value.replace(",", "");
|
|
22
22
|
m(e);
|
|
23
23
|
} else
|
|
24
24
|
g(t.target.value);
|
|
25
|
-
},
|
|
25
|
+
}, w = (t) => {
|
|
26
26
|
t.key === "Enter" && (t.preventDefault(), m(l));
|
|
27
27
|
};
|
|
28
|
-
return /* @__PURE__ */ r(
|
|
28
|
+
return /* @__PURE__ */ r(F, { type: "tags", label: u, hint: v, description: h, inline: T, classes: `${n.tagField} ${f}`, children: /* @__PURE__ */ p("div", { className: n.tagBox, children: [
|
|
29
29
|
s.map((t, e) => /* @__PURE__ */ p("div", { className: n.tag, children: [
|
|
30
|
-
/* @__PURE__ */ r(
|
|
30
|
+
/* @__PURE__ */ r(D, { size: 13, type: y || "tags" }),
|
|
31
31
|
" ",
|
|
32
32
|
t,
|
|
33
33
|
" ",
|
|
34
|
-
/* @__PURE__ */ r("i", { title: "Remove", onClick: () =>
|
|
34
|
+
/* @__PURE__ */ r("i", { title: "Remove", onClick: () => x(t), children: "✖" })
|
|
35
35
|
] }, t + e)),
|
|
36
36
|
/* @__PURE__ */ r("div", { className: n.textInput, children: /* @__PURE__ */ r(
|
|
37
37
|
"input",
|
|
38
38
|
{
|
|
39
39
|
type: "text",
|
|
40
40
|
value: l,
|
|
41
|
-
onChange: (t) =>
|
|
42
|
-
onKeyDown:
|
|
41
|
+
onChange: (t) => $(t),
|
|
42
|
+
onKeyDown: w,
|
|
43
43
|
placeholder: `${i}${s.length + 1}, ${i}${s.length + 2}`
|
|
44
44
|
}
|
|
45
45
|
) })
|
|
46
46
|
] }) });
|
|
47
47
|
};
|
|
48
48
|
export {
|
|
49
|
-
|
|
49
|
+
K as default
|
|
50
50
|
};
|
|
51
51
|
//# sourceMappingURL=TagsInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagsInput.js","sources":["../../../../../src/components/common/form/TagsInput/TagsInput.tsx"],"sourcesContent":["import { ChangeEvent, KeyboardEvent, useEffect, useState } from 'react';\r\nimport classes from './TagsInput.module.scss';\r\nimport Icon from '../../Icon/Icon';\r\nimport FormField from '../FormField/FormField';\r\n\r\ntype TagsInputProps = {\r\n label?: string;\r\n description?: string;\r\n customClasses?: string;\r\n icon?: string;\r\n type?: string;\r\n inline?: boolean;\r\n fieldValue: string[];\r\n onUpdate: (f: string[]) => void;\r\n};\r\n\r\nconst TagsInput = ({ label, description, customClasses = '', fieldValue = [], onUpdate, icon, type = 'tag', inline }: TagsInputProps) => {\r\n const [tags, setTags] = useState<string[]>(() => (Array.isArray(fieldValue) ? fieldValue : []));\r\n const [newTag, setNewTag] = useState('');\r\n\r\n useEffect(() => {\r\n if (Array.isArray(fieldValue)) {\r\n setTags(fieldValue);\r\n }\r\n }, [fieldValue]);\r\n\r\n const addTag = (tag: string) => {\r\n if (tag.length > 1) {\r\n const updated = [...tags, tag];\r\n setTags(updated);\r\n setNewTag('');\r\n onUpdate(updated);\r\n }\r\n };\r\n\r\n const removeTag = (t: string) => {\r\n const updatedTags = tags.filter((tag) => t !== tag);\r\n setTags(updatedTags);\r\n onUpdate(updatedTags);\r\n };\r\n\r\n const updateTag = (e: ChangeEvent<HTMLInputElement>) => {\r\n if (e.target.value.includes(',')) {\r\n const tagValue = e.target.value.replace(',', '');\r\n addTag(tagValue);\r\n } else {\r\n setNewTag(e.target.value);\r\n }\r\n };\r\n\r\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\r\n if (e.key === 'Enter') {\r\n e.preventDefault();\r\n addTag(newTag);\r\n }\r\n };\r\n\r\n return (\r\n <FormField type={'tags'} label={label} description={description} inline={inline} classes={`${classes.tagField} ${customClasses}`}>\r\n <div className={classes.tagBox}>\r\n {tags.map((t, i) => (\r\n <div className={classes.tag} key={t + i}>\r\n <Icon size={13} type={icon || 'tags'} /> {t}{' '}\r\n <i title=\"Remove\" onClick={() => removeTag(t)}>\r\n ✖\r\n </i>\r\n </div>\r\n ))}\r\n <div className={classes.textInput}>\r\n <input\r\n type=\"text\"\r\n value={newTag}\r\n onChange={(e) => updateTag(e)}\r\n onKeyDown={handleKeyDown}\r\n placeholder={`${type}${tags.length + 1}, ${type}${tags.length + 2}`}\r\n />\r\n </div>\r\n </div>\r\n </FormField>\r\n );\r\n};\r\n\r\nexport default TagsInput;\r\n"],"names":["TagsInput","label","description","customClasses","fieldValue","onUpdate","icon","type","inline","tags","setTags","useState","newTag","setNewTag","useEffect","addTag","tag","updated","removeTag","updatedTags","updateTag","e","tagValue","handleKeyDown","FormField","classes","i","jsx","Icon"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"TagsInput.js","sources":["../../../../../src/components/common/form/TagsInput/TagsInput.tsx"],"sourcesContent":["import { ChangeEvent, KeyboardEvent, useEffect, useState } from 'react';\r\nimport classes from './TagsInput.module.scss';\r\nimport Icon from '../../Icon/Icon';\r\nimport FormField from '../FormField/FormField';\r\n\r\ntype TagsInputProps = {\r\n label?: string;\r\n description?: string;\r\n customClasses?: string;\r\n icon?: string;\r\n type?: string;\r\n inline?: boolean;\r\n hint?: string;\r\n fieldValue: string[];\r\n onUpdate: (f: string[]) => void;\r\n};\r\n\r\nconst TagsInput = ({ label, description, customClasses = '', hint = '', fieldValue = [], onUpdate, icon, type = 'tag', inline }: TagsInputProps) => {\r\n const [tags, setTags] = useState<string[]>(() => (Array.isArray(fieldValue) ? fieldValue : []));\r\n const [newTag, setNewTag] = useState('');\r\n\r\n useEffect(() => {\r\n if (Array.isArray(fieldValue)) {\r\n setTags(fieldValue);\r\n }\r\n }, [fieldValue]);\r\n\r\n const addTag = (tag: string) => {\r\n if (tag.length > 1) {\r\n const updated = [...tags, tag];\r\n setTags(updated);\r\n setNewTag('');\r\n onUpdate(updated);\r\n }\r\n };\r\n\r\n const removeTag = (t: string) => {\r\n const updatedTags = tags.filter((tag) => t !== tag);\r\n setTags(updatedTags);\r\n onUpdate(updatedTags);\r\n };\r\n\r\n const updateTag = (e: ChangeEvent<HTMLInputElement>) => {\r\n if (e.target.value.includes(',')) {\r\n const tagValue = e.target.value.replace(',', '');\r\n addTag(tagValue);\r\n } else {\r\n setNewTag(e.target.value);\r\n }\r\n };\r\n\r\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\r\n if (e.key === 'Enter') {\r\n e.preventDefault();\r\n addTag(newTag);\r\n }\r\n };\r\n\r\n return (\r\n <FormField type={'tags'} label={label} hint={hint} description={description} inline={inline} classes={`${classes.tagField} ${customClasses}`}>\r\n <div className={classes.tagBox}>\r\n {tags.map((t, i) => (\r\n <div className={classes.tag} key={t + i}>\r\n <Icon size={13} type={icon || 'tags'} /> {t}{' '}\r\n <i title=\"Remove\" onClick={() => removeTag(t)}>\r\n ✖\r\n </i>\r\n </div>\r\n ))}\r\n <div className={classes.textInput}>\r\n <input\r\n type=\"text\"\r\n value={newTag}\r\n onChange={(e) => updateTag(e)}\r\n onKeyDown={handleKeyDown}\r\n placeholder={`${type}${tags.length + 1}, ${type}${tags.length + 2}`}\r\n />\r\n </div>\r\n </div>\r\n </FormField>\r\n );\r\n};\r\n\r\nexport default TagsInput;\r\n"],"names":["TagsInput","label","description","customClasses","hint","fieldValue","onUpdate","icon","type","inline","tags","setTags","useState","newTag","setNewTag","useEffect","addTag","tag","updated","removeTag","updatedTags","updateTag","e","tagValue","handleKeyDown","FormField","classes","i","jsx","Icon"],"mappings":";;;;;AAiBA,MAAMA,IAAY,CAAC,EAAE,OAAAC,GAAO,aAAAC,GAAa,eAAAC,IAAgB,IAAI,MAAAC,IAAO,IAAI,YAAAC,IAAa,CAAA,GAAI,UAAAC,GAAU,MAAAC,GAAM,MAAAC,IAAO,OAAO,QAAAC,QAA6B;AACjJ,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAmB,MAAO,MAAM,QAAQP,CAAU,IAAIA,IAAa,EAAG,GACxF,CAACQ,GAAQC,CAAS,IAAIF,EAAS,EAAE;AAEvC,EAAAG,EAAU,MAAM;AACb,IAAI,MAAM,QAAQV,CAAU,KACzBM,EAAQN,CAAU;AAAA,EAExB,GAAG,CAACA,CAAU,CAAC;AAEf,QAAMW,IAAS,CAACC,MAAgB;AAC7B,QAAIA,EAAI,SAAS,GAAG;AACjB,YAAMC,IAAU,CAAC,GAAGR,GAAMO,CAAG;AAC7B,MAAAN,EAAQO,CAAO,GACfJ,EAAU,EAAE,GACZR,EAASY,CAAO;AAAA,IACnB;AAAA,EACH,GAEMC,IAAY,CAAC,MAAc;AAC9B,UAAMC,IAAcV,EAAK,OAAO,CAACO,MAAQ,MAAMA,CAAG;AAClD,IAAAN,EAAQS,CAAW,GACnBd,EAASc,CAAW;AAAA,EACvB,GAEM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28 +1,28 @@
|
|
|
1
|
-
const e = "
|
|
1
|
+
const e = "_fieldLabel_ULrhm", t = "_description_rw8mf", i = "_timePickerField_4fodp", c = "_fieldInner_UTZUY", m = "_currentTime_dReP3", n = "_dropBtn_Moh49", s = "_timeSelect_d41Qr", r = "_times_BcmYs", _ = "_timeInput_hMH0v", o = "_ampm_HZ5i5", d = "_ampmActive_7Wbcf", l = {
|
|
2
2
|
fieldLabel: e,
|
|
3
3
|
description: t,
|
|
4
4
|
timePickerField: i,
|
|
5
|
-
fieldInner:
|
|
6
|
-
currentTime:
|
|
7
|
-
dropBtn:
|
|
5
|
+
fieldInner: c,
|
|
6
|
+
currentTime: m,
|
|
7
|
+
dropBtn: n,
|
|
8
8
|
timeSelect: s,
|
|
9
|
-
times:
|
|
10
|
-
timeInput:
|
|
11
|
-
ampm:
|
|
9
|
+
times: r,
|
|
10
|
+
timeInput: _,
|
|
11
|
+
ampm: o,
|
|
12
12
|
ampmActive: d
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
o as ampm,
|
|
16
16
|
d as ampmActive,
|
|
17
|
-
|
|
17
|
+
m as currentTime,
|
|
18
18
|
l as default,
|
|
19
19
|
t as description,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
n as dropBtn,
|
|
21
|
+
c as fieldInner,
|
|
22
22
|
e as fieldLabel,
|
|
23
|
-
|
|
23
|
+
_ as timeInput,
|
|
24
24
|
i as timePickerField,
|
|
25
25
|
s as timeSelect,
|
|
26
|
-
|
|
26
|
+
r as times
|
|
27
27
|
};
|
|
28
28
|
//# sourceMappingURL=TimePicker.module.scss.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as r } from "react";
|
|
2
2
|
import { useParams as U, useNavigate as C } from "react-router";
|
|
3
3
|
import { toast as t } from "react-toastify";
|
|
4
4
|
import { usePerformBackup as I, usePausePlan as N, useResumePlan as D, useGetPlan as F } from "../services/plans.js";
|
|
5
5
|
const J = () => {
|
|
6
|
-
const [f, m] =
|
|
6
|
+
const [f, m] = r(!1), [k, h] = r(!1), [w, S] = r(!1), [B, M] = r(!1), [y, E] = r(!1), { id: b } = U(), R = C(), l = I(), p = N(), d = D(), { data: c, isLoading: $, refetch: v, error: A } = F(b), s = (c == null ? void 0 : c.result) || {}, o = s.method === "sync", a = [...s.backups || []].sort((e, n) => n.started - e.started), i = a.filter((e) => e.inProgress), g = (s.restores || []).filter((e) => e.inProgress), L = o ? a.filter((e) => e.status === "completed")[0] : a[0], P = i.length > 0 || g.length > 0, u = p.isPending || d.isPending || l.isPending;
|
|
7
7
|
return {
|
|
8
8
|
// State
|
|
9
9
|
showDeleteModal: f,
|
|
@@ -20,7 +20,7 @@ const J = () => {
|
|
|
20
20
|
plan: s,
|
|
21
21
|
isLoading: $,
|
|
22
22
|
refetchPlan: v,
|
|
23
|
-
sortedHistory:
|
|
23
|
+
sortedHistory: a,
|
|
24
24
|
activeBackups: i,
|
|
25
25
|
activeRestores: g,
|
|
26
26
|
lastBackupItem: L,
|
|
@@ -54,19 +54,19 @@ const J = () => {
|
|
|
54
54
|
return t.error("A Backup/Restore Process is in Progress.");
|
|
55
55
|
if (u)
|
|
56
56
|
return;
|
|
57
|
-
const e = t.loading(`Starting ${
|
|
57
|
+
const e = t.loading(`Starting ${o ? "Sync" : "Backup"}...`);
|
|
58
58
|
l.mutate(s.id, {
|
|
59
59
|
onSuccess: (n) => {
|
|
60
60
|
t.update(e, {
|
|
61
|
-
render:
|
|
61
|
+
render: o ? (n == null ? void 0 : n.message) || "Sync initiated successfully! 🚀" : "Backup initiated successfully! 🚀",
|
|
62
62
|
type: "success",
|
|
63
63
|
isLoading: !1,
|
|
64
64
|
autoClose: 3e3
|
|
65
|
-
}),
|
|
65
|
+
}), o || R(`/plan/${s.id}?pendingbackup=1`);
|
|
66
66
|
},
|
|
67
67
|
onError: (n) => {
|
|
68
68
|
t.update(e, {
|
|
69
|
-
render: `${
|
|
69
|
+
render: `${o ? "Sync" : "Backup"} failed to start. ${(n == null ? void 0 : n.message) || "Unknown Error."}`,
|
|
70
70
|
type: "error",
|
|
71
71
|
isLoading: !1,
|
|
72
72
|
autoClose: !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePlanSingleActions.js","sources":["../../src/hooks/usePlanSingleActions.tsx"],"sourcesContent":["import { useState } from 'react';\r\nimport { useNavigate, useParams } from 'react-router';\r\nimport { toast } from 'react-toastify';\r\nimport { useGetPlan, usePausePlan, usePerformBackup, useResumePlan } from '../services/plans';\r\nimport { Plan } from '../@types/plans';\r\nimport { Backup } from '../@types/backups';\r\nimport { RestoreSlim } from '../@types/restores';\r\n\r\nexport const usePlanSingleActions = (): {\r\n showDeleteModal: boolean;\r\n setShowDeleteModal: (show: boolean) => void;\r\n showEditModal: boolean;\r\n setShowEditModal: (show: boolean) => void;\r\n showPruneModal: boolean;\r\n setShowPruneModal: (show: boolean) => void;\r\n showLogsModal: boolean;\r\n setShowLogsModal: (show: boolean) => void;\r\n showUnlockModal: boolean;\r\n setShowUnlockModal: (show: boolean) => void;\r\n plan: Plan;\r\n isLoading: boolean;\r\n refetchPlan: () => void;\r\n sortedHistory: Backup[];\r\n activeBackups: Backup[];\r\n activeRestores: RestoreSlim[];\r\n lastBackupItem: Backup;\r\n actionInProgress: boolean;\r\n taskPending: boolean;\r\n planError: any;\r\n changeStatus: () => void;\r\n backupNow: () => void;\r\n} => {\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n const [showEditModal, setShowEditModal] = useState(false);\r\n const [showUnlockModal, setShowUnlockModal] = useState(false);\r\n const [showPruneModal, setShowPruneModal] = useState(false);\r\n const [showLogsModal, setShowLogsModal] = useState(false);\r\n\r\n const { id } = useParams();\r\n const navigate = useNavigate();\r\n\r\n const performBackupMutation = usePerformBackup();\r\n const pauseMutation = usePausePlan();\r\n const resumeMutation = useResumePlan();\r\n\r\n const { data, isLoading, refetch: refetchPlan, error: planError } = useGetPlan(id as string);\r\n const plan: Plan = data?.result || {};\r\n\r\n const isSync = plan.method === 'sync';\r\n\r\n const sortedHistory = [...(plan.backups || [])].sort((a, b) => b.started - a.started);\r\n const activeBackups = sortedHistory.filter((s) => s.inProgress);\r\n const activeRestores = (plan.restores || []).filter((s) => s.
|
|
1
|
+
{"version":3,"file":"usePlanSingleActions.js","sources":["../../src/hooks/usePlanSingleActions.tsx"],"sourcesContent":["import { useState } from 'react';\r\nimport { useNavigate, useParams } from 'react-router';\r\nimport { toast } from 'react-toastify';\r\nimport { useGetPlan, usePausePlan, usePerformBackup, useResumePlan } from '../services/plans';\r\nimport { Plan } from '../@types/plans';\r\nimport { Backup } from '../@types/backups';\r\nimport { RestoreSlim } from '../@types/restores';\r\n\r\nexport const usePlanSingleActions = (): {\r\n showDeleteModal: boolean;\r\n setShowDeleteModal: (show: boolean) => void;\r\n showEditModal: boolean;\r\n setShowEditModal: (show: boolean) => void;\r\n showPruneModal: boolean;\r\n setShowPruneModal: (show: boolean) => void;\r\n showLogsModal: boolean;\r\n setShowLogsModal: (show: boolean) => void;\r\n showUnlockModal: boolean;\r\n setShowUnlockModal: (show: boolean) => void;\r\n plan: Plan;\r\n isLoading: boolean;\r\n refetchPlan: () => void;\r\n sortedHistory: Backup[];\r\n activeBackups: Backup[];\r\n activeRestores: RestoreSlim[];\r\n lastBackupItem: Backup;\r\n actionInProgress: boolean;\r\n taskPending: boolean;\r\n planError: any;\r\n changeStatus: () => void;\r\n backupNow: () => void;\r\n} => {\r\n const [showDeleteModal, setShowDeleteModal] = useState(false);\r\n const [showEditModal, setShowEditModal] = useState(false);\r\n const [showUnlockModal, setShowUnlockModal] = useState(false);\r\n const [showPruneModal, setShowPruneModal] = useState(false);\r\n const [showLogsModal, setShowLogsModal] = useState(false);\r\n\r\n const { id } = useParams();\r\n const navigate = useNavigate();\r\n\r\n const performBackupMutation = usePerformBackup();\r\n const pauseMutation = usePausePlan();\r\n const resumeMutation = useResumePlan();\r\n\r\n const { data, isLoading, refetch: refetchPlan, error: planError } = useGetPlan(id as string);\r\n const plan: Plan = data?.result || {};\r\n\r\n const isSync = plan.method === 'sync';\r\n\r\n const sortedHistory = [...(plan.backups || [])].sort((a, b) => b.started - a.started);\r\n const activeBackups = sortedHistory.filter((s) => s.inProgress);\r\n const activeRestores = (plan.restores || []).filter((s) => s.inProgress);\r\n const lastBackupItem = isSync ? sortedHistory.filter((s) => s.status === 'completed')[0] : sortedHistory[0];\r\n const actionInProgress = activeBackups.length > 0 || activeRestores.length > 0;\r\n const taskPending = pauseMutation.isPending || resumeMutation.isPending || performBackupMutation.isPending;\r\n\r\n const changeStatus = () => {\r\n if (activeBackups.length > 0) {\r\n return toast.error(`Can't pause a Plan while a Backup is in progress.`);\r\n }\r\n if (plan.inProgress || taskPending) {\r\n return;\r\n }\r\n // isActive, set it to false, else true\r\n // When the action is being performed, the item should grey out and stay inaccessible.\r\n if (plan.isActive) {\r\n toast.promise(pauseMutation.mutateAsync(plan.id), {\r\n pending: 'Pausing backup Plan...',\r\n success: 'Backup Plan Paused',\r\n error: {\r\n render({ data }: any) {\r\n return `Failed to Pause Backup Plan. ${data?.message || 'Unknown Error.'}`;\r\n },\r\n },\r\n });\r\n } else {\r\n toast.promise(resumeMutation.mutateAsync(plan.id), {\r\n pending: 'Resuming backup Plan...',\r\n success: 'Backup Plan Resumed',\r\n error: {\r\n render({ data }: any) {\r\n return `Failed to Resume Backup Plan. ${data?.message || 'Unknown Error.'}`;\r\n },\r\n },\r\n });\r\n }\r\n };\r\n\r\n const backupNow = () => {\r\n if (actionInProgress) {\r\n return toast.error('A Backup/Restore Process is in Progress.');\r\n }\r\n if (taskPending) {\r\n return;\r\n }\r\n\r\n const toastId = toast.loading(`Starting ${isSync ? 'Sync' : 'Backup'}...`);\r\n\r\n performBackupMutation.mutate(plan.id, {\r\n onSuccess: (data) => {\r\n toast.update(toastId, {\r\n render: isSync ? data?.message || 'Sync initiated successfully! 🚀' : 'Backup initiated successfully! 🚀',\r\n type: 'success',\r\n isLoading: false,\r\n autoClose: 3000,\r\n });\r\n if (!isSync) {\r\n navigate(`/plan/${plan.id}?pendingbackup=1`);\r\n }\r\n },\r\n onError: (error: any) => {\r\n toast.update(toastId, {\r\n render: `${isSync ? 'Sync' : 'Backup'} failed to start. ${error?.message || 'Unknown Error.'}`,\r\n type: 'error',\r\n isLoading: false,\r\n autoClose: false,\r\n closeButton: true,\r\n });\r\n },\r\n });\r\n };\r\n\r\n return {\r\n // State\r\n showDeleteModal,\r\n setShowDeleteModal,\r\n showEditModal,\r\n setShowEditModal,\r\n showPruneModal,\r\n setShowPruneModal,\r\n showLogsModal,\r\n setShowLogsModal,\r\n showUnlockModal,\r\n setShowUnlockModal,\r\n\r\n // Data\r\n plan,\r\n isLoading,\r\n refetchPlan,\r\n sortedHistory,\r\n activeBackups,\r\n activeRestores,\r\n lastBackupItem,\r\n actionInProgress,\r\n taskPending,\r\n planError,\r\n\r\n // Actions\r\n changeStatus,\r\n backupNow,\r\n };\r\n};\r\n"],"names":["usePlanSingleActions","showDeleteModal","setShowDeleteModal","useState","showEditModal","setShowEditModal","showUnlockModal","setShowUnlockModal","showPruneModal","setShowPruneModal","showLogsModal","setShowLogsModal","id","useParams","navigate","useNavigate","performBackupMutation","usePerformBackup","pauseMutation","usePausePlan","resumeMutation","useResumePlan","data","isLoading","refetchPlan","planError","useGetPlan","plan","isSync","sortedHistory","a","b","activeBackups","s","activeRestores","lastBackupItem","actionInProgress","taskPending","toast","toastId","error"],"mappings":";;;;AAQO,MAAMA,IAAuB,MAuB/B;AACF,QAAM,CAACC,GAAiBC,CAAkB,IAAIC,EAAS,EAAK,GACtD,CAACC,GAAeC,CAAgB,IAAIF,EAAS,EAAK,GAClD,CAACG,GAAiBC,CAAkB,IAAIJ,EAAS,EAAK,GACtD,CAACK,GAAgBC,CAAiB,IAAIN,EAAS,EAAK,GACpD,CAACO,GAAeC,CAAgB,IAAIR,EAAS,EAAK,GAElD,EAAE,IAAAS,EAAA,IAAOC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