diff --git a/packages/client/src/components/panels/EmbeddingPanel/index.tsx b/packages/client/src/components/panels/EmbeddingPanel/index.tsx
index 39999cb4c1..3b4325aa9f 100644
--- a/packages/client/src/components/panels/EmbeddingPanel/index.tsx
+++ b/packages/client/src/components/panels/EmbeddingPanel/index.tsx
@@ -44,9 +44,6 @@ import { ComboBox, TOption } from "@docspace/shared/components/combobox";
import { TData } from "@docspace/shared/components/toast/Toast.type";
import { TTranslation } from "@docspace/shared/types";
import { TColorScheme, TTheme } from "@docspace/shared/themes";
-
-import { SettingsStore } from "@docspace/shared/store/SettingsStore";
-import { UserStore } from "@docspace/shared/store/UserStore";
import {
ModalDialog,
ModalDialogType,
@@ -65,8 +62,6 @@ import { StyledModalDialog, StyledBody } from "./StyledEmbeddingPanel";
import { DisplayBlock } from "./sub-components/DisplayBlock";
import { CheckboxElement } from "./sub-components/CheckboxElement";
-import PublicRoomStore from "../../../store/PublicRoomStore";
-import DialogsStore from "../../../store/DialogsStore";
type LinkParamsLinkShareToType = {
denyDownload: boolean;
diff --git a/packages/client/src/pages/Home/InfoPanel/Body/views/Members/index.js b/packages/client/src/pages/Home/InfoPanel/Body/views/Members/index.js
index ab938c824e..ce42e7a44e 100644
--- a/packages/client/src/pages/Home/InfoPanel/Body/views/Members/index.js
+++ b/packages/client/src/pages/Home/InfoPanel/Body/views/Members/index.js
@@ -29,7 +29,7 @@ import { inject, observer } from "mobx-react";
import { withTranslation } from "react-i18next";
import { toastr } from "@docspace/shared/components/toast";
-import { RoomsType, ShareAccessRights } from "@docspace/shared/enums";
+import { RoomsType } from "@docspace/shared/enums";
import { LINKS_LIMIT_COUNT } from "@docspace/shared/constants";
import InfoPanelViewLoader from "@docspace/shared/skeletons/info-panel/body";
import MembersHelper from "../../helpers/MembersHelper";
@@ -182,6 +182,7 @@ const Members = ({
key="general-link"
link={primaryLink}
setIsScrollLocked={setIsScrollLocked}
+ isShareLink
/>,
);
}
@@ -193,6 +194,7 @@ const Members = ({
link={link}
key={link?.sharedTo?.id}
setIsScrollLocked={setIsScrollLocked}
+ isShareLink
/>,
);
});
@@ -202,6 +204,7 @@ const Members = ({
key="create-additional-link"
className="additional-link"
onClick={onAddNewLink}
+ isShareLink
>
diff --git a/packages/client/src/pages/Home/InfoPanel/Body/views/Members/sub-components/LinkRow.js b/packages/client/src/pages/Home/InfoPanel/Body/views/Members/sub-components/LinkRow.tsx
similarity index 50%
rename from packages/client/src/pages/Home/InfoPanel/Body/views/Members/sub-components/LinkRow.js
rename to packages/client/src/pages/Home/InfoPanel/Body/views/Members/sub-components/LinkRow.tsx
index 6501d852f7..0c5725c25f 100644
--- a/packages/client/src/pages/Home/InfoPanel/Body/views/Members/sub-components/LinkRow.js
+++ b/packages/client/src/pages/Home/InfoPanel/Body/views/Members/sub-components/LinkRow.tsx
@@ -24,70 +24,75 @@
// 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 React, { useState } from "react";
import { observer, inject } from "mobx-react";
import { withTranslation } from "react-i18next";
import copy from "copy-to-clipboard";
-import { Avatar } from "@docspace/shared/components/avatar";
-import { Link } from "@docspace/shared/components/link";
-import { Text } from "@docspace/shared/components/text";
-import { IconButton } from "@docspace/shared/components/icon-button";
-import { ContextMenuButton } from "@docspace/shared/components/context-menu-button";
+import moment from "moment";
+import LinkRowComponent from "@docspace/shared/components/share/sub-components/LinkRow";
import { toastr } from "@docspace/shared/components/toast";
-import CopyReactSvgUrl from "PUBLIC_DIR/images/copy.react.svg?url";
-import LinkReactSvgUrl from "PUBLIC_DIR/images/tablet-link.react.svg?url";
import SettingsReactSvgUrl from "PUBLIC_DIR/images/catalog.settings.react.svg?url";
-import ShareReactSvgUrl from "PUBLIC_DIR/images/share.react.svg?url";
import CodeReactSvgUrl from "PUBLIC_DIR/images/code.react.svg?url";
import CopyToReactSvgUrl from "PUBLIC_DIR/images/copyTo.react.svg?url";
import OutlineReactSvgUrl from "PUBLIC_DIR/images/outline-true.react.svg?url";
import LockedReactSvgUrl from "PUBLIC_DIR/images/locked.react.svg?url";
-import LoadedReactSvgUrl from "PUBLIC_DIR/images/loaded.react.svg?url";
import TrashReactSvgUrl from "PUBLIC_DIR/images/trash.react.svg?url";
-import ClockReactSvg from "PUBLIC_DIR/images/clock.react.svg";
-import moment from "moment-timezone";
import { RoomsType } from "@docspace/shared/enums";
+import { TTranslation } from "@docspace/shared/types";
+import { TFileLink } from "@docspace/shared/api/files/types";
+import { useState } from "react";
+import { TOption } from "@docspace/shared/components/combobox";
-import { StyledLinkRow } from "./Styled";
+type LinkRowProps = {
+ t: TTranslation;
+ link: TFileLink;
+ roomId: string | number;
+ setLinkParams: (linkParams: {
+ roomId: number | string;
+ isEdit?: boolean;
+ link: TFileLink;
+ isPublic?: boolean;
+ isFormRoom?: boolean;
+ }) => void;
+ setEditLinkPanelIsVisible: (value: boolean) => void;
+ setDeleteLinkDialogVisible: (value: boolean) => void;
+ setEmbeddingPanelData: (value: {
+ visible: boolean;
+ itemId?: string | number;
+ }) => void;
-const LinkRow = (props) => {
+ isArchiveFolder: boolean;
+ setIsScrollLocked: (isScrollLocked: boolean) => void;
+ isPublicRoomType: boolean;
+ isFormRoom: boolean;
+};
+
+const LinkRow = (props: LinkRowProps) => {
const {
t,
link,
roomId,
setLinkParams,
- setExternalLink,
- editExternalLink,
setEditLinkPanelIsVisible,
setDeleteLinkDialogVisible,
setEmbeddingPanelData,
isArchiveFolder,
- theme,
setIsScrollLocked,
isPublicRoomType,
isFormRoom,
- ...rest
+ editExternalLink,
+ setExternalLink,
} = props;
- const [isLoading, setIsLoading] = useState(false);
-
- const {
- title,
- shareLink,
- password,
- disabled,
- expirationDate,
- isExpired,
- primary,
- } = link.sharedTo;
+ const { title, shareLink, password, isExpired, primary } = link.sharedTo;
const isLocked = !!password;
- const expiryDate = !!expirationDate;
- const date = moment(expirationDate).tz(window.timezone).format("LLL");
+ const isDisabled = isExpired;
- const tooltipContent = isExpired
- ? t("Translations:LinkHasExpiredAndHasBeenDisabled")
- : t("Translations:PublicRoomLinkValidTime", { date });
+ const [loadingLinks, setLoadingLinks] = useState<(string | number)[]>([]);
+
+ const onCloseContextMenu = () => {
+ setIsScrollLocked(false);
+ };
const onEditLink = () => {
setEditLinkPanelIsVisible(true);
@@ -101,33 +106,11 @@ const LinkRow = (props) => {
onCloseContextMenu();
};
- // const onDisableLink = () => {
- // if (isExpired) {
- // setEditLinkPanelIsVisible(true);
- // setLinkParams({ isEdit: true, link, roomId, isPublic: isPublicRoomType, isFormRoom });
- // return;
- // }
-
- // setIsLoading(true);
-
- // const newLink = JSON.parse(JSON.stringify(link));
- // newLink.sharedTo.disabled = !newLink.sharedTo.disabled;
-
- // editExternalLink(roomId, newLink)
- // .then((link) => {
- // setExternalLink(link);
-
- // disabled
- // ? toastr.success(t("Files:LinkEnabledSuccessfully"))
- // : toastr.success(t("Files:LinkDisabledSuccessfully"));
- // })
- // .catch((err) => toastr.error(err?.message))
- // .finally(() => setIsLoading(false));
- // };
-
const onCopyPassword = () => {
- copy(password);
- toastr.success(t("Files:PasswordSuccessfullyCopied"));
+ if (password) {
+ copy(password);
+ toastr.success(t("Files:PasswordSuccessfullyCopied"));
+ }
};
const onEmbeddingClick = () => {
@@ -152,12 +135,6 @@ const LinkRow = (props) => {
setIsScrollLocked(true);
};
- const onCloseContextMenu = () => {
- setIsScrollLocked(false);
- };
-
- const isDisabled = disabled || isExpired;
-
const getData = () => {
return [
{
@@ -166,17 +143,6 @@ const LinkRow = (props) => {
icon: SettingsReactSvgUrl,
onClick: onEditLink,
},
- // {
- // key: "edit-link-separator",
- // isSeparator: true,
- // },
- // {
- // key: "share-key",
- // label: t("Files:Share"),
- // icon: ShareReactSvgUrl,
- // // onClick: () => args.onClickLabel("label2"),
- // },
-
!isDisabled && {
key: "copy-link-settings-key",
label: t("Files:CopySharedLink"),
@@ -184,27 +150,21 @@ const LinkRow = (props) => {
onClick: onCopyExternalLink,
},
+ !isDisabled &&
+ isLocked && {
+ key: "copy-link-password-key",
+ label: t("Files:CopyLinkPassword"),
+ icon: LockedReactSvgUrl,
+ onClick: onCopyPassword,
+ },
+
!isDisabled && {
key: "embedding-settings-key",
- label: t("Files:EmbeddingSettings"),
+ label: t("Files:Embed"),
icon: CodeReactSvgUrl,
onClick: onEmbeddingClick,
},
- // disabled
- // ? {
- // key: "enable-link-key",
- // label: t("Files:EnableLink"),
- // icon: LoadedReactSvgUrl,
- // onClick: onDisableLink,
- // }
- // : {
- // key: "disable-link-key",
- // label: t("Files:DisableLink"),
- // icon: OutlineReactSvgUrl,
- // onClick: onDisableLink,
- // },
-
{
key: "delete-link-separator",
isSeparator: true,
@@ -222,91 +182,65 @@ const LinkRow = (props) => {
];
};
- const textColor = disabled ? theme.text.disableColor : theme.text.color;
+ const editExternalLinkAction = (newLink: TFileLink) => {
+ setLoadingLinks([newLink.sharedTo.id]);
+
+ console.log("newLink", newLink);
+
+ editExternalLink(roomId, newLink)
+ .then((linkData: TFileLink) => {
+ setExternalLink(linkData);
+ setLinkParams({
+ link: linkData,
+ roomId,
+ isPublic: isPublicRoomType,
+ isFormRoom,
+ });
+
+ copy(link?.sharedTo?.shareLink);
+ toastr.success(t("Files:LinkEditedSuccessfully"));
+ })
+ .catch((err: Error) => toastr.error(err?.message))
+ .finally(() => setLoadingLinks([]));
+ };
+
+ const onAccessRightsSelect = (opt: TOption) => {
+ const newLink = { ...link };
+ if (opt.access) newLink.access = opt.access;
+ editExternalLinkAction(newLink);
+ };
+
+ const changeExpirationOption = async (
+ linkData: TFileLink,
+ expirationDate: moment.Moment | null,
+ ) => {
+ const newLink = { ...link };
+ newLink.sharedTo.expirationDate = moment(expirationDate);
+ editExternalLinkAction(newLink);
+ };
return (
-
-
-
-
- ) : null
- }
- withTooltip={expiryDate}
- tooltipContent={tooltipContent}
- />
- {isArchiveFolder ? (
-
- {!disabled && !isExpired && !isArchiveFolder && (
- <>
- {isLocked && (
-
- )}
-
- >
- )}
-
- {!isArchiveFolder && (
-
- )}
-
-
+