Web: Doceditor: refactoring hooks

This commit is contained in:
Artem Tarasov 2022-03-20 22:15:39 +03:00
parent 663fad253b
commit 53842400ce
6 changed files with 20 additions and 11 deletions

View File

@ -17,10 +17,12 @@ import {
import { EditorWrapper } from "./StyledEditor";
import { useTranslation } from "react-i18next";
import useSharingDialog from "./helpers/useSharingDialog";
import useSelectFileDialog from "./helpers/useSelectFileDialog";
import useSelectFolderDialog from "./helpers/useSelectFolderDialog";
import useFilesUtils from "./helpers/useFilesUtils";
import {
useFilesUtils,
useSelectFileDialog,
useSelectFolderDialog,
useSharingDialog,
} from "./hooks";
const LoaderComponent = (
<Loader

View File

@ -0,0 +1,4 @@
export { default as useFilesUtils } from "./useFilesUtils";
export { default as useSelectFileDialog } from "./useSelectFileDialog";
export { default as useSelectFolderDialog } from "./useSelectFolderDialog";
export { default as useSharingDialog } from "./useSharingDialog";

View File

@ -1,6 +1,6 @@
import React from "react";
import { loadComponent } from "../components/dynamic";
import { FILES_SCOPE } from "./constants";
import { FILES_SCOPE } from "../helpers/constants";
function useFilesUtils() {
React.useEffect(() => {
if (document.getElementById(FILES_SCOPE)) {

View File

@ -1,6 +1,7 @@
import React, { useState } from "react";
import DynamicComponent from "../components/dynamic";
import { getPresignedUri } from "@appserver/common/api/files";
import { FILES_REMOTE_ENTRY_URL, FILES_SCOPE } from "../helpers/constants";
const insertImageAction = "imageFileType";
const mailMergeAction = "mailMergeFileType";
@ -122,8 +123,8 @@ function useSelectFileDialog(docEditor, t) {
typeof window !== "undefined" && isFileDialogVisible ? (
<DynamicComponent
system={{
scope: "files",
url: "/products/files/remoteEntry.js",
scope: FILES_SCOPE,
url: FILES_REMOTE_ENTRY_URL,
module: "./SelectFileDialog",
}}
resetTreeFolders

View File

@ -4,6 +4,7 @@ import Text from "@appserver/components/text";
import TextInput from "@appserver/components/text-input";
import Checkbox from "@appserver/components/checkbox";
import { StyledSelectFolder } from "../StyledEditor";
import { FILES_REMOTE_ENTRY_URL, FILES_SCOPE } from "../helpers/constants";
function useSelectFolderDialog(t) {
const [isFolderDialogVisible, setIsFolderDialogVisible] = useState(false);
@ -71,8 +72,8 @@ function useSelectFolderDialog(t) {
asideHeightContent="calc(100% - 50px)"
foldersType="exceptSortedByTags"
system={{
scope: "files",
url: "/products/files/remoteEntry.js",
scope: FILES_SCOPE,
url: FILES_REMOTE_ENTRY_URL,
module: "./SelectFolderDialog",
}}
isPanelVisible={isFolderDialogVisible}

View File

@ -1,5 +1,6 @@
import React, { useState } from "react";
import DynamicComponent from "../components/dynamic";
import { FILES_REMOTE_ENTRY_URL, FILES_SCOPE } from "../helpers/constants";
function useSharingDialog(fileInfo, fileId, docEditor) {
const [isVisible, setIsVisible] = useState(false);
@ -23,8 +24,8 @@ function useSharingDialog(fileInfo, fileId, docEditor) {
<DynamicComponent
className="dynamic-sharing-dialog"
system={{
scope: "files",
url: "/products/files/remoteEntry.js",
scope: FILES_SCOPE,
url: FILES_REMOTE_ENTRY_URL,
module: "./SharingDialog",
name: "SharingDialog",
}}