Client: Add opening export file in same/new tab depending on setting. Move jsx out of mobx
This commit is contained in:
parent
e5dd58ac08
commit
b220f57954
57
packages/client/src/helpers/toast-helpers.tsx
Normal file
57
packages/client/src/helpers/toast-helpers.tsx
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// (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 { TFunction } from "i18next";
|
||||||
|
|
||||||
|
import { Link, LinkTarget } from "@docspace/shared/components/link";
|
||||||
|
import { Text } from "@docspace/shared/components/text";
|
||||||
|
import { toastr } from "@docspace/shared/components/toast";
|
||||||
|
|
||||||
|
export const showSuccessExportRoomIndexToast = (
|
||||||
|
t: TFunction,
|
||||||
|
fileName: string,
|
||||||
|
fileUrl: string,
|
||||||
|
openOnNewPage: boolean,
|
||||||
|
) => {
|
||||||
|
const toastMessage = (
|
||||||
|
<>
|
||||||
|
<Link
|
||||||
|
color="#5299E0"
|
||||||
|
fontSize="12px"
|
||||||
|
target={openOnNewPage ? LinkTarget.blank : LinkTarget.self}
|
||||||
|
href={fileUrl}
|
||||||
|
>
|
||||||
|
{fileName}
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Text as="span" fontSize="12px">
|
||||||
|
{t<string>("Files:FileExportedToMyDocuments")}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
toastr.success(toastMessage);
|
||||||
|
};
|
@ -89,8 +89,6 @@ import saveAs from "file-saver";
|
|||||||
import { isMobile, isIOS, isTablet } from "react-device-detect";
|
import { isMobile, isIOS, isTablet } from "react-device-detect";
|
||||||
import config from "PACKAGE_FILE";
|
import config from "PACKAGE_FILE";
|
||||||
import { toastr } from "@docspace/shared/components/toast";
|
import { toastr } from "@docspace/shared/components/toast";
|
||||||
import { Link } from "@docspace/shared/components/link";
|
|
||||||
import { Text } from "@docspace/shared/components/text";
|
|
||||||
import { combineUrl } from "@docspace/shared/utils/combineUrl";
|
import { combineUrl } from "@docspace/shared/utils/combineUrl";
|
||||||
import { isDesktop } from "@docspace/shared/utils";
|
import { isDesktop } from "@docspace/shared/utils";
|
||||||
import { getDefaultAccessUser } from "@docspace/shared/utils/getDefaultAccessUser";
|
import { getDefaultAccessUser } from "@docspace/shared/utils/getDefaultAccessUser";
|
||||||
@ -117,6 +115,7 @@ import { getFileLink, getFolderLink } from "@docspace/shared/api/files";
|
|||||||
import { resendInvitesAgain } from "@docspace/shared/api/people";
|
import { resendInvitesAgain } from "@docspace/shared/api/people";
|
||||||
import { checkDialogsOpen } from "@docspace/shared/utils/checkDialogsOpen";
|
import { checkDialogsOpen } from "@docspace/shared/utils/checkDialogsOpen";
|
||||||
import { PRODUCT_NAME } from "@docspace/shared/constants";
|
import { PRODUCT_NAME } from "@docspace/shared/constants";
|
||||||
|
import { showSuccessExportRoomIndexToast } from "SRC_DIR/helpers/toast-helpers";
|
||||||
|
|
||||||
const LOADER_TIMER = 500;
|
const LOADER_TIMER = 500;
|
||||||
let loadingTime;
|
let loadingTime;
|
||||||
@ -928,20 +927,11 @@ class ContextOptionsStore {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
showSuccessExportRoomIndexToast = (t, fileName, fileUrl) => {
|
onSuccessExportRoomIndex = (t, fileName, fileUrl) => {
|
||||||
const toastMessage = (
|
const { openOnNewPage } = this.filesSettingsStore;
|
||||||
<>
|
const urlWithProxy = combineUrl(window.DocSpaceConfig?.proxy?.url, fileUrl);
|
||||||
<Link color="#5299E0" fontSize="12px" target="_blank" href={fileUrl}>
|
|
||||||
{fileName}
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Text as="span" fontSize="12px">
|
|
||||||
{t("Files:FileExportedToMyDocuments")}
|
|
||||||
</Text>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
toastr.success(toastMessage);
|
showSuccessExportRoomIndexToast(t, fileName, urlWithProxy, openOnNewPage);
|
||||||
};
|
};
|
||||||
|
|
||||||
onExportRoomIndex = async (t, roomId) => {
|
onExportRoomIndex = async (t, roomId) => {
|
||||||
@ -960,16 +950,7 @@ class ContextOptionsStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (res.status === ExportRoomIndexTaskStatus.Completed) {
|
if (res.status === ExportRoomIndexTaskStatus.Completed) {
|
||||||
const urlWithProxy = combineUrl(
|
this.onSuccessExportRoomIndex(t, res.resultFileName, res.resultFileUrl);
|
||||||
window.DocSpaceConfig?.proxy?.url,
|
|
||||||
res.resultFileUrl,
|
|
||||||
);
|
|
||||||
|
|
||||||
this.showSuccessExportRoomIndexToast(
|
|
||||||
t,
|
|
||||||
res.resultFileName,
|
|
||||||
urlWithProxy,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
toastr.error(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user