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 { EditorWrapper } from "./StyledEditor";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import useSharingDialog from "./helpers/useSharingDialog"; import {
import useSelectFileDialog from "./helpers/useSelectFileDialog"; useFilesUtils,
import useSelectFolderDialog from "./helpers/useSelectFolderDialog"; useSelectFileDialog,
import useFilesUtils from "./helpers/useFilesUtils"; useSelectFolderDialog,
useSharingDialog,
} from "./hooks";
const LoaderComponent = ( const LoaderComponent = (
<Loader <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 React from "react";
import { loadComponent } from "../components/dynamic"; import { loadComponent } from "../components/dynamic";
import { FILES_SCOPE } from "./constants"; import { FILES_SCOPE } from "../helpers/constants";
function useFilesUtils() { function useFilesUtils() {
React.useEffect(() => { React.useEffect(() => {
if (document.getElementById(FILES_SCOPE)) { if (document.getElementById(FILES_SCOPE)) {

View File

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

View File

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

View File

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