Web: Files: Public-room: refactoring
This commit is contained in:
parent
8cc54600bf
commit
12f3dc0caa
@ -18,7 +18,6 @@ const DeleteLinkDialogComponent = (props) => {
|
||||
setExternalLinks,
|
||||
editExternalLink,
|
||||
} = props;
|
||||
const { id: linkId, title } = link.sharedTo;
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
@ -42,9 +41,10 @@ const DeleteLinkDialogComponent = (props) => {
|
||||
const onDelete = () => {
|
||||
setIsLoading(true);
|
||||
|
||||
link.access = 0;
|
||||
const newLink = JSON.parse(JSON.stringify(link));
|
||||
newLink.access = 0;
|
||||
|
||||
editExternalLink(roomId, link)
|
||||
editExternalLink(roomId, newLink)
|
||||
.then((res) => {
|
||||
setExternalLinks(res);
|
||||
toastr.success("Files:LinkRemovedSuccessfully");
|
||||
|
@ -5,6 +5,7 @@ import { withTranslation } from "react-i18next";
|
||||
import ModalDialog from "@docspace/components/modal-dialog";
|
||||
import Button from "@docspace/components/button";
|
||||
import InputBlock from "@docspace/components/input-block";
|
||||
import TextInput from "@docspace/components/text-input";
|
||||
import copy from "copy-to-clipboard";
|
||||
import toastr from "@docspace/components/toast/toastr";
|
||||
|
||||
@ -38,7 +39,7 @@ const RoomSharingDialog = ({ t, tReady, visible, setIsVisible }) => {
|
||||
<ModalDialog.Header>{t("Files:ShareRoom")}</ModalDialog.Header>
|
||||
<ModalDialog.Body>
|
||||
<div className="modal-dialog-content-body">
|
||||
<InputBlock value={roomHref} scale isReadOnly isDisabled />
|
||||
<TextInput value={roomHref} scale isReadOnly isDisabled />
|
||||
<Button
|
||||
label={t("Translations:Copy")}
|
||||
size="small"
|
||||
|
@ -21,6 +21,7 @@ import LinkBlock from "./LinkBlock";
|
||||
import ToggleBlock from "./ToggleBlock";
|
||||
import PasswordAccessBlock from "./PasswordAccessBlock";
|
||||
import LimitTimeBlock from "./LimitTimeBlock";
|
||||
import { LinkType } from "../../../helpers/constants";
|
||||
|
||||
const EditLinkPanel = (props) => {
|
||||
const {
|
||||
@ -86,13 +87,15 @@ const EditLinkPanel = (props) => {
|
||||
// ? createPasswordHash(passwordValue, hashSettings)
|
||||
// : null;
|
||||
|
||||
link.sharedTo.title = linkNameValue;
|
||||
link.sharedTo.password = passwordAccessIsChecked ? passwordValue : null;
|
||||
link.sharedTo.denyDownload = denyDownload;
|
||||
const newLink = JSON.parse(JSON.stringify(link));
|
||||
|
||||
newLink.sharedTo.title = linkNameValue;
|
||||
newLink.sharedTo.password = passwordAccessIsChecked ? passwordValue : null;
|
||||
newLink.sharedTo.denyDownload = denyDownload;
|
||||
// link.sharedTo.expirationDate=expirationDate;
|
||||
|
||||
setIsLoading(true);
|
||||
editExternalLink(roomId, link)
|
||||
editExternalLink(roomId, newLink)
|
||||
.then((res) => {
|
||||
setExternalLinks(res);
|
||||
|
||||
@ -245,7 +248,10 @@ export default inject(({ auth, dialogsStore, publicRoomStore }) => {
|
||||
|
||||
const linkId = linkParams?.link?.sharedTo?.id;
|
||||
const link = externalLinks.find((l) => l?.sharedTo?.id === linkId);
|
||||
const template = externalLinks.find((t) => t?.sharedTo?.isTemplate);
|
||||
const template = externalLinks.find(
|
||||
(t) =>
|
||||
t?.sharedTo?.isTemplate && t?.sharedTo?.linkType === LinkType.External
|
||||
);
|
||||
const shareLink = link?.sharedTo?.shareLink ?? template?.sharedTo?.shareLink;
|
||||
|
||||
return {
|
||||
|
@ -20,6 +20,7 @@ import ItemsList from "./sub-components/ItemsList";
|
||||
import InviteInput from "./sub-components/InviteInput";
|
||||
import ExternalLinks from "./sub-components/ExternalLinks";
|
||||
import Scrollbar from "@docspace/components/scrollbar";
|
||||
import { LinkType } from "../../../helpers/constants";
|
||||
const InvitePanel = ({
|
||||
folders,
|
||||
getFolderInfo,
|
||||
@ -83,7 +84,7 @@ const InvitePanel = ({
|
||||
users.map((user) => {
|
||||
const { shareLink, id, title, expirationDate, linkType } = user.sharedTo;
|
||||
|
||||
if (!!shareLink && linkType !== 1) {
|
||||
if (!!shareLink && linkType === LinkType.Invite) {
|
||||
links.push({
|
||||
id,
|
||||
title,
|
||||
|
@ -121,4 +121,9 @@ export const SortByFieldName = Object.freeze({
|
||||
RoomType: "roomType",
|
||||
});
|
||||
|
||||
export const LinkType = Object.freeze({
|
||||
Invite: 0,
|
||||
External: 1,
|
||||
});
|
||||
|
||||
export const SSO_LABEL = "SSO";
|
||||
|
@ -60,9 +60,10 @@ const LinkRow = (props) => {
|
||||
const onDisableLink = () => {
|
||||
setIsLoading(true);
|
||||
|
||||
link.sharedTo.disabled = !link.sharedTo.disabled;
|
||||
const newLink = JSON.parse(JSON.stringify(link));
|
||||
newLink.sharedTo.disabled = !newLink.sharedTo.disabled;
|
||||
|
||||
editExternalLink(roomId, link)
|
||||
editExternalLink(roomId, newLink)
|
||||
.then((res) => {
|
||||
setExternalLink(id, res);
|
||||
|
||||
@ -174,20 +175,24 @@ const LinkRow = (props) => {
|
||||
)}
|
||||
|
||||
<div className="external-row-icons">
|
||||
{isLocked && (
|
||||
<IconButton
|
||||
className="locked-icon"
|
||||
size={16}
|
||||
iconName={LockedReactSvgUrl}
|
||||
onClick={onLockClick}
|
||||
/>
|
||||
{!disabled && (
|
||||
<>
|
||||
{isLocked && (
|
||||
<IconButton
|
||||
className="locked-icon"
|
||||
size={16}
|
||||
iconName={LockedReactSvgUrl}
|
||||
onClick={onLockClick}
|
||||
/>
|
||||
)}
|
||||
<IconButton
|
||||
className="copy-icon"
|
||||
size={16}
|
||||
iconName={CopyReactSvgUrl}
|
||||
onClick={onCopyExternalLink}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<IconButton
|
||||
className="copy-icon"
|
||||
size={16}
|
||||
iconName={CopyReactSvgUrl}
|
||||
onClick={onCopyExternalLink}
|
||||
/>
|
||||
|
||||
<ContextMenuButton getData={getData} isDisabled={false} />
|
||||
</div>
|
||||
@ -203,9 +208,7 @@ export default inject(({ auth, dialogsStore, publicRoomStore }) => {
|
||||
setEmbeddingPanelIsVisible,
|
||||
setLinkParams,
|
||||
} = dialogsStore;
|
||||
const { editExternalLink, externalLinks, setExternalLink } = publicRoomStore;
|
||||
|
||||
const links = externalLinks.filter((l) => !l.sharedTo.isTemplate);
|
||||
const { editExternalLink, setExternalLink } = publicRoomStore;
|
||||
|
||||
return {
|
||||
setLinkParams,
|
||||
|
@ -7,6 +7,7 @@ import LinksToViewingIcon from "PUBLIC_DIR/images/links-to-viewing.react.svg?url
|
||||
import PublicRoomBar from "./PublicRoomBar";
|
||||
import { LinksBlock } from "./StyledPublicRoom";
|
||||
import LinkRow from "./LinkRow";
|
||||
import { LinkType } from "../../../../../../../helpers/constants";
|
||||
|
||||
const PublicRoomBlock = ({ t, externalLinks, onCopyLink }) => {
|
||||
const [barIsVisible, setBarVisible] = useState(true);
|
||||
@ -42,7 +43,8 @@ const PublicRoomBlock = ({ t, externalLinks, onCopyLink }) => {
|
||||
{externalLinks.length ? (
|
||||
externalLinks.map(
|
||||
(link) =>
|
||||
!link.sharedTo.isTemplate && (
|
||||
!link.sharedTo.isTemplate &&
|
||||
link.sharedTo.linkType === LinkType.External && (
|
||||
<LinkRow link={link} key={link?.sharedTo?.id} />
|
||||
)
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import api from "@docspace/common/api";
|
||||
import { ValidationResult } from "../helpers/constants";
|
||||
import { LinkType, ValidationResult } from "../helpers/constants";
|
||||
|
||||
class PublicRoomStore {
|
||||
externalLinks = [];
|
||||
@ -54,7 +54,7 @@ class PublicRoomStore {
|
||||
};
|
||||
|
||||
editExternalLink = (roomId, link) => {
|
||||
const linkType = 1;
|
||||
const linkType = LinkType.External;
|
||||
|
||||
const { id, title, expirationDate, password, disabled, denyDownload } =
|
||||
link.sharedTo;
|
||||
@ -92,12 +92,11 @@ class PublicRoomStore {
|
||||
}
|
||||
|
||||
get roomLinks() {
|
||||
const a = this.externalLinks.filter(
|
||||
(l) => l.sharedTo.shareLink && !l.sharedTo.isTemplate
|
||||
);
|
||||
|
||||
return this.externalLinks.filter(
|
||||
(l) => l.sharedTo.shareLink && !l.sharedTo.isTemplate
|
||||
(l) =>
|
||||
l.sharedTo.shareLink &&
|
||||
!l.sharedTo.isTemplate &&
|
||||
l.sharedTo.linkType === LinkType.External
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user