Web: Client: Data Import: status pooling was corrected
This commit is contained in:
parent
1b8ba6be4f
commit
8e5a6f654a
@ -89,6 +89,8 @@ const ErrorBlock = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
const FAILS_TRIES = 1;
|
||||
|
||||
const SelectFileStep = ({
|
||||
t,
|
||||
onNextStep,
|
||||
@ -117,9 +119,10 @@ const SelectFileStep = ({
|
||||
const uploadInterval = useRef(null);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [failTries, setFailsTries] = useState(FAILS_TRIES);
|
||||
|
||||
const goBack = () => {
|
||||
cancelMigration();
|
||||
setTimeout(() => navigate("/portal-settings/data-import/migration"), 100);
|
||||
navigate("/portal-settings/data-import/migration");
|
||||
};
|
||||
|
||||
const checkMigrationStatusAndUpdate = async () => {
|
||||
@ -187,7 +190,6 @@ const SelectFileStep = ({
|
||||
};
|
||||
|
||||
const onUploadFile = async (file) => {
|
||||
setProgress(0);
|
||||
setIsVisible(true);
|
||||
try {
|
||||
if (file.length) {
|
||||
@ -195,23 +197,18 @@ const SelectFileStep = ({
|
||||
} else {
|
||||
await singleFileUploading(file, setProgress, isAbort);
|
||||
}
|
||||
|
||||
if (isAbort.current) return;
|
||||
|
||||
await initMigrationName(searchParams.get("service"));
|
||||
|
||||
uploadInterval.current = setInterval(async () => {
|
||||
try {
|
||||
const res = await getMigrationStatus();
|
||||
setProgress(res?.progress);
|
||||
|
||||
if (res.progress > 10) {
|
||||
setIsVisible(false);
|
||||
} else {
|
||||
setIsVisible(true);
|
||||
}
|
||||
|
||||
if (res.error || res.parseResult.failedArchives.length > 0) {
|
||||
setShowErrorText(true);
|
||||
} else {
|
||||
setShowErrorText(false);
|
||||
if (!res && failTries) {
|
||||
setFailsTries((tries) => tries - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!res || res.parseResult.failedArchives.length > 0 || res.error) {
|
||||
@ -219,12 +216,14 @@ const SelectFileStep = ({
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
clearInterval(uploadInterval.current);
|
||||
} else if (res.isCompleted || res.parseResult.progress === 100) {
|
||||
setShowErrorText(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.isCompleted || res.parseResult.progress === 100) {
|
||||
clearInterval(uploadInterval.current);
|
||||
setIsFileLoading(false);
|
||||
setIsVisible(false);
|
||||
setProgress(100);
|
||||
|
||||
if (
|
||||
res.parseResult.users.length +
|
||||
res.parseResult.existUsers.length +
|
||||
@ -239,12 +238,23 @@ const SelectFileStep = ({
|
||||
cancelMigration();
|
||||
}
|
||||
}
|
||||
|
||||
setProgress(res?.progress);
|
||||
|
||||
if (res.progress > 10) {
|
||||
setIsVisible(false);
|
||||
} else {
|
||||
setIsVisible(true);
|
||||
}
|
||||
setShowErrorText(false);
|
||||
} catch (error) {
|
||||
toastr.error(error || t("Common:SomethingWentWrong"));
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
setIsError(true);
|
||||
clearInterval(uploadInterval.current);
|
||||
} finally {
|
||||
isAbort.current = false;
|
||||
}
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
@ -259,6 +269,7 @@ const SelectFileStep = ({
|
||||
setIsFileError(false);
|
||||
setShowReminder(false);
|
||||
setIsFileLoading(true);
|
||||
setFailsTries(FAILS_TRIES);
|
||||
try {
|
||||
onUploadFile(file);
|
||||
} catch (error) {
|
||||
@ -286,7 +297,6 @@ const SelectFileStep = ({
|
||||
});
|
||||
} catch (error) {
|
||||
toastr.error(error);
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,6 +51,7 @@ const SelectUsersStep = ({
|
||||
}) => {
|
||||
const [dataPortion, setDataPortion] = useState(withEmailUsers.slice(0, 25));
|
||||
const [quota, setQuota] = useState({ used: 0, max: 0 });
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setSearchValue("");
|
||||
@ -83,7 +84,11 @@ const SelectUsersStep = ({
|
||||
|
||||
const goBack = () => {
|
||||
cancelMigration();
|
||||
setTimeout(onPrevStep, 100);
|
||||
setIsSaving(true);
|
||||
setTimeout(() => {
|
||||
setIsSaving(false);
|
||||
onPrevStep();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const totalUsedUsers =
|
||||
@ -103,6 +108,7 @@ const SelectUsersStep = ({
|
||||
saveButtonDisabled={
|
||||
areCheckedUsersEmpty || (quota.max && totalUsedUsers > quota.max)
|
||||
}
|
||||
isSaving={isSaving}
|
||||
/>
|
||||
|
||||
{quota.max && (
|
||||
@ -147,6 +153,7 @@ const SelectUsersStep = ({
|
||||
saveButtonDisabled={
|
||||
areCheckedUsersEmpty || (quota.max && totalUsedUsers > quota.max)
|
||||
}
|
||||
isSaving={isSaving}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
@ -96,7 +96,7 @@ const ImportCompleteStep = ({
|
||||
setIsSaving(true);
|
||||
setTimeout(() => {
|
||||
setIsSaving(false);
|
||||
setTimeout(() => navigate("/portal-settings/data-import/migration"), 100);
|
||||
navigate("/portal-settings/data-import/migration");
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,6 @@ import { SaveCancelButtons } from "@docspace/shared/components/save-cancel-butto
|
||||
import { Box } from "@docspace/shared/components/box";
|
||||
import { Link } from "@docspace/shared/components/link";
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
// import { mockRes } from "./tempMock";
|
||||
|
||||
const Wrapper = styled.div`
|
||||
max-width: 700px;
|
||||
@ -101,6 +100,8 @@ const ErrorBlock = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
const FAILS_TRIES = 1;
|
||||
|
||||
const SelectFileStep = ({
|
||||
t,
|
||||
incrementStep,
|
||||
@ -125,9 +126,10 @@ const SelectFileStep = ({
|
||||
const uploadInterval = useRef(null);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [failTries, setFailsTries] = useState(FAILS_TRIES);
|
||||
|
||||
const goBack = () => {
|
||||
cancelMigration();
|
||||
setTimeout(() => navigate("/portal-settings/data-import/migration"), 100);
|
||||
navigate("/portal-settings/data-import/migration");
|
||||
};
|
||||
|
||||
const checkMigrationStatusAndUpdate = async () => {
|
||||
@ -188,16 +190,41 @@ const SelectFileStep = ({
|
||||
};
|
||||
|
||||
const onUploadFile = async (file) => {
|
||||
setProgress(0);
|
||||
setIsVisible(true);
|
||||
try {
|
||||
if (Array.isArray(file)) throw new Error(t("Common:SomethingWentWrong"));
|
||||
|
||||
await singleFileUploading(file, setProgress, isAbort);
|
||||
|
||||
if (isAbort.current) return;
|
||||
|
||||
await initMigrationName(searchParams.get("service"));
|
||||
|
||||
uploadInterval.current = setInterval(async () => {
|
||||
try {
|
||||
const res = await getMigrationStatus();
|
||||
|
||||
if (!res && failTries) {
|
||||
setFailsTries((tries) => tries - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!res || res.parseResult.failedArchives.length > 0 || res.error) {
|
||||
clearInterval(uploadInterval.current);
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
toastr.error(res.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.isCompleted || res.parseResult.progress === 100) {
|
||||
clearInterval(uploadInterval.current);
|
||||
setIsFileLoading(false);
|
||||
setIsVisible(false);
|
||||
setUsers(res.parseResult);
|
||||
setIsSaveDisabled(true);
|
||||
}
|
||||
|
||||
setProgress(res.progress);
|
||||
|
||||
if (res.progress > 10) {
|
||||
@ -205,26 +232,14 @@ const SelectFileStep = ({
|
||||
} else {
|
||||
setIsVisible(true);
|
||||
}
|
||||
|
||||
if (!res || res.parseResult.failedArchives.length > 0 || res.error) {
|
||||
toastr.error(res.error);
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
clearInterval(uploadInterval.current);
|
||||
} else if (res.isCompleted || res.parseResult.progress === 100) {
|
||||
clearInterval(uploadInterval.current);
|
||||
setIsFileLoading(false);
|
||||
setIsVisible(false);
|
||||
setProgress(100);
|
||||
setUsers(res.parseResult);
|
||||
setIsSaveDisabled(true);
|
||||
}
|
||||
} catch (error) {
|
||||
toastr.error(error || error.message);
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
setIsError(true);
|
||||
clearInterval(uploadInterval.current);
|
||||
} finally {
|
||||
isAbort.current = false;
|
||||
}
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
@ -239,6 +254,7 @@ const SelectFileStep = ({
|
||||
setIsFileError(false);
|
||||
setIsSaveDisabled(false);
|
||||
setIsFileLoading(true);
|
||||
setFailsTries(FAILS_TRIES);
|
||||
try {
|
||||
onUploadFile(file);
|
||||
} catch (error) {
|
||||
@ -265,7 +281,6 @@ const SelectFileStep = ({
|
||||
window.URL.revokeObjectURL(url);
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
toastr.error(error);
|
||||
}
|
||||
};
|
||||
|
@ -55,6 +55,7 @@ const SelectUsersStep = (props) => {
|
||||
|
||||
const [dataPortion, setDataPortion] = useState(withEmailUsers.slice(0, 25));
|
||||
const [quota, setQuota] = useState({ used: 0, max: 0 });
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setSearchValue("");
|
||||
@ -82,7 +83,11 @@ const SelectUsersStep = (props) => {
|
||||
|
||||
const goBack = () => {
|
||||
cancelMigration();
|
||||
setTimeout(decrementStep, 100);
|
||||
setIsSaving(true);
|
||||
setTimeout(() => {
|
||||
setIsSaving(false);
|
||||
decrementStep();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const numberOfSelectedUsers =
|
||||
@ -105,6 +110,7 @@ const SelectUsersStep = (props) => {
|
||||
cancelButtonLabel={t("Common:Back")}
|
||||
showReminder
|
||||
displaySettings
|
||||
isSaving={isSaving}
|
||||
/>
|
||||
|
||||
{quota.max && (
|
||||
@ -151,6 +157,7 @@ const SelectUsersStep = (props) => {
|
||||
cancelButtonLabel={t("Common:Back")}
|
||||
showReminder
|
||||
displaySettings
|
||||
isSaving={isSaving}
|
||||
/>
|
||||
)}
|
||||
</Wrapper>
|
||||
|
@ -107,7 +107,7 @@ const ImportCompleteStep = ({
|
||||
setIsSaving(true);
|
||||
setTimeout(() => {
|
||||
setIsSaving(false);
|
||||
setTimeout(() => navigate("/portal-settings/data-import/migration"), 100);
|
||||
navigate("/portal-settings/data-import/migration")
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
|
@ -89,6 +89,8 @@ const ErrorBlock = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
const FAILS_TRIES = 1;
|
||||
|
||||
const SelectFileStep = ({
|
||||
t,
|
||||
onNextStep,
|
||||
@ -115,9 +117,10 @@ const SelectFileStep = ({
|
||||
const uploadInterval = useRef(null);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [failTries, setFailsTries] = useState(FAILS_TRIES);
|
||||
|
||||
const goBack = () => {
|
||||
cancelMigration();
|
||||
setTimeout(() => navigate("/portal-settings/data-import/migration"), 100);
|
||||
navigate("/portal-settings/data-import/migration");
|
||||
};
|
||||
|
||||
const checkMigrationStatusAndUpdate = async () => {
|
||||
@ -178,20 +181,45 @@ const SelectFileStep = ({
|
||||
};
|
||||
|
||||
const onUploadFile = async (file) => {
|
||||
setProgress(0);
|
||||
setIsVisible(true);
|
||||
try {
|
||||
if (Array.isArray(file)) {
|
||||
setShowErrorText(true);
|
||||
throw new Error(t("Common:SomethingWentWrong"));
|
||||
}
|
||||
|
||||
await singleFileUploading(file, setProgress, isAbort);
|
||||
|
||||
if (isAbort.current) return;
|
||||
|
||||
await initMigrationName(searchParams.get("service"));
|
||||
|
||||
uploadInterval.current = setInterval(async () => {
|
||||
try {
|
||||
const res = await getMigrationStatus();
|
||||
setProgress(res?.progress);
|
||||
|
||||
if (!res && failTries) {
|
||||
setFailsTries((tries) => tries - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!res || res.parseResult.failedArchives.length > 0 || res.error) {
|
||||
toastr.error(res.error || t("Common:SomethingWentWrong"));
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
clearInterval(uploadInterval.current);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.isCompleted || res.parseResult.progress === 100) {
|
||||
clearInterval(uploadInterval.current);
|
||||
setIsFileLoading(false);
|
||||
setIsVisible(false);
|
||||
setUsers(res.parseResult);
|
||||
setShowReminder(true);
|
||||
}
|
||||
|
||||
setProgress(res.progress);
|
||||
|
||||
if (res.progress > 10) {
|
||||
setIsVisible(false);
|
||||
@ -204,26 +232,14 @@ const SelectFileStep = ({
|
||||
} else {
|
||||
setShowErrorText(false);
|
||||
}
|
||||
|
||||
if (!res || res.parseResult.failedArchives.length > 0 || res.error) {
|
||||
toastr.error(res.error || t("Common:SomethingWentWrong"));
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
clearInterval(uploadInterval.current);
|
||||
} else if (res.isCompleted || res.parseResult.progress === 100) {
|
||||
clearInterval(uploadInterval.current);
|
||||
setIsFileLoading(false);
|
||||
setIsVisible(false);
|
||||
setProgress(100);
|
||||
setUsers(res.parseResult);
|
||||
setShowReminder(true);
|
||||
}
|
||||
} catch (error) {
|
||||
toastr.error(error || t("Common:SomethingWentWrong"));
|
||||
setIsFileError(true);
|
||||
setIsFileLoading(false);
|
||||
setIsError(true);
|
||||
clearInterval(uploadInterval.current);
|
||||
} finally {
|
||||
isAbort.current = false;
|
||||
}
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
@ -238,6 +254,7 @@ const SelectFileStep = ({
|
||||
setIsFileError(false);
|
||||
setShowReminder(false);
|
||||
setIsFileLoading(true);
|
||||
setFailsTries(FAILS_TRIES);
|
||||
try {
|
||||
onUploadFile(file);
|
||||
} catch (error) {
|
||||
@ -265,7 +282,6 @@ const SelectFileStep = ({
|
||||
});
|
||||
} catch (error) {
|
||||
toastr.error(error);
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,6 +51,7 @@ const SelectUsersStep = ({
|
||||
}) => {
|
||||
const [dataPortion, setDataPortion] = useState(withEmailUsers.slice(0, 25));
|
||||
const [quota, setQuota] = useState({ used: 0, max: 0 });
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setSearchValue("");
|
||||
@ -83,7 +84,11 @@ const SelectUsersStep = ({
|
||||
|
||||
const goBack = () => {
|
||||
cancelMigration();
|
||||
setTimeout(onPrevStep, 100);
|
||||
setIsSaving(true);
|
||||
setTimeout(() => {
|
||||
setIsSaving(false);
|
||||
onPrevStep();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const totalUsedUsers =
|
||||
@ -103,6 +108,7 @@ const SelectUsersStep = ({
|
||||
saveButtonDisabled={
|
||||
areCheckedUsersEmpty || (quota.max && totalUsedUsers > quota.max)
|
||||
}
|
||||
isSaving={isSaving}
|
||||
/>
|
||||
|
||||
{quota.max && (
|
||||
@ -147,6 +153,7 @@ const SelectUsersStep = ({
|
||||
saveButtonDisabled={
|
||||
areCheckedUsersEmpty || (quota.max && totalUsedUsers > quota.max)
|
||||
}
|
||||
isSaving={isSaving}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
@ -102,7 +102,9 @@ class ImportAccountsStore {
|
||||
get filteredUsers() {
|
||||
return this.users.result.filter(
|
||||
(user) =>
|
||||
!this.users.existing.some((existingUser) => existingUser.key === user.key),
|
||||
!this.users.existing.some(
|
||||
(existingUser) => existingUser.key === user.key,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -290,8 +292,6 @@ class ImportAccountsStore {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
isAbort.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -331,8 +331,6 @@ class ImportAccountsStore {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
isAbort.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user