Merge branch 'release/v2.6.0' into hotfix/v2.6.1

This commit is contained in:
Alexey Safronov 2024-07-26 15:31:25 +04:00
commit 0685910347
5 changed files with 44 additions and 8 deletions

View File

@ -32,7 +32,7 @@ import FilesFilter from "@docspace/shared/api/files/filter";
import RoomsFilter from "@docspace/shared/api/rooms/filter";
import { getGroup } from "@docspace/shared/api/groups";
import { getUserById } from "@docspace/shared/api/people";
import { MEDIA_VIEW_URL } from "@docspace/shared/constants";
import { CREATED_FORM_KEY, MEDIA_VIEW_URL } from "@docspace/shared/constants";
import {
Events,
@ -78,6 +78,7 @@ const useFiles = ({
scrollToTop,
selectedFolderStore,
wsCreatedPDFForm,
}) => {
const navigate = useNavigate();
const { id } = useParams();
@ -292,7 +293,15 @@ const useFiles = ({
);
} else {
const folderId = filter.folder;
return fetchFiles(folderId, filter);
return fetchFiles(folderId, filter)?.finally(() => {
const data = sessionStorage.getItem(CREATED_FORM_KEY);
if (data) {
wsCreatedPDFForm({
data,
});
sessionStorage.removeItem(CREATED_FORM_KEY);
}
});
}
}

View File

@ -160,6 +160,7 @@ const PureHome = (props) => {
getFolderModel,
scrollToTop,
isEmptyGroups,
wsCreatedPDFForm,
} = props;
//console.log(t("ComingSoon"))
@ -206,6 +207,7 @@ const PureHome = (props) => {
scrollToTop,
selectedFolderStore,
wsCreatedPDFForm,
});
const { showUploadPanel } = useOperations({
@ -500,6 +502,7 @@ export default inject(
removeTagsFromRoom,
getRooms,
scrollToTop,
wsCreatedPDFForm,
} = filesStore;
const { updateProfileCulture } = peopleStore.targetUserStore;
@ -686,6 +689,7 @@ export default inject(
getFolderModel,
scrollToTop,
isEmptyGroups,
wsCreatedPDFForm,
};
},
)(observer(Home));

View File

@ -34,7 +34,7 @@ import {
} from "@docspace/shared/api/files";
// import { getOperationProgress } from "@docspace/shared/utils/getOperationProgress";
import { toastr } from "@docspace/shared/components/toast";
import { EDITOR_ID } from "@docspace/shared/constants";
import { CREATED_FORM_KEY, EDITOR_ID } from "@docspace/shared/constants";
import type {
TFile,
@ -52,6 +52,13 @@ import type { TData } from "@docspace/shared/components/toast/Toast.type";
import { saveAs } from "@/utils";
import type { ConflictStateType } from "@/types";
type SuccessResponseType = {
form: TFile;
message: string;
};
type FaildResponseType = string;
type ResponseType = SuccessResponseType | FaildResponseType;
const DefaultConflictDataDialogState: ConflictStateType = {
visible: false,
resolve: () => {},
@ -70,6 +77,12 @@ const hasFileUrl = (arg: object): arg is { data: { url: string } } => {
);
};
const isSuccessResponse = (
res: ResponseType | undefined,
): res is SuccessResponseType => {
return Boolean(res) && typeof res === "object" && "form" in res;
};
const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => {
// const { t } = useTranslation(["Common"]);
const resolveRef = useRef<(value: string | PromiseLike<string>) => void>();
@ -179,14 +192,22 @@ const useStartFillingSelectDialog = (fileInfo: TFile | undefined) => {
const fileUrl = await getFileUrl();
const response = await saveAs(
const response = await saveAs<ResponseType>(
fileInfo.title,
fileUrl,
selectedItemId,
false,
"createForm",
);
const [key, value] = response?.split(":") ?? [];
if (isSuccessResponse(response)) {
const { form } = response;
sessionStorage.setItem(CREATED_FORM_KEY, JSON.stringify(form));
}
const [key, value] =
typeof response === "string" ? response.split(":") : [];
// await copyToFolder(
// Number(selectedItemId),

View File

@ -101,14 +101,15 @@ export const getDataSaveAs = async (params: string) => {
}
};
export const saveAs = (
export const saveAs = <T = string>(
title: string,
url: string,
folderId: string | number,
openNewTab: boolean,
action = "create",
) => {
const options = {
action: "create",
action,
fileuri: url,
title: title,
folderid: folderId,
@ -117,7 +118,7 @@ export const saveAs = (
const params = toUrlParams(options, true);
if (!openNewTab) {
return getDataSaveAs(params);
return getDataSaveAs(params) as Promise<T>;
} else {
const handlerUrl = combineUrl(
window.ClientConfig?.proxy?.url,

View File

@ -53,6 +53,7 @@ export const ROOM = "room";
export const USERS = "users";
export const USERS_IN_ROOM = "usersInRoom";
export const PDF_FORM_DIALOG_KEY = "pdf_form_dialog";
export const CREATED_FORM_KEY = "created_form_key";
export const COUNT_FOR_SHOWING_BAR = 2;
export const PERCENTAGE_FOR_SHOWING_BAR = 90;