Web: Refactoring.
This commit is contained in:
parent
ea78cff437
commit
02fb8738ce
@ -195,9 +195,7 @@ const EditRoomEvent = ({
|
||||
actions.push(removeTagsFromRoom(room.id, removedTags));
|
||||
|
||||
if (watermarksSettings && !isNotWatermarkSet()) {
|
||||
const request = !watermarksSettings.enabled
|
||||
? deleteWatermarkSettings(room.id)
|
||||
: setWatermarkSettings(room.id, watermarksSettings);
|
||||
const request = setWatermarkSettings(room.id, watermarksSettings);
|
||||
|
||||
actions.push(request);
|
||||
}
|
||||
@ -300,6 +298,7 @@ const EditRoomEvent = ({
|
||||
const [tags, watermarks] = await Promise.all(requests);
|
||||
|
||||
setFetchedTags(tags);
|
||||
console.log("watermarks", watermarks);
|
||||
setWatermarks(watermarks, true);
|
||||
|
||||
setIsInitLoading(false);
|
||||
|
@ -7,7 +7,7 @@ import { Text } from "@docspace/shared/components/text";
|
||||
import { ToggleButton } from "@docspace/shared/components/toggle-button";
|
||||
|
||||
import FileLifetime from "./FileLifetime";
|
||||
import Watermarks from "../sub-components/Watermarks";
|
||||
import WatermarkBlock from "./Watermarks/WatermarkBlock";
|
||||
|
||||
const StyledVirtualDataRoomBlock = styled.div`
|
||||
.virtual-data-room-block {
|
||||
@ -68,21 +68,11 @@ const Block = ({
|
||||
);
|
||||
};
|
||||
|
||||
const VirtualDataRoomBlock = ({
|
||||
t,
|
||||
roomParams,
|
||||
setRoomParams,
|
||||
isEdit = false,
|
||||
isWatermarks = false,
|
||||
setWatermarks,
|
||||
}) => {
|
||||
const VirtualDataRoomBlock = ({ t, roomParams, setRoomParams, isEdit }) => {
|
||||
const role = t("Translations:RoleViewer");
|
||||
|
||||
const [fileLifetimeChecked, setFileLifetimeChecked] = useState(false);
|
||||
const [copyAndDownloadChecked, setCopyAndDownloadChecked] = useState(false);
|
||||
const [watermarksChecked, setWatermarksChecked] = useState(
|
||||
isWatermarks && isEdit,
|
||||
);
|
||||
|
||||
const onChangeAutomaticIndexing = () => {
|
||||
setRoomParams({ ...roomParams, indexing: !roomParams.indexing });
|
||||
@ -96,12 +86,6 @@ const VirtualDataRoomBlock = ({
|
||||
setCopyAndDownloadChecked(!copyAndDownloadChecked);
|
||||
};
|
||||
|
||||
const onChangeAddWatermarksToDocuments = () => {
|
||||
setWatermarksChecked(!watermarksChecked);
|
||||
|
||||
setWatermarks({ enabled: !watermarksChecked });
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledVirtualDataRoomBlock>
|
||||
<Block
|
||||
@ -132,24 +116,10 @@ const VirtualDataRoomBlock = ({
|
||||
isDisabled={false}
|
||||
isChecked={copyAndDownloadChecked}
|
||||
></Block>
|
||||
<Block
|
||||
headerText={t("AddWatermarksToDocuments")}
|
||||
bodyText={t("AddWatermarksToDocumentsDescription")}
|
||||
onChange={onChangeAddWatermarksToDocuments}
|
||||
isDisabled={false}
|
||||
isChecked={watermarksChecked}
|
||||
>
|
||||
<Watermarks setRoomParams={setRoomParams} isEdit={isEdit} />
|
||||
</Block>
|
||||
|
||||
<WatermarkBlock BlockComponent={Block} t={t} isEdit={isEdit} />
|
||||
</StyledVirtualDataRoomBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject(({ createEditRoomStore }) => {
|
||||
const { watermarksSettings, setWatermarks } = createEditRoomStore;
|
||||
|
||||
return {
|
||||
setWatermarks,
|
||||
isWatermarks: watermarksSettings?.enabled,
|
||||
};
|
||||
})(observer(VirtualDataRoomBlock));
|
||||
export default VirtualDataRoomBlock;
|
||||
|
@ -117,13 +117,13 @@ const ImageWatermark = ({
|
||||
const initialInfoRef = initialInfo.current;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEdit)
|
||||
setWatermarks(
|
||||
{
|
||||
rotate: initialInfoRef.rotate.key,
|
||||
imageScale: initialInfoRef.scale.key,
|
||||
imageUrl: initialInfoRef.url,
|
||||
text: "",
|
||||
enabled: true,
|
||||
additions: 0,
|
||||
},
|
||||
true,
|
||||
@ -138,8 +138,7 @@ const ImageWatermark = ({
|
||||
|
||||
imageProcessing(file)
|
||||
.then((f) => {
|
||||
if (f instanceof File)
|
||||
setWatermarks({ ...watermarksSettings, image: f });
|
||||
if (f instanceof File) setWatermarks({ image: f });
|
||||
})
|
||||
.catch((error) => {
|
||||
if (
|
||||
@ -153,13 +152,13 @@ const ImageWatermark = ({
|
||||
const onScaleChange = (item) => {
|
||||
setScale(item);
|
||||
|
||||
setWatermarks({ ...watermarksSettings, imageScale: item.key });
|
||||
setWatermarks({ imageScale: item.key });
|
||||
};
|
||||
|
||||
const onRotateChange = (item) => {
|
||||
setRotate(item);
|
||||
|
||||
setWatermarks({ ...watermarksSettings, rotate: item.key });
|
||||
setWatermarks({ rotate: item.key });
|
||||
};
|
||||
|
||||
const rotateItems = () => {
|
||||
|
@ -136,11 +136,11 @@ const ViewerInfoWatermark = ({
|
||||
const initialInfoRef = initialInfo.current;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEdit)
|
||||
setWatermarks(
|
||||
{
|
||||
rotate: initialInfoRef.rotate.key,
|
||||
text: initialInfoRef.text,
|
||||
enabled: true,
|
||||
additions: initialInfoRef.additions,
|
||||
},
|
||||
true,
|
||||
@ -167,20 +167,20 @@ const ViewerInfoWatermark = ({
|
||||
flagsCount += WatermarkAdditions[key];
|
||||
}
|
||||
}
|
||||
setWatermarks({ ...watermarksSettings, additions: flagsCount });
|
||||
setWatermarks({ additions: flagsCount });
|
||||
};
|
||||
|
||||
const onPositionChange = (item) => {
|
||||
setSelectedPosition(item);
|
||||
|
||||
setWatermarks({ ...watermarksSettings, rotate: item.key });
|
||||
setWatermarks({ rotate: item.key });
|
||||
};
|
||||
|
||||
const onTextChange = (e) => {
|
||||
const { value } = e.target;
|
||||
setTextValue(value);
|
||||
|
||||
setWatermarks({ ...watermarksSettings, text: value });
|
||||
setWatermarks({ text: value });
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -0,0 +1,98 @@
|
||||
// (c) Copyright Ascensio System SIA 2009-2024
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
||||
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
||||
// any third-party rights.
|
||||
//
|
||||
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
// (c) Copyright Ascensio System SIA 2009-2024
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
||||
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
||||
// any third-party rights.
|
||||
//
|
||||
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
import Watermarks from "./index";
|
||||
|
||||
const WatermarkBlock = ({
|
||||
BlockComponent,
|
||||
setWatermarks,
|
||||
isEdit = false,
|
||||
isWatermarks = false,
|
||||
t,
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
console.log("!!!!watermarksChecked", watermarksChecked);
|
||||
if (!isEdit) setWatermarks({ enabled: watermarksChecked }, true);
|
||||
}, []);
|
||||
|
||||
const [watermarksChecked, setWatermarksChecked] = useState(
|
||||
isWatermarks && isEdit,
|
||||
);
|
||||
const onChangeAddWatermarksToDocuments = () => {
|
||||
setWatermarksChecked(!watermarksChecked);
|
||||
|
||||
setWatermarks({ enabled: !watermarksChecked });
|
||||
};
|
||||
return (
|
||||
<BlockComponent
|
||||
headerText={t("AddWatermarksToDocuments")}
|
||||
bodyText={t("AddWatermarksToDocumentsDescription")}
|
||||
onChange={onChangeAddWatermarksToDocuments}
|
||||
isDisabled={false}
|
||||
isChecked={watermarksChecked}
|
||||
>
|
||||
<Watermarks isEdit={isEdit} />
|
||||
</BlockComponent>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject(({ createEditRoomStore }) => {
|
||||
const { setWatermarks, watermarksSettings } = createEditRoomStore;
|
||||
return {
|
||||
setWatermarks,
|
||||
|
||||
isWatermarks: watermarksSettings?.enabled,
|
||||
};
|
||||
})(observer(WatermarkBlock));
|
@ -101,7 +101,10 @@ class CreateEditRoomStore {
|
||||
this.initialWatermarksSettings = watermarksSettings;
|
||||
}
|
||||
|
||||
this.watermarksSettings = watermarksSettings;
|
||||
this.watermarksSettings = {
|
||||
...this.watermarksSettings,
|
||||
...watermarksSettings,
|
||||
};
|
||||
};
|
||||
|
||||
setIsImageWatermarkType = (isImageType, isInit) => {
|
||||
@ -119,7 +122,6 @@ class CreateEditRoomStore {
|
||||
};
|
||||
|
||||
isNotWatermarkSet = () => {
|
||||
|
||||
if (this.isImageType && !this.watermarksSettings.image) return true;
|
||||
|
||||
if (!this.isImageType && this.watermarksSettings.additions === 0)
|
||||
@ -226,7 +228,11 @@ class CreateEditRoomStore {
|
||||
|
||||
const requests = [];
|
||||
|
||||
if (this.watermarksSettings && !this.isNotWatermarkSet()) {
|
||||
if (
|
||||
this.watermarksSettings &&
|
||||
!this.isNotWatermarkSet() &&
|
||||
this.watermarksSettings.enabled
|
||||
) {
|
||||
requests.push(this.getWatermarkRequest(room));
|
||||
}
|
||||
// delete thirdparty account if not needed
|
||||
|
Loading…
Reference in New Issue
Block a user